diff options
| author | tb <> | 2023-12-20 11:31:17 +0000 |
|---|---|---|
| committer | tb <> | 2023-12-20 11:31:17 +0000 |
| commit | f905cf6f2724519266a683845b62c72e7a98a2c7 (patch) | |
| tree | c9e9e0d1b451ed9285f6d6c5287d63a06f1a0b3d /src | |
| parent | 74b8ddb5b61f63537bdc48dc15df226c190bd7e0 (diff) | |
| download | openbsd-f905cf6f2724519266a683845b62c72e7a98a2c7.tar.gz openbsd-f905cf6f2724519266a683845b62c72e7a98a2c7.tar.bz2 openbsd-f905cf6f2724519266a683845b62c72e7a98a2c7.zip | |
Rename buf_len into partial_len in EVP_CIPHER_CTX
suggested by jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 18 | ||||
| -rw-r--r-- | src/lib/libcrypto/evp/evp_local.h | 4 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index 2bcef15fc2..ee1c12b70c 100644 --- a/src/lib/libcrypto/evp/evp_enc.c +++ b/src/lib/libcrypto/evp/evp_enc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp_enc.c,v 1.66 2023/12/20 11:01:34 tb Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.67 2023/12/20 11:31:17 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -184,7 +184,7 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | |||
| 184 | if (!ctx->cipher->init(ctx, key, iv, enc)) | 184 | if (!ctx->cipher->init(ctx, key, iv, enc)) |
| 185 | return 0; | 185 | return 0; |
| 186 | } | 186 | } |
| 187 | ctx->buf_len = 0; | 187 | ctx->partial_len = 0; |
| 188 | ctx->final_used = 0; | 188 | ctx->final_used = 0; |
| 189 | ctx->block_mask = ctx->cipher->block_size - 1; | 189 | ctx->block_mask = ctx->cipher->block_size - 1; |
| 190 | return 1; | 190 | return 1; |
| @@ -298,7 +298,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | |||
| 298 | { | 298 | { |
| 299 | const int block_size = ctx->cipher->block_size; | 299 | const int block_size = ctx->cipher->block_size; |
| 300 | const int block_mask = ctx->block_mask; | 300 | const int block_mask = ctx->block_mask; |
| 301 | int buf_offset = ctx->buf_len; | 301 | int buf_offset = ctx->partial_len; |
| 302 | int len = 0, total_len = 0; | 302 | int len = 0, total_len = 0; |
| 303 | 303 | ||
| 304 | *outl = 0; | 304 | *outl = 0; |
| @@ -326,7 +326,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | |||
| 326 | 326 | ||
| 327 | if ((buf_avail = block_size - buf_offset) > inl) { | 327 | if ((buf_avail = block_size - buf_offset) > inl) { |
| 328 | memcpy(&ctx->buf[buf_offset], in, inl); | 328 | memcpy(&ctx->buf[buf_offset], in, inl); |
| 329 | ctx->buf_len += inl; | 329 | ctx->partial_len += inl; |
| 330 | return 1; | 330 | return 1; |
| 331 | } | 331 | } |
| 332 | 332 | ||
| @@ -366,7 +366,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | |||
| 366 | 366 | ||
| 367 | if (buf_offset != 0) | 367 | if (buf_offset != 0) |
| 368 | memcpy(ctx->buf, &in[inl], buf_offset); | 368 | memcpy(ctx->buf, &in[inl], buf_offset); |
| 369 | ctx->buf_len = buf_offset; | 369 | ctx->partial_len = buf_offset; |
| 370 | 370 | ||
| 371 | *outl = total_len; | 371 | *outl = total_len; |
| 372 | 372 | ||
| @@ -383,7 +383,7 @@ int | |||
| 383 | EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | 383 | EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) |
| 384 | { | 384 | { |
| 385 | const int block_size = ctx->cipher->block_size; | 385 | const int block_size = ctx->cipher->block_size; |
| 386 | int buf_offset = ctx->buf_len; | 386 | int buf_offset = ctx->partial_len; |
| 387 | int pad; | 387 | int pad; |
| 388 | 388 | ||
| 389 | *outl = 0; | 389 | *outl = 0; |
| @@ -441,7 +441,7 @@ EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | |||
| 441 | 441 | ||
| 442 | if (ctx->final_used) { | 442 | if (ctx->final_used) { |
| 443 | /* | 443 | /* |
| 444 | * final_used is only set if buf_len is 0. Therefore the maximum | 444 | * final_used is only set if partial_len is 0. Therefore the maximum |
| 445 | * length output from EVP_EncryptUpdate() is inl & ~block_mask. | 445 | * length output from EVP_EncryptUpdate() is inl & ~block_mask. |
| 446 | * Ensure (inl & ~block_mask) + block_size doesn't overflow. | 446 | * Ensure (inl & ~block_mask) + block_size doesn't overflow. |
| 447 | */ | 447 | */ |
| @@ -461,7 +461,7 @@ EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | |||
| 461 | return 0; | 461 | return 0; |
| 462 | 462 | ||
| 463 | /* Keep copy of last block if a multiple of block_size was decrypted. */ | 463 | /* Keep copy of last block if a multiple of block_size was decrypted. */ |
| 464 | if (block_size > 1 && ctx->buf_len == 0) { | 464 | if (block_size > 1 && ctx->partial_len == 0) { |
| 465 | if (len < block_size) | 465 | if (len < block_size) |
| 466 | return 0; | 466 | return 0; |
| 467 | len -= block_size; | 467 | len -= block_size; |
| @@ -488,7 +488,7 @@ int | |||
| 488 | EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | 488 | EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) |
| 489 | { | 489 | { |
| 490 | const int block_size = ctx->cipher->block_size; | 490 | const int block_size = ctx->cipher->block_size; |
| 491 | int buf_offset = ctx->buf_len; | 491 | int buf_offset = ctx->partial_len; |
| 492 | int i, pad, plain_len; | 492 | int i, pad, plain_len; |
| 493 | 493 | ||
| 494 | *outl = 0; | 494 | *outl = 0; |
diff --git a/src/lib/libcrypto/evp/evp_local.h b/src/lib/libcrypto/evp/evp_local.h index 5df1733cbc..7bc266250c 100644 --- a/src/lib/libcrypto/evp/evp_local.h +++ b/src/lib/libcrypto/evp/evp_local.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp_local.h,v 1.6 2023/11/29 21:35:57 tb Exp $ */ | 1 | /* $OpenBSD: evp_local.h,v 1.7 2023/12/20 11:31:17 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -168,7 +168,7 @@ struct evp_cipher_st { | |||
| 168 | struct evp_cipher_ctx_st { | 168 | struct evp_cipher_ctx_st { |
| 169 | const EVP_CIPHER *cipher; | 169 | const EVP_CIPHER *cipher; |
| 170 | int encrypt; /* encrypt or decrypt */ | 170 | int encrypt; /* encrypt or decrypt */ |
| 171 | int buf_len; /* number we have left */ | 171 | int partial_len; /* number of bytes written to buf */ |
| 172 | 172 | ||
| 173 | unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ | 173 | unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ |
| 174 | unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ | 174 | unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ |
