Skip to content

Commit 645c855

Browse files
committed
update vendored HACL* project
This pull the required files from the HACL* project. Once streaming HACL* HMAC becomes available upstream, we will update this commit with the required files.
1 parent 20ce770 commit 645c855

32 files changed

+7196
-940
lines changed

Misc/sbom.spdx.json

Lines changed: 164 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_hacl/Hacl_HMAC.c

Lines changed: 1567 additions & 0 deletions
Large diffs are not rendered by default.

Modules/_hacl/Hacl_HMAC.h

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/* MIT License
2+
*
3+
* Copyright (c) 2016-2022 INRIA, CMU and Microsoft Corporation
4+
* Copyright (c) 2022-2023 HACL* Contributors
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
26+
#ifndef __Hacl_HMAC_H
27+
#define __Hacl_HMAC_H
28+
29+
#if defined(__cplusplus)
30+
extern "C" {
31+
#endif
32+
33+
#include <string.h>
34+
#include "python_hacl_namespaces.h"
35+
#include "krml/types.h"
36+
#include "krml/lowstar_endianness.h"
37+
#include "krml/internal/target.h"
38+
39+
/**
40+
Write the HMAC-MD5 MAC of a message (`data`) by using a key (`key`) into `dst`.
41+
42+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 byte.
43+
`dst` must point to 16 bytes of memory.
44+
*/
45+
void
46+
Hacl_HMAC_compute_md5(
47+
uint8_t *dst,
48+
uint8_t *key,
49+
uint32_t key_len,
50+
uint8_t *data,
51+
uint32_t data_len
52+
);
53+
54+
/**
55+
Write the HMAC-SHA-1 MAC of a message (`data`) by using a key (`key`) into `dst`.
56+
57+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 byte.
58+
`dst` must point to 20 bytes of memory.
59+
*/
60+
void
61+
Hacl_HMAC_compute_sha1(
62+
uint8_t *dst,
63+
uint8_t *key,
64+
uint32_t key_len,
65+
uint8_t *data,
66+
uint32_t data_len
67+
);
68+
69+
/**
70+
Write the HMAC-SHA-2-224 MAC of a message (`data`) by using a key (`key`) into `dst`.
71+
72+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 bytes.
73+
`dst` must point to 28 bytes of memory.
74+
*/
75+
void
76+
Hacl_HMAC_compute_sha2_224(
77+
uint8_t *dst,
78+
uint8_t *key,
79+
uint32_t key_len,
80+
uint8_t *data,
81+
uint32_t data_len
82+
);
83+
84+
/**
85+
Write the HMAC-SHA-2-256 MAC of a message (`data`) by using a key (`key`) into `dst`.
86+
87+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 bytes.
88+
`dst` must point to 32 bytes of memory.
89+
*/
90+
void
91+
Hacl_HMAC_compute_sha2_256(
92+
uint8_t *dst,
93+
uint8_t *key,
94+
uint32_t key_len,
95+
uint8_t *data,
96+
uint32_t data_len
97+
);
98+
99+
/**
100+
Write the HMAC-SHA-2-384 MAC of a message (`data`) by using a key (`key`) into `dst`.
101+
102+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 128 bytes.
103+
`dst` must point to 48 bytes of memory.
104+
*/
105+
void
106+
Hacl_HMAC_compute_sha2_384(
107+
uint8_t *dst,
108+
uint8_t *key,
109+
uint32_t key_len,
110+
uint8_t *data,
111+
uint32_t data_len
112+
);
113+
114+
/**
115+
Write the HMAC-SHA-2-512 MAC of a message (`data`) by using a key (`key`) into `dst`.
116+
117+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 128 bytes.
118+
`dst` must point to 64 bytes of memory.
119+
*/
120+
void
121+
Hacl_HMAC_compute_sha2_512(
122+
uint8_t *dst,
123+
uint8_t *key,
124+
uint32_t key_len,
125+
uint8_t *data,
126+
uint32_t data_len
127+
);
128+
129+
/**
130+
Write the HMAC-SHA-3-224 MAC of a message (`data`) by using a key (`key`) into `dst`.
131+
132+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 144 bytes.
133+
`dst` must point to 28 bytes of memory.
134+
*/
135+
void
136+
Hacl_HMAC_compute_sha3_224(
137+
uint8_t *dst,
138+
uint8_t *key,
139+
uint32_t key_len,
140+
uint8_t *data,
141+
uint32_t data_len
142+
);
143+
144+
/**
145+
Write the HMAC-SHA-3-256 MAC of a message (`data`) by using a key (`key`) into `dst`.
146+
147+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 136 bytes.
148+
`dst` must point to 32 bytes of memory.
149+
*/
150+
void
151+
Hacl_HMAC_compute_sha3_256(
152+
uint8_t *dst,
153+
uint8_t *key,
154+
uint32_t key_len,
155+
uint8_t *data,
156+
uint32_t data_len
157+
);
158+
159+
/**
160+
Write the HMAC-SHA-3-384 MAC of a message (`data`) by using a key (`key`) into `dst`.
161+
162+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 104 bytes.
163+
`dst` must point to 48 bytes of memory.
164+
*/
165+
void
166+
Hacl_HMAC_compute_sha3_384(
167+
uint8_t *dst,
168+
uint8_t *key,
169+
uint32_t key_len,
170+
uint8_t *data,
171+
uint32_t data_len
172+
);
173+
174+
/**
175+
Write the HMAC-SHA-3-512 MAC of a message (`data`) by using a key (`key`) into `dst`.
176+
177+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 72 bytes.
178+
`dst` must point to 64 bytes of memory.
179+
*/
180+
void
181+
Hacl_HMAC_compute_sha3_512(
182+
uint8_t *dst,
183+
uint8_t *key,
184+
uint32_t key_len,
185+
uint8_t *data,
186+
uint32_t data_len
187+
);
188+
189+
/**
190+
Write the HMAC-BLAKE2s MAC of a message (`data`) by using a key (`key`) into `dst`.
191+
192+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 bytes.
193+
`dst` must point to 32 bytes of memory.
194+
*/
195+
void
196+
Hacl_HMAC_compute_blake2s_32(
197+
uint8_t *dst,
198+
uint8_t *key,
199+
uint32_t key_len,
200+
uint8_t *data,
201+
uint32_t data_len
202+
);
203+
204+
/**
205+
Write the HMAC-BLAKE2b MAC of a message (`data`) by using a key (`key`) into `dst`.
206+
207+
The key can be any length and will be hashed if it is longer and padded if it is shorter than 128 bytes.
208+
`dst` must point to 64 bytes of memory.
209+
*/
210+
void
211+
Hacl_HMAC_compute_blake2b_32(
212+
uint8_t *dst,
213+
uint8_t *key,
214+
uint32_t key_len,
215+
uint8_t *data,
216+
uint32_t data_len
217+
);
218+
219+
#if defined(__cplusplus)
220+
}
221+
#endif
222+
223+
#define __Hacl_HMAC_H_DEFINED
224+
#endif

0 commit comments

Comments
 (0)