summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHolger Dengler <dengler@linux.ibm.com>2024-01-05 14:16:53 +0100
committerTomas Mraz <tomas@openssl.org>2024-01-12 10:34:39 +0100
commitf9ccd209c3d121668c51a992613c698f2a774cb3 (patch)
tree01b94f1ff49f7e492ed64f22478e74b97aab2fef /crypto
parent576a3572bebf6115df1c03527114cbf74d06f861 (diff)
Fix partial block encryption in cfb and ofb for s390x (legacy)
Use the number of processed bytes information (num) from the generic cipher context for the partial block handling in cfb and ofb also in s390x-legacy code. For more details see 4df92c1a14 ("Fix partial block encryption in cfb and ofb for s390x"). Signed-off-by: Holger Dengler <dengler@linux.ibm.com> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/23201)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/e_aes.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c
index 450ebe8a0d..0d61f4e49f 100644
--- a/crypto/evp/e_aes.c
+++ b/crypto/evp/e_aes.c
@@ -885,8 +885,6 @@ typedef struct {
/* KMO-AES parameter block - end */
} kmo;
unsigned int fc;
-
- int res;
} S390X_AES_OFB_CTX;
typedef struct {
@@ -903,8 +901,6 @@ typedef struct {
/* KMF-AES parameter block - end */
} kmf;
unsigned int fc;
-
- int res;
} S390X_AES_CFB_CTX;
typedef struct {
@@ -1068,7 +1064,6 @@ static int s390x_aes_ofb_init_key(EVP_CIPHER_CTX *ctx,
memcpy(cctx->kmo.param.cv, iv, ivlen);
memcpy(cctx->kmo.param.k, key, keylen);
cctx->fc = S390X_AES_FC(keylen);
- cctx->res = 0;
return 1;
}
@@ -1078,7 +1073,7 @@ static int s390x_aes_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
S390X_AES_OFB_CTX *cctx = EVP_C_DATA(S390X_AES_OFB_CTX, ctx);
const int ivlen = EVP_CIPHER_CTX_get_iv_length(ctx);
unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx);
- int n = cctx->res;
+ int n = ctx->num;
int rem;
memcpy(cctx->kmo.param.cv, iv, ivlen);
@@ -1111,7 +1106,7 @@ static int s390x_aes_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
}
memcpy(iv, cctx->kmo.param.cv, ivlen);
- cctx->res = n;
+ ctx->num = n;
return 1;
}
@@ -1137,7 +1132,6 @@ static int s390x_aes_cfb_init_key(EVP_CIPHER_CTX *ctx,
if (!enc)
cctx->fc |= S390X_DECRYPT;
- cctx->res = 0;
memcpy(cctx->kmf.param.cv, iv, ivlen);
memcpy(cctx->kmf.param.k, key, keylen);
return 1;
@@ -1151,7 +1145,7 @@ static int s390x_aes_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const int enc = EVP_CIPHER_CTX_is_encrypting(ctx);
const int ivlen = EVP_CIPHER_CTX_get_iv_length(ctx);
unsigned char *iv = EVP_CIPHER_CTX_iv_noconst(ctx);
- int n = cctx->res;
+ int n = ctx->num;
int rem;
unsigned char tmp;
@@ -1197,7 +1191,7 @@ static int s390x_aes_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
}
memcpy(iv, cctx->kmf.param.cv, ivlen);
- cctx->res = n;
+ ctx->num = n;
return 1;
}