示例#1
0
CryptorAESIV::CryptorAESIV (const Key &key, const IV &iv) :
	encryptor(0),
	decryptor(0)
{
	LogDebug(mailiverse::core::crypt, "CryptorAES");

	SymmetricKey _key (OctetString((const byte *)key.data(), key.size()));
	InitializationVector _iv (OctetString((const byte *)iv.data(), iv.size()));
	
	int keySize = key.size();
	if (keySize == 16)
	{
		encryptor = new Pipe(get_cipher("AES-128/CBC/PKCS7", _key, _iv, ENCRYPTION));
		decryptor = new Pipe(get_cipher("AES-128/CBC/PKCS7", _key, _iv, DECRYPTION));
	}
	else
	{
		encryptor = new Pipe(get_cipher("AES-256/CBC/PKCS7", _key, _iv, ENCRYPTION));
		decryptor = new Pipe(get_cipher("AES-256/CBC/PKCS7", _key, _iv, DECRYPTION));
	}
}
示例#2
0
void dumpIV(const IV& X, const char* s) { 
  IVec V; V.copy(X.size(), X.data());
  V.print(g_MSGFile, s, "d",  0, 4, true); 
}