change AesCBC end/dec to return status, will add failure cases with align checks

This commit is contained in:
toddouska
2013-03-26 12:36:39 -07:00
parent 8e53c7a62e
commit 6bc7ba1592
5 changed files with 32 additions and 20 deletions

View File

@@ -73,7 +73,7 @@
return AesSetIV(aes, iv);
}
void AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
int AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
word32 *enc_key, *iv;
CRYP_InitTypeDef AES_CRYP_InitStructure;
@@ -174,9 +174,11 @@
/* disable crypto processor */
CRYP_Cmd(DISABLE);
return 0;
}
void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
int AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
word32 *dec_key, *iv;
CRYP_InitTypeDef AES_CRYP_InitStructure;
@@ -293,6 +295,8 @@
/* disable crypto processor */
CRYP_Cmd(DISABLE);
return 0;
}
#ifdef CYASSL_AES_COUNTER
@@ -1678,7 +1682,7 @@ static void AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
}
void AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
int AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
word32 blocks = sz / AES_BLOCK_SIZE;
@@ -1702,7 +1706,7 @@ void AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
aes->rounds);
/* store iv for next call */
XMEMCPY(aes->reg, out + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
return;
return 0;
}
#endif
@@ -1714,10 +1718,12 @@ void AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
out += AES_BLOCK_SIZE;
in += AES_BLOCK_SIZE;
}
return 0;
}
void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
int AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{
word32 blocks = sz / AES_BLOCK_SIZE;
@@ -1744,7 +1750,7 @@ void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
aes->rounds);
/* store iv for next call */
XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
return;
return 0;
}
#endif
@@ -1757,6 +1763,8 @@ void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
out += AES_BLOCK_SIZE;
in += AES_BLOCK_SIZE;
}
return 0;
}