/src/nss/lib/freebl/verified/libcrux_sha3.h
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * SPDX-FileCopyrightText: 2024 Cryspen Sarl <info@cryspen.com>  | 
3  |  |  *  | 
4  |  |  * SPDX-License-Identifier: MIT or Apache-2.0  | 
5  |  |  *  | 
6  |  |  * This code was generated with the following revisions:  | 
7  |  |  * Charon: b351338f6a84c7a1afc27433eb0ffdc668b3581d  | 
8  |  |  * Eurydice: 7efec1624422fd5e94388ef06b9c76dfe7a48d46  | 
9  |  |  * Karamel: c96fb69d15693284644d6aecaa90afa37e4de8f0  | 
10  |  |  * F*: 58c915a86a2c07c8eca8d9deafd76cb7a91f0eb7  | 
11  |  |  * Libcrux: 6ff01fb3c57ff29ecb59bc62d9dc7fd231060cfb  | 
12  |  |  */  | 
13  |  |  | 
14  |  | #ifndef __libcrux_sha3_H  | 
15  |  | #define __libcrux_sha3_H  | 
16  |  |  | 
17  |  | #if defined(__cplusplus)  | 
18  |  | extern "C" { | 
19  |  | #endif  | 
20  |  |  | 
21  |  | #include "eurydice_glue.h"  | 
22  |  | #include "libcrux_core.h"  | 
23  |  | #include "libcrux_sha3_internal.h"  | 
24  |  |  | 
25  |  | /**  | 
26  |  |  A portable SHA3 512 implementation.  | 
27  |  | */  | 
28  |  | static KRML_MUSTINLINE void  | 
29  |  | libcrux_sha3_portable_sha512(Eurydice_slice digest,  | 
30  |  |                              Eurydice_slice data)  | 
31  | 0  | { | 
32  | 0  |     Eurydice_slice buf0[1U] = { data }; | 
33  | 0  |     Eurydice_slice buf[1U] = { digest }; | 
34  | 0  |     libcrux_sha3_portable_keccakx1_e4(buf0, buf);  | 
35  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_portable_sha512 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_portable_sha512  | 
36  |  |  | 
37  |  | /**  | 
38  |  |  A portable SHA3 256 implementation.  | 
39  |  | */  | 
40  |  | static KRML_MUSTINLINE void  | 
41  |  | libcrux_sha3_portable_sha256(Eurydice_slice digest,  | 
42  |  |                              Eurydice_slice data)  | 
43  | 0  | { | 
44  | 0  |     Eurydice_slice buf0[1U] = { data }; | 
45  | 0  |     Eurydice_slice buf[1U] = { digest }; | 
46  | 0  |     libcrux_sha3_portable_keccakx1_e40(buf0, buf);  | 
47  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_portable_sha256 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_portable_sha256  | 
48  |  |  | 
49  |  | /**  | 
50  |  |  A portable SHAKE256 implementation.  | 
51  |  | */  | 
52  |  | static KRML_MUSTINLINE void  | 
53  |  | libcrux_sha3_portable_shake256(  | 
54  |  |     Eurydice_slice digest, Eurydice_slice data)  | 
55  | 0  | { | 
56  | 0  |     Eurydice_slice buf0[1U] = { data }; | 
57  | 0  |     Eurydice_slice buf[1U] = { digest }; | 
58  | 0  |     libcrux_sha3_portable_keccakx1_e41(buf0, buf);  | 
59  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_portable_shake256 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_portable_shake256  | 
60  |  |  | 
61  |  | /**  | 
62  |  |  A portable SHA3 224 implementation.  | 
63  |  | */  | 
64  |  | static KRML_MUSTINLINE void  | 
65  |  | libcrux_sha3_portable_sha224(Eurydice_slice digest,  | 
66  |  |                              Eurydice_slice data)  | 
67  | 0  | { | 
68  | 0  |     Eurydice_slice buf0[1U] = { data }; | 
69  | 0  |     Eurydice_slice buf[1U] = { digest }; | 
70  | 0  |     libcrux_sha3_portable_keccakx1_e42(buf0, buf);  | 
71  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_portable_sha224 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_portable_sha224  | 
72  |  |  | 
73  |  | /**  | 
74  |  |  A portable SHA3 384 implementation.  | 
75  |  | */  | 
76  |  | static KRML_MUSTINLINE void  | 
77  |  | libcrux_sha3_portable_sha384(Eurydice_slice digest,  | 
78  |  |                              Eurydice_slice data)  | 
79  | 0  | { | 
80  | 0  |     Eurydice_slice buf0[1U] = { data }; | 
81  | 0  |     Eurydice_slice buf[1U] = { digest }; | 
82  | 0  |     libcrux_sha3_portable_keccakx1_e43(buf0, buf);  | 
83  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_portable_sha384 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_portable_sha384  | 
84  |  |  | 
85  |  | /**  | 
86  |  |  SHA3 224  | 
87  |  |  | 
88  |  |  Preconditions:  | 
89  |  |  - `digest.len() == 28`  | 
90  |  | */  | 
91  |  | static KRML_MUSTINLINE void  | 
92  |  | libcrux_sha3_sha224_ema(Eurydice_slice digest,  | 
93  |  |                         Eurydice_slice payload)  | 
94  | 0  | { | 
95  | 0  |     libcrux_sha3_portable_sha224(digest, payload);  | 
96  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha224_ema Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha224_ema  | 
97  |  |  | 
98  |  | /**  | 
99  |  |  SHA3 224  | 
100  |  | */  | 
101  |  | static KRML_MUSTINLINE void  | 
102  |  | libcrux_sha3_sha224(Eurydice_slice data,  | 
103  |  |                     uint8_t ret[28U])  | 
104  | 0  | { | 
105  | 0  |     uint8_t out[28U] = { 0U }; | 
106  | 0  |     libcrux_sha3_sha224_ema(Eurydice_array_to_slice((size_t)28U, out, uint8_t),  | 
107  | 0  |                             data);  | 
108  | 0  |     memcpy(ret, out, (size_t)28U * sizeof(uint8_t));  | 
109  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha224 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha224  | 
110  |  |  | 
111  |  | /**  | 
112  |  |  SHA3 256  | 
113  |  | */  | 
114  |  | static KRML_MUSTINLINE void  | 
115  |  | libcrux_sha3_sha256_ema(Eurydice_slice digest,  | 
116  |  |                         Eurydice_slice payload)  | 
117  | 0  | { | 
118  | 0  |     libcrux_sha3_portable_sha256(digest, payload);  | 
119  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha256_ema Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha256_ema  | 
120  |  |  | 
121  |  | /**  | 
122  |  |  SHA3 256  | 
123  |  | */  | 
124  |  | static KRML_MUSTINLINE void  | 
125  |  | libcrux_sha3_sha256(Eurydice_slice data,  | 
126  |  |                     uint8_t ret[32U])  | 
127  | 0  | { | 
128  | 0  |     uint8_t out[32U] = { 0U }; | 
129  | 0  |     libcrux_sha3_sha256_ema(Eurydice_array_to_slice((size_t)32U, out, uint8_t),  | 
130  | 0  |                             data);  | 
131  | 0  |     memcpy(ret, out, (size_t)32U * sizeof(uint8_t));  | 
132  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha256 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha256  | 
133  |  |  | 
134  |  | /**  | 
135  |  |  SHA3 384  | 
136  |  | */  | 
137  |  | static KRML_MUSTINLINE void  | 
138  |  | libcrux_sha3_sha384_ema(Eurydice_slice digest,  | 
139  |  |                         Eurydice_slice payload)  | 
140  | 0  | { | 
141  | 0  |     libcrux_sha3_portable_sha384(digest, payload);  | 
142  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha384_ema Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha384_ema  | 
143  |  |  | 
144  |  | /**  | 
145  |  |  SHA3 384  | 
146  |  | */  | 
147  |  | static KRML_MUSTINLINE void  | 
148  |  | libcrux_sha3_sha384(Eurydice_slice data,  | 
149  |  |                     uint8_t ret[48U])  | 
150  | 0  | { | 
151  | 0  |     uint8_t out[48U] = { 0U }; | 
152  | 0  |     libcrux_sha3_sha384_ema(Eurydice_array_to_slice((size_t)48U, out, uint8_t),  | 
153  | 0  |                             data);  | 
154  | 0  |     memcpy(ret, out, (size_t)48U * sizeof(uint8_t));  | 
155  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha384 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha384  | 
156  |  |  | 
157  |  | /**  | 
158  |  |  SHA3 512  | 
159  |  | */  | 
160  |  | static KRML_MUSTINLINE void  | 
161  |  | libcrux_sha3_sha512_ema(Eurydice_slice digest,  | 
162  |  |                         Eurydice_slice payload)  | 
163  | 0  | { | 
164  | 0  |     libcrux_sha3_portable_sha512(digest, payload);  | 
165  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha512_ema Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha512_ema  | 
166  |  |  | 
167  |  | /**  | 
168  |  |  SHA3 512  | 
169  |  | */  | 
170  |  | static KRML_MUSTINLINE void  | 
171  |  | libcrux_sha3_sha512(Eurydice_slice data,  | 
172  |  |                     uint8_t ret[64U])  | 
173  | 0  | { | 
174  | 0  |     uint8_t out[64U] = { 0U }; | 
175  | 0  |     libcrux_sha3_sha512_ema(Eurydice_array_to_slice((size_t)64U, out, uint8_t),  | 
176  | 0  |                             data);  | 
177  | 0  |     memcpy(ret, out, (size_t)64U * sizeof(uint8_t));  | 
178  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_sha512 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_sha512  | 
179  |  |  | 
180  |  | /**  | 
181  |  |  A portable SHAKE128 implementation.  | 
182  |  | */  | 
183  |  | static KRML_MUSTINLINE void  | 
184  |  | libcrux_sha3_portable_shake128(  | 
185  |  |     Eurydice_slice digest, Eurydice_slice data)  | 
186  | 0  | { | 
187  | 0  |     Eurydice_slice buf0[1U] = { data }; | 
188  | 0  |     Eurydice_slice buf[1U] = { digest }; | 
189  | 0  |     libcrux_sha3_portable_keccakx1_e44(buf0, buf);  | 
190  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_portable_shake128 Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_portable_shake128  | 
191  |  |  | 
192  |  | /**  | 
193  |  |  SHAKE 128  | 
194  |  |  | 
195  |  |  Writes `out.len()` bytes.  | 
196  |  | */  | 
197  |  | static KRML_MUSTINLINE void  | 
198  |  | libcrux_sha3_shake128_ema(Eurydice_slice out,  | 
199  |  |                           Eurydice_slice data)  | 
200  | 0  | { | 
201  | 0  |     libcrux_sha3_portable_shake128(out, data);  | 
202  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_shake128_ema Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_shake128_ema  | 
203  |  |  | 
204  |  | /**  | 
205  |  |  SHAKE 256  | 
206  |  |  | 
207  |  |  Writes `out.len()` bytes.  | 
208  |  | */  | 
209  |  | static KRML_MUSTINLINE void  | 
210  |  | libcrux_sha3_shake256_ema(Eurydice_slice out,  | 
211  |  |                           Eurydice_slice data)  | 
212  | 0  | { | 
213  | 0  |     libcrux_sha3_portable_shake256(out, data);  | 
214  | 0  | } Unexecuted instantiation: libcrux_mlkem768_portable.c:libcrux_sha3_shake256_ema Unexecuted instantiation: libcrux_mlkem_portable.c:libcrux_sha3_shake256_ema  | 
215  |  |  | 
216  |  | #if defined(__cplusplus)  | 
217  |  | }  | 
218  |  | #endif  | 
219  |  |  | 
220  |  | #define __libcrux_sha3_H_DEFINED  | 
221  |  | #endif  |