aligned AES keys

This commit is contained in:
orignal 2014-11-01 21:53:45 -04:00
parent f7791e5289
commit faf1fe7a7c
5 changed files with 18 additions and 17 deletions

18
aes.h
View file

@ -34,7 +34,7 @@ namespace crypto
protected:
void ExpandKey (const uint8_t * key);
void ExpandKey (const AESKey& key);
protected:
@ -46,7 +46,7 @@ namespace crypto
{
public:
void SetKey (const uint8_t * key) { ExpandKey (key); };
void SetKey (const AESKey& key) { ExpandKey (key); };
void Encrypt (const ChipherBlock * in, ChipherBlock * out);
};
@ -54,7 +54,7 @@ namespace crypto
{
public:
void SetKey (const uint8_t * key);
void SetKey (const AESKey& key);
void Decrypt (const ChipherBlock * in, ChipherBlock * out);
};
@ -67,7 +67,7 @@ namespace crypto
{
public:
void SetKey (const uint8_t * key)
void SetKey (const AESKey& key)
{
m_Encryption.SetKey (key, 32);
}
@ -85,7 +85,7 @@ namespace crypto
{
public:
void SetKey (const uint8_t * key)
void SetKey (const AESKey& key)
{
m_Decryption.SetKey (key, 32);
}
@ -108,7 +108,7 @@ namespace crypto
CBCEncryption () { memset (m_LastBlock.buf, 0, 16); };
void SetKey (const uint8_t * key) { m_ECBEncryption.SetKey (key); }; // 32 bytes
void SetKey (const AESKey& key) { m_ECBEncryption.SetKey (key); }; // 32 bytes
void SetIV (const uint8_t * iv) { memcpy (m_LastBlock.buf, iv, 16); }; // 16 bytes
void Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out);
@ -128,7 +128,7 @@ namespace crypto
CBCDecryption () { memset (m_IV.buf, 0, 16); };
void SetKey (const uint8_t * key) { m_ECBDecryption.SetKey (key); }; // 32 bytes
void SetKey (const AESKey& key) { m_ECBDecryption.SetKey (key); }; // 32 bytes
void SetIV (const uint8_t * iv) { memcpy (m_IV.buf, iv, 16); }; // 16 bytes
void Decrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out);
@ -145,7 +145,7 @@ namespace crypto
{
public:
void SetKeys (const uint8_t * layerKey, const uint8_t * ivKey)
void SetKeys (const AESKey& layerKey, const AESKey& ivKey)
{
m_LayerEncryption.SetKey (layerKey);
m_IVEncryption.SetKey (ivKey);
@ -167,7 +167,7 @@ namespace crypto
{
public:
void SetKeys (const uint8_t * layerKey, const uint8_t * ivKey)
void SetKeys (const AESKey& layerKey, const AESKey& ivKey)
{
m_LayerDecryption.SetKey (layerKey);
m_IVDecryption.SetKey (ivKey);