diff options
| author | tb <> | 2023-12-20 14:14:39 +0000 |
|---|---|---|
| committer | tb <> | 2023-12-20 14:14:39 +0000 |
| commit | 75c6a9c35c287a802f786ab62e0bd64dc3a70d45 (patch) | |
| tree | 5a8984bcb9b8cbd7ac139f9c13b3d9fc5da20b77 /src | |
| parent | 51440ddc705eae29ae918082831aa86d1a50372a (diff) | |
| download | openbsd-75c6a9c35c287a802f786ab62e0bd64dc3a70d45.tar.gz openbsd-75c6a9c35c287a802f786ab62e0bd64dc3a70d45.tar.bz2 openbsd-75c6a9c35c287a802f786ab62e0bd64dc3a70d45.zip | |
Rename inl to in_len throughout the file
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index b7cba33aa1..2526106eb3 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.71 2023/12/20 14:13:07 tb Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.72 2023/12/20 14:14:39 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 | * |
| @@ -194,12 +194,12 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | |||
| 194 | 194 | ||
| 195 | int | 195 | int |
| 196 | EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | 196 | EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, |
| 197 | const unsigned char *in, int inl) | 197 | const unsigned char *in, int in_len) |
| 198 | { | 198 | { |
| 199 | if (ctx->encrypt) | 199 | if (ctx->encrypt) |
| 200 | return EVP_EncryptUpdate(ctx, out, out_len, in, inl); | 200 | return EVP_EncryptUpdate(ctx, out, out_len, in, in_len); |
| 201 | 201 | ||
| 202 | return EVP_DecryptUpdate(ctx, out, out_len, in, inl); | 202 | return EVP_DecryptUpdate(ctx, out, out_len, in, in_len); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | int | 205 | int |
| @@ -262,9 +262,9 @@ EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, | |||
| 262 | */ | 262 | */ |
| 263 | int | 263 | int |
| 264 | EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, | 264 | EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, |
| 265 | unsigned int inl) | 265 | unsigned int in_len) |
| 266 | { | 266 | { |
| 267 | return ctx->cipher->do_cipher(ctx, out, in, inl); | 267 | return ctx->cipher->do_cipher(ctx, out, in, in_len); |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | static int | 270 | static int |
| @@ -296,7 +296,7 @@ evp_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 296 | 296 | ||
| 297 | int | 297 | int |
| 298 | EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | 298 | EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, |
| 299 | const unsigned char *in, int inl) | 299 | const unsigned char *in, int in_len) |
| 300 | { | 300 | { |
| 301 | const int block_size = ctx->cipher->block_size; | 301 | const int block_size = ctx->cipher->block_size; |
| 302 | const int block_mask = block_size - 1; | 302 | const int block_mask = block_size - 1; |
| @@ -308,17 +308,17 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 308 | if ((block_size & block_mask) != 0) | 308 | if ((block_size & block_mask) != 0) |
| 309 | return 0; | 309 | return 0; |
| 310 | 310 | ||
| 311 | if (inl < 0) | 311 | if (in_len < 0) |
| 312 | return 0; | 312 | return 0; |
| 313 | 313 | ||
| 314 | if (inl == 0 && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE) | 314 | if (in_len == 0 && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE) |
| 315 | return 1; | 315 | return 1; |
| 316 | 316 | ||
| 317 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) != 0) | 317 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) != 0) |
| 318 | return evp_cipher(ctx, out, out_len, in, inl); | 318 | return evp_cipher(ctx, out, out_len, in, in_len); |
| 319 | 319 | ||
| 320 | if (partial_len == 0 && (inl & block_mask) == 0) | 320 | if (partial_len == 0 && (in_len & block_mask) == 0) |
| 321 | return evp_cipher(ctx, out, out_len, in, inl); | 321 | return evp_cipher(ctx, out, out_len, in, in_len); |
| 322 | 322 | ||
| 323 | /* XXX - check that block_size > partial_len. */ | 323 | /* XXX - check that block_size > partial_len. */ |
| 324 | if (block_size > sizeof(ctx->buf)) { | 324 | if (block_size > sizeof(ctx->buf)) { |
| @@ -329,19 +329,19 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 329 | if (partial_len != 0) { | 329 | if (partial_len != 0) { |
| 330 | int partial_needed; | 330 | int partial_needed; |
| 331 | 331 | ||
| 332 | if ((partial_needed = block_size - partial_len) > inl) { | 332 | if ((partial_needed = block_size - partial_len) > in_len) { |
| 333 | memcpy(&ctx->buf[partial_len], in, inl); | 333 | memcpy(&ctx->buf[partial_len], in, in_len); |
| 334 | ctx->partial_len += inl; | 334 | ctx->partial_len += in_len; |
| 335 | return 1; | 335 | return 1; |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | /* | 338 | /* |
| 339 | * Once the first partial_needed bytes from in are processed, | 339 | * Once the first partial_needed bytes from in are processed, |
| 340 | * the number of multiples of block_size of data remaining is | 340 | * the number of multiples of block_size of data remaining is |
| 341 | * (inl - partial_needed) & ~block_mask. Ensure that this | 341 | * (in_len - partial_needed) & ~block_mask. Ensure that this |
| 342 | * plus the block processed from ctx->buf doesn't overflow. | 342 | * plus the block processed from ctx->buf doesn't overflow. |
| 343 | */ | 343 | */ |
| 344 | if (((inl - partial_needed) & ~block_mask) > INT_MAX - block_size) { | 344 | if (((in_len - partial_needed) & ~block_mask) > INT_MAX - block_size) { |
| 345 | EVPerror(EVP_R_TOO_LARGE); | 345 | EVPerror(EVP_R_TOO_LARGE); |
| 346 | return 0; | 346 | return 0; |
| 347 | } | 347 | } |
| @@ -352,17 +352,17 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 352 | return 0; | 352 | return 0; |
| 353 | total_len = len; | 353 | total_len = len; |
| 354 | 354 | ||
| 355 | inl -= partial_needed; | 355 | in_len -= partial_needed; |
| 356 | in += partial_needed; | 356 | in += partial_needed; |
| 357 | out += len; | 357 | out += len; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | partial_len = inl & block_mask; | 360 | partial_len = in_len & block_mask; |
| 361 | if ((inl -= partial_len) > 0) { | 361 | if ((in_len -= partial_len) > 0) { |
| 362 | if (INT_MAX - inl < total_len) | 362 | if (INT_MAX - in_len < total_len) |
| 363 | return 0; | 363 | return 0; |
| 364 | len = 0; | 364 | len = 0; |
| 365 | if (!evp_cipher(ctx, out, &len, in, inl)) | 365 | if (!evp_cipher(ctx, out, &len, in, in_len)) |
| 366 | return 0; | 366 | return 0; |
| 367 | if (INT_MAX - len < total_len) | 367 | if (INT_MAX - len < total_len) |
| 368 | return 0; | 368 | return 0; |
| @@ -370,7 +370,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | if (partial_len != 0) | 372 | if (partial_len != 0) |
| 373 | memcpy(ctx->buf, &in[inl], partial_len); | 373 | memcpy(ctx->buf, &in[in_len], partial_len); |
| 374 | ctx->partial_len = partial_len; | 374 | ctx->partial_len = partial_len; |
| 375 | 375 | ||
| 376 | *out_len = total_len; | 376 | *out_len = total_len; |
| @@ -420,7 +420,7 @@ EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) | |||
| 420 | 420 | ||
| 421 | int | 421 | int |
| 422 | EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | 422 | EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, |
| 423 | const unsigned char *in, int inl) | 423 | const unsigned char *in, int in_len) |
| 424 | { | 424 | { |
| 425 | const int block_size = ctx->cipher->block_size; | 425 | const int block_size = ctx->cipher->block_size; |
| 426 | const int block_mask = block_size - 1; | 426 | const int block_mask = block_size - 1; |
| @@ -431,17 +431,17 @@ EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 431 | if ((block_size & block_mask) != 0) | 431 | if ((block_size & block_mask) != 0) |
| 432 | return 0; | 432 | return 0; |
| 433 | 433 | ||
| 434 | if (inl < 0) | 434 | if (in_len < 0) |
| 435 | return 0; | 435 | return 0; |
| 436 | 436 | ||
| 437 | if (inl == 0 && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE) | 437 | if (in_len == 0 && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE) |
| 438 | return 1; | 438 | return 1; |
| 439 | 439 | ||
| 440 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) != 0) | 440 | if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) != 0) |
| 441 | return evp_cipher(ctx, out, out_len, in, inl); | 441 | return evp_cipher(ctx, out, out_len, in, in_len); |
| 442 | 442 | ||
| 443 | if ((ctx->flags & EVP_CIPH_NO_PADDING) != 0) | 443 | if ((ctx->flags & EVP_CIPH_NO_PADDING) != 0) |
| 444 | return EVP_EncryptUpdate(ctx, out, out_len, in, inl); | 444 | return EVP_EncryptUpdate(ctx, out, out_len, in, in_len); |
| 445 | 445 | ||
| 446 | if (block_size > sizeof(ctx->final)) { | 446 | if (block_size > sizeof(ctx->final)) { |
| 447 | EVPerror(EVP_R_BAD_BLOCK_LENGTH); | 447 | EVPerror(EVP_R_BAD_BLOCK_LENGTH); |
| @@ -451,10 +451,10 @@ EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 451 | if (ctx->final_used) { | 451 | if (ctx->final_used) { |
| 452 | /* | 452 | /* |
| 453 | * final_used is only set if partial_len is 0. Therefore the | 453 | * final_used is only set if partial_len is 0. Therefore the |
| 454 | * output from EVP_EncryptUpdate() is inl & ~block_mask. | 454 | * output from EVP_EncryptUpdate() is in_len & ~block_mask. |
| 455 | * Ensure (inl & ~block_mask) + block_size doesn't overflow. | 455 | * Ensure (in_len & ~block_mask) + block_size doesn't overflow. |
| 456 | */ | 456 | */ |
| 457 | if ((inl & ~block_mask) > INT_MAX - block_size) { | 457 | if ((in_len & ~block_mask) > INT_MAX - block_size) { |
| 458 | EVPerror(EVP_R_TOO_LARGE); | 458 | EVPerror(EVP_R_TOO_LARGE); |
| 459 | return 0; | 459 | return 0; |
| 460 | } | 460 | } |
| @@ -466,7 +466,7 @@ EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 466 | ctx->final_used = 0; | 466 | ctx->final_used = 0; |
| 467 | 467 | ||
| 468 | len = 0; | 468 | len = 0; |
| 469 | if (!EVP_EncryptUpdate(ctx, out, &len, in, inl)) | 469 | if (!EVP_EncryptUpdate(ctx, out, &len, in, in_len)) |
| 470 | return 0; | 470 | return 0; |
| 471 | 471 | ||
| 472 | /* Keep copy of last block if a multiple of block_size was decrypted. */ | 472 | /* Keep copy of last block if a multiple of block_size was decrypted. */ |
