本文整理汇总了C++中CFX_ByteTextBuf::AppendBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ CFX_ByteTextBuf::AppendBlock方法的具体用法?C++ CFX_ByteTextBuf::AppendBlock怎么用?C++ CFX_ByteTextBuf::AppendBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFX_ByteTextBuf
的用法示例。
在下文中一共展示了CFX_ByteTextBuf::AppendBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Revision6_Hash
void Revision6_Hash(const uint8_t* password,
uint32_t size,
const uint8_t* salt,
const uint8_t* vector,
uint8_t* hash) {
int iBlockSize = 32;
uint8_t sha[128];
CRYPT_SHA256Start(sha);
CRYPT_SHA256Update(sha, password, size);
CRYPT_SHA256Update(sha, salt, 8);
if (vector) {
CRYPT_SHA256Update(sha, vector, 48);
}
uint8_t digest[32];
CRYPT_SHA256Finish(sha, digest);
CFX_ByteTextBuf buf;
uint8_t* input = digest;
uint8_t* key = input;
uint8_t* iv = input + 16;
uint8_t* E = buf.GetBuffer();
int iBufLen = buf.GetLength();
CFX_ByteTextBuf interDigest;
int i = 0;
uint8_t* aes = FX_Alloc(uint8_t, 2048);
while (i < 64 || i < E[iBufLen - 1] + 32) {
int iRoundSize = size + iBlockSize;
if (vector) {
iRoundSize += 48;
}
iBufLen = iRoundSize * 64;
buf.EstimateSize(iBufLen);
E = buf.GetBuffer();
CFX_ByteTextBuf content;
for (int j = 0; j < 64; ++j) {
content.AppendBlock(password, size);
content.AppendBlock(input, iBlockSize);
if (vector) {
content.AppendBlock(vector, 48);
}
}
CRYPT_AESSetKey(aes, 16, key, 16, TRUE);
CRYPT_AESSetIV(aes, iv);
CRYPT_AESEncrypt(aes, E, content.GetBuffer(), iBufLen);
int iHash = 0;
switch (BigOrder64BitsMod3(E)) {
case 0:
iHash = 0;
iBlockSize = 32;
break;
case 1:
iHash = 1;
iBlockSize = 48;
break;
default:
iHash = 2;
iBlockSize = 64;
break;
}
interDigest.EstimateSize(iBlockSize);
input = interDigest.GetBuffer();
if (iHash == 0) {
CRYPT_SHA256Generate(E, iBufLen, input);
} else if (iHash == 1) {
CRYPT_SHA384Generate(E, iBufLen, input);
} else if (iHash == 2) {
CRYPT_SHA512Generate(E, iBufLen, input);
}
key = input;
iv = input + 16;
++i;
}
FX_Free(aes);
if (hash) {
FXSYS_memcpy(hash, input, 32);
}
}