mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-07 06:40:21 +00:00
improve cbc encrypt perf
Signed-off-by: Dave Rodgman <dave.rodgman@gmail.com>
This commit is contained in:
parent
3f47b3f7a3
commit
f1e396c427
@ -1068,8 +1068,6 @@ int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,
|
||||
}
|
||||
#endif
|
||||
|
||||
const unsigned char *ivp = iv;
|
||||
|
||||
if (mode == MBEDTLS_AES_DECRYPT) {
|
||||
unsigned char temp2[16];
|
||||
while (length > 0) {
|
||||
@ -1089,19 +1087,18 @@ int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx,
|
||||
}
|
||||
} else {
|
||||
while (length > 0) {
|
||||
mbedtls_xor(output, input, ivp, 16);
|
||||
mbedtls_xor(temp, input, iv, 16);
|
||||
|
||||
ret = mbedtls_aes_crypt_ecb(ctx, mode, output, output);
|
||||
ret = mbedtls_aes_crypt_ecb(ctx, mode, temp, iv);
|
||||
memcpy(output, iv, 16);
|
||||
if (ret != 0) {
|
||||
goto exit;
|
||||
}
|
||||
ivp = output;
|
||||
|
||||
input += 16;
|
||||
output += 16;
|
||||
length -= 16;
|
||||
}
|
||||
memcpy(iv, ivp, 16);
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user