3030extern "C" {
3131#endif
3232
33- #include <string.h>
3433#include "python_hacl_namespaces.h"
35- #include "krml/types.h"
36- #include "krml/lowstar_endianness.h"
37- #include "krml/internal/target.h"
3834
3935#include "Hacl_Streaming_Types.h"
4036
4137#include "Hacl_Hash_Blake2b.h"
42- #include "libintvector.h"
43-
44- #define HACL_HASH_BLAKE2B_SIMD256_BLOCK_BYTES (128U)
45-
46- #define HACL_HASH_BLAKE2B_SIMD256_OUT_BYTES (64U)
47-
48- #define HACL_HASH_BLAKE2B_SIMD256_KEY_BYTES (64U)
49-
50- #define HACL_HASH_BLAKE2B_SIMD256_SALT_BYTES (16U)
51-
52- #define HACL_HASH_BLAKE2B_SIMD256_PERSONAL_BYTES (16U)
53-
54- typedef struct K____Lib_IntVector_Intrinsics_vec256___Lib_IntVector_Intrinsics_vec256__s
55- {
56- Lib_IntVector_Intrinsics_vec256 * fst ;
57- Lib_IntVector_Intrinsics_vec256 * snd ;
58- }
59- K____Lib_IntVector_Intrinsics_vec256___Lib_IntVector_Intrinsics_vec256_ ;
60-
61- typedef struct Hacl_Hash_Blake2b_Simd256_block_state_t_s
62- {
63- uint8_t fst ;
64- uint8_t snd ;
65- bool thd ;
66- K____Lib_IntVector_Intrinsics_vec256___Lib_IntVector_Intrinsics_vec256_ f3 ;
67- }
68- Hacl_Hash_Blake2b_Simd256_block_state_t ;
69-
70- typedef struct Hacl_Hash_Blake2b_Simd256_state_t_s
71- {
72- Hacl_Hash_Blake2b_Simd256_block_state_t block_state ;
73- uint8_t * buf ;
74- uint64_t total_len ;
75- }
76- Hacl_Hash_Blake2b_Simd256_state_t ;
7738
7839/**
7940 General-purpose allocation function that gives control over all
@@ -90,74 +51,19 @@ The caller must satisfy the following requirements.
9051- The digest_length must not exceed 256 for S, 64 for B.
9152
9253*/
93- Hacl_Hash_Blake2b_Simd256_state_t
54+ void
9455* Hacl_Hash_Blake2b_Simd256_malloc_with_params_and_key (
9556 Hacl_Hash_Blake2b_blake2_params * p ,
9657 bool last_node ,
9758 uint8_t * k
9859);
9960
100- /**
101- Specialized allocation function that picks default values for all
102- parameters, except for the key_length. Further resettings of the state SHALL be
103- done with `reset_with_key`, and SHALL feature the exact same key length `kk` as
104- passed here. In other words, once you commit to a key length, the only way to
105- change this parameter is to allocate a new object.
106-
107- The caller must satisfy the following requirements.
108- - The key_length must not exceed 256 for S, 64 for B.
109-
110- */
111- Hacl_Hash_Blake2b_Simd256_state_t
112- * Hacl_Hash_Blake2b_Simd256_malloc_with_key0 (uint8_t * k , uint8_t kk );
113-
114- /**
115- Specialized allocation function that picks default values for all
116- parameters, and has no key. Effectively, this is what you want if you intend to
117- use Blake2 as a hash function. Further resettings of the state SHALL be done with `reset`.
118- */
119- Hacl_Hash_Blake2b_Simd256_state_t * Hacl_Hash_Blake2b_Simd256_malloc (void );
120-
121- /**
122- General-purpose re-initialization function with parameters and
123- key. You cannot change digest_length, key_length, or last_node, meaning those values in
124- the parameters object must be the same as originally decided via one of the
125- malloc functions. All other values of the parameter can be changed. The behavior
126- is unspecified if you violate this precondition.
127- */
128- void
129- Hacl_Hash_Blake2b_Simd256_reset_with_key_and_params (
130- Hacl_Hash_Blake2b_Simd256_state_t * s ,
131- Hacl_Hash_Blake2b_blake2_params * p ,
132- uint8_t * k
133- );
134-
135- /**
136- Specialized-purpose re-initialization function with no parameters,
137- and a key. The key length must be the same as originally decided via your choice
138- of malloc function. All other parameters are reset to their default values. The
139- original call to malloc MUST have set digest_length to the default value. The
140- behavior is unspecified if you violate this precondition.
141- */
142- void
143- Hacl_Hash_Blake2b_Simd256_reset_with_key (Hacl_Hash_Blake2b_Simd256_state_t * s , uint8_t * k );
144-
145- /**
146- Specialized-purpose re-initialization function with no parameters
147- and no key. This is what you want if you intend to use Blake2 as a hash
148- function. The key length and digest length must have been set to their
149- respective default values via your choice of malloc function (always true if you
150- used `malloc`). All other parameters are reset to their default values. The
151- behavior is unspecified if you violate this precondition.
152- */
153- void Hacl_Hash_Blake2b_Simd256_reset (Hacl_Hash_Blake2b_Simd256_state_t * s );
154-
15561/**
15662 Update function; 0 = success, 1 = max length exceeded
15763*/
15864Hacl_Streaming_Types_error_code
15965Hacl_Hash_Blake2b_Simd256_update (
160- Hacl_Hash_Blake2b_Simd256_state_t * state ,
66+ void * state ,
16167 uint8_t * chunk ,
16268 uint32_t chunk_len
16369);
@@ -173,55 +79,20 @@ For convenience, this function returns `digest_length`. When in doubt, callers
17379can pass an array of size HACL_BLAKE2B_256_OUT_BYTES, then use the return value
17480to see how many bytes were actually written.
17581*/
176- uint8_t Hacl_Hash_Blake2b_Simd256_digest (Hacl_Hash_Blake2b_Simd256_state_t * s , uint8_t * dst );
82+ uint8_t Hacl_Hash_Blake2b_Simd256_digest (void * s , uint8_t * dst );
17783
178- Hacl_Hash_Blake2b_index Hacl_Hash_Blake2b_Simd256_info (Hacl_Hash_Blake2b_Simd256_state_t * s );
84+ Hacl_Hash_Blake2b_index Hacl_Hash_Blake2b_Simd256_info (void * s );
17985
18086/**
18187 Free state function when there is no key
18288*/
183- void Hacl_Hash_Blake2b_Simd256_free (Hacl_Hash_Blake2b_Simd256_state_t * state );
89+ void Hacl_Hash_Blake2b_Simd256_free (void * state );
18490
18591/**
18692 Copying. This preserves all parameters.
18793*/
188- Hacl_Hash_Blake2b_Simd256_state_t
189- * Hacl_Hash_Blake2b_Simd256_copy (Hacl_Hash_Blake2b_Simd256_state_t * state );
190-
191- /**
192- Write the BLAKE2b digest of message `input` using key `key` into `output`.
193-
194- @param output Pointer to `output_len` bytes of memory where the digest is written to.
195- @param output_len Length of the to-be-generated digest with 1 <= `output_len` <= 64.
196- @param input Pointer to `input_len` bytes of memory where the input message is read from.
197- @param input_len Length of the input message.
198- @param key Pointer to `key_len` bytes of memory where the key is read from.
199- @param key_len Length of the key. Can be 0.
200- */
20194void
202- Hacl_Hash_Blake2b_Simd256_hash_with_key (
203- uint8_t * output ,
204- uint32_t output_len ,
205- uint8_t * input ,
206- uint32_t input_len ,
207- uint8_t * key ,
208- uint32_t key_len
209- );
210-
211- /**
212- Write the BLAKE2b digest of message `input` using key `key` and
213- parameters `params` into `output`. The `key` array must be of length
214- `params.key_length`. The `output` array must be of length
215- `params.digest_length`.
216- */
217- void
218- Hacl_Hash_Blake2b_Simd256_hash_with_key_and_params (
219- uint8_t * output ,
220- uint8_t * input ,
221- uint32_t input_len ,
222- Hacl_Hash_Blake2b_blake2_params params ,
223- uint8_t * key
224- );
95+ * Hacl_Hash_Blake2b_Simd256_copy (void * state );
22596
22697#if defined(__cplusplus )
22798 }
0 commit comments