1 /* Copyright (c) 2024, Google LLC 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 #ifndef OPENSSL_HEADER_CRYPTO_SLHDSA_PARAMS_H 16 #define OPENSSL_HEADER_CRYPTO_SLHDSA_PARAMS_H 17 18 #include <openssl/base.h> 19 20 #if defined(__cplusplus) 21 extern "C" { 22 #endif 23 24 25 // Output length of the hash function. 26 #define SLHDSA_SHA2_128S_N 16 27 // Total height of the tree structure. 28 #define SLHDSA_SHA2_128S_FULL_HEIGHT 63 29 // Number of subtree layers. 30 #define SLHDSA_SHA2_128S_D 7 31 // Height of the trees on each layer 32 #define SLHDSA_SHA2_128S_TREE_HEIGHT 9 33 // Height of each individual FORS tree. 34 #define SLHDSA_SHA2_128S_FORS_HEIGHT 12 35 // Total number of FORS tree used. 36 #define SLHDSA_SHA2_128S_FORS_TREES 14 37 // Size of a FORS signature 38 #define SLHDSA_SHA2_128S_FORS_BYTES \ 39 ((SLHDSA_SHA2_128S_FORS_HEIGHT + 1) * SLHDSA_SHA2_128S_FORS_TREES * \ 40 SLHDSA_SHA2_128S_N) 41 // The number of bytes at the beginning of M', the augmented message, before the 42 // context. 43 #define SLHDSA_M_PRIME_HEADER_LEN 2 44 45 // Winternitz parameter and derived values 46 #define SLHDSA_SHA2_128S_WOTS_W 16 47 #define SLHDSA_SHA2_128S_WOTS_LOG_W 4 48 #define SLHDSA_SHA2_128S_WOTS_LEN1 32 49 #define SLHDSA_SHA2_128S_WOTS_LEN2 3 50 #define SLHDSA_SHA2_128S_WOTS_LEN 35 51 #define SLHDSA_SHA2_128S_WOTS_BYTES \ 52 (SLHDSA_SHA2_128S_N * SLHDSA_SHA2_128S_WOTS_LEN) 53 54 // XMSS sizes 55 #define SLHDSA_SHA2_128S_XMSS_BYTES \ 56 (SLHDSA_SHA2_128S_WOTS_BYTES + \ 57 (SLHDSA_SHA2_128S_N * SLHDSA_SHA2_128S_TREE_HEIGHT)) 58 59 // Size of the message digest (NOTE: This is only correct for the SHA-256 params 60 // here) 61 #define SLHDSA_SHA2_128S_DIGEST_SIZE \ 62 (((SLHDSA_SHA2_128S_FORS_TREES * SLHDSA_SHA2_128S_FORS_HEIGHT) / 8) + \ 63 (((SLHDSA_SHA2_128S_FULL_HEIGHT - SLHDSA_SHA2_128S_TREE_HEIGHT) / 8) + 1) + \ 64 (SLHDSA_SHA2_128S_TREE_HEIGHT / 8) + 1) 65 66 // Compressed address size when using SHA-256 67 #define SLHDSA_SHA2_128S_SHA256_ADDR_BYTES 22 68 69 // Size of the FORS message hash 70 #define SLHDSA_SHA2_128S_FORS_MSG_BYTES \ 71 ((SLHDSA_SHA2_128S_FORS_HEIGHT * SLHDSA_SHA2_128S_FORS_TREES + 7) / 8) 72 #define SLHDSA_SHA2_128S_TREE_BITS \ 73 (SLHDSA_SHA2_128S_TREE_HEIGHT * (SLHDSA_SHA2_128S_D - 1)) 74 #define SLHDSA_SHA2_128S_TREE_BYTES ((SLHDSA_SHA2_128S_TREE_BITS + 7) / 8) 75 #define SLHDSA_SHA2_128S_LEAF_BITS SLHDSA_SHA2_128S_TREE_HEIGHT 76 #define SLHDSA_SHA2_128S_LEAF_BYTES ((SLHDSA_SHA2_128S_LEAF_BITS + 7) / 8) 77 78 79 #if defined(__cplusplus) 80 } // extern C 81 #endif 82 83 #endif // OPENSSL_HEADER_CRYPTO_SLHDSA_PARAMS_H 84