ASCON Suite
aead.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 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 ASCON_AEAD_H
24 #define ASCON_AEAD_H
25 
26 #include <ascon/permutation.h>
27 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
55 #define ASCON128_KEY_SIZE 16
56 
60 #define ASCON128_NONCE_SIZE 16
61 
65 #define ASCON128_TAG_SIZE 16
66 
70 #define ASCON80PQ_KEY_SIZE 20
71 
75 #define ASCON80PQ_NONCE_SIZE 16
76 
80 #define ASCON80PQ_TAG_SIZE 16
81 
85 #define ASCON128_RATE 8
86 
90 #define ASCON128A_RATE 16
91 
95 #define ASCON80PQ_RATE 8
96 
115  (unsigned char *c, size_t *clen,
116  const unsigned char *m, size_t mlen,
117  const unsigned char *ad, size_t adlen,
118  const unsigned char *npub,
119  const unsigned char *k);
120 
143  (unsigned char *m, size_t *mlen,
144  const unsigned char *c, size_t clen,
145  const unsigned char *ad, size_t adlen,
146  const unsigned char *npub,
147  const unsigned char *k);
148 
167  (unsigned char *c, size_t *clen,
168  const unsigned char *m, size_t mlen,
169  const unsigned char *ad, size_t adlen,
170  const unsigned char *npub,
171  const unsigned char *k);
172 
195  (unsigned char *m, size_t *mlen,
196  const unsigned char *c, size_t clen,
197  const unsigned char *ad, size_t adlen,
198  const unsigned char *npub,
199  const unsigned char *k);
200 
219  (unsigned char *c, size_t *clen,
220  const unsigned char *m, size_t mlen,
221  const unsigned char *ad, size_t adlen,
222  const unsigned char *npub,
223  const unsigned char *k);
224 
247  (unsigned char *m, size_t *mlen,
248  const unsigned char *c, size_t clen,
249  const unsigned char *ad, size_t adlen,
250  const unsigned char *npub,
251  const unsigned char *k);
252 
253 /* ---------------------------------------------------------------- */
254 /* Incremental API's for the AEAD modes below */
255 /* ---------------------------------------------------------------- */
256 
262 typedef struct
263 {
266 
268  unsigned char key[ASCON128_KEY_SIZE];
269 
271  unsigned char posn;
272 
274 
280 typedef struct
281 {
284 
286  unsigned char key[ASCON128_KEY_SIZE];
287 
289  unsigned char posn;
290 
292 
298 typedef struct
299 {
302 
304  unsigned char key[ASCON80PQ_KEY_SIZE];
305 
307  unsigned char posn;
308 
310 
358  (ascon128_state_t *state, const unsigned char *ad, size_t adlen,
359  const unsigned char *npub, const unsigned char *k);
360 
371 
385  (ascon128_state_t *state, const unsigned char *in,
386  unsigned char *out, size_t len);
387 
402  (ascon128_state_t *state, unsigned char *tag);
403 
417  (ascon128_state_t *state, const unsigned char *in,
418  unsigned char *out, size_t len);
419 
437  (ascon128_state_t *state, const unsigned char *tag);
438 
486  (ascon128a_state_t *state, const unsigned char *ad, size_t adlen,
487  const unsigned char *npub, const unsigned char *k);
488 
499 
513  (ascon128a_state_t *state, const unsigned char *in,
514  unsigned char *out, size_t len);
515 
530  (ascon128a_state_t *state, unsigned char *tag);
531 
545  (ascon128a_state_t *state, const unsigned char *in,
546  unsigned char *out, size_t len);
547 
565  (ascon128a_state_t *state, const unsigned char *tag);
566 
614  (ascon80pq_state_t *state, const unsigned char *ad, size_t adlen,
615  const unsigned char *npub, const unsigned char *k);
616 
627 
641  (ascon80pq_state_t *state, const unsigned char *in,
642  unsigned char *out, size_t len);
643 
658  (ascon80pq_state_t *state, unsigned char *tag);
659 
673  (ascon80pq_state_t *state, const unsigned char *in,
674  unsigned char *out, size_t len);
675 
693  (ascon80pq_state_t *state, const unsigned char *tag);
694 
695 #ifdef __cplusplus
696 }
697 #endif
698 
699 #endif
int ascon128a_aead_decrypt_finalize(ascon128a_state_t *state, const unsigned char *tag)
Finalizes an incremental ASCON-128a decryption operation and checks the authentication tag.
void ascon80pq_aead_encrypt(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 ASCON-80pq.
void ascon128a_aead_encrypt_finalize(ascon128a_state_t *state, unsigned char *tag)
Finalizes an incremental ASCON-128a encryption operation and generates the authentication tag.
void ascon128_aead_abort(ascon128_state_t *state)
Aborts use of ASCON-128 in incremental mode.
void ascon80pq_aead_start(ascon80pq_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Starts encrypting or decrypting a packet with ASCON-80pq in incremental mode.
void ascon128a_aead_decrypt_block(ascon128a_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Decrypts a block of data with ASCON-128a in incremental mode.
int ascon80pq_aead_decrypt(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 ASCON-80pq.
void ascon80pq_aead_encrypt_block(ascon80pq_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Encrypts a block of data with ASCON-80pq in incremental mode.
#define ASCON128_KEY_SIZE
Size of the key for ASCON-128 and ASCON-128a.
Definition: aead.h:55
void ascon128a_aead_encrypt(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 ASCON-128a.
int ascon128_aead_decrypt(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 ASCON-128.
#define ASCON80PQ_KEY_SIZE
Size of the key for ASCON-80pq.
Definition: aead.h:70
void ascon128_aead_decrypt_block(ascon128_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Decrypts a block of data with ASCON-128 in incremental mode.
void ascon128_aead_encrypt_finalize(ascon128_state_t *state, unsigned char *tag)
Finalizes an incremental ASCON-128 encryption operation and generates the authentication tag.
void ascon80pq_aead_abort(ascon80pq_state_t *state)
Aborts use of ASCON-80pq in incremental mode.
void ascon80pq_aead_decrypt_block(ascon80pq_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Decrypts a block of data with ASCON-80pq in incremental mode.
void ascon128a_aead_start(ascon128a_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Starts encrypting or decrypting a packet with ASCON-128a in incremental mode.
void ascon128_aead_start(ascon128_state_t *state, const unsigned char *ad, size_t adlen, const unsigned char *npub, const unsigned char *k)
Starts encrypting or decrypting a packet with ASCON-128 in incremental mode.
void ascon80pq_aead_encrypt_finalize(ascon80pq_state_t *state, unsigned char *tag)
Finalizes an incremental ASCON-80pq encryption operation and generates the authentication tag.
int ascon128_aead_decrypt_finalize(ascon128_state_t *state, const unsigned char *tag)
Finalizes an incremental ASCON-128 decryption operation and checks the authentication tag.
void ascon128a_aead_encrypt_block(ascon128a_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Encrypts a block of data with ASCON-128a in incremental mode.
void ascon128_aead_encrypt(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 ASCON-128.
int ascon128a_aead_decrypt(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 ASCON-128a.
void ascon128_aead_encrypt_block(ascon128_state_t *state, const unsigned char *in, unsigned char *out, size_t len)
Encrypts a block of data with ASCON-128 in incremental mode.
int ascon80pq_aead_decrypt_finalize(ascon80pq_state_t *state, const unsigned char *tag)
Finalizes an incremental ASCON-80pq decryption operation and checks the authentication tag.
void ascon128a_aead_abort(ascon128a_state_t *state)
Aborts use of ASCON-128a in incremental mode.
Direct access to the ASCON permutation primitive.
ascon_state_t state
[snippet_key]
Definition: snippets.c:2
State information for the incremental version of ASCON-128.
Definition: aead.h:263
ascon_state_t state
Definition: aead.h:265
unsigned char posn
Definition: aead.h:271
State information for the incremental version of ASCON-128a.
Definition: aead.h:281
ascon_state_t state
Definition: aead.h:283
unsigned char posn
Definition: aead.h:289
State information for the incremental version of ASCON-80pq.
Definition: aead.h:299
ascon_state_t state
Definition: aead.h:301
unsigned char posn
Definition: aead.h:307
Structure of the internal state of the ASCON permutation.
Definition: permutation.h:63