Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
xoodyak.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_XOODYAK_H
24 #define LWCRYPTO_XOODYAK_H
25 
26 #include "aead-common.h"
27 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
59 #define XOODYAK_KEY_SIZE 16
60 
64 #define XOODYAK_TAG_SIZE 16
65 
69 #define XOODYAK_NONCE_SIZE 16
70 
74 #define XOODYAK_HASH_SIZE 32
75 
79 typedef union
80 {
81  struct {
82  unsigned char state[48];
83  unsigned char count;
84  unsigned char mode;
85  } s;
86  unsigned long long align;
89 
93 extern aead_cipher_t const xoodyak_cipher;
94 
99 
122  (unsigned char *c, unsigned long long *clen,
123  const unsigned char *m, unsigned long long mlen,
124  const unsigned char *ad, unsigned long long adlen,
125  const unsigned char *nsec,
126  const unsigned char *npub,
127  const unsigned char *k);
128 
152  (unsigned char *m, unsigned long long *mlen,
153  unsigned char *nsec,
154  const unsigned char *c, unsigned long long clen,
155  const unsigned char *ad, unsigned long long adlen,
156  const unsigned char *npub,
157  const unsigned char *k);
158 
170 int xoodyak_hash
171  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
172 
181 
192  (xoodyak_hash_state_t *state, const unsigned char *in,
193  unsigned long long inlen);
194 
205  (xoodyak_hash_state_t *state, unsigned char *out,
206  unsigned long long outlen);
207 
220  (xoodyak_hash_state_t *state, unsigned char *out);
221 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif
unsigned long long align
Definition: xoodyak.h:86
Meta-information about an AEAD cipher.
Definition: aead-common.h:185
Definitions that are common across AEAD schemes.
aead_cipher_t const xoodyak_cipher
Meta-information block for the Xoodyak cipher.
Definition: xoodyak.c:27
void xoodyak_hash_init(xoodyak_hash_state_t *state)
Initializes the state for a Xoodyak hashing operation.
Definition: xoodyak.c:237
int xoodyak_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 Xoodyak.
Definition: xoodyak.c:112
aead_hash_algorithm_t const xoodyak_hash_algorithm
Meta-information block for the Xoodyak hash algorithm.
Definition: xoodyak.c:37
void xoodyak_hash_squeeze(xoodyak_hash_state_t *state, unsigned char *out, unsigned long long outlen)
Squeezes output data from a Xoodyak hashing state.
Definition: xoodyak.c:281
Meta-information about a hash algorithm that is related to an AEAD.
Definition: aead-common.h:204
int xoodyak_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with Xoodyak to generate a hash value.
Definition: xoodyak.c:221
State information for Xoodyak incremental hashing modes.
Definition: xoodyak.h:79
unsigned char mode
Definition: xoodyak.h:84
int xoodyak_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 Xoodyak.
Definition: xoodyak.c:165
void xoodyak_hash_finalize(xoodyak_hash_state_t *state, unsigned char *out)
Returns the final hash value from a Xoodyak hashing operation.
Definition: xoodyak.c:318
void xoodyak_hash_absorb(xoodyak_hash_state_t *state, const unsigned char *in, unsigned long long inlen)
Aborbs more input data into a Xoodyak hashing state.
Definition: xoodyak.c:244
unsigned char count
Definition: xoodyak.h:83