* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
+{-
+use OpenSSL::paramnames qw(produce_param_decoder);
+-}
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/proverr.h>
#include "crypto/ml_kem.h"
+#include "internal/cryptlib.h"
#include "prov/provider_ctx.h"
#include "prov/implementations.h"
#include "prov/securitycheck.h"
return ml_kem_init(vctx, EVP_PKEY_OP_DECAPSULATE, key, params);
}
+{- produce_param_decoder('ml_kem_set_ctx_params',
+ (['KEM_PARAM_IKME', 'ikme', 'octet_string'],
+ )); -}
+
static int ml_kem_set_ctx_params(void *vctx, const OSSL_PARAM params[])
{
PROV_ML_KEM_CTX *ctx = vctx;
- const OSSL_PARAM *p;
+ struct ml_kem_set_ctx_params_st p;
- if (ctx == NULL)
+ if (ctx == NULL || !ml_kem_set_ctx_params_decoder(params, &p))
return 0;
if (ctx->op == EVP_PKEY_OP_DECAPSULATE && ctx->entropy != NULL) {
ctx->entropy = NULL;
}
- if (ossl_param_is_empty(params))
- return 1;
-
/* Encapsulation ephemeral input key material "ikmE" */
- if (ctx->op == EVP_PKEY_OP_ENCAPSULATE
- && (p = OSSL_PARAM_locate_const(params, OSSL_KEM_PARAM_IKME)) != NULL) {
+ if (ctx->op == EVP_PKEY_OP_ENCAPSULATE && p.ikme != NULL) {
size_t len = ML_KEM_RANDOM_BYTES;
ctx->entropy = ctx->entropy_buf;
- if (OSSL_PARAM_get_octet_string(p, (void **)&ctx->entropy,
+ if (OSSL_PARAM_get_octet_string(p.ikme, (void **)&ctx->entropy,
len, &len)
&& len == ML_KEM_RANDOM_BYTES)
return 1;
static const OSSL_PARAM *ml_kem_settable_ctx_params(ossl_unused void *vctx,
ossl_unused void *provctx)
{
- static const OSSL_PARAM params[] = {
- OSSL_PARAM_octet_string(OSSL_KEM_PARAM_IKME, NULL, 0),
- OSSL_PARAM_END
- };
-
- return params;
+ return ml_kem_set_ctx_params_list;
}
static int ml_kem_encapsulate(void *vctx, unsigned char *ctext, size_t *clen,