| 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. |
| 4 | module 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. |
| 8 | fn 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 |
| 15 | pub const C.NID_SLH_DSA_SHA2_128s int |
| 16 | pub const C.NID_SLH_DSA_SHA2_128f int |
| 17 | pub const C.NID_SLH_DSA_SHA2_192s int |
| 18 | pub const C.NID_SLH_DSA_SHA2_192f int |
| 19 | pub const C.NID_SLH_DSA_SHA2_256s int |
| 20 | pub const C.NID_SLH_DSA_SHA2_256f int |
| 21 | pub const C.NID_SLH_DSA_SHAKE_128s int |
| 22 | pub const C.NID_SLH_DSA_SHAKE_128f int |
| 23 | pub const C.NID_SLH_DSA_SHAKE_192s int |
| 24 | pub const C.NID_SLH_DSA_SHAKE_192f int |
| 25 | pub const C.NID_SLH_DSA_SHAKE_256s int |
| 26 | pub const C.NID_SLH_DSA_SHAKE_256f int |
| 27 | |
| 28 | pub const C.LN_SLH_DSA_SHA2_128s int |
| 29 | pub const C.LN_SLH_DSA_SHA2_128f int |
| 30 | pub const C.LN_SLH_DSA_SHA2_192s int |
| 31 | pub const C.LN_SLH_DSA_SHA2_192f int |
| 32 | pub const C.LN_SLH_DSA_SHA2_256s int |
| 33 | pub const C.LN_SLH_DSA_SHA2_256f int |
| 34 | pub const C.LN_SLH_DSA_SHAKE_128s int |
| 35 | pub const C.LN_SLH_DSA_SHAKE_128f int |
| 36 | pub const C.LN_SLH_DSA_SHAKE_192s int |
| 37 | pub const C.LN_SLH_DSA_SHAKE_192f int |
| 38 | pub const C.LN_SLH_DSA_SHAKE_256s int |
| 39 | pub 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 | |
| 42 | const nid_slhdsa_sha2_128s = C.NID_SLH_DSA_SHA2_128s |
| 43 | const 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 |
| 47 | const nid_slhdsa_sha2_128f = C.NID_SLH_DSA_SHA2_128f |
| 48 | const 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 |
| 52 | const ln_slhdsa_sha2_192s = &char(C.LN_SLH_DSA_SHA2_192s) |
| 53 | const 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 |
| 57 | const ln_slhdsa_sha2_192f = &char(C.LN_SLH_DSA_SHA2_192f) |
| 58 | const 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 |
| 62 | const ln_slhdsa_sha2_256s = &char(C.LN_SLH_DSA_SHA2_256s) |
| 63 | const 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 |
| 67 | const ln_slhdsa_sha2_256f = &char(C.LN_SLH_DSA_SHA2_256f) |
| 68 | const 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 |
| 72 | const ln_slhdsa_shake_128s = &char(C.LN_SLH_DSA_SHAKE_128s) |
| 73 | const 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 |
| 77 | const ln_slhdsa_shake_128f = &char(C.LN_SLH_DSA_SHAKE_128f) |
| 78 | const 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 |
| 82 | const ln_slhdsa_shake_192s = &char(C.LN_SLH_DSA_SHAKE_192s) |
| 83 | const 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 |
| 87 | const ln_slhdsa_shake_192f = &char(C.LN_SLH_DSA_SHAKE_192f) |
| 88 | const 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 |
| 92 | const ln_slhdsa_shake_256s = &char(C.LN_SLH_DSA_SHAKE_256s) |
| 93 | const 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 |
| 97 | const ln_slhdsa_shake_256f = &char(C.LN_SLH_DSA_SHAKE_256f) |
| 98 | const nid_slhdsa_shake_256f = C.NID_SLH_DSA_SHAKE_256f |
| 99 | |
| 100 | const evp_pkey_keypair = C.EVP_PKEY_KEYPAIR |
| 101 | const evp_pkey_public_key = C.EVP_PKEY_PUBLIC_KEY |
| 102 | |