Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
knot.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_KNOT_H
24 #define LWCRYPTO_KNOT_H
25 
26 #include "aead-common.h"
27 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
64 #define KNOT_AEAD_128_KEY_SIZE 16
65 
70 #define KNOT_AEAD_128_TAG_SIZE 16
71 
75 #define KNOT_AEAD_128_NONCE_SIZE 16
76 
80 #define KNOT_AEAD_192_KEY_SIZE 24
81 
85 #define KNOT_AEAD_192_TAG_SIZE 24
86 
90 #define KNOT_AEAD_192_NONCE_SIZE 24
91 
95 #define KNOT_AEAD_256_KEY_SIZE 32
96 
100 #define KNOT_AEAD_256_TAG_SIZE 32
101 
105 #define KNOT_AEAD_256_NONCE_SIZE 32
106 
110 #define KNOT_HASH_256_SIZE 32
111 
115 #define KNOT_HASH_384_SIZE 48
116 
120 #define KNOT_HASH_512_SIZE 64
121 
126 
131 
136 
141 
146 
151 
156 
161 
184  (unsigned char *c, unsigned long long *clen,
185  const unsigned char *m, unsigned long long mlen,
186  const unsigned char *ad, unsigned long long adlen,
187  const unsigned char *nsec,
188  const unsigned char *npub,
189  const unsigned char *k);
190 
214  (unsigned char *m, unsigned long long *mlen,
215  unsigned char *nsec,
216  const unsigned char *c, unsigned long long clen,
217  const unsigned char *ad, unsigned long long adlen,
218  const unsigned char *npub,
219  const unsigned char *k);
220 
243  (unsigned char *c, unsigned long long *clen,
244  const unsigned char *m, unsigned long long mlen,
245  const unsigned char *ad, unsigned long long adlen,
246  const unsigned char *nsec,
247  const unsigned char *npub,
248  const unsigned char *k);
249 
273  (unsigned char *m, unsigned long long *mlen,
274  unsigned char *nsec,
275  const unsigned char *c, unsigned long long clen,
276  const unsigned char *ad, unsigned long long adlen,
277  const unsigned char *npub,
278  const unsigned char *k);
279 
280 
303  (unsigned char *c, unsigned long long *clen,
304  const unsigned char *m, unsigned long long mlen,
305  const unsigned char *ad, unsigned long long adlen,
306  const unsigned char *nsec,
307  const unsigned char *npub,
308  const unsigned char *k);
309 
333  (unsigned char *m, unsigned long long *mlen,
334  unsigned char *nsec,
335  const unsigned char *c, unsigned long long clen,
336  const unsigned char *ad, unsigned long long adlen,
337  const unsigned char *npub,
338  const unsigned char *k);
339 
362  (unsigned char *c, unsigned long long *clen,
363  const unsigned char *m, unsigned long long mlen,
364  const unsigned char *ad, unsigned long long adlen,
365  const unsigned char *nsec,
366  const unsigned char *npub,
367  const unsigned char *k);
368 
392  (unsigned char *m, unsigned long long *mlen,
393  unsigned char *nsec,
394  const unsigned char *c, unsigned long long clen,
395  const unsigned char *ad, unsigned long long adlen,
396  const unsigned char *npub,
397  const unsigned char *k);
398 
411  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
412 
425  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
426 
439  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
440 
453  (unsigned char *out, const unsigned char *in, unsigned long long inlen);
454 
455 #ifdef __cplusplus
456 }
457 #endif
458 
459 #endif
Meta-information about an AEAD cipher.
Definition: aead-common.h:185
Definitions that are common across AEAD schemes.
int knot_aead_192_384_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 KNOT-AEAD-192-384.
Definition: knot-aead.c:380
int knot_hash_256_384(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with KNOT-HASH-256-384.
Definition: knot-hash.c:122
int knot_aead_128_256_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 KNOT-AEAD-128-256.
Definition: knot-aead.c:168
Meta-information about a hash algorithm that is related to an AEAD.
Definition: aead-common.h:204
int knot_aead_256_512_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 KNOT-AEAD-256-512.
Definition: knot-aead.c:423
aead_hash_algorithm_t const knot_hash_256_256_algorithm
Meta-information block for the KNOT-HASH-256-256 algorithm.
Definition: knot-hash.c:27
aead_cipher_t const knot_aead_128_256_cipher
Meta-information block for the KNOT-AEAD-128-256 cipher.
Definition: knot-aead.c:27
aead_hash_algorithm_t const knot_hash_256_384_algorithm
Meta-information block for the KNOT-HASH-256-384 algorithm.
Definition: knot-hash.c:40
int knot_aead_128_384_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 KNOT-AEAD-128-384.
Definition: knot-aead.c:251
int knot_aead_128_384_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 KNOT-AEAD-128-384.
Definition: knot-aead.c:294
aead_cipher_t const knot_aead_256_512_cipher
Meta-information block for the KNOT-AEAD-256-512 cipher.
Definition: knot-aead.c:57
aead_cipher_t const knot_aead_128_384_cipher
Meta-information block for the KNOT-AEAD-128-384 cipher.
Definition: knot-aead.c:37
int knot_aead_256_512_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 KNOT-AEAD-256-512.
Definition: knot-aead.c:463
aead_hash_algorithm_t const knot_hash_512_512_algorithm
Meta-information block for the KNOT-HASH-512-512 algorithm.
Definition: knot-hash.c:66
int knot_aead_192_384_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 KNOT-AEAD-192-384.
Definition: knot-aead.c:340
aead_cipher_t const knot_aead_192_384_cipher
Meta-information block for the KNOT-AEAD-192-384 cipher.
Definition: knot-aead.c:47
int knot_aead_128_256_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 KNOT-AEAD-128-256.
Definition: knot-aead.c:208
int knot_hash_512_512(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with KNOT-HASH-512-512.
Definition: knot-hash.c:167
int knot_hash_384_384(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with KNOT-HASH-384-384.
Definition: knot-hash.c:145
int knot_hash_256_256(unsigned char *out, const unsigned char *in, unsigned long long inlen)
Hashes a block of input data with KNOT-HASH-256-256.
Definition: knot-hash.c:100
aead_hash_algorithm_t const knot_hash_384_384_algorithm
Meta-information block for the KNOT-HASH-384-384 algorithm.
Definition: knot-hash.c:53