diff options
author | tb <> | 2023-12-01 06:53:18 +0000 |
---|---|---|
committer | tb <> | 2023-12-01 06:53:18 +0000 |
commit | 7129e109fdac17c935230717075e826277b3c26a (patch) | |
tree | cf13ccad19558d7f0d3c750d99bea132a239adf6 /src | |
parent | 1585202f052c6925b43e2faa17ba8f0bcbd644a3 (diff) | |
download | openbsd-7129e109fdac17c935230717075e826277b3c26a.tar.gz openbsd-7129e109fdac17c935230717075e826277b3c26a.tar.bz2 openbsd-7129e109fdac17c935230717075e826277b3c26a.zip |
Unify various EVP_*{Update,Final}*() wrappers
The correct way of wrapping foo() is 'int ret; ret = foo(); return ret;'
because 'return foo();' would be too simple... Also unify branching from
EVP_Cipher* into EVP_Encrypt* EVP_Decrypt*.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index 0867070a76..04aa8f57a7 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.56 2023/11/29 21:35:57 tb Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.57 2023/12/01 06:53:18 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 | * |
@@ -198,8 +198,8 @@ EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | |||
198 | { | 198 | { |
199 | if (ctx->encrypt) | 199 | if (ctx->encrypt) |
200 | return EVP_EncryptUpdate(ctx, out, outl, in, inl); | 200 | return EVP_EncryptUpdate(ctx, out, outl, in, inl); |
201 | else | 201 | |
202 | return EVP_DecryptUpdate(ctx, out, outl, in, inl); | 202 | return EVP_DecryptUpdate(ctx, out, outl, in, inl); |
203 | } | 203 | } |
204 | 204 | ||
205 | int | 205 | int |
@@ -207,8 +207,8 @@ EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | |||
207 | { | 207 | { |
208 | if (ctx->encrypt) | 208 | if (ctx->encrypt) |
209 | return EVP_EncryptFinal_ex(ctx, out, outl); | 209 | return EVP_EncryptFinal_ex(ctx, out, outl); |
210 | else | 210 | |
211 | return EVP_DecryptFinal_ex(ctx, out, outl); | 211 | return EVP_DecryptFinal_ex(ctx, out, outl); |
212 | } | 212 | } |
213 | 213 | ||
214 | __warn_references(EVP_CipherFinal, | 214 | __warn_references(EVP_CipherFinal, |
@@ -217,12 +217,10 @@ __warn_references(EVP_CipherFinal, | |||
217 | int | 217 | int |
218 | EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | 218 | EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) |
219 | { | 219 | { |
220 | int ret; | ||
221 | if (ctx->encrypt) | 220 | if (ctx->encrypt) |
222 | ret = EVP_EncryptFinal_ex(ctx, out, outl); | 221 | return EVP_EncryptFinal_ex(ctx, out, outl); |
223 | else | 222 | |
224 | ret = EVP_DecryptFinal_ex(ctx, out, outl); | 223 | return EVP_DecryptFinal_ex(ctx, out, outl); |
225 | return ret; | ||
226 | } | 224 | } |
227 | 225 | ||
228 | int | 226 | int |
@@ -341,10 +339,7 @@ __warn_references(EVP_EncryptFinal, | |||
341 | int | 339 | int |
342 | EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | 340 | EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) |
343 | { | 341 | { |
344 | int ret; | 342 | return EVP_EncryptFinal_ex(ctx, out, outl); |
345 | |||
346 | ret = EVP_EncryptFinal_ex(ctx, out, outl); | ||
347 | return ret; | ||
348 | } | 343 | } |
349 | 344 | ||
350 | int | 345 | int |
@@ -469,10 +464,7 @@ __warn_references(EVP_DecryptFinal, | |||
469 | int | 464 | int |
470 | EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | 465 | EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) |
471 | { | 466 | { |
472 | int ret; | 467 | return EVP_DecryptFinal_ex(ctx, out, outl); |
473 | |||
474 | ret = EVP_DecryptFinal_ex(ctx, out, outl); | ||
475 | return ret; | ||
476 | } | 468 | } |
477 | 469 | ||
478 | int | 470 | int |