-/* $OpenBSD: evp.h,v 1.90 2021/12/24 12:55:04 tb Exp $ */
+/* $OpenBSD: evp.h,v 1.91 2022/01/07 21:58:17 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* should be used. */
#define EVP_AEAD_DEFAULT_TAG_LENGTH 0
-/* EVP_AEAD_init initializes the context for the given AEAD algorithm.
+#if defined(LIBRESSL_CRYPTO_INTERANL) || defined(LIBRESSL_NEXT_API)
+/* EVP_AEAD_CTX_new allocates a new context for use with EVP_AEAD_CTX_init.
+ * It can be cleaned up for reuse with EVP_AEAD_CTX_cleanup and must be freed
+ * with EVP_AEAD_CTX_free. */
+EVP_AEAD_CTX *EVP_AEAD_CTX_new(void);
+
+/* EVP_AEAD_CTX_free releases all memory owned by the context. */
+void EVP_AEAD_CTX_free(EVP_AEAD_CTX *ctx);
+#endif
+
+/* EVP_AEAD_CTX_init initializes the context for the given AEAD algorithm.
* The implementation argument may be NULL to choose the default implementation.
* Authentication tags may be truncated by passing a tag length. A tag length
* of zero indicates the default tag length should be used. */
-/* $OpenBSD: evp_aead.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */
+/* $OpenBSD: evp_aead.c,v 1.7 2022/01/07 21:58:17 tb Exp $ */
/*
* Copyright (c) 2014, Google Inc.
*
ctx->aead = NULL;
}
+EVP_AEAD_CTX *
+EVP_AEAD_CTX_new(void)
+{
+ return calloc(1, sizeof(EVP_AEAD_CTX));
+}
+
+void
+EVP_AEAD_CTX_free(EVP_AEAD_CTX *ctx)
+{
+ if (ctx == NULL)
+ return;
+
+ EVP_AEAD_CTX_cleanup(ctx);
+ free(ctx);
+}
+
/* check_alias returns 0 if out points within the buffer determined by in
* and in_len and 1 otherwise.
*