|
| 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 | +#include "Hacl_Streaming_Types.h" |
| 40 | + |
| 41 | +#include "Hacl_Hash_SHA3.h" |
| 42 | +#include "Hacl_Hash_SHA2.h" |
| 43 | +#include "Hacl_Hash_Blake2s.h" |
| 44 | +#include "Hacl_Hash_Blake2b.h" |
| 45 | + |
| 46 | +/** |
| 47 | +Write the HMAC-MD5 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 48 | +
|
| 49 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 byte. |
| 50 | +`dst` must point to 16 bytes of memory. |
| 51 | +*/ |
| 52 | +void |
| 53 | +Hacl_HMAC_compute_md5( |
| 54 | + uint8_t *dst, |
| 55 | + uint8_t *key, |
| 56 | + uint32_t key_len, |
| 57 | + uint8_t *data, |
| 58 | + uint32_t data_len |
| 59 | +); |
| 60 | + |
| 61 | +/** |
| 62 | +Write the HMAC-SHA-1 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 63 | +
|
| 64 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 byte. |
| 65 | +`dst` must point to 20 bytes of memory. |
| 66 | +*/ |
| 67 | +void |
| 68 | +Hacl_HMAC_compute_sha1( |
| 69 | + uint8_t *dst, |
| 70 | + uint8_t *key, |
| 71 | + uint32_t key_len, |
| 72 | + uint8_t *data, |
| 73 | + uint32_t data_len |
| 74 | +); |
| 75 | + |
| 76 | +/** |
| 77 | +Write the HMAC-SHA-2-224 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 78 | +
|
| 79 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 bytes. |
| 80 | +`dst` must point to 28 bytes of memory. |
| 81 | +*/ |
| 82 | +void |
| 83 | +Hacl_HMAC_compute_sha2_224( |
| 84 | + uint8_t *dst, |
| 85 | + uint8_t *key, |
| 86 | + uint32_t key_len, |
| 87 | + uint8_t *data, |
| 88 | + uint32_t data_len |
| 89 | +); |
| 90 | + |
| 91 | +/** |
| 92 | +Write the HMAC-SHA-2-256 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 93 | +
|
| 94 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 bytes. |
| 95 | +`dst` must point to 32 bytes of memory. |
| 96 | +*/ |
| 97 | +void |
| 98 | +Hacl_HMAC_compute_sha2_256( |
| 99 | + uint8_t *dst, |
| 100 | + uint8_t *key, |
| 101 | + uint32_t key_len, |
| 102 | + uint8_t *data, |
| 103 | + uint32_t data_len |
| 104 | +); |
| 105 | + |
| 106 | +/** |
| 107 | +Write the HMAC-SHA-2-384 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 108 | +
|
| 109 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 128 bytes. |
| 110 | +`dst` must point to 48 bytes of memory. |
| 111 | +*/ |
| 112 | +void |
| 113 | +Hacl_HMAC_compute_sha2_384( |
| 114 | + uint8_t *dst, |
| 115 | + uint8_t *key, |
| 116 | + uint32_t key_len, |
| 117 | + uint8_t *data, |
| 118 | + uint32_t data_len |
| 119 | +); |
| 120 | + |
| 121 | +/** |
| 122 | +Write the HMAC-SHA-2-512 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 123 | +
|
| 124 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 128 bytes. |
| 125 | +`dst` must point to 64 bytes of memory. |
| 126 | +*/ |
| 127 | +void |
| 128 | +Hacl_HMAC_compute_sha2_512( |
| 129 | + uint8_t *dst, |
| 130 | + uint8_t *key, |
| 131 | + uint32_t key_len, |
| 132 | + uint8_t *data, |
| 133 | + uint32_t data_len |
| 134 | +); |
| 135 | + |
| 136 | +/** |
| 137 | +Write the HMAC-SHA-3-224 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 138 | +
|
| 139 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 144 bytes. |
| 140 | +`dst` must point to 28 bytes of memory. |
| 141 | +*/ |
| 142 | +void |
| 143 | +Hacl_HMAC_compute_sha3_224( |
| 144 | + uint8_t *dst, |
| 145 | + uint8_t *key, |
| 146 | + uint32_t key_len, |
| 147 | + uint8_t *data, |
| 148 | + uint32_t data_len |
| 149 | +); |
| 150 | + |
| 151 | +/** |
| 152 | +Write the HMAC-SHA-3-256 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 153 | +
|
| 154 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 136 bytes. |
| 155 | +`dst` must point to 32 bytes of memory. |
| 156 | +*/ |
| 157 | +void |
| 158 | +Hacl_HMAC_compute_sha3_256( |
| 159 | + uint8_t *dst, |
| 160 | + uint8_t *key, |
| 161 | + uint32_t key_len, |
| 162 | + uint8_t *data, |
| 163 | + uint32_t data_len |
| 164 | +); |
| 165 | + |
| 166 | +/** |
| 167 | +Write the HMAC-SHA-3-384 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 168 | +
|
| 169 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 104 bytes. |
| 170 | +`dst` must point to 48 bytes of memory. |
| 171 | +*/ |
| 172 | +void |
| 173 | +Hacl_HMAC_compute_sha3_384( |
| 174 | + uint8_t *dst, |
| 175 | + uint8_t *key, |
| 176 | + uint32_t key_len, |
| 177 | + uint8_t *data, |
| 178 | + uint32_t data_len |
| 179 | +); |
| 180 | + |
| 181 | +/** |
| 182 | +Write the HMAC-SHA-3-512 MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 183 | +
|
| 184 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 72 bytes. |
| 185 | +`dst` must point to 64 bytes of memory. |
| 186 | +*/ |
| 187 | +void |
| 188 | +Hacl_HMAC_compute_sha3_512( |
| 189 | + uint8_t *dst, |
| 190 | + uint8_t *key, |
| 191 | + uint32_t key_len, |
| 192 | + uint8_t *data, |
| 193 | + uint32_t data_len |
| 194 | +); |
| 195 | + |
| 196 | +/** |
| 197 | +Write the HMAC-BLAKE2s MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 198 | +
|
| 199 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 64 bytes. |
| 200 | +`dst` must point to 32 bytes of memory. |
| 201 | +*/ |
| 202 | +void |
| 203 | +Hacl_HMAC_compute_blake2s_32( |
| 204 | + uint8_t *dst, |
| 205 | + uint8_t *key, |
| 206 | + uint32_t key_len, |
| 207 | + uint8_t *data, |
| 208 | + uint32_t data_len |
| 209 | +); |
| 210 | + |
| 211 | +/** |
| 212 | +Write the HMAC-BLAKE2b MAC of a message (`data`) by using a key (`key`) into `dst`. |
| 213 | +
|
| 214 | +The key can be any length and will be hashed if it is longer and padded if it is shorter than 128 bytes. |
| 215 | +`dst` must point to 64 bytes of memory. |
| 216 | +*/ |
| 217 | +void |
| 218 | +Hacl_HMAC_compute_blake2b_32( |
| 219 | + uint8_t *dst, |
| 220 | + uint8_t *key, |
| 221 | + uint32_t key_len, |
| 222 | + uint8_t *data, |
| 223 | + uint32_t data_len |
| 224 | +); |
| 225 | + |
| 226 | +#if defined(__cplusplus) |
| 227 | +} |
| 228 | +#endif |
| 229 | + |
| 230 | +#define __Hacl_HMAC_H_DEFINED |
| 231 | +#endif |
0 commit comments