v2 / vlib / x / crypto / slhdsa / const.c.v
101 lines · 85 sloc · 4.14 KB · e2e5cf8db56f3562c7baa735061690be936bdf3e
Raw
1// Copyright (c) blackshirt. All rights reserved.
2// Use of this source code is governed by an MIT license
3// that can be found in the LICENSE file.
4module slhdsa
5
6// The SLH-DSA functionality was added in recent OpenSSL 3.5 version.
7// So, we would panic if this module run on unmeet version on the current stock.
8fn init() {
9 if C.OpenSSL_version_num() < u64(0x030500000) {
10 panic('Your OpenSSL version ${C.OpenSSL_version_num().hex()} does not support for SLH-DSA')
11 }
12}
13
14// NID and LN constants for SLH-DSA algorithms
15pub const C.NID_SLH_DSA_SHA2_128s int
16pub const C.NID_SLH_DSA_SHA2_128f int
17pub const C.NID_SLH_DSA_SHA2_192s int
18pub const C.NID_SLH_DSA_SHA2_192f int
19pub const C.NID_SLH_DSA_SHA2_256s int
20pub const C.NID_SLH_DSA_SHA2_256f int
21pub const C.NID_SLH_DSA_SHAKE_128s int
22pub const C.NID_SLH_DSA_SHAKE_128f int
23pub const C.NID_SLH_DSA_SHAKE_192s int
24pub const C.NID_SLH_DSA_SHAKE_192f int
25pub const C.NID_SLH_DSA_SHAKE_256s int
26pub const C.NID_SLH_DSA_SHAKE_256f int
27
28pub const C.LN_SLH_DSA_SHA2_128s int
29pub const C.LN_SLH_DSA_SHA2_128f int
30pub const C.LN_SLH_DSA_SHA2_192s int
31pub const C.LN_SLH_DSA_SHA2_192f int
32pub const C.LN_SLH_DSA_SHA2_256s int
33pub const C.LN_SLH_DSA_SHA2_256f int
34pub const C.LN_SLH_DSA_SHAKE_128s int
35pub const C.LN_SLH_DSA_SHAKE_128f int
36pub const C.LN_SLH_DSA_SHAKE_192s int
37pub const C.LN_SLH_DSA_SHAKE_192f int
38pub const C.LN_SLH_DSA_SHAKE_256s int
39pub const C.LN_SLH_DSA_SHAKE_256f int // #define LN_SLH_DSA_SHA2_128s "SLH-DSA-SHA2-128s"
40// #define NID_SLH_DSA_SHA2_128s 1460
41
42const nid_slhdsa_sha2_128s = C.NID_SLH_DSA_SHA2_128s
43const ln_slhdsa_sha2_128s = &char(C.LN_SLH_DSA_SHA2_128s)
44
45// #define LN_SLH_DSA_SHA2_128f "SLH-DSA-SHA2-128f"
46// #define NID_SLH_DSA_SHA2_128f 1461
47const nid_slhdsa_sha2_128f = C.NID_SLH_DSA_SHA2_128f
48const ln_slhdsa_sha2_128f = &char(C.LN_SLH_DSA_SHA2_128f)
49
50// #define LN_SLH_DSA_SHA2_192s "SLH-DSA-SHA2-192s"
51// #define NID_SLH_DSA_SHA2_192s 1462
52const ln_slhdsa_sha2_192s = &char(C.LN_SLH_DSA_SHA2_192s)
53const nid_slhdsa_sha2_192s = C.NID_SLH_DSA_SHA2_192s
54
55// #define LN_SLH_DSA_SHA2_192f "SLH-DSA-SHA2-192f"
56// #define NID_SLH_DSA_SHA2_192f 1463
57const ln_slhdsa_sha2_192f = &char(C.LN_SLH_DSA_SHA2_192f)
58const nid_slhdsa_sha2_192f = C.NID_SLH_DSA_SHA2_192f
59
60// #define LN_SLH_DSA_SHA2_256s "SLH-DSA-SHA2-256s"
61// #define NID_SLH_DSA_SHA2_256s 1464
62const ln_slhdsa_sha2_256s = &char(C.LN_SLH_DSA_SHA2_256s)
63const nid_slhdsa_sha2_256s = C.NID_SLH_DSA_SHA2_256s
64
65// #define LN_SLH_DSA_SHA2_256f "SLH-DSA-SHA2-256f"
66// #define NID_SLH_DSA_SHA2_256f 1465
67const ln_slhdsa_sha2_256f = &char(C.LN_SLH_DSA_SHA2_256f)
68const nid_slhdsa_sha2_256f = C.NID_SLH_DSA_SHA2_256f
69
70// #define LN_SLH_DSA_SHAKE_128s "SLH-DSA-SHAKE-128s"
71// #define NID_SLH_DSA_SHAKE_128s 1466
72const ln_slhdsa_shake_128s = &char(C.LN_SLH_DSA_SHAKE_128s)
73const nid_slhdsa_shake_128s = C.NID_SLH_DSA_SHAKE_128s
74
75// #define LN_SLH_DSA_SHAKE_128f "SLH-DSA-SHAKE-128f"
76// #define NID_SLH_DSA_SHAKE_128f 1467
77const ln_slhdsa_shake_128f = &char(C.LN_SLH_DSA_SHAKE_128f)
78const nid_slhdsa_shake_128f = C.NID_SLH_DSA_SHAKE_128f
79
80// #define LN_SLH_DSA_SHAKE_192s "SLH-DSA-SHAKE-192s"
81// #define NID_SLH_DSA_SHAKE_192s 1468
82const ln_slhdsa_shake_192s = &char(C.LN_SLH_DSA_SHAKE_192s)
83const nid_slhdsa_shake_192s = C.NID_SLH_DSA_SHAKE_192s
84
85// #define LN_SLH_DSA_SHAKE_192f "SLH-DSA-SHAKE-192f"
86// #define NID_SLH_DSA_SHAKE_192f 1469
87const ln_slhdsa_shake_192f = &char(C.LN_SLH_DSA_SHAKE_192f)
88const nid_slhdsa_shake_192f = C.NID_SLH_DSA_SHAKE_192f
89
90// #define LN_SLH_DSA_SHAKE_256s "SLH-DSA-SHAKE-256s"
91// #define NID_SLH_DSA_SHAKE_256s 1470
92const ln_slhdsa_shake_256s = &char(C.LN_SLH_DSA_SHAKE_256s)
93const nid_slhdsa_shake_256s = C.NID_SLH_DSA_SHAKE_256s
94
95// #define LN_SLH_DSA_SHAKE_256f "SLH-DSA-SHAKE-256f"
96// #define NID_SLH_DSA_SHAKE_256f 1471
97const ln_slhdsa_shake_256f = &char(C.LN_SLH_DSA_SHAKE_256f)
98const nid_slhdsa_shake_256f = C.NID_SLH_DSA_SHAKE_256f
99
100const evp_pkey_keypair = C.EVP_PKEY_KEYPAIR
101const evp_pkey_public_key = C.EVP_PKEY_PUBLIC_KEY
102