diff options
Diffstat (limited to 'include/crypto/hpke.h')
-rw-r--r-- | include/crypto/hpke.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/crypto/hpke.h b/include/crypto/hpke.h new file mode 100644 index 0000000000..e3596fdb90 --- /dev/null +++ b/include/crypto/hpke.h @@ -0,0 +1,47 @@ +/* + * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_HPKE_H +# define OSSL_CRYPTO_HPKE_H +# pragma once + +/* Constants from RFC 9180 Section 7.1 and 7.3 */ +#define OSSL_HPKE_MAX_SECRET 64 +#define OSSL_HPKE_MAX_PUBLIC 133 +#define OSSL_HPKE_MAX_PRIVATE 66 +#define OSSL_HPKE_MAX_NONCE 12 +#define OSSL_HPKE_MAX_KDF_INPUTLEN 64 + +int ossl_hpke_kdf_extract(EVP_KDF_CTX *kctx, + unsigned char *prk, size_t prklen, + const unsigned char *salt, size_t saltlen, + const unsigned char *ikm, size_t ikmlen); + +int ossl_hpke_kdf_expand(EVP_KDF_CTX *kctx, + unsigned char *okm, size_t okmlen, + const unsigned char *prk, size_t prklen, + const unsigned char *info, size_t infolen); + +int ossl_hpke_labeled_extract(EVP_KDF_CTX *kctx, + unsigned char *prk, size_t prklen, + const unsigned char *salt, size_t saltlen, + const unsigned char *suiteid, size_t suiteidlen, + const char *label, + const unsigned char *ikm, size_t ikmlen); +int ossl_hpke_labeled_expand(EVP_KDF_CTX *kctx, + unsigned char *okm, size_t okmlen, + const unsigned char *prk, size_t prklen, + const unsigned char *suiteid, size_t suiteidlen, + const char *label, + const unsigned char *info, size_t infolen); + +EVP_KDF_CTX *ossl_kdf_ctx_create(const char *kdfname, const char *mdname, + OSSL_LIB_CTX *libctx, const char *propq); + +#endif |