diff options
| author | jsing <> | 2022-09-10 17:39:47 +0000 |
|---|---|---|
| committer | jsing <> | 2022-09-10 17:39:47 +0000 |
| commit | de6c106921914263e126f0a65ff53578716ce425 (patch) | |
| tree | 80e430face99f2837d3b687cded293385ab116a5 /src/lib/libcrypto/evp/e_camellia.c | |
| parent | c74f413bd1f193fdb7e8e0864816c61d07d7f523 (diff) | |
| download | openbsd-de6c106921914263e126f0a65ff53578716ce425.tar.gz openbsd-de6c106921914263e126f0a65ff53578716ce425.tar.bz2 openbsd-de6c106921914263e126f0a65ff53578716ce425.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 'src/lib/libcrypto/evp/e_camellia.c')
| -rw-r--r-- | src/lib/libcrypto/evp/e_camellia.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/libcrypto/evp/e_camellia.c b/src/lib/libcrypto/evp/e_camellia.c index bff323b932..3976baaa48 100644 --- a/src/lib/libcrypto/evp/e_camellia.c +++ b/src/lib/libcrypto/evp/e_camellia.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: e_camellia.c,v 1.14 2022/09/06 06:17:11 jsing Exp $ */ | 1 | /* $OpenBSD: e_camellia.c,v 1.15 2022/09/10 17:39:47 jsing Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -113,7 +113,7 @@ camellia_128_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsign | |||
| 113 | chunk = inl; | 113 | chunk = inl; |
| 114 | 114 | ||
| 115 | while (inl && inl >= chunk) { | 115 | while (inl && inl >= chunk) { |
| 116 | Camellia_cfb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 116 | Camellia_cfb128_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 117 | inl -= chunk; | 117 | inl -= chunk; |
| 118 | in += chunk; | 118 | in += chunk; |
| 119 | out += chunk; | 119 | out += chunk; |
| @@ -271,7 +271,7 @@ camellia_192_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsign | |||
| 271 | chunk = inl; | 271 | chunk = inl; |
| 272 | 272 | ||
| 273 | while (inl && inl >= chunk) { | 273 | while (inl && inl >= chunk) { |
| 274 | Camellia_cfb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 274 | Camellia_cfb128_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 275 | inl -= chunk; | 275 | inl -= chunk; |
| 276 | in += chunk; | 276 | in += chunk; |
| 277 | out += chunk; | 277 | out += chunk; |
| @@ -429,7 +429,7 @@ camellia_256_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsign | |||
| 429 | chunk = inl; | 429 | chunk = inl; |
| 430 | 430 | ||
| 431 | while (inl && inl >= chunk) { | 431 | while (inl && inl >= chunk) { |
| 432 | Camellia_cfb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 432 | Camellia_cfb128_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 433 | inl -= chunk; | 433 | inl -= chunk; |
| 434 | in += chunk; | 434 | in += chunk; |
| 435 | out += chunk; | 435 | out += chunk; |
| @@ -573,7 +573,7 @@ camellia_128_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned | |||
| 573 | chunk = inl; | 573 | chunk = inl; |
| 574 | 574 | ||
| 575 | while (inl && inl >= chunk) { | 575 | while (inl && inl >= chunk) { |
| 576 | Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? inl * 8 : inl), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 576 | Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? chunk * 8 : chunk), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 577 | inl -= chunk; | 577 | inl -= chunk; |
| 578 | in += chunk; | 578 | in += chunk; |
| 579 | out += chunk; | 579 | out += chunk; |
| @@ -617,7 +617,7 @@ camellia_192_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned | |||
| 617 | chunk = inl; | 617 | chunk = inl; |
| 618 | 618 | ||
| 619 | while (inl && inl >= chunk) { | 619 | while (inl && inl >= chunk) { |
| 620 | Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? inl * 8 : inl), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 620 | Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? chunk * 8 : chunk), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 621 | inl -= chunk; | 621 | inl -= chunk; |
| 622 | in += chunk; | 622 | in += chunk; |
| 623 | out += chunk; | 623 | out += chunk; |
| @@ -661,7 +661,7 @@ camellia_256_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned | |||
| 661 | chunk = inl; | 661 | chunk = inl; |
| 662 | 662 | ||
| 663 | while (inl && inl >= chunk) { | 663 | while (inl && inl >= chunk) { |
| 664 | Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? inl * 8 : inl), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 664 | Camellia_cfb1_encrypt(in, out, ((1 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? chunk * 8 : chunk), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 665 | inl -= chunk; | 665 | inl -= chunk; |
| 666 | in += chunk; | 666 | in += chunk; |
| 667 | out += chunk; | 667 | out += chunk; |
| @@ -704,7 +704,7 @@ camellia_128_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned | |||
| 704 | chunk = inl; | 704 | chunk = inl; |
| 705 | 705 | ||
| 706 | while (inl && inl >= chunk) { | 706 | while (inl && inl >= chunk) { |
| 707 | Camellia_cfb8_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 707 | Camellia_cfb8_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 708 | inl -= chunk; | 708 | inl -= chunk; |
| 709 | in += chunk; | 709 | in += chunk; |
| 710 | out += chunk; | 710 | out += chunk; |
| @@ -746,7 +746,7 @@ camellia_192_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned | |||
| 746 | chunk = inl; | 746 | chunk = inl; |
| 747 | 747 | ||
| 748 | while (inl && inl >= chunk) { | 748 | while (inl && inl >= chunk) { |
| 749 | Camellia_cfb8_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 749 | Camellia_cfb8_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 750 | inl -= chunk; | 750 | inl -= chunk; |
| 751 | in += chunk; | 751 | in += chunk; |
| 752 | out += chunk; | 752 | out += chunk; |
| @@ -788,7 +788,7 @@ camellia_256_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned | |||
| 788 | chunk = inl; | 788 | chunk = inl; |
| 789 | 789 | ||
| 790 | while (inl && inl >= chunk) { | 790 | while (inl && inl >= chunk) { |
| 791 | Camellia_cfb8_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 791 | Camellia_cfb8_encrypt(in, out, chunk, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 792 | inl -= chunk; | 792 | inl -= chunk; |
| 793 | in += chunk; | 793 | in += chunk; |
| 794 | out += chunk; | 794 | out += chunk; |
