Revert "improve cbc encrypt perf"
This reverts commit f1e396c427
.
Performance is slightly better with this reverted, especially
for AES-CBC 192.
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
5c394ff203
commit
906c63cf35
1 changed files with 6 additions and 3 deletions
|
@ -1068,6 +1068,8 @@ int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,
|
|||
}
|
||||
#endif
|
||||
|
||||
const unsigned char *ivp = iv;
|
||||
|
||||
if (mode == MBEDTLS_AES_DECRYPT) {
|
||||
while (length > 0) {
|
||||
memcpy(temp, input, 16);
|
||||
|
@ -1086,18 +1088,19 @@ int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,
|
|||
}
|
||||
} else {
|
||||
while (length > 0) {
|
||||
mbedtls_xor(temp, input, iv, 16);
|
||||
mbedtls_xor(output, input, ivp, 16);
|
||||
|
||||
ret = mbedtls_aes_crypt_ecb(ctx, mode, temp, iv);
|
||||
memcpy(output, iv, 16);
|
||||
ret = mbedtls_aes_crypt_ecb(ctx, mode, output, output);
|
||||
if (ret != 0) {
|
||||
goto exit;
|
||||
}
|
||||
ivp = output;
|
||||
|
||||
input += 16;
|
||||
output += 16;
|
||||
length -= 16;
|
||||
}
|
||||
memcpy(iv, ivp, 16);
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue