本文整理汇总了C++中cryptopp::SHA1::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ SHA1::Update方法的具体用法?C++ SHA1::Update怎么用?C++ SHA1::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptopp::SHA1
的用法示例。
在下文中一共展示了SHA1::Update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeParameters
void cProtocol132::StartEncryption(const byte * a_Key)
{
m_Encryptor.SetKey(a_Key, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(a_Key, 16))(Name::FeedbackSize(), 1));
m_Decryptor.SetKey(a_Key, 16, MakeParameters(Name::IV(), ConstByteArrayParameter(a_Key, 16))(Name::FeedbackSize(), 1));
m_IsEncrypted = true;
// Prepare the m_AuthServerID:
CryptoPP::SHA1 Checksum;
AString ServerID = cRoot::Get()->GetServer()->GetServerID();
Checksum.Update((const byte *)ServerID.c_str(), ServerID.length());
Checksum.Update(a_Key, 16);
Checksum.Update((const byte *)m_ServerPublicKey.c_str(), m_ServerPublicKey.length());
byte Digest[20];
Checksum.Final(Digest);
DigestToJava(Digest, m_AuthServerID);
}
示例2: updateHash
void updateHash(CryptoPP::SHA1 & hash, uint8_t *buf, int width, int height, int stride) {
for(int i = 0; i < height; i++)
hash.Update(buf + i * stride, width);
}
示例3: coumpute_authcode
void Token::coumpute_authcode(BYTE challenge[8], BYTE rte_data[20]){
BYTE static_rte64[64],
response[8], //result
data[64],
rte_data64[64],
digest[20],
key_3des_24[24],
magic_sum_out64[64];
int pass_len = strlen(this->upass),
pass_len_u = 2 * (pass_len + 1); //in UTF-8
BYTE *token_pass_u = new BYTE[pass_len_u];
memset(token_pass_u, 0, pass_len_u);
for (int i = 0; i < pass_len; i++){
token_pass_u[i * 2] = 0;
token_pass_u[i * 2 + 1] = this->upass[i];
}
token_pass_u[pass_len * 2] = token_pass_u[pass_len * 2 + 1] = 0;
//cout << "token_pass_u "; showarr(token_pass_u, pass_len_u, ':'); //DEBUG
for (int i = 0; i < 64; i++){
static_rte64[i] = 0x03;
data[i] = token_pass_u[i % pass_len_u];
rte_data64[i] = rte_data[i % 20];
}
//cout << "rte_data64 "; showarr(rte_data64, 64, ':'); //DEBUG
//cout << "static_rte64 "; showarr(static_rte64, 64, ':'); //DEBUG
//cout << "data "; showarr(data, 64, ':'); //DEBUG
CryptoPP::SHA1 h;
h.Update(static_rte64, 64);
h.Update(rte_data64, 64);
h.Update(data, 64);
h.Final(digest);
//cout << "1st digest "; showarr(digest, 20, ':'); //DEBUG
for (int i = 0; i < 998; i++){
CryptoPP::SHA1 h_cycle;
h_cycle.Update(digest, 20);
h_cycle.Final(digest);
}
memcpy(key_3des_24, digest, 20); //now we have 20 bytes of key, we need 4 bytes more
h.Restart();
h.Update(static_rte64, 64);
this->magic_sum64(magic_sum_out64, digest, rte_data64);
h.Update(magic_sum_out64, 64);
this->magic_sum64(magic_sum_out64, digest, data);
h.Update(magic_sum_out64, 64);
h.Final(digest);
for (int i = 0; i < 998; i++){
CryptoPP::SHA1 h_cycle;
h_cycle.Update(digest, 20);
h_cycle.Final(digest);
}
memcpy(key_3des_24 + 20, digest, 4); //add remaining 4 bytes, now we have complete key
//cout << "DES-EDE24 key "; showarr(key_3des_24, 24, ':'); //DEBUG
//DES-EDE24
//CryptoPP::DES_EDE3::Encryption e(key_3des_24, CryptoPP::DES_EDE3::DEFAULT_KEYLENGTH);
//CryptoPP::ECB_Mode_ExternalCipher::Encryption ecb(e);
CryptoPP::ECB_Mode<CryptoPP::DES_EDE3>::Encryption ecb(key_3des_24, CryptoPP::DES_EDE3::DEFAULT_KEYLENGTH);
ecb.ProcessData(response, challenge, 8);
memcpy(challenge, response, 8);
delete[] token_pass_u;
}