| 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_Streaming_HMAC_H |
| 27 |
#define Hacl_Streaming_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/internal/types.h" |
| 36 |
#include "krml/lowstar_endianness.h" |
| 37 |
#include "krml/internal/target.h" |
| 38 |
|
| 39 |
#include "Hacl_Streaming_Types.h" |
| 40 |
|
| 41 |
#define Hacl_Agile_Hash_MD5 0 |
| 42 |
#define Hacl_Agile_Hash_SHA1 1 |
| 43 |
#define Hacl_Agile_Hash_SHA2_224 2 |
| 44 |
#define Hacl_Agile_Hash_SHA2_256 3 |
| 45 |
#define Hacl_Agile_Hash_SHA2_384 4 |
| 46 |
#define Hacl_Agile_Hash_SHA2_512 5 |
| 47 |
#define Hacl_Agile_Hash_SHA3_224 6 |
| 48 |
#define Hacl_Agile_Hash_SHA3_256 7 |
| 49 |
#define Hacl_Agile_Hash_SHA3_384 8 |
| 50 |
#define Hacl_Agile_Hash_SHA3_512 9 |
| 51 |
#define Hacl_Agile_Hash_Blake2S_32 10 |
| 52 |
#define Hacl_Agile_Hash_Blake2S_128 11 |
| 53 |
#define Hacl_Agile_Hash_Blake2B_32 12 |
| 54 |
#define Hacl_Agile_Hash_Blake2B_256 13 |
| 55 |
|
| 56 |
typedef uint8_t Hacl_Agile_Hash_impl; |
| 57 |
|
| 58 |
typedef struct Hacl_Agile_Hash_state_s_s Hacl_Agile_Hash_state_s; |
| 59 |
|
| 60 |
typedef struct Hacl_Streaming_HMAC_Definitions_index_s |
| 61 |
{ |
| 62 |
Hacl_Agile_Hash_impl fst; |
| 63 |
uint32_t snd; |
| 64 |
} |
| 65 |
Hacl_Streaming_HMAC_Definitions_index; |
| 66 |
|
| 67 |
typedef struct Hacl_Streaming_HMAC_Definitions_two_state_s |
| 68 |
{ |
| 69 |
uint32_t fst; |
| 70 |
Hacl_Agile_Hash_state_s *snd; |
| 71 |
Hacl_Agile_Hash_state_s *thd; |
| 72 |
} |
| 73 |
Hacl_Streaming_HMAC_Definitions_two_state; |
| 74 |
|
| 75 |
Hacl_Agile_Hash_state_s |
| 76 |
*Hacl_Streaming_HMAC_s1( |
| 77 |
Hacl_Streaming_HMAC_Definitions_index i, |
| 78 |
Hacl_Streaming_HMAC_Definitions_two_state s |
| 79 |
); |
| 80 |
|
| 81 |
Hacl_Agile_Hash_state_s |
| 82 |
*Hacl_Streaming_HMAC_s2( |
| 83 |
Hacl_Streaming_HMAC_Definitions_index i, |
| 84 |
Hacl_Streaming_HMAC_Definitions_two_state s |
| 85 |
); |
| 86 |
|
| 87 |
Hacl_Streaming_HMAC_Definitions_index |
| 88 |
Hacl_Streaming_HMAC_index_of_state(Hacl_Streaming_HMAC_Definitions_two_state s); |
| 89 |
|
| 90 |
typedef struct Hacl_Streaming_HMAC_agile_state_s Hacl_Streaming_HMAC_agile_state; |
| 91 |
|
| 92 |
Hacl_Streaming_Types_error_code |
| 93 |
Hacl_Streaming_HMAC_malloc_( |
| 94 |
Hacl_Agile_Hash_impl impl, |
| 95 |
uint8_t *key, |
| 96 |
uint32_t key_length, |
| 97 |
Hacl_Streaming_HMAC_agile_state **dst |
| 98 |
); |
| 99 |
|
| 100 |
Hacl_Streaming_HMAC_Definitions_index |
| 101 |
Hacl_Streaming_HMAC_get_impl(Hacl_Streaming_HMAC_agile_state *s); |
| 102 |
|
| 103 |
Hacl_Streaming_Types_error_code |
| 104 |
Hacl_Streaming_HMAC_reset( |
| 105 |
Hacl_Streaming_HMAC_agile_state *state, |
| 106 |
uint8_t *key, |
| 107 |
uint32_t key_length |
| 108 |
); |
| 109 |
|
| 110 |
Hacl_Streaming_Types_error_code |
| 111 |
Hacl_Streaming_HMAC_update( |
| 112 |
Hacl_Streaming_HMAC_agile_state *state, |
| 113 |
uint8_t *chunk, |
| 114 |
uint32_t chunk_len |
| 115 |
); |
| 116 |
|
| 117 |
Hacl_Streaming_Types_error_code |
| 118 |
Hacl_Streaming_HMAC_digest( |
| 119 |
Hacl_Streaming_HMAC_agile_state *state, |
| 120 |
uint8_t *output, |
| 121 |
uint32_t digest_length |
| 122 |
); |
| 123 |
|
| 124 |
void Hacl_Streaming_HMAC_free(Hacl_Streaming_HMAC_agile_state *state); |
| 125 |
|
| 126 |
Hacl_Streaming_HMAC_agile_state |
| 127 |
*Hacl_Streaming_HMAC_copy(Hacl_Streaming_HMAC_agile_state *state); |
| 128 |
|
| 129 |
#if defined(__cplusplus) |
| 130 |
} |
| 131 |
#endif |
| 132 |
|
| 133 |
#define Hacl_Streaming_HMAC_H_DEFINED |
| 134 |
#endif /* Hacl_Streaming_HMAC_H */ |