summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-01-07 21:58:17 +0000
committertb <>2022-01-07 21:58:17 +0000
commite0dd10037282a66d4a2bcfc5c36b7c21cce955b6 (patch)
tree8a6c466640238dc21c24bad392663918ae2df85c
parent93766d9d251f83e33b1dc4f3f25b70bea25a1997 (diff)
downloadopenbsd-e0dd10037282a66d4a2bcfc5c36b7c21cce955b6.tar.gz
openbsd-e0dd10037282a66d4a2bcfc5c36b7c21cce955b6.tar.bz2
openbsd-e0dd10037282a66d4a2bcfc5c36b7c21cce955b6.zip
Prepare to provide EVP_AEAD_CTX_{new,free}()
ok jsing
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/evp/evp.h14
-rw-r--r--src/lib/libcrypto/evp/evp_aead.c18
2 files changed, 29 insertions, 3 deletions
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index aa0a9e77c9..b5afa477da 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp.h,v 1.90 2021/12/24 12:55:04 tb Exp $ */ 1/* $OpenBSD: evp.h,v 1.91 2022/01/07 21:58:17 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 *
@@ -1331,7 +1331,17 @@ typedef struct evp_aead_ctx_st {
1331 * should be used. */ 1331 * should be used. */
1332#define EVP_AEAD_DEFAULT_TAG_LENGTH 0 1332#define EVP_AEAD_DEFAULT_TAG_LENGTH 0
1333 1333
1334/* EVP_AEAD_init initializes the context for the given AEAD algorithm. 1334#if defined(LIBRESSL_CRYPTO_INTERANL) || defined(LIBRESSL_NEXT_API)
1335/* EVP_AEAD_CTX_new allocates a new context for use with EVP_AEAD_CTX_init.
1336 * It can be cleaned up for reuse with EVP_AEAD_CTX_cleanup and must be freed
1337 * with EVP_AEAD_CTX_free. */
1338EVP_AEAD_CTX *EVP_AEAD_CTX_new(void);
1339
1340/* EVP_AEAD_CTX_free releases all memory owned by the context. */
1341void EVP_AEAD_CTX_free(EVP_AEAD_CTX *ctx);
1342#endif
1343
1344/* EVP_AEAD_CTX_init initializes the context for the given AEAD algorithm.
1335 * The implementation argument may be NULL to choose the default implementation. 1345 * The implementation argument may be NULL to choose the default implementation.
1336 * Authentication tags may be truncated by passing a tag length. A tag length 1346 * Authentication tags may be truncated by passing a tag length. A tag length
1337 * of zero indicates the default tag length should be used. */ 1347 * of zero indicates the default tag length should be used. */
diff --git a/src/lib/libcrypto/evp/evp_aead.c b/src/lib/libcrypto/evp/evp_aead.c
index 40471b0022..93d523af7c 100644
--- a/src/lib/libcrypto/evp/evp_aead.c
+++ b/src/lib/libcrypto/evp/evp_aead.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_aead.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ 1/* $OpenBSD: evp_aead.c,v 1.7 2022/01/07 21:58:17 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -68,6 +68,22 @@ EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx)
68 ctx->aead = NULL; 68 ctx->aead = NULL;
69} 69}
70 70
71EVP_AEAD_CTX *
72EVP_AEAD_CTX_new(void)
73{
74 return calloc(1, sizeof(EVP_AEAD_CTX));
75}
76
77void
78EVP_AEAD_CTX_free(EVP_AEAD_CTX *ctx)
79{
80 if (ctx == NULL)
81 return;
82
83 EVP_AEAD_CTX_cleanup(ctx);
84 free(ctx);
85}
86
71/* check_alias returns 0 if out points within the buffer determined by in 87/* check_alias returns 0 if out points within the buffer determined by in
72 * and in_len and 1 otherwise. 88 * and in_len and 1 otherwise.
73 * 89 *