ASCON Suite
isap.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 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_ISAP_H
24 #define ASCON_ISAP_H
25 
26 #include <ascon/permutation.h>
27 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
63 #define ASCON128_ISAP_KEY_SIZE 16
64 
68 #define ASCON80PQ_ISAP_KEY_SIZE 20
69 
73 #define ASCON_ISAP_TAG_SIZE 16
74 
78 #define ASCON_ISAP_NONCE_SIZE 16
79 
83 #define ASCON_ISAP_SAVED_KEY_SIZE 80
84 
88 typedef struct
89 {
94 
98 typedef struct
99 {
104 
108 typedef struct
109 {
114 
129  (ascon128a_isap_aead_key_t *pk, const unsigned char *k);
130 
143  const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE]);
144 
156  unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE]);
157 
166 
186  (unsigned char *c, size_t *clen,
187  const unsigned char *m, size_t mlen,
188  const unsigned char *ad, size_t adlen,
189  const unsigned char *npub,
190  const ascon128a_isap_aead_key_t *pk);
191 
215  (unsigned char *m, size_t *mlen,
216  const unsigned char *c, size_t clen,
217  const unsigned char *ad, size_t adlen,
218  const unsigned char *npub,
219  const ascon128a_isap_aead_key_t *pk);
220 
235  (ascon128_isap_aead_key_t *pk, const unsigned char *k);
236 
249  const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE]);
250 
262  unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE]);
263 
272 
292  (unsigned char *c, size_t *clen,
293  const unsigned char *m, size_t mlen,
294  const unsigned char *ad, size_t adlen,
295  const unsigned char *npub,
296  const ascon128_isap_aead_key_t *pk);
297 
321  (unsigned char *m, size_t *mlen,
322  const unsigned char *c, size_t clen,
323  const unsigned char *ad, size_t adlen,
324  const unsigned char *npub,
325  const ascon128_isap_aead_key_t *pk);
326 
341  (ascon80pq_isap_aead_key_t *pk, const unsigned char *k);
342 
355  const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE]);
356 
368  unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE]);
369 
378 
398  (unsigned char *c, size_t *clen,
399  const unsigned char *m, size_t mlen,
400  const unsigned char *ad, size_t adlen,
401  const unsigned char *npub,
402  const ascon80pq_isap_aead_key_t *pk);
403 
427  (unsigned char *m, size_t *mlen,
428  const unsigned char *c, size_t clen,
429  const unsigned char *ad, size_t adlen,
430  const unsigned char *npub,
431  const ascon80pq_isap_aead_key_t *pk);
432 
433 #ifdef __cplusplus
434 }
435 #endif
436 
437 #endif
void ascon128a_isap_aead_free(ascon128a_isap_aead_key_t *pk)
Frees a pre-computed key for ISAP-A-128A.
void ascon128a_isap_aead_save_key(ascon128a_isap_aead_key_t *pk, unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
Saves a previously pre-computed key for ISAP-A-128A to a buffer.
void ascon80pq_isap_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 ascon80pq_isap_aead_key_t *pk)
Encrypts and authenticates a packet with ISAP-A-80PQ and pre-computed keys.
void ascon80pq_isap_aead_load_key(ascon80pq_isap_aead_key_t *pk, const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
Initializes a pre-computed key for ISAP-A-80PQ from a previously-saved key value.
void ascon128_isap_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 ascon128_isap_aead_key_t *pk)
Encrypts and authenticates a packet with ISAP-A-128 and pre-computed keys.
void ascon128_isap_aead_init(ascon128_isap_aead_key_t *pk, const unsigned char *k)
Initializes a pre-computed key for ISAP-A-128.
#define ASCON_ISAP_SAVED_KEY_SIZE
Size of a pre-computed key in its save format.
Definition: isap.h:83
int ascon128a_isap_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 ascon128a_isap_aead_key_t *pk)
Decrypts and authenticates a packet with ISAP-A-128A and pre-computed keys.
void ascon80pq_isap_aead_init(ascon80pq_isap_aead_key_t *pk, const unsigned char *k)
Initializes a pre-computed key for ISAP-A-80PQ.
void ascon128_isap_aead_load_key(ascon128_isap_aead_key_t *pk, const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
Initializes a pre-computed key for ISAP-A-128 from a previously-saved key value.
void ascon80pq_isap_aead_free(ascon80pq_isap_aead_key_t *pk)
Frees a pre-computed key for ISAP-A-80PQ.
void ascon128_isap_aead_save_key(ascon128_isap_aead_key_t *pk, unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
Saves a previously pre-computed key for ISAP-A-128 to a buffer.
void ascon128a_isap_aead_init(ascon128a_isap_aead_key_t *pk, const unsigned char *k)
Initializes a pre-computed key for ISAP-A-128A.
int ascon128_isap_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 ascon128_isap_aead_key_t *pk)
Decrypts and authenticates a packet with ISAP-A-128 and pre-computed keys.
int ascon80pq_isap_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 ascon80pq_isap_aead_key_t *pk)
Decrypts and authenticates a packet with ISAP-A-80PQ and pre-computed keys.
void ascon128_isap_aead_free(ascon128_isap_aead_key_t *pk)
Frees a pre-computed key for ISAP-A-128.
void ascon80pq_isap_aead_save_key(ascon80pq_isap_aead_key_t *pk, unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
Saves a previously pre-computed key for ISAP-A-80PQ to a buffer.
void ascon128a_isap_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 ascon128a_isap_aead_key_t *pk)
Encrypts and authenticates a packet with ISAP-A-128A and pre-computed keys.
void ascon128a_isap_aead_load_key(ascon128a_isap_aead_key_t *pk, const unsigned char k[ASCON_ISAP_SAVED_KEY_SIZE])
Initializes a pre-computed key for ISAP-A-128A from a previously-saved key value.
Direct access to the ASCON permutation primitive.
Pre-computed key information for ISAP-A-128.
Definition: isap.h:99
ascon_state_t ke
Definition: isap.h:100
ascon_state_t ka
Definition: isap.h:101
Pre-computed key information for ISAP-A-128A.
Definition: isap.h:89
ascon_state_t ke
Definition: isap.h:90
ascon_state_t ka
Definition: isap.h:91
Pre-computed key information for ISAP-A-80PQ.
Definition: isap.h:109
ascon_state_t ke
Definition: isap.h:110
ascon_state_t ka
Definition: isap.h:111
Structure of the internal state of the ASCON permutation.
Definition: permutation.h:63