mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 15:10:48 +02:00
cleanup inspired by false positive F-675: AES-CTR and AES-OFB Modes Bypass WC_C_DYNAMIC_FALLBACK Selection Logic
This commit is contained in:
+10
-26
@@ -2509,13 +2509,10 @@ static int km_AesCtrEncrypt(struct skcipher_request *req)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
|
||||
aes_copy = (struct Aes *)malloc(sizeof(Aes));
|
||||
if (aes_copy == NULL) {
|
||||
err = -ENOMEM;
|
||||
err = km_AesGet(ctx, 0 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
|
||||
if (unlikely(err)) {
|
||||
goto out;
|
||||
}
|
||||
XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes));
|
||||
|
||||
err = wc_AesSetIV(aes_copy, walk.iv);
|
||||
|
||||
@@ -2583,16 +2580,11 @@ static int km_AesCtrDecrypt(struct skcipher_request *req)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
|
||||
aes_copy = (struct Aes *)malloc(sizeof(Aes));
|
||||
if (aes_copy == NULL) {
|
||||
err = -ENOMEM;
|
||||
/* CTR uses the same schedule for encrypt and decrypt. */
|
||||
err = km_AesGet(ctx, 0 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
|
||||
if (unlikely(err)) {
|
||||
goto out;
|
||||
}
|
||||
XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes)); /* CTR uses the same
|
||||
* schedule for encrypt
|
||||
* and decrypt.
|
||||
*/
|
||||
|
||||
err = wc_AesSetIV(aes_copy, walk.iv);
|
||||
|
||||
@@ -2697,13 +2689,10 @@ static int km_AesOfbEncrypt(struct skcipher_request *req)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
|
||||
aes_copy = (struct Aes *)malloc(sizeof(Aes));
|
||||
if (aes_copy == NULL) {
|
||||
err = -ENOMEM;
|
||||
err = km_AesGet(ctx, 0 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
|
||||
if (unlikely(err)) {
|
||||
goto out;
|
||||
}
|
||||
XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes));
|
||||
|
||||
err = wc_AesSetIV(aes_copy, walk.iv);
|
||||
|
||||
@@ -2771,16 +2760,11 @@ static int km_AesOfbDecrypt(struct skcipher_request *req)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
|
||||
aes_copy = (struct Aes *)malloc(sizeof(Aes));
|
||||
if (aes_copy == NULL) {
|
||||
err = -ENOMEM;
|
||||
/* OFB uses the same schedule for encrypt and decrypt. */
|
||||
err = km_AesGet(ctx, 0 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
|
||||
if (unlikely(err)) {
|
||||
goto out;
|
||||
}
|
||||
XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes)); /* OFB uses the same
|
||||
* schedule for encrypt
|
||||
* and decrypt.
|
||||
*/
|
||||
|
||||
err = wc_AesSetIV(aes_copy, walk.iv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user