Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
gascon128.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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_GASCON_H
24 #define LWCRYPTO_GASCON_H
25 
26 #include "aead-common.h"
27 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
54 #define GASCON128_KEY_SIZE 16
55 
59 #define GASCON128_NONCE_SIZE 16
60 
64 #define GASCON128_TAG_SIZE 16
65 
69 #define GASCON80PQ_KEY_SIZE 20
70 
74 #define GASCON80PQ_NONCE_SIZE 16
75 
79 #define GASCON80PQ_TAG_SIZE 16
80 
84 #define GASCON_HASH_SIZE 32
85 
89 typedef union
90 {
91  struct {
92  unsigned char state[40];
93  unsigned char count;
94  unsigned char mode;
95  } s;
96  unsigned long long align;
99 
103 extern aead_cipher_t const gascon128_cipher;
104 
108 extern aead_cipher_t const gascon128a_cipher;
109 
113 extern aead_cipher_t const gascon80pq_cipher;
114 
119 
124 
147  (unsigned char *c, unsigned long long *clen,
148  const unsigned char *m, unsigned long long mlen,
149  const unsigned char *ad, unsigned long long adlen,
150  const unsigned char *nsec,
151  const unsigned char *npub,
152  const unsigned char *k);
153 
177  (unsigned char *m, unsigned long long *mlen,
178  unsigned char *nsec,
179  const unsigned char *c, unsigned long long clen,
180  const unsigned char *ad, unsigned long long adlen,
181  const unsigned char *npub,
182  const unsigned char *k);
183 
206  (unsigned char *c, unsigned long long *clen,
207  const unsigned char *m, unsigned long long mlen,
208  const unsigned char *ad, unsigned long long adlen,
209  const unsigned char *nsec,
210  const unsigned char *npub,
211  const unsigned char *k);
212 
236  (unsigned char *m, unsigned long long *mlen,
237  unsigned char *nsec,
238  const unsigned char *c, unsigned long long clen,
239  const unsigned char *ad, unsigned long long adlen,
240  const unsigned char *npub,
241  const unsigned char *k);
242 
265  (unsigned char *c, unsigned long long *clen,
266  const unsigned char *m, unsigned long long mlen,
267  const unsigned char *ad, unsigned long long adlen,
268  const unsigned char *nsec,
269  const unsigned char *npub,
270  const unsigned char *k);
271 
295  (unsigned char *m, unsigned long long *mlen,
296  unsigned char *nsec,
297  const unsigned char *c, unsigned long long clen,
298  const unsigned char *ad, unsigned long long adlen,
299  const unsigned char *npub,
300  const unsigned char *k);
301 
315 int gascon_hash
316  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
317 
326 
337  (gascon_hash_state_t *state, const unsigned char *in,
338  unsigned long long inlen);
339 
349  (gascon_hash_state_t *state, unsigned char *out);
350 
367 int gascon_xof
368  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
369 
378 
389  (gascon_hash_state_t *state, const unsigned char *in,
390  unsigned long long inlen);
391 
402  (gascon_hash_state_t *state, unsigned char *out, unsigned long long outlen);
403 
404 #ifdef __cplusplus
405 }
406 #endif
407 
408 #endif
Meta-information about an AEAD cipher.
Definition: aead-common.h:185
Definitions that are common across AEAD schemes.
void gascon_xof_squeeze(gascon_hash_state_t *state, unsigned char *out, unsigned long long outlen)
Squeezes output data from an GASCON-XOF state.
unsigned char mode
Definition: gascon128.h:94
void gascon_hash_finalize(gascon_hash_state_t *state, unsigned char *out)
Returns the final hash value from an GASCON-HASH hashing operation.
int gascon128_aead_decrypt(unsigned char *m, unsigned long long *mlen, unsigned char *nsec, const unsigned char *c, unsigned long long clen, const unsigned char *ad, unsigned long long adlen, const unsigned char *npub, const unsigned char *k)
Decrypts and authenticates a packet with GASCON-128.
Definition: gascon128.c:310
Meta-information about a hash algorithm that is related to an AEAD.
Definition: aead-common.h:204
unsigned long long align
Definition: gascon128.h:96
void gascon_hash_update(gascon_hash_state_t *state, const unsigned char *in, unsigned long long inlen)
Updates an GASCON-HASH state with more input data.
aead_hash_algorithm_t const gascon_hash_algorithm
Meta-information block for the GASCON-HASH algorithm.
unsigned char count
Definition: gascon128.h:93
int gascon_xof(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with GASCON-XOF and generates a fixed-length 32 byte output...
void gascon_hash_init(gascon_hash_state_t *state)
Initializes the state for an GASCON-HASH hashing operation.
int gascon128a_aead_encrypt(unsigned char *c, unsigned long long *clen, const unsigned char *m, unsigned long long mlen, const unsigned char *ad, unsigned long long adlen, const unsigned char *nsec, const unsigned char *npub, const unsigned char *k)
Encrypts and authenticates a packet with GASCON-128a.
Definition: gascon128.c:351
int gascon80pq_aead_encrypt(unsigned char *c, unsigned long long *clen, const unsigned char *m, unsigned long long mlen, const unsigned char *ad, unsigned long long adlen, const unsigned char *nsec, const unsigned char *npub, const unsigned char *k)
Encrypts and authenticates a packet with GASCON-80pq.
Definition: gascon128.c:430
aead_cipher_t const gascon128a_cipher
Meta-information block for the GASCON-128a cipher.
Definition: gascon128.c:52
void gascon_xof_init(gascon_hash_state_t *state)
Initializes the state for an GASCON-XOF hashing operation.
int gascon_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with GASCON-HASH.
aead_cipher_t const gascon80pq_cipher
Meta-information block for the GASCON-80pq cipher.
Definition: gascon128.c:62
void gascon_xof_absorb(gascon_hash_state_t *state, const unsigned char *in, unsigned long long inlen)
Aborbs more input data into an GASCON-XOF state.
aead_cipher_t const gascon128_cipher
Meta-information block for the GASCON-128 cipher.
Definition: gascon128.c:42
aead_hash_algorithm_t const gascon_xof_algorithm
Meta-information block for the GASCON-XOF algorithm.
State information for GASCON-HASH and GASCON-XOF incremental modes.
Definition: gascon128.h:89
int gascon80pq_aead_decrypt(unsigned char *m, unsigned long long *mlen, unsigned char *nsec, const unsigned char *c, unsigned long long clen, const unsigned char *ad, unsigned long long adlen, const unsigned char *npub, const unsigned char *k)
Decrypts and authenticates a packet with GASCON-80pq.
Definition: gascon128.c:468
int gascon128a_aead_decrypt(unsigned char *m, unsigned long long *mlen, unsigned char *nsec, const unsigned char *c, unsigned long long clen, const unsigned char *ad, unsigned long long adlen, const unsigned char *npub, const unsigned char *k)
Decrypts and authenticates a packet with GASCON-128a.
Definition: gascon128.c:389
int gascon128_aead_encrypt(unsigned char *c, unsigned long long *clen, const unsigned char *m, unsigned long long mlen, const unsigned char *ad, unsigned long long adlen, const unsigned char *nsec, const unsigned char *npub, const unsigned char *k)
Encrypts and authenticates a packet with GASCON-128.
Definition: gascon128.c:272