diff options
author | jsing <> | 2022-09-10 17:39:47 +0000 |
---|---|---|
committer | jsing <> | 2022-09-10 17:39:47 +0000 |
commit | bb3c52398649c1e41080621f529dbb1d1cee3afb (patch) | |
tree | 80e430face99f2837d3b687cded293385ab116a5 /src/lib/libcrypto/evp/e_sm4.c | |
parent | b9b7e24dd08d9f1c9b144d42e8f56eacfefeb36b (diff) | |
download | openbsd-bb3c52398649c1e41080621f529dbb1d1cee3afb.tar.gz openbsd-bb3c52398649c1e41080621f529dbb1d1cee3afb.tar.bz2 openbsd-bb3c52398649c1e41080621f529dbb1d1cee3afb.zip |
Use correct length for EVP CFB mode ciphers.
The BLOCK_CIPHER_* macros contained a bug where the total length is passed
to the underlying cipher implementation, rather than the length of the
current chunk. Correct this and use the chunk length instead.
Should address the remaining issues reported by Coverity.
ok tb@
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/evp/e_sm4.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/evp/e_sm4.c b/src/lib/libcrypto/evp/e_sm4.c index 4fecae9671..11e9a74d69 100644 --- a/src/lib/libcrypto/evp/e_sm4.c +++ b/src/lib/libcrypto/evp/e_sm4.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_sm4.c,v 1.5 2022/09/06 06:17:11 jsing Exp $ */ | 1 | /* $OpenBSD: e_sm4.c,v 1.6 2022/09/10 17:39:47 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017, 2019 Ribose Inc | 3 | * Copyright (c) 2017, 2019 Ribose Inc |
4 | * | 4 | * |
@@ -99,7 +99,7 @@ sm4_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char * | |||
99 | chunk = inl; | 99 | chunk = inl; |
100 | 100 | ||
101 | while (inl && inl >= chunk) { | 101 | while (inl && inl >= chunk) { |
102 | sm4_cfb128_encrypt(in, out, inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 102 | sm4_cfb128_encrypt(in, out, chunk, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
103 | inl -= chunk; | 103 | inl -= chunk; |
104 | in += chunk; | 104 | in += chunk; |
105 | out += chunk; | 105 | out += chunk; |