Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
aead-metadata.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef LWCRYPTO_AEAD_METADATA_H
24 #define LWCRYPTO_AEAD_METADATA_H
25 
26 #include <stddef.h>
27 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
58 typedef int (*aead_cipher_encrypt_t)
59  (unsigned char *c, size_t *clen,
60  const unsigned char *m, size_t mlen,
61  const unsigned char *ad, size_t adlen,
62  const unsigned char *npub,
63  const unsigned char *k);
64 
83 typedef int (*aead_cipher_decrypt_t)
84  (unsigned char *m, size_t *mlen,
85  const unsigned char *c, size_t clen,
86  const unsigned char *ad, size_t adlen,
87  const unsigned char *npub,
88  const unsigned char *k);
89 
99 typedef int (*aead_cipher_pk_init_t)
100  (unsigned char *pk, const unsigned char *k);
101 
112 typedef int (*aead_hash_t)
113  (unsigned char *out, const unsigned char *in, size_t inlen);
114 
120 typedef void (*aead_hash_init_t)(void *state);
121 
129 typedef void (*aead_hash_update_t)
130  (void *state, const unsigned char *in, size_t inlen);
131 
138 typedef void (*aead_hash_finalize_t)(void *state, unsigned char *out);
139 
149 typedef void (*aead_xof_absorb_t)
150  (void *state, const unsigned char *in, size_t inlen);
151 
159 typedef void (*aead_xof_squeeze_t)
160  (void *state, unsigned char *out, size_t outlen);
161 
165 #define AEAD_FLAG_NONE 0x0000
166 
177 #define AEAD_FLAG_LITTLE_ENDIAN 0x0001
178 
182 #define AEAD_FLAG_SC_PROTECT_KEY 0x0002
183 
188 #define AEAD_FLAG_SC_PROTECT_ALL 0x0004
189 
194 #define AEAD_FLAG_SLOW 0x0008
195 
199 #define AEAD_FLAG_MASKED 0x0010
200 
204 typedef struct
205 {
206  const char *name;
207  unsigned key_len;
208  unsigned nonce_len;
209  unsigned tag_len;
210  unsigned flags;
213  unsigned pk_state_len;
216 } aead_cipher_t;
217 
225 typedef struct
226 {
227  const char *name;
228  size_t state_size;
229  unsigned hash_len;
230  unsigned flags;
239 
240 /*------------------------ AES-GCM ------------------------*/
241 
245 extern aead_cipher_t const aesgcm128_cipher;
246 
250 extern aead_cipher_t const aesgcm192_cipher;
251 
255 extern aead_cipher_t const aesgcm256_cipher;
256 
257 /*------------------------- ASCON -------------------------*/
258 
262 extern aead_cipher_t const ascon128_cipher;
263 
267 extern aead_cipher_t const ascon128a_cipher;
268 
272 extern aead_cipher_t const ascon80pq_cipher;
273 
278 
283 
288 
293 
298 
303 
308 
313 
318 
323 
324 /*----------------------- Elephant ------------------------*/
325 
329 extern aead_cipher_t const delirium_cipher;
330 
334 extern aead_cipher_t const dumbo_cipher;
335 
339 extern aead_cipher_t const jumbo_cipher;
340 
341 /*----------------------- GIFT-COFB -----------------------*/
342 
346 extern aead_cipher_t const gift_cofb_cipher;
347 
352 
353 /*--------------------- Grain128-AEAD ---------------------*/
354 
359 
360 /*-------------------------- ISAP -------------------------*/
361 
366 
371 
376 
381 
386 
391 
396 
401 
402 /*--------------------- PHOTON-Beetle ---------------------*/
403 
408 
413 
418 
419 /*------------------------ Romulus ------------------------*/
420 
424 extern aead_cipher_t const romulus_n_cipher;
425 
429 extern aead_cipher_t const romulus_m_cipher;
430 
434 extern aead_cipher_t const romulus_t_cipher;
435 
440 
445 
446 /*------------------------ SPARKLE ------------------------*/
447 
452 
457 
462 
467 
472 
477 
482 
487 
488 /*----------------------- TinyJAMBU -----------------------*/
489 
494 
499 
504 
509 
514 
519 
520 /*------------------------ Xoodyak ------------------------*/
521 
525 extern aead_cipher_t const xoodyak_cipher;
526 
531 
536 
537 #ifdef __cplusplus
538 }
539 #endif
540 
541 #endif
aead_cipher_t const ascon128a_siv_cipher
Meta-information block for the ASCON-128a-SIV cipher.
Definition: aead-metadata.c:234
aead_cipher_t const ascon80pq_cipher
Meta-information block for the ASCON-80pq cipher.
Definition: aead-metadata.c:115
aead_cipher_t const gift_cofb_masked_cipher
Meta-information block for the masked GIFT-COFB cipher.
Definition: aead-metadata.c:304
Meta-information about an AEAD cipher.
Definition: aead-metadata.h:204
aead_cipher_t const romulus_t_cipher
Meta-information block for the Romulus-T cipher.
Definition: aead-metadata.c:483
aead_cipher_t const isap_ascon_128a_pk_cipher
Meta-information block for the pre-computed ISAP-A-128A cipher.
Definition: aead-metadata.c:386
aead_cipher_t const isap_keccak_128a_cipher
Meta-information block for the ISAP-K-128A cipher.
Definition: aead-metadata.c:330
aead_cipher_t const isap_keccak_128_cipher
Meta-information block for the ISAP-K-128 cipher.
Definition: aead-metadata.c:352
aead_cipher_t const ascon128_masked_cipher
Meta-information block for the masked ASCON-128 cipher.
Definition: aead-metadata.c:178
int(* aead_cipher_pk_init_t)(unsigned char *pk, const unsigned char *k)
Initializes a pre-computed key for an AEAD scheme.
Definition: aead-metadata.h:100
int(* aead_hash_t)(unsigned char *out, const unsigned char *in, size_t inlen)
Hashes a block of input data.
Definition: aead-metadata.h:113
unsigned pk_state_len
Definition: aead-metadata.h:213
aead_cipher_t const isap_ascon_128_cipher
Meta-information block for the ISAP-A-128 cipher.
Definition: aead-metadata.c:363
aead_cipher_t const delirium_cipher
Meta-information block for the Delirium cipher.
Definition: aead-metadata.c:258
aead_hash_algorithm_t const esch_256_hash_algorithm
Meta-information block for the Esch256 hash algorithm.
Definition: aead-metadata.c:566
Meta-information about a hash algorithm that is related to an AEAD.
Definition: aead-metadata.h:225
void(* aead_xof_absorb_t)(void *state, const unsigned char *in, size_t inlen)
Aborbs more input data into an XOF state.
Definition: aead-metadata.h:150
unsigned nonce_len
Definition: aead-metadata.h:208
aead_cipher_t const schwaemm_192_192_cipher
Meta-information block for the Schwaemm192-192 cipher.
Definition: aead-metadata.c:533
aead_hash_algorithm_t const ascon_hasha_algorithm
Meta-information block for the ASCON-HASHA algorithm.
Definition: aead-metadata.c:139
aead_cipher_pk_init_t pk_init
Definition: aead-metadata.h:214
unsigned flags
Definition: aead-metadata.h:210
aead_cipher_t const tiny_jambu_192_cipher
Meta-information block for the TinyJAMBU-192 cipher.
Definition: aead-metadata.c:631
aead_cipher_t const ascon80pq_siv_cipher
Meta-information block for the ASCON-80pq-SIV cipher.
Definition: aead-metadata.c:245
unsigned hash_len
Definition: aead-metadata.h:229
aead_cipher_t const schwaemm_128_128_cipher
Meta-information block for the Schwaemm128-128 cipher.
Definition: aead-metadata.c:544
aead_cipher_t const jumbo_cipher
Meta-information block for the Jumbo cipher.
Definition: aead-metadata.c:280
aead_cipher_t const dumbo_cipher
Meta-information block for the Dumbo cipher.
Definition: aead-metadata.c:269
aead_cipher_t const aesgcm256_cipher
Meta-information block for the AES-256-GCM cipher.
Definition: aead-metadata.c:80
size_t state_size
Definition: aead-metadata.h:228
aead_cipher_t const gift_cofb_cipher
Meta-information block for the GIFT-COFB cipher.
Definition: aead-metadata.c:293
aead_cipher_t const xoodyak_cipher
Meta-information block for the Xoodyak cipher.
Definition: aead-metadata.c:688
aead_cipher_t const romulus_n_cipher
Meta-information block for the Romulus-N cipher.
Definition: aead-metadata.c:461
aead_hash_init_t init
Definition: aead-metadata.h:232
const char * name
Definition: aead-metadata.h:227
aead_hash_algorithm_t const esch_384_hash_algorithm
Meta-information block for the Esch384 hash algorithm.
Definition: aead-metadata.c:579
void(* aead_hash_finalize_t)(void *state, unsigned char *out)
Returns the final hash value from a hashing operation.
Definition: aead-metadata.h:138
aead_cipher_t const xoodyak_masked_cipher
Meta-information block for the masked Xoodyak cipher.
Definition: aead-metadata.c:712
aead_xof_squeeze_t squeeze
Definition: aead-metadata.h:236
aead_cipher_t const tiny_jambu_128_cipher
Meta-information block for the TinyJAMBU-128 cipher.
Definition: aead-metadata.c:620
aead_hash_finalize_t finalize
Definition: aead-metadata.h:234
aead_cipher_t const isap_ascon_128_pk_cipher
Meta-information block for the pre-computed ISAP-A-128 cipher.
Definition: aead-metadata.c:410
aead_cipher_t const schwaemm_256_128_cipher
Meta-information block for the Schwaemm256-128 cipher.
Definition: aead-metadata.c:522
aead_hash_t hash
Definition: aead-metadata.h:231
aead_cipher_t const schwaemm_256_256_cipher
Meta-information block for the Schwaemm256-256 cipher.
Definition: aead-metadata.c:555
aead_hash_update_t update
Definition: aead-metadata.h:233
aead_cipher_t const tiny_jambu_256_masked_cipher
Meta-information block for the masked TinyJAMBU-256 cipher.
Definition: aead-metadata.c:675
int(* aead_cipher_decrypt_t)(unsigned char *m, size_t *mlen, const unsigned char *c, size_t clen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Decrypts and authenticates a packet with an AEAD scheme.
Definition: aead-metadata.h:84
unsigned tag_len
Definition: aead-metadata.h:209
void(* aead_hash_init_t)(void *state)
Initializes the state for a hashing operation.
Definition: aead-metadata.h:120
aead_cipher_t const ascon128a_cipher
Meta-information block for the ASCON-128a cipher.
Definition: aead-metadata.c:104
int(* aead_cipher_encrypt_t)(unsigned char *c, size_t *clen, const unsigned char *m, size_t mlen, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Encrypts and authenticates a packet with an AEAD scheme.
Definition: aead-metadata.h:59
aead_cipher_t const ascon128_cipher
Meta-information block for the ASCON-128 cipher.
Definition: aead-metadata.c:93
aead_cipher_t const grain128_aead_cipher
Meta-information block for the Grain-128AEAD cipher.
Definition: aead-metadata.c:317
unsigned flags
Definition: aead-metadata.h:230
aead_hash_algorithm_t const romulus_hash_algorithm
Meta-information block for the Romulus-H hash algorithm.
Definition: aead-metadata.c:494
unsigned key_len
Definition: aead-metadata.h:207
const char * name
Definition: aead-metadata.h:206
aead_cipher_t const photon_beetle_32_cipher
Meta-information block for the PHOTON-Beetle-AEAD-ENC-32 cipher.
Definition: aead-metadata.c:435
aead_cipher_t const tiny_jambu_192_masked_cipher
Meta-information block for the masked TinyJAMBU-192 cipher.
Definition: aead-metadata.c:664
aead_cipher_t const romulus_m_cipher
Meta-information block for the Romulus-M cipher.
Definition: aead-metadata.c:472
aead_cipher_t const tiny_jambu_256_cipher
Meta-information block for the TinyJAMBU-256 cipher.
Definition: aead-metadata.c:642
aead_cipher_t const ascon80pq_masked_cipher
Meta-information block for the masked ASCON-80pq cipher.
Definition: aead-metadata.c:208
aead_hash_algorithm_t const esch_384_xof_algorithm
Meta-information block for the XOEsch384 XOF algorithm.
Definition: aead-metadata.c:605
aead_cipher_encrypt_t encrypt
Definition: aead-metadata.h:211
aead_hash_algorithm_t const romulus_xof_algorithm
Meta-information block for the Romulus-H based XOF algorithm.
Definition: aead-metadata.c:507
void(* aead_xof_squeeze_t)(void *state, unsigned char *out, size_t outlen)
Squeezes output data from an XOF state.
Definition: aead-metadata.h:160
aead_cipher_t const isap_ascon_128a_cipher
Meta-information block for the ISAP-A-128A cipher.
Definition: aead-metadata.c:341
aead_cipher_t const aesgcm192_cipher
Meta-information block for the AES-192-GCM cipher.
Definition: aead-metadata.c:69
aead_cipher_decrypt_t decrypt
Definition: aead-metadata.h:212
aead_hash_algorithm_t const esch_256_xof_algorithm
Meta-information block for the XOEsch256 XOF algorithm.
Definition: aead-metadata.c:592
aead_cipher_t const ascon128a_masked_cipher
Meta-information block for the masked ASCON-128a cipher.
Definition: aead-metadata.c:193
aead_hash_algorithm_t const ascon_hash_algorithm
Meta-information block for the ASCON-HASH algorithm.
Definition: aead-metadata.c:126
aead_cipher_t const tiny_jambu_128_masked_cipher
Meta-information block for the masked TinyJAMBU-128 cipher.
Definition: aead-metadata.c:653
aead_hash_algorithm_t const ascon_xofa_algorithm
Meta-information block for the ASCON-XOFA algorithm.
Definition: aead-metadata.c:165
aead_cipher_t const isap_keccak_128_pk_cipher
Meta-information block for the pre-computed ISAP-K-128 cipher.
Definition: aead-metadata.c:398
aead_cipher_t const ascon128_siv_cipher
Meta-information block for the ASCON-128-SIV cipher.
Definition: aead-metadata.c:223
aead_cipher_t const photon_beetle_128_cipher
Meta-information block for the PHOTON-Beetle-AEAD-ENC-128 cipher.
Definition: aead-metadata.c:424
aead_cipher_t const isap_keccak_128a_pk_cipher
Meta-information block for the pre-computed ISAP-K-128A cipher.
Definition: aead-metadata.c:374
aead_cipher_t const aesgcm128_cipher
Meta-information block for the AES-128-GCM cipher.
Definition: aead-metadata.c:58
aead_hash_algorithm_t const ascon_xof_algorithm
Meta-information block for the ASCON-XOF algorithm.
Definition: aead-metadata.c:152
aead_xof_absorb_t absorb
Definition: aead-metadata.h:235
void(* aead_hash_update_t)(void *state, const unsigned char *in, size_t inlen)
Updates a hash state with more input data.
Definition: aead-metadata.h:130
aead_hash_algorithm_t const photon_beetle_hash_algorithm
Meta-information block for the PHOTON-Beetle-HASH algorithm.
Definition: aead-metadata.c:446
aead_hash_algorithm_t const xoodyak_hash_algorithm
Meta-information block for the Xoodyak hash algorithm.
Definition: aead-metadata.c:699