xref: /freebsd/crypto/openssl/include/crypto/slh_dsa.h (revision e7be843b4a162e68651d3911f0357ed464915629)
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 SLH_DSA_KEY *ossl_slh_dsa_key_new(OSSL_LIB_CTX *libctx, const char *propq,
27                                          const char *alg);
28 void ossl_slh_dsa_key_free(SLH_DSA_KEY *key);
29 __owur SLH_DSA_KEY *ossl_slh_dsa_key_dup(const SLH_DSA_KEY *src, int selection);
30 __owur int ossl_slh_dsa_key_equal(const SLH_DSA_KEY *key1, const SLH_DSA_KEY *key2,
31                                   int selection);
32 __owur int ossl_slh_dsa_key_has(const SLH_DSA_KEY *key, int selection);
33 __owur int ossl_slh_dsa_key_pairwise_check(const SLH_DSA_KEY *key);
34 __owur int ossl_slh_dsa_key_fromdata(SLH_DSA_KEY *key, const OSSL_PARAM *params,
35                                      int include_private);
36 __owur int ossl_slh_dsa_generate_key(SLH_DSA_HASH_CTX *ctx, SLH_DSA_KEY *out,
37                                      OSSL_LIB_CTX *libctx,
38                                      const uint8_t *entropy, size_t entropy_len);
39 __owur int ossl_slh_dsa_key_to_text(BIO *out, const SLH_DSA_KEY *key, int selection);
40 __owur const uint8_t *ossl_slh_dsa_key_get_pub(const SLH_DSA_KEY *key);
41 __owur const uint8_t *ossl_slh_dsa_key_get_priv(const SLH_DSA_KEY *key);
42 __owur size_t ossl_slh_dsa_key_get_pub_len(const SLH_DSA_KEY *key);
43 __owur int ossl_slh_dsa_set_priv(SLH_DSA_KEY *key, const uint8_t *priv,
44                                  size_t priv_len);
45 __owur int ossl_slh_dsa_set_pub(SLH_DSA_KEY *key, const uint8_t *pub,
46                                 size_t pub_len);
47 __owur size_t ossl_slh_dsa_key_get_priv_len(const SLH_DSA_KEY *key);
48 __owur size_t ossl_slh_dsa_key_get_n(const SLH_DSA_KEY *key);
49 __owur size_t ossl_slh_dsa_key_get_sig_len(const SLH_DSA_KEY *key);
50 __owur const char *ossl_slh_dsa_key_get_name(const SLH_DSA_KEY *key);
51 __owur int ossl_slh_dsa_key_get_type(const SLH_DSA_KEY *key);
52 __owur int ossl_slh_dsa_key_type_matches(const SLH_DSA_KEY *key, const char *alg);
53 __owur SLH_DSA_HASH_CTX *ossl_slh_dsa_hash_ctx_new(const SLH_DSA_KEY *key);
54 void ossl_slh_dsa_hash_ctx_free(SLH_DSA_HASH_CTX *ctx);
55 __owur SLH_DSA_HASH_CTX *ossl_slh_dsa_hash_ctx_dup(const SLH_DSA_HASH_CTX *src);
56 
57 __owur int ossl_slh_dsa_sign(SLH_DSA_HASH_CTX *slh_ctx,
58                              const uint8_t *msg, size_t msg_len,
59                              const uint8_t *ctx, size_t ctx_len,
60                              const uint8_t *add_rand, int encode,
61                              unsigned char *sig, size_t *siglen, size_t sigsize);
62 __owur int ossl_slh_dsa_verify(SLH_DSA_HASH_CTX *slh_ctx,
63                                const uint8_t *msg, size_t msg_len,
64                                const uint8_t *ctx, size_t ctx_len, int encode,
65                                const uint8_t *sig, size_t sig_len);
66 
67 #endif /* OSSL_CRYPTO_SLH_DSA_H */
68