Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
saturnin.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_SATURNIN_H
24 #define LWCRYPTO_SATURNIN_H
25 
26 #include "aead-common.h"
27 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
53 #define SATURNIN_KEY_SIZE 32
54 
59 #define SATURNIN_TAG_SIZE 32
60 
64 #define SATURNIN_NONCE_SIZE 16
65 
69 #define SATURNIN_HASH_SIZE 32
70 
74 typedef union
75 {
76  struct {
77  unsigned char hash[32];
78  unsigned char block[32];
79  unsigned char count;
80  unsigned char mode;
81  } s;
82  unsigned long long align;
85 
89 extern aead_cipher_t const saturnin_cipher;
90 
95 
100 
123  (unsigned char *c, unsigned long long *clen,
124  const unsigned char *m, unsigned long long mlen,
125  const unsigned char *ad, unsigned long long adlen,
126  const unsigned char *nsec,
127  const unsigned char *npub,
128  const unsigned char *k);
129 
153  (unsigned char *m, unsigned long long *mlen,
154  unsigned char *nsec,
155  const unsigned char *c, unsigned long long clen,
156  const unsigned char *ad, unsigned long long adlen,
157  const unsigned char *npub,
158  const unsigned char *k);
159 
182  (unsigned char *c, unsigned long long *clen,
183  const unsigned char *m, unsigned long long mlen,
184  const unsigned char *ad, unsigned long long adlen,
185  const unsigned char *nsec,
186  const unsigned char *npub,
187  const unsigned char *k);
188 
212  (unsigned char *m, unsigned long long *mlen,
213  unsigned char *nsec,
214  const unsigned char *c, unsigned long long clen,
215  const unsigned char *ad, unsigned long long adlen,
216  const unsigned char *npub,
217  const unsigned char *k);
218 
230 int saturnin_hash
231  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
232 
241 
252  (saturnin_hash_state_t *state, const unsigned char *in,
253  unsigned long long inlen);
254 
264  (saturnin_hash_state_t *state, unsigned char *out);
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif
Meta-information about an AEAD cipher.
Definition: aead-common.h:185
Definitions that are common across AEAD schemes.
unsigned long long align
Definition: saturnin.h:82
aead_cipher_t const saturnin_cipher
Meta-information block for the SATURNIN-CTR-Cascade cipher.
Definition: saturnin.c:27
Meta-information about a hash algorithm that is related to an AEAD.
Definition: aead-common.h:204
unsigned char count
Definition: saturnin.h:79
int saturnin_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 SATURNIN-CTR-Cascade.
Definition: saturnin.c:179
int saturnin_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with SATURNIN to generate a hash value.
Definition: saturnin.c:314
aead_cipher_t const saturnin_short_cipher
Meta-information block for the SATURNIN-Short cipher.
Definition: saturnin.c:37
int saturnin_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 SATURNIN-CTR-Cascade.
Definition: saturnin.c:140
int saturnin_short_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 SATURNIN-Short.
Definition: saturnin.c:224
int saturnin_short_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 SATURNIN-Short.
Definition: saturnin.c:256
aead_hash_algorithm_t const saturnin_hash_algorithm
Meta-information block for SATURNIN-Hash.
Definition: saturnin.c:47
void saturnin_hash_update(saturnin_hash_state_t *state, const unsigned char *in, unsigned long long inlen)
Updates an SATURNIN-Hash state with more input data.
Definition: saturnin.c:331
unsigned char mode
Definition: saturnin.h:80
void saturnin_hash_finalize(saturnin_hash_state_t *state, unsigned char *out)
Returns the final hash value from an SATURNIN-Hash hashing operation.
Definition: saturnin.c:368
State information for SATURNIN-Hash incremental modes.
Definition: saturnin.h:74
void saturnin_hash_init(saturnin_hash_state_t *state)
Initializes the state for an SATURNIN-Hash hashing operation.
Definition: saturnin.c:325