add direct AES one block access and ECB DES for compatibility

This commit is contained in:
toddouska
2011-10-26 17:10:44 -07:00
parent d3bb4bf4d4
commit 3ac390c147
5 changed files with 60 additions and 5 deletions

View File

@@ -847,7 +847,8 @@ int AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
checkAESNI = 1;
}
if (haveAESNI) {
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
if (iv)
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
if (dir == AES_ENCRYPTION)
return AES_set_encrypt_key(userKey, keylen * 8, aes);
else
@@ -975,7 +976,8 @@ int AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv,
Td[3][Te[4][GETBYTE(rk[3], 0)] & 0xff];
}
}
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
if (iv)
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
return 0;
}
@@ -1327,5 +1329,24 @@ void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
}
#ifdef CYASSL_AES_DIRECT
/* Allow direct access to one block encrypt */
void AesEncryptDirect(Aes* aes, byte* out, const byte* in)
{
return AesEncrypt(aes, in, out);
}
/* Allow direct access to one block decrypt */
void AesDecryptDirect(Aes* aes, byte* out, const byte* in)
{
return AesDecrypt(aes, in, out);
}
#endif
#endif /* NO_AES */