1*e7be843bSPierre Pronchery /* 2*e7be843bSPierre Pronchery * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved. 3*e7be843bSPierre Pronchery * 4*e7be843bSPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use 5*e7be843bSPierre Pronchery * this file except in compliance with the License. You can obtain a copy 6*e7be843bSPierre Pronchery * in the file LICENSE in the source distribution or at 7*e7be843bSPierre Pronchery * https://www.openssl.org/source/license.html 8*e7be843bSPierre Pronchery */ 9*e7be843bSPierre Pronchery 10*e7be843bSPierre Pronchery #ifndef OSSL_MLX_KEM_H 11*e7be843bSPierre Pronchery # define OSSL_MLX_KEM_H 12*e7be843bSPierre Pronchery # pragma once 13*e7be843bSPierre Pronchery 14*e7be843bSPierre Pronchery #include <openssl/evp.h> 15*e7be843bSPierre Pronchery #include <openssl/ml_kem.h> 16*e7be843bSPierre Pronchery #include <crypto/ml_kem.h> 17*e7be843bSPierre Pronchery #include <crypto/ecx.h> 18*e7be843bSPierre Pronchery 19*e7be843bSPierre Pronchery typedef struct ecdh_vinfo_st { 20*e7be843bSPierre Pronchery const char *algorithm_name; 21*e7be843bSPierre Pronchery const char *group_name; 22*e7be843bSPierre Pronchery size_t pubkey_bytes; 23*e7be843bSPierre Pronchery size_t prvkey_bytes; 24*e7be843bSPierre Pronchery size_t shsec_bytes; 25*e7be843bSPierre Pronchery int ml_kem_slot; 26*e7be843bSPierre Pronchery int ml_kem_variant; 27*e7be843bSPierre Pronchery } ECDH_VINFO; 28*e7be843bSPierre Pronchery 29*e7be843bSPierre Pronchery typedef struct mlx_key_st { 30*e7be843bSPierre Pronchery OSSL_LIB_CTX *libctx; 31*e7be843bSPierre Pronchery char *propq; 32*e7be843bSPierre Pronchery const ML_KEM_VINFO *minfo; 33*e7be843bSPierre Pronchery const ECDH_VINFO *xinfo; 34*e7be843bSPierre Pronchery EVP_PKEY *mkey; 35*e7be843bSPierre Pronchery EVP_PKEY *xkey; 36*e7be843bSPierre Pronchery unsigned int state; 37*e7be843bSPierre Pronchery } MLX_KEY; 38*e7be843bSPierre Pronchery 39*e7be843bSPierre Pronchery #define MLX_HAVE_NOKEYS 0 40*e7be843bSPierre Pronchery #define MLX_HAVE_PUBKEY 1 41*e7be843bSPierre Pronchery #define MLX_HAVE_PRVKEY 2 42*e7be843bSPierre Pronchery 43*e7be843bSPierre Pronchery /* Both key parts have whatever the ML-KEM component has */ 44*e7be843bSPierre Pronchery #define mlx_kem_have_pubkey(key) ((key)->state > 0) 45*e7be843bSPierre Pronchery #define mlx_kem_have_prvkey(key) ((key)->state > 1) 46*e7be843bSPierre Pronchery 47*e7be843bSPierre Pronchery #endif 48