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 /* Internal SLH_DSA functions for other submodules, not for application use */ 11 12 #ifndef OSSL_CRYPTO_SLH_DSA_H 13 # define OSSL_CRYPTO_SLH_DSA_H 14 15 # pragma once 16 # include <openssl/e_os2.h> 17 # include <openssl/types.h> 18 # include "crypto/types.h" 19 20 # define SLH_DSA_MAX_CONTEXT_STRING_LEN 255 21 # define SLH_DSA_MAX_N 32 22 23 typedef struct slh_dsa_hash_ctx_st SLH_DSA_HASH_CTX; 24 typedef struct slh_dsa_key_st SLH_DSA_KEY; 25 26 __owur OSSL_LIB_CTX *ossl_slh_dsa_key_get0_libctx(const SLH_DSA_KEY *key); 27 __owur SLH_DSA_KEY *ossl_slh_dsa_key_new(OSSL_LIB_CTX *libctx, const char *propq, 28 const char *alg); 29 void ossl_slh_dsa_key_free(SLH_DSA_KEY *key); 30 void ossl_slh_dsa_key_reset(SLH_DSA_KEY *key); 31 __owur SLH_DSA_KEY *ossl_slh_dsa_key_dup(const SLH_DSA_KEY *src, int selection); 32 __owur int ossl_slh_dsa_key_equal(const SLH_DSA_KEY *key1, const SLH_DSA_KEY *key2, 33 int selection); 34 __owur int ossl_slh_dsa_key_has(const SLH_DSA_KEY *key, int selection); 35 __owur int ossl_slh_dsa_key_pairwise_check(const SLH_DSA_KEY *key); 36 __owur int ossl_slh_dsa_key_fromdata(SLH_DSA_KEY *key, const OSSL_PARAM *params, 37 int include_private); 38 __owur int ossl_slh_dsa_generate_key(SLH_DSA_HASH_CTX *ctx, SLH_DSA_KEY *out, 39 OSSL_LIB_CTX *libctx, 40 const uint8_t *entropy, size_t entropy_len); 41 __owur int ossl_slh_dsa_key_to_text(BIO *out, const SLH_DSA_KEY *key, int selection); 42 __owur const uint8_t *ossl_slh_dsa_key_get_pub(const SLH_DSA_KEY *key); 43 __owur const uint8_t *ossl_slh_dsa_key_get_priv(const SLH_DSA_KEY *key); 44 __owur size_t ossl_slh_dsa_key_get_pub_len(const SLH_DSA_KEY *key); 45 __owur int ossl_slh_dsa_set_priv(SLH_DSA_KEY *key, const uint8_t *priv, 46 size_t priv_len); 47 __owur int ossl_slh_dsa_set_pub(SLH_DSA_KEY *key, const uint8_t *pub, 48 size_t pub_len); 49 __owur size_t ossl_slh_dsa_key_get_priv_len(const SLH_DSA_KEY *key); 50 __owur size_t ossl_slh_dsa_key_get_n(const SLH_DSA_KEY *key); 51 __owur size_t ossl_slh_dsa_key_get_sig_len(const SLH_DSA_KEY *key); 52 __owur const char *ossl_slh_dsa_key_get_name(const SLH_DSA_KEY *key); 53 __owur int ossl_slh_dsa_key_get_type(const SLH_DSA_KEY *key); 54 __owur int ossl_slh_dsa_key_type_matches(const SLH_DSA_KEY *key, const char *alg); 55 __owur SLH_DSA_HASH_CTX *ossl_slh_dsa_hash_ctx_new(const SLH_DSA_KEY *key); 56 void ossl_slh_dsa_hash_ctx_free(SLH_DSA_HASH_CTX *ctx); 57 __owur SLH_DSA_HASH_CTX *ossl_slh_dsa_hash_ctx_dup(const SLH_DSA_HASH_CTX *src); 58 59 __owur int ossl_slh_dsa_sign(SLH_DSA_HASH_CTX *slh_ctx, 60 const uint8_t *msg, size_t msg_len, 61 const uint8_t *ctx, size_t ctx_len, 62 const uint8_t *add_rand, int encode, 63 unsigned char *sig, size_t *siglen, size_t sigsize); 64 __owur int ossl_slh_dsa_verify(SLH_DSA_HASH_CTX *slh_ctx, 65 const uint8_t *msg, size_t msg_len, 66 const uint8_t *ctx, size_t ctx_len, int encode, 67 const uint8_t *sig, size_t sig_len); 68 69 #endif /* OSSL_CRYPTO_SLH_DSA_H */ 70