Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/include/crypto/lms_sig.h

raw
1 /*
2 * Copyright 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 /*
11 * Internal LMS/LM_OTS functions for other submodules,
12 * not for application use
13 *
14 * Refer to RFC 8554 Sections 5.4 & 4.5 for information related to
15 * LMS Signatures & LM_OTS Signature Generation respectively.
16 */
17
18 #ifndef OSSL_CRYPTO_LMS_SIG_H
19 #define OSSL_CRYPTO_LMS_SIG_H
20 #pragma once
21 #ifndef OPENSSL_NO_LMS
22 #include "lms.h"
23 #include "internal/packet.h"
24
25 /* The values defined for 8 byte TAGS */
26 extern const uint16_t OSSL_LMS_D_PBLC; /* 8080 */
27 extern const uint16_t OSSL_LMS_D_MESG; /* 8181 */
28 extern const uint16_t OSSL_LMS_D_LEAF; /* 8282 */
29 extern const uint16_t OSSL_LMS_D_INTR; /* 8383 */
30
31 /* Used by OTS signature when calculating Q || Cksm(Q) */
32 #define LMS_SIZE_CHECKSUM 2
33 #define LMS_SIZE_QSUM 2
34
35 /*
36 * An object for storing a One-Time Signature
37 * See RFC 8554 Section 4.5
38 */
39 typedef struct lm_ots_sig_st {
40 const LM_OTS_PARAMS *params;
41 /* For verify operations the following pointers are not allocated */
42 unsigned char *C; /* A salt value of size n */
43 unsigned char *y; /* The trailing part of a signature of size p * n */
44 } LM_OTS_SIG;
45
46 /*
47 * An object for storing a LMS signature
48 * See RFC 8554 Section 5.4
49 */
50 typedef struct lms_signature_st {
51 uint32_t q;
52 LM_OTS_SIG sig;
53 const LMS_PARAMS *params; /* contains the LMS type */
54 unsigned char *paths; /* size is h * m */
55 } LMS_SIG;
56
57 LMS_SIG *ossl_lms_sig_new(void);
58 void ossl_lms_sig_free(LMS_SIG *sig);
59 LMS_SIG *ossl_lms_sig_from_pkt(PACKET *pkt, const LMS_KEY *pub);
60 int ossl_lms_sig_decode(LMS_SIG **out, LMS_KEY *pub,
61 const unsigned char *sig, size_t siglen);
62 int ossl_lms_sig_verify(const LMS_SIG *lms_sig, const LMS_KEY *pub,
63 const EVP_MD *md,
64 const unsigned char *msg, size_t msglen);
65
66 int ossl_lm_ots_compute_pubkey(EVP_MD_CTX *ctx, EVP_MD_CTX *ctxIq,
67 const LM_OTS_SIG *sig, const LM_OTS_PARAMS *pub,
68 const unsigned char *Id, uint32_t q,
69 const unsigned char *msg, size_t msglen,
70 unsigned char *Kc);
71 uint16_t ossl_lm_ots_params_checksum(const LM_OTS_PARAMS *params,
72 const unsigned char *S);
73
74 #endif /* OPENSSL_NO_LMS */
75 #endif /* OSSL_CRYPTO_LMS_SIG_H */