1 // Copyright 2024 The BoringSSL Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef OPENSSL_HEADER_CRYPTO_FIPSMODULE_SLHDSA_FORS_H
16 #define OPENSSL_HEADER_CRYPTO_FIPSMODULE_SLHDSA_FORS_H
17 
18 #include "./params.h"
19 
20 #if defined(__cplusplus)
21 extern "C" {
22 #endif
23 
24 
25 // Implements Algorithm 14: fors_skGen function (page 29)
26 void slhdsa_fors_sk_gen(uint8_t fors_sk[BCM_SLHDSA_SHA2_128S_N], uint32_t idx,
27                         const uint8_t sk_seed[BCM_SLHDSA_SHA2_128S_N],
28                         const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N],
29                         uint8_t addr[32]);
30 
31 // Implements Algorithm 15: fors_node function (page 30)
32 void slhdsa_fors_treehash(uint8_t root_node[BCM_SLHDSA_SHA2_128S_N],
33                           const uint8_t sk_seed[BCM_SLHDSA_SHA2_128S_N],
34                           uint32_t i /*target node index*/,
35                           uint32_t z /*target node height*/,
36                           const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N],
37                           uint8_t addr[32]);
38 
39 // Implements Algorithm 16: fors_sign function (page 31)
40 void slhdsa_fors_sign(uint8_t fors_sig[SLHDSA_SHA2_128S_FORS_BYTES],
41                       const uint8_t message[SLHDSA_SHA2_128S_FORS_MSG_BYTES],
42                       const uint8_t sk_seed[BCM_SLHDSA_SHA2_128S_N],
43                       const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N],
44                       uint8_t addr[32]);
45 
46 // Implements Algorithm 17: fors_pkFromSig function (page 32)
47 void slhdsa_fors_pk_from_sig(
48     uint8_t fors_pk[BCM_SLHDSA_SHA2_128S_N],
49     const uint8_t fors_sig[SLHDSA_SHA2_128S_FORS_BYTES],
50     const uint8_t message[SLHDSA_SHA2_128S_FORS_MSG_BYTES],
51     const uint8_t pk_seed[BCM_SLHDSA_SHA2_128S_N], uint8_t addr[32]);
52 
53 
54 #if defined(__cplusplus)
55 }  // extern C
56 #endif
57 
58 #endif  // OPENSSL_HEADER_CRYPTO_FIPSMODULE_SLHDSA_FORS_H
59