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