Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
ace.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_ACE_H
24 #define LWCRYPTO_ACE_H
25 
26 #include "aead-common.h"
27 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
48 #define ACE_KEY_SIZE 16
49 
53 #define ACE_TAG_SIZE 16
54 
58 #define ACE_NONCE_SIZE 16
59 
63 #define ACE_HASH_SIZE 32
64 
68 extern aead_cipher_t const ace_cipher;
69 
74 
78 typedef union
79 {
80  struct {
81  unsigned char state[40];
82  unsigned char count;
83  } s;
84  unsigned long long align;
87 
110  (unsigned char *c, unsigned long long *clen,
111  const unsigned char *m, unsigned long long mlen,
112  const unsigned char *ad, unsigned long long adlen,
113  const unsigned char *nsec,
114  const unsigned char *npub,
115  const unsigned char *k);
116 
140  (unsigned char *m, unsigned long long *mlen,
141  unsigned char *nsec,
142  const unsigned char *c, unsigned long long clen,
143  const unsigned char *ad, unsigned long long adlen,
144  const unsigned char *npub,
145  const unsigned char *k);
146 
158 int ace_hash
159  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
160 
168 void ace_hash_init(ace_hash_state_t *state);
169 
179 void ace_hash_update
180  (ace_hash_state_t *state, const unsigned char *in,
181  unsigned long long inlen);
182 
191 void ace_hash_finalize(ace_hash_state_t *state, unsigned char *out);
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif
Meta-information about an AEAD cipher.
Definition: aead-common.h:185
Definitions that are common across AEAD schemes.
void ace_hash_init(ace_hash_state_t *state)
Initializes the state for an ACE-HASH hashing operation.
Definition: ace.c:279
unsigned char count
Definition: ace.h:82
Meta-information about a hash algorithm that is related to an AEAD.
Definition: aead-common.h:204
int ace_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with ACE-HASH to generate a hash value.
Definition: ace.c:241
State information for the ACE-HASH incremental hash mode.
Definition: ace.h:78
aead_cipher_t const ace_cipher
Meta-information block for the ACE cipher.
Definition: ace.c:39
aead_hash_algorithm_t const ace_hash_algorithm
Meta-information block for the ACE-HASH hash algorithm.
Definition: ace.c:49
void ace_hash_update(ace_hash_state_t *state, const unsigned char *in, unsigned long long inlen)
Updates the ACE-HASH state with more input data.
Definition: ace.c:286
unsigned long long align
Definition: ace.h:84
void ace_hash_finalize(ace_hash_state_t *state, unsigned char *out)
Returns the final hash value from an ACE-HASH hashing operation.
Definition: ace.c:323
int ace_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 ACE.
Definition: ace.c:150
int ace_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 ACE.
Definition: ace.c:189