summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-12-23 13:05:06 +0000
committertb <>2023-12-23 13:05:06 +0000
commit087d716bad393341950e91422118869cabd427d3 (patch)
tree51d05cc125495283077cab49991645615c703cdc /src/lib
parent21a1e7fee905de67c806420e9a84b1ee36df6881 (diff)
downloadopenbsd-087d716bad393341950e91422118869cabd427d3.tar.gz
openbsd-087d716bad393341950e91422118869cabd427d3.tar.bz2
openbsd-087d716bad393341950e91422118869cabd427d3.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/lib')
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c34
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
209int 209int
210EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) 210EVP_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
218int 218int
219EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len) 219EVP_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
241int
242EVP_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
248int
249EVP_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
424int 410int
411EVP_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
417int
418EVP_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
424int
425EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len, 425EVP_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{