diff options
Diffstat (limited to 'src/lib/libcrypto')
| -rw-r--r-- | src/lib/libcrypto/evp/e_camellia.c | 44 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/e_gost2814789.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/e_sm4.c | 12 |
3 files changed, 31 insertions, 31 deletions
diff --git a/src/lib/libcrypto/evp/e_camellia.c b/src/lib/libcrypto/evp/e_camellia.c index bd43180d01..bff323b932 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.13 2022/09/04 15:54:42 jsing Exp $ */ | 1 | /* $OpenBSD: e_camellia.c,v 1.14 2022/09/06 06:17:11 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 | * |
| @@ -92,14 +92,14 @@ static int | |||
| 92 | camellia_128_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 92 | camellia_128_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 93 | { | 93 | { |
| 94 | while (inl >= EVP_MAXCHUNK) { | 94 | while (inl >= EVP_MAXCHUNK) { |
| 95 | Camellia_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 95 | Camellia_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 96 | inl -= EVP_MAXCHUNK; | 96 | inl -= EVP_MAXCHUNK; |
| 97 | in += EVP_MAXCHUNK; | 97 | in += EVP_MAXCHUNK; |
| 98 | out += EVP_MAXCHUNK; | 98 | out += EVP_MAXCHUNK; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | if (inl) | 101 | if (inl) |
| 102 | Camellia_cbc_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 102 | Camellia_cbc_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 103 | 103 | ||
| 104 | return 1; | 104 | return 1; |
| 105 | } | 105 | } |
| @@ -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, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 116 | Camellia_cfb128_encrypt(in, out, inl, &((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; |
| @@ -146,14 +146,14 @@ static int | |||
| 146 | camellia_128_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 146 | camellia_128_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 147 | { | 147 | { |
| 148 | while (inl >= EVP_MAXCHUNK) { | 148 | while (inl >= EVP_MAXCHUNK) { |
| 149 | Camellia_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 149 | Camellia_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 150 | inl -= EVP_MAXCHUNK; | 150 | inl -= EVP_MAXCHUNK; |
| 151 | in += EVP_MAXCHUNK; | 151 | in += EVP_MAXCHUNK; |
| 152 | out += EVP_MAXCHUNK; | 152 | out += EVP_MAXCHUNK; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | if (inl) | 155 | if (inl) |
| 156 | Camellia_ofb128_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 156 | Camellia_ofb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 157 | 157 | ||
| 158 | return 1; | 158 | return 1; |
| 159 | } | 159 | } |
| @@ -250,14 +250,14 @@ static int | |||
| 250 | camellia_192_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 250 | camellia_192_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 251 | { | 251 | { |
| 252 | while (inl >= EVP_MAXCHUNK) { | 252 | while (inl >= EVP_MAXCHUNK) { |
| 253 | Camellia_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 253 | Camellia_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 254 | inl -= EVP_MAXCHUNK; | 254 | inl -= EVP_MAXCHUNK; |
| 255 | in += EVP_MAXCHUNK; | 255 | in += EVP_MAXCHUNK; |
| 256 | out += EVP_MAXCHUNK; | 256 | out += EVP_MAXCHUNK; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | if (inl) | 259 | if (inl) |
| 260 | Camellia_cbc_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 260 | Camellia_cbc_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 261 | 261 | ||
| 262 | return 1; | 262 | return 1; |
| 263 | } | 263 | } |
| @@ -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, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 274 | Camellia_cfb128_encrypt(in, out, inl, &((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; |
| @@ -304,14 +304,14 @@ static int | |||
| 304 | camellia_192_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 304 | camellia_192_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 305 | { | 305 | { |
| 306 | while (inl >= EVP_MAXCHUNK) { | 306 | while (inl >= EVP_MAXCHUNK) { |
| 307 | Camellia_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 307 | Camellia_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 308 | inl -= EVP_MAXCHUNK; | 308 | inl -= EVP_MAXCHUNK; |
| 309 | in += EVP_MAXCHUNK; | 309 | in += EVP_MAXCHUNK; |
| 310 | out += EVP_MAXCHUNK; | 310 | out += EVP_MAXCHUNK; |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | if (inl) | 313 | if (inl) |
| 314 | Camellia_ofb128_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 314 | Camellia_ofb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 315 | 315 | ||
| 316 | return 1; | 316 | return 1; |
| 317 | } | 317 | } |
| @@ -408,14 +408,14 @@ static int | |||
| 408 | camellia_256_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 408 | camellia_256_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 409 | { | 409 | { |
| 410 | while (inl >= EVP_MAXCHUNK) { | 410 | while (inl >= EVP_MAXCHUNK) { |
| 411 | Camellia_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 411 | Camellia_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 412 | inl -= EVP_MAXCHUNK; | 412 | inl -= EVP_MAXCHUNK; |
| 413 | in += EVP_MAXCHUNK; | 413 | in += EVP_MAXCHUNK; |
| 414 | out += EVP_MAXCHUNK; | 414 | out += EVP_MAXCHUNK; |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | if (inl) | 417 | if (inl) |
| 418 | Camellia_cbc_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 418 | Camellia_cbc_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 419 | 419 | ||
| 420 | return 1; | 420 | return 1; |
| 421 | } | 421 | } |
| @@ -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, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 432 | Camellia_cfb128_encrypt(in, out, inl, &((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; |
| @@ -462,14 +462,14 @@ static int | |||
| 462 | camellia_256_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 462 | camellia_256_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 463 | { | 463 | { |
| 464 | while (inl >= EVP_MAXCHUNK) { | 464 | while (inl >= EVP_MAXCHUNK) { |
| 465 | Camellia_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 465 | Camellia_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 466 | inl -= EVP_MAXCHUNK; | 466 | inl -= EVP_MAXCHUNK; |
| 467 | in += EVP_MAXCHUNK; | 467 | in += EVP_MAXCHUNK; |
| 468 | out += EVP_MAXCHUNK; | 468 | out += EVP_MAXCHUNK; |
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | if (inl) | 471 | if (inl) |
| 472 | Camellia_ofb128_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 472 | Camellia_ofb128_encrypt(in, out, inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 473 | 473 | ||
| 474 | return 1; | 474 | return 1; |
| 475 | } | 475 | } |
| @@ -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, (long)((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) ? inl * 8 : inl), &((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, (long)((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) ? inl * 8 : inl), &((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, (long)((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) ? inl * 8 : inl), &((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, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 707 | Camellia_cfb8_encrypt(in, out, inl, &((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, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 749 | Camellia_cfb8_encrypt(in, out, inl, &((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, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 791 | Camellia_cfb8_encrypt(in, out, inl, &((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; |
diff --git a/src/lib/libcrypto/evp/e_gost2814789.c b/src/lib/libcrypto/evp/e_gost2814789.c index b880c66954..f4b903b913 100644 --- a/src/lib/libcrypto/evp/e_gost2814789.c +++ b/src/lib/libcrypto/evp/e_gost2814789.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: e_gost2814789.c,v 1.8 2022/09/04 13:55:39 jsing Exp $ */ | 1 | /* $OpenBSD: e_gost2814789.c,v 1.9 2022/09/06 06:17:11 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
| 4 | * Copyright (c) 2005-2006 Cryptocom LTD | 4 | * Copyright (c) 2005-2006 Cryptocom LTD |
| @@ -213,7 +213,7 @@ gost2814789_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned | |||
| 213 | chunk = inl; | 213 | chunk = inl; |
| 214 | 214 | ||
| 215 | while (inl && inl >= chunk) { | 215 | while (inl && inl >= chunk) { |
| 216 | Gost2814789_cfb64_encrypt(in, out, (long)inl, &((EVP_GOST2814789_CTX *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 216 | Gost2814789_cfb64_encrypt(in, out, inl, &((EVP_GOST2814789_CTX *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); |
| 217 | inl -= chunk; | 217 | inl -= chunk; |
| 218 | in += chunk; | 218 | in += chunk; |
| 219 | out += chunk; | 219 | out += chunk; |
| @@ -231,7 +231,7 @@ gost2814789_cnt_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | |||
| 231 | EVP_GOST2814789_CTX *c = ctx->cipher_data; | 231 | EVP_GOST2814789_CTX *c = ctx->cipher_data; |
| 232 | 232 | ||
| 233 | while (inl >= EVP_MAXCHUNK) { | 233 | while (inl >= EVP_MAXCHUNK) { |
| 234 | Gost2814789_cnt_encrypt(in, out, (long)EVP_MAXCHUNK, &c->ks, | 234 | Gost2814789_cnt_encrypt(in, out, EVP_MAXCHUNK, &c->ks, |
| 235 | ctx->iv, ctx->buf, &ctx->num); | 235 | ctx->iv, ctx->buf, &ctx->num); |
| 236 | inl -= EVP_MAXCHUNK; | 236 | inl -= EVP_MAXCHUNK; |
| 237 | in += EVP_MAXCHUNK; | 237 | in += EVP_MAXCHUNK; |
diff --git a/src/lib/libcrypto/evp/e_sm4.c b/src/lib/libcrypto/evp/e_sm4.c index c4bbe567c5..4fecae9671 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.4 2022/09/04 15:56:51 jsing Exp $ */ | 1 | /* $OpenBSD: e_sm4.c,v 1.5 2022/09/06 06:17:11 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2017, 2019 Ribose Inc | 3 | * Copyright (c) 2017, 2019 Ribose Inc |
| 4 | * | 4 | * |
| @@ -78,14 +78,14 @@ static int | |||
| 78 | sm4_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 78 | sm4_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 79 | { | 79 | { |
| 80 | while (inl >= EVP_MAXCHUNK) { | 80 | while (inl >= EVP_MAXCHUNK) { |
| 81 | sm4_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 81 | sm4_cbc_encrypt(in, out, EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 82 | inl -= EVP_MAXCHUNK; | 82 | inl -= EVP_MAXCHUNK; |
| 83 | in += EVP_MAXCHUNK; | 83 | in += EVP_MAXCHUNK; |
| 84 | out += EVP_MAXCHUNK; | 84 | out += EVP_MAXCHUNK; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | if (inl) | 87 | if (inl) |
| 88 | sm4_cbc_encrypt(in, out, (long)inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | 88 | sm4_cbc_encrypt(in, out, inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 89 | 89 | ||
| 90 | return 1; | 90 | return 1; |
| 91 | } | 91 | } |
| @@ -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, (long)inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | 102 | sm4_cfb128_encrypt(in, out, inl, &((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; |
| @@ -132,14 +132,14 @@ static int | |||
| 132 | sm4_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | 132 | sm4_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 133 | { | 133 | { |
| 134 | while (inl >= EVP_MAXCHUNK) { | 134 | while (inl >= EVP_MAXCHUNK) { |
| 135 | sm4_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 135 | sm4_ofb128_encrypt(in, out, EVP_MAXCHUNK, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 136 | inl -= EVP_MAXCHUNK; | 136 | inl -= EVP_MAXCHUNK; |
| 137 | in += EVP_MAXCHUNK; | 137 | in += EVP_MAXCHUNK; |
| 138 | out += EVP_MAXCHUNK; | 138 | out += EVP_MAXCHUNK; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | if (inl) | 141 | if (inl) |
| 142 | sm4_ofb128_encrypt(in, out, (long)inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | 142 | sm4_ofb128_encrypt(in, out, inl, &((EVP_SM4_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); |
| 143 | 143 | ||
| 144 | return 1; | 144 | return 1; |
| 145 | } | 145 | } |
