Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/lms/lms_params.c

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 #include "crypto/lms.h"
11
12 /* Refer to SP800-208 Section 4 LMS Parameter Sets */
13 static const LMS_PARAMS lms_params[] = {
14 { OSSL_LMS_TYPE_SHA256_N32_H5, "SHA256", 32, 5 },
15 { OSSL_LMS_TYPE_SHA256_N32_H10, "SHA256", 32, 10 },
16 { OSSL_LMS_TYPE_SHA256_N32_H15, "SHA256", 32, 15 },
17 { OSSL_LMS_TYPE_SHA256_N32_H20, "SHA256", 32, 20 },
18 { OSSL_LMS_TYPE_SHA256_N32_H25, "SHA256", 32, 25 },
19 { OSSL_LMS_TYPE_SHA256_N24_H5, "SHA256-192", 24, 5 },
20 { OSSL_LMS_TYPE_SHA256_N24_H10, "SHA256-192", 24, 10 },
21 { OSSL_LMS_TYPE_SHA256_N24_H15, "SHA256-192", 24, 15 },
22 { OSSL_LMS_TYPE_SHA256_N24_H20, "SHA256-192", 24, 20 },
23 { OSSL_LMS_TYPE_SHA256_N24_H25, "SHA256-192", 24, 25 },
24 { OSSL_LMS_TYPE_SHAKE_N32_H5, "SHAKE-256", 32, 5 },
25 { OSSL_LMS_TYPE_SHAKE_N32_H10, "SHAKE-256", 32, 10 },
26 { OSSL_LMS_TYPE_SHAKE_N32_H15, "SHAKE-256", 32, 15 },
27 { OSSL_LMS_TYPE_SHAKE_N32_H20, "SHAKE-256", 32, 20 },
28 { OSSL_LMS_TYPE_SHAKE_N32_H25, "SHAKE-256", 32, 25 },
29 /* SHAKE-256/192 */
30 { OSSL_LMS_TYPE_SHAKE_N24_H5, "SHAKE-256", 24, 5 },
31 { OSSL_LMS_TYPE_SHAKE_N24_H10, "SHAKE-256", 24, 10 },
32 { OSSL_LMS_TYPE_SHAKE_N24_H15, "SHAKE-256", 24, 15 },
33 { OSSL_LMS_TYPE_SHAKE_N24_H20, "SHAKE-256", 24, 20 },
34 { OSSL_LMS_TYPE_SHAKE_N24_H25, "SHAKE-256", 24, 25 },
35
36 { 0, NULL, 0, 0 }
37 };
38
39 /**
40 * @brief A getter to convert a |lms_type| into a LMS_PARAMS object.
41 *
42 * @param lms_type The type such as OSSL_LMS_TYPE_SHA256_N32_H5.
43 * @returns The LMS_PARAMS object associated with the |lms_type|, or
44 * NULL if |lms_type| is undefined.
45 */
46 const LMS_PARAMS *ossl_lms_params_get(uint32_t lms_type)
47 {
48 const LMS_PARAMS *p;
49
50 for (p = lms_params; p->digestname != NULL; ++p)
51 if (p->lms_type == lms_type)
52 return p;
53 return NULL;
54 }