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 #include <openssl/e_os2.h> 11 12 #define SLH_DSA_MAX_N 32 13 #define SLH_DSA_SK_SEED(key) ((key)->priv) 14 #define SLH_DSA_SK_PRF(key) ((key)->priv + (key)->params->n) 15 #define SLH_DSA_PK_SEED(key) ((key)->priv + (key)->params->n * 2) 16 #define SLH_DSA_PK_ROOT(key) ((key)->priv + (key)->params->n * 3) 17 #define SLH_DSA_PUB(key) SLH_DSA_PK_SEED(key) 18 #define SLH_DSA_PRIV(key) SLH_DSA_SK_SEED(key) 19 20 /* 21 * NOTE: Any changes to this structure may require updating ossl_slh_dsa_key_dup(). 22 */ 23 struct slh_dsa_key_st { 24 /* 25 * A private key consists of 26 * Private SEED and PRF values of size |n| 27 * Public SEED and ROOT values of size |n| 28 * (Unlike X25519 the public key is not (fully) constructed from the 29 * private key so when encoded the private key must contain the public key) 30 */ 31 uint8_t priv[4 * SLH_DSA_MAX_N]; 32 /* 33 * pub will be NULL initially. 34 * When either a private or public key is loaded it will then point 35 * to &priv[n * 2] 36 */ 37 uint8_t *pub; 38 OSSL_LIB_CTX *libctx; 39 char *propq; 40 int has_priv; /* Set to 1 if there is a private key component */ 41 42 const SLH_DSA_PARAMS *params; 43 const SLH_ADRS_FUNC *adrs_func; 44 const SLH_HASH_FUNC *hash_func; 45 /* See FIPS 205 Section 11.1 */ 46 47 EVP_MD *md; /* Used for SHAKE and SHA-256 */ 48 EVP_MD *md_big; /* Used for SHA-256 or SHA-512 */ 49 EVP_MAC *hmac; 50 }; 51