summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-12-24 22:17:05 +0000
committertb <>2023-12-24 22:17:05 +0000
commit6fa6f1c08bcf2350166093fc8f21d894e801d520 (patch)
treeb61ee7c07174a0c5157f93ee515b32f71f9c7992
parent087d716bad393341950e91422118869cabd427d3 (diff)
downloadopenbsd-6fa6f1c08bcf2350166093fc8f21d894e801d520.tar.gz
openbsd-6fa6f1c08bcf2350166093fc8f21d894e801d520.tar.bz2
openbsd-6fa6f1c08bcf2350166093fc8f21d894e801d520.zip
Move EVP_Digest() next to the functions it wraps
It really makes no sense to have the mess that is EVP_MD_CTX_copy{,_ex}() live between EVP_Digest{Init{,_ex},Update,Final{,_ex}}() and EVP_Digest(), the latter being a relatively simple wrapper of Init_ex/Update/Final_ex.
-rw-r--r--src/lib/libcrypto/evp/digest.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c
index ee0c68e707..56decc231c 100644
--- a/src/lib/libcrypto/evp/digest.c
+++ b/src/lib/libcrypto/evp/digest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: digest.c,v 1.40 2023/11/29 21:35:57 tb Exp $ */ 1/* $OpenBSD: digest.c,v 1.41 2023/12/24 22:17:05 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 *
@@ -201,6 +201,23 @@ EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)
201} 201}
202 202
203int 203int
204EVP_Digest(const void *data, size_t count,
205 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl)
206{
207 EVP_MD_CTX ctx;
208 int ret;
209
210 EVP_MD_CTX_init(&ctx);
211 EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_ONESHOT);
212 ret = EVP_DigestInit_ex(&ctx, type, NULL) &&
213 EVP_DigestUpdate(&ctx, data, count) &&
214 EVP_DigestFinal_ex(&ctx, md, size);
215 EVP_MD_CTX_cleanup(&ctx);
216
217 return ret;
218}
219
220int
204EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in) 221EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)
205{ 222{
206 EVP_MD_CTX_init(out); 223 EVP_MD_CTX_init(out);
@@ -262,23 +279,6 @@ EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
262 return 1; 279 return 1;
263} 280}
264 281
265int
266EVP_Digest(const void *data, size_t count,
267 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl)
268{
269 EVP_MD_CTX ctx;
270 int ret;
271
272 EVP_MD_CTX_init(&ctx);
273 EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_ONESHOT);
274 ret = EVP_DigestInit_ex(&ctx, type, NULL) &&
275 EVP_DigestUpdate(&ctx, data, count) &&
276 EVP_DigestFinal_ex(&ctx, md, size);
277 EVP_MD_CTX_cleanup(&ctx);
278
279 return ret;
280}
281
282EVP_MD_CTX * 282EVP_MD_CTX *
283EVP_MD_CTX_new(void) 283EVP_MD_CTX_new(void)
284{ 284{