diff options
| author | tb <> | 2023-12-23 13:05:06 +0000 |
|---|---|---|
| committer | tb <> | 2023-12-23 13:05:06 +0000 |
| commit | 88fa80fab32a0f53ac1fe72bc4d1a77d9083eaeb (patch) | |
| tree | 51d05cc125495283077cab49991645615c703cdc /src | |
| parent | 2efa258063d0f5b91c3ba9cd5ecb696033d034c4 (diff) | |
| download | openbsd-88fa80fab32a0f53ac1fe72bc4d1a77d9083eaeb.tar.gz openbsd-88fa80fab32a0f53ac1fe72bc4d1a77d9083eaeb.tar.bz2 openbsd-88fa80fab32a0f53ac1fe72bc4d1a77d9083eaeb.zip | |
Use more consistent order for Init/Update/Final
Consistently implement the _ex() version after the non-extended versions,
First Cipher Init/Update/Final, then Encrypt, then Decrypt. This only
switches the order of CipherFinal{,_ex} and move the DecryptInit* down,
so they are no longer somewhere in the middle of the Encrypt* functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index ec4dae03f5..1bde05f493 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.78 2023/12/22 17:37:14 tb Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.79 2023/12/23 13:05:06 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 | * |
| @@ -207,7 +207,7 @@ EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | |||
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | int | 209 | int |
| 210 | EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) | 210 | EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) |
| 211 | { | 211 | { |
| 212 | if (ctx->encrypt) | 212 | if (ctx->encrypt) |
| 213 | return EVP_EncryptFinal_ex(ctx, out, out_len); | 213 | return EVP_EncryptFinal_ex(ctx, out, out_len); |
| @@ -216,7 +216,7 @@ EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) | |||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | int | 218 | int |
| 219 | EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) | 219 | EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) |
| 220 | { | 220 | { |
| 221 | if (ctx->encrypt) | 221 | if (ctx->encrypt) |
| 222 | return EVP_EncryptFinal_ex(ctx, out, out_len); | 222 | return EVP_EncryptFinal_ex(ctx, out, out_len); |
| @@ -238,20 +238,6 @@ EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine | |||
| 238 | return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 1); | 238 | return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 1); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | int | ||
| 242 | EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | ||
| 243 | const unsigned char *key, const unsigned char *iv) | ||
| 244 | { | ||
| 245 | return EVP_CipherInit(ctx, cipher, key, iv, 0); | ||
| 246 | } | ||
| 247 | |||
| 248 | int | ||
| 249 | EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine, | ||
| 250 | const unsigned char *key, const unsigned char *iv) | ||
| 251 | { | ||
| 252 | return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 0); | ||
| 253 | } | ||
| 254 | |||
| 255 | /* | 241 | /* |
| 256 | * EVP_Cipher() is an implementation detail of EVP_Cipher{Update,Final}(). | 242 | * EVP_Cipher() is an implementation detail of EVP_Cipher{Update,Final}(). |
| 257 | * Behavior depends on EVP_CIPH_FLAG_CUSTOM_CIPHER being set on ctx->cipher. | 243 | * Behavior depends on EVP_CIPH_FLAG_CUSTOM_CIPHER being set on ctx->cipher. |
| @@ -422,6 +408,20 @@ EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) | |||
| 422 | } | 408 | } |
| 423 | 409 | ||
| 424 | int | 410 | int |
| 411 | EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | ||
| 412 | const unsigned char *key, const unsigned char *iv) | ||
| 413 | { | ||
| 414 | return EVP_CipherInit(ctx, cipher, key, iv, 0); | ||
| 415 | } | ||
| 416 | |||
| 417 | int | ||
| 418 | EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine, | ||
| 419 | const unsigned char *key, const unsigned char *iv) | ||
| 420 | { | ||
| 421 | return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 0); | ||
| 422 | } | ||
| 423 | |||
| 424 | int | ||
| 425 | EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, | 425 | EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, |
| 426 | const unsigned char *in, int in_len) | 426 | const unsigned char *in, int in_len) |
| 427 | { | 427 | { |
