LibAscon 1.2.1
Lightweight Authenticated Encryption & Hashing, also with Init-Update-Final paradigm.
ascon.h
Go to the documentation of this file.
1
32#ifndef ASCON_H
33#define ASCON_H
34
35#ifdef __cplusplus
36extern "C"
37{
38#endif
39
40#include <stdint.h> /* For uint8_t, uint_fast8_t, uint64_t */
41#include <stddef.h> /* For size_t, NULL */
42#include <stdbool.h> /* For bool, true, false */
43
44#if defined(ASCON_INPUT_ASSERTS) && !defined(ASCON_ASSERT)
60// Redefining ASCON_INPUT_ASSERTS otherwise Doxygen does not find it
61#undef ASCON_INPUT_ASSERTS
62#define ASCON_INPUT_ASSERTS 1
72#include <assert.h> /* For assert() */
73#define ASCON_ASSERT(expr) assert(expr)
74#elif !defined(ASCON_ASSERT)
75// Neither ASCON_INPUT_ASSERTS nor ASCON_ASSERT are defined,
76// so make the assert macro do nothing.
77#define ASCON_ASSERT(expr)
78#endif
79
85#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__NT__)
91#define ASCON_WINDOWS 1
92#define ASCON_API __declspec(dllexport)
93#else
94#define ASCON_API
95#endif
96
98#define ASCON_API_VERSION_MAJOR 1
100#define ASCON_API_VERSION_MINOR 2
102#define ASCON_API_VERSION_BUGFIX 1
104#define ASCON_API_VERSION "1.2.1"
105
109#define ASCON_AEAD128_KEY_LEN 16U
110
114#define ASCON_AEAD128a_KEY_LEN 16U
115
119#define ASCON_AEAD80pq_KEY_LEN 20U
120
125#define ASCON_AEAD_NONCE_LEN 16U
126
131#define ASCON_AEAD_TAG_MIN_SECURE_LEN 16U
132
137#define ASCON_HASH_DIGEST_LEN 32U
138
143#define ASCON_HASHA_DIGEST_LEN ASCON_HASH_DIGEST_LEN
144
149#define ASCON_RATE 8U
150
156#define ASCON_DOUBLE_RATE (2U * ASCON_RATE)
157
161#define ASCON_TAG_OK true
166#define ASCON_TAG_INVALID false
167
171typedef struct ascon_sponge
172{
174 uint64_t x0;
176 uint64_t x1;
178 uint64_t x2;
180 uint64_t x3;
182 uint64_t x4;
184
189typedef struct ascon_bufstate
190{
193
196
198 uint8_t buffer_len;
199
213 uint8_t flow_state;
214
217 uint8_t pad[6];
219
222
229typedef struct ascon_aead_ctx
230{
233
235 uint64_t k0;
236
238 uint64_t k1;
239
242 uint64_t k2;
244
288ASCON_API void
289ascon_aead128_encrypt(uint8_t* ciphertext,
290 uint8_t* tag,
291 const uint8_t key[ASCON_AEAD128_KEY_LEN],
292 const uint8_t nonce[ASCON_AEAD_NONCE_LEN],
293 const uint8_t* assoc_data,
294 const uint8_t* plaintext,
295 size_t assoc_data_len,
296 size_t plaintext_len,
297 size_t tag_len);
298
339ASCON_API void
341 const uint8_t key[ASCON_AEAD128_KEY_LEN],
342 const uint8_t nonce[ASCON_AEAD_NONCE_LEN]);
343
381ASCON_API void
383 const uint8_t* assoc_data,
384 size_t assoc_data_len);
385
426ASCON_API size_t
428 uint8_t* ciphertext,
429 const uint8_t* plaintext,
430 size_t plaintext_len);
431
476ASCON_API size_t
478 uint8_t* ciphertext,
479 uint8_t* tag,
480 size_t tag_len);
481
522ASCON_API bool
523ascon_aead128_decrypt(uint8_t* plaintext,
524 const uint8_t key[ASCON_AEAD128_KEY_LEN],
525 const uint8_t nonce[ASCON_AEAD_NONCE_LEN],
526 const uint8_t* assoc_data,
527 const uint8_t* ciphertext,
528 const uint8_t* expected_tag,
529 size_t assoc_data_len,
530 size_t ciphertext_len,
531 size_t expected_tag_len);
532
567ASCON_API size_t
569 uint8_t* plaintext,
570 const uint8_t* ciphertext,
571 size_t ciphertext_len);
572
616ASCON_API size_t
618 uint8_t* plaintext,
619 bool* is_tag_valid,
620 const uint8_t* expected_tag,
621 size_t expected_tag_len);
622
639ASCON_API void
641
686ASCON_API void
687ascon_aead128a_encrypt(uint8_t* ciphertext,
688 uint8_t* tag,
689 const uint8_t key[ASCON_AEAD128_KEY_LEN],
690 const uint8_t nonce[ASCON_AEAD_NONCE_LEN],
691 const uint8_t* assoc_data,
692 const uint8_t* plaintext,
693 size_t assoc_data_len,
694 size_t plaintext_len,
695 size_t tag_len);
696
697
739ASCON_API void
741 const uint8_t key[ASCON_AEAD128a_KEY_LEN],
742 const uint8_t nonce[ASCON_AEAD_NONCE_LEN]);
743
782ASCON_API void
784 const uint8_t* assoc_data,
785 size_t assoc_data_len);
786
827ASCON_API size_t
829 uint8_t* ciphertext,
830 const uint8_t* plaintext,
831 size_t plaintext_len);
832
833
878ASCON_API size_t
880 uint8_t* ciphertext,
881 uint8_t* tag,
882 size_t tag_len);
883
925ASCON_API bool
926ascon_aead128a_decrypt(uint8_t* plaintext,
927 const uint8_t key[ASCON_AEAD128a_KEY_LEN],
928 const uint8_t nonce[ASCON_AEAD_NONCE_LEN],
929 const uint8_t* assoc_data,
930 const uint8_t* ciphertext,
931 const uint8_t* expected_tag,
932 size_t assoc_data_len,
933 size_t ciphertext_len,
934 size_t expected_tag_len);
935
970ASCON_API size_t
972 uint8_t* plaintext,
973 const uint8_t* ciphertext,
974 size_t ciphertext_len);
975
976
1020ASCON_API size_t
1022 uint8_t* plaintext,
1023 bool* is_tag_valid,
1024 const uint8_t* expected_tag,
1025 size_t expected_tag_len);
1026
1027
1071ASCON_API void
1072ascon_aead80pq_encrypt(uint8_t* ciphertext,
1073 uint8_t* tag,
1074 const uint8_t key[ASCON_AEAD80pq_KEY_LEN],
1075 const uint8_t nonce[ASCON_AEAD_NONCE_LEN],
1076 const uint8_t* assoc_data,
1077 const uint8_t* plaintext,
1078 size_t assoc_data_len,
1079 size_t plaintext_len,
1080 size_t tag_len);
1081
1082
1125ASCON_API void
1127 const uint8_t key[ASCON_AEAD80pq_KEY_LEN],
1128 const uint8_t nonce[ASCON_AEAD_NONCE_LEN]);
1129
1168ASCON_API void
1170 const uint8_t* assoc_data,
1171 size_t assoc_data_len);
1172
1213ASCON_API size_t
1215 uint8_t* ciphertext,
1216 const uint8_t* plaintext,
1217 size_t plaintext_len);
1218
1219
1264ASCON_API size_t
1266 uint8_t* ciphertext,
1267 uint8_t* tag,
1268 size_t tag_len);
1269
1311ASCON_API bool
1312ascon_aead80pq_decrypt(uint8_t* plaintext,
1313 const uint8_t key[ASCON_AEAD80pq_KEY_LEN],
1314 const uint8_t nonce[ASCON_AEAD_NONCE_LEN],
1315 const uint8_t* assoc_data,
1316 const uint8_t* ciphertext,
1317 const uint8_t* expected_tag,
1318 size_t assoc_data_len,
1319 size_t ciphertext_len,
1320 size_t expected_tag_len);
1321
1356ASCON_API size_t
1358 uint8_t* plaintext,
1359 const uint8_t* ciphertext,
1360 size_t ciphertext_len);
1361
1405ASCON_API size_t
1407 uint8_t* plaintext,
1408 bool* is_tag_valid,
1409 const uint8_t* expected_tag,
1410 size_t expected_tag_len);
1411
1433ASCON_API void
1435 const uint8_t* data,
1436 size_t data_len);
1437
1460ASCON_API void
1462 const uint8_t* data,
1463 size_t data_len);
1464
1494ASCON_API bool
1495ascon_hash_matches(const uint8_t expected_digest[ASCON_HASH_DIGEST_LEN],
1496 const uint8_t* data,
1497 size_t data_len);
1498
1529ASCON_API bool
1530ascon_hasha_matches(const uint8_t expected_digest[ASCON_HASHA_DIGEST_LEN],
1531 const uint8_t* data,
1532 size_t data_len);
1533
1556ASCON_API void
1558
1582ASCON_API void
1584
1601ASCON_API void
1603 const uint8_t* data,
1604 size_t data_len);
1605
1623ASCON_API void
1625 const uint8_t* data,
1626 size_t data_len);
1627
1648ASCON_API void
1650 uint8_t digest[ASCON_HASH_DIGEST_LEN]);
1651
1673ASCON_API void
1675 uint8_t digest[ASCON_HASHA_DIGEST_LEN]);
1676
1702ASCON_API bool
1704 const uint8_t expected_digest[ASCON_HASH_DIGEST_LEN]);
1705
1732ASCON_API bool
1734 const uint8_t expected_digest[ASCON_HASHA_DIGEST_LEN]);
1735
1765ASCON_API void
1766ascon_hash_xof(uint8_t* digest,
1767 const uint8_t* data,
1768 size_t digest_len,
1769 size_t data_len);
1770
1801ASCON_API void
1802ascon_hasha_xof(uint8_t* digest,
1803 const uint8_t* data,
1804 size_t digest_len,
1805 size_t data_len);
1806
1844ASCON_API bool
1845ascon_hash_xof_matches(const uint8_t* expected_digest,
1846 const uint8_t* data,
1847 size_t expected_digest_len,
1848 size_t data_len);
1849
1888ASCON_API bool
1889ascon_hasha_xof_matches(const uint8_t* expected_digest,
1890 const uint8_t* data,
1891 size_t expected_digest_len,
1892 size_t data_len);
1893
1916ASCON_API void
1918
1942ASCON_API void
1944
1962ASCON_API void
1964 const uint8_t* data,
1965 size_t data_len);
1966
1985ASCON_API void
1987 const uint8_t* data,
1988 size_t data_len);
1989
2017ASCON_API void
2019 uint8_t* digest,
2020 size_t digest_len);
2021
2050ASCON_API void
2052 uint8_t* digest,
2053 size_t digest_len);
2054
2076ASCON_API bool
2078 const uint8_t* expected_digest,
2079 size_t expected_digest_len);
2080
2103ASCON_API bool
2105 const uint8_t* expected_digest,
2106 size_t expected_digest_len);
2107
2124ASCON_API void
2126
2127#ifdef __cplusplus
2128}
2129#endif
2130
2131#endif /* ASCON_H */
ASCON_API bool ascon_aead80pq_decrypt(uint8_t *plaintext, const uint8_t key[ASCON_AEAD80pq_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN], const uint8_t *assoc_data, const uint8_t *ciphertext, const uint8_t *expected_tag, size_t assoc_data_len, size_t ciphertext_len, size_t expected_tag_len)
Offline symmetric decryption using Ascon80pq, which uses a larger key compared to Ascon128.
ASCON_API bool ascon_hash_xof_matches(const uint8_t *expected_digest, const uint8_t *data, size_t expected_digest_len, size_t data_len)
Offline Ascon-Hash with custom digest length (eXtendable Output Function, XOF) and validation of the ...
ASCON_API void ascon_hasha_final(ascon_hash_ctx_t *ctx, uint8_t digest[ASCON_HASHA_DIGEST_LEN])
Online Ascon-Hasha with fixed digest length, finalisation and digest generation.
ASCON_API bool ascon_hash_final_matches(ascon_hash_ctx_t *ctx, const uint8_t expected_digest[ASCON_HASH_DIGEST_LEN])
Online Ascon-Hasha with fixed digest length, finalisation and digest validation of the expected one.
ASCON_API bool ascon_hasha_xof_final_matches(ascon_hash_ctx_t *ctx, const uint8_t *expected_digest, size_t expected_digest_len)
Online Ascon-Hasha with custom digest length (eXtendable Output Function, XOF), finalisation and dige...
ASCON_API void ascon_hash_init(ascon_hash_ctx_t *ctx)
Online Ascon-Hash with fixed digest length, initialisation.
#define ASCON_HASH_DIGEST_LEN
Length in bytes of the digest generated by the fixed-size (non-xof) hash function.
Definition: ascon.h:137
ASCON_API void ascon_hasha_xof_final(ascon_hash_ctx_t *ctx, uint8_t *digest, size_t digest_len)
Online Ascon-Hasha with custom digest length (eXtendable Output Function, XOF), finalisation and dige...
ASCON_API void ascon_hash_xof_init(ascon_hash_ctx_t *ctx)
Online Ascon-Hash with custom digest length (eXtendable Output Function, XOF), initialisation.
ASCON_API void ascon_aead80pq_init(ascon_aead_ctx_t *ctx, const uint8_t key[ASCON_AEAD80pq_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN])
Online symmetric encryption/decryption using Ascon80pq, initialisation - note that a larger key is us...
#define ASCON_AEAD128a_KEY_LEN
Length in bytes of the secret symmetric key used for the Ascon128a cipher.
Definition: ascon.h:114
ASCON_API void ascon_aead128_init(ascon_aead_ctx_t *ctx, const uint8_t key[ASCON_AEAD128_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN])
Online symmetric encryption/decryption using Ascon128, initialisation.
ASCON_API void ascon_aead128_assoc_data_update(ascon_aead_ctx_t *ctx, const uint8_t *assoc_data, size_t assoc_data_len)
Online symmetric encryption/decryption using Ascon128, feeding associated data.
#define ASCON_HASHA_DIGEST_LEN
Length in bytes of the digest generated by the fixed-size (non-xof) hasha function.
Definition: ascon.h:143
#define ASCON_API
Marker of all the library's public API functions.
Definition: ascon.h:92
ASCON_API size_t ascon_aead80pq_decrypt_update(ascon_aead_ctx_t *ctx, uint8_t *plaintext, const uint8_t *ciphertext, size_t ciphertext_len)
Online symmetric decryption using Ascon80pq, feeding ciphertext and getting plaintext.
#define ASCON_DOUBLE_RATE
Number of bytes the cipher can process at the time in AEAD128a mode.
Definition: ascon.h:156
ASCON_API void ascon_hash_cleanup(ascon_hash_ctx_t *ctx)
Security cleanup of the hashing context, in case the online processing is not completed to the end.
ASCON_API void ascon_hasha_xof_update(ascon_hash_ctx_t *ctx, const uint8_t *data, size_t data_len)
Online Ascon-Hasha with custom digest length (eXtendable Output Function, XOF), feeding data to hash.
ASCON_API size_t ascon_aead80pq_encrypt_final(ascon_aead_ctx_t *ctx, uint8_t *ciphertext, uint8_t *tag, size_t tag_len)
Online symmetric encryption using Ascon80pq, finalisation and tag generation.
#define ASCON_AEAD128_KEY_LEN
Length in bytes of the secret symmetric key used for the Ascon128 cipher.
Definition: ascon.h:109
ASCON_API size_t ascon_aead128_decrypt_update(ascon_aead_ctx_t *ctx, uint8_t *plaintext, const uint8_t *ciphertext, size_t ciphertext_len)
Online symmetric decryption using Ascon128, feeding ciphertext and getting plaintext.
ASCON_API size_t ascon_aead128a_encrypt_final(ascon_aead_ctx_t *ctx, uint8_t *ciphertext, uint8_t *tag, size_t tag_len)
Online symmetric encryption using Ascon128a, finalisation and tag generation.
ASCON_API size_t ascon_aead128_encrypt_final(ascon_aead_ctx_t *ctx, uint8_t *ciphertext, uint8_t *tag, size_t tag_len)
Online symmetric encryption using Ascon128, finalisation and tag generation.
ascon_bufstate_t ascon_hash_ctx_t
Cipher context for hashing.
Definition: ascon.h:221
ASCON_API void ascon_hash_xof_update(ascon_hash_ctx_t *ctx, const uint8_t *data, size_t data_len)
Online Ascon-Hash with custom digest length (eXtendable Output Function, XOF), feeding data to hash.
ASCON_API size_t ascon_aead80pq_encrypt_update(ascon_aead_ctx_t *ctx, uint8_t *ciphertext, const uint8_t *plaintext, size_t plaintext_len)
Online symmetric encryption using Ascon80pq, feeding plaintext and getting ciphertext.
ASCON_API bool ascon_aead128a_decrypt(uint8_t *plaintext, const uint8_t key[ASCON_AEAD128a_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN], const uint8_t *assoc_data, const uint8_t *ciphertext, const uint8_t *expected_tag, size_t assoc_data_len, size_t ciphertext_len, size_t expected_tag_len)
Offline symmetric decryption using Ascon128a, which uses a double data rate compared to Ascon128.
ASCON_API void ascon_aead128a_assoc_data_update(ascon_aead_ctx_t *ctx, const uint8_t *assoc_data, size_t assoc_data_len)
Online symmetric encryption/decryption using Ascon128a, feeding associated data.
ASCON_API bool ascon_hasha_final_matches(ascon_hash_ctx_t *ctx, const uint8_t expected_digest[ASCON_HASHA_DIGEST_LEN])
Online Ascon-Hasha with fixed digest length, finalisation and digest validation of the expected one.
ASCON_API size_t ascon_aead128a_encrypt_update(ascon_aead_ctx_t *ctx, uint8_t *ciphertext, const uint8_t *plaintext, size_t plaintext_len)
Online symmetric encryption using Ascon128a, feeding plaintext and getting ciphertext.
ASCON_API bool ascon_hash_xof_final_matches(ascon_hash_ctx_t *ctx, const uint8_t *expected_digest, size_t expected_digest_len)
Online Ascon-Hash with custom digest length (eXtendable Output Function, XOF), finalisation and diges...
ASCON_API void ascon_hasha(uint8_t digest[ASCON_HASHA_DIGEST_LEN], const uint8_t *data, size_t data_len)
Offline Ascon-Hasha with fixed digest length.
ASCON_API bool ascon_hasha_xof_matches(const uint8_t *expected_digest, const uint8_t *data, size_t expected_digest_len, size_t data_len)
Offline Ascon-Hasha with custom digest length (eXtendable Output Function, XOF) and validation of the...
ASCON_API bool ascon_aead128_decrypt(uint8_t *plaintext, const uint8_t key[ASCON_AEAD128_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN], const uint8_t *assoc_data, const uint8_t *ciphertext, const uint8_t *expected_tag, size_t assoc_data_len, size_t ciphertext_len, size_t expected_tag_len)
Offline symmetric decryption using Ascon128.
ASCON_API size_t ascon_aead128a_decrypt_final(ascon_aead_ctx_t *ctx, uint8_t *plaintext, bool *is_tag_valid, const uint8_t *expected_tag, size_t expected_tag_len)
Online symmetric decryption using Ascon128a, finalisation and tag validation.
ASCON_API size_t ascon_aead128_encrypt_update(ascon_aead_ctx_t *ctx, uint8_t *ciphertext, const uint8_t *plaintext, size_t plaintext_len)
Online symmetric encryption using Ascon128, feeding plaintext and getting ciphertext.
ASCON_API void ascon_hash(uint8_t digest[ASCON_HASH_DIGEST_LEN], const uint8_t *data, size_t data_len)
Offline Ascon-Hash with fixed digest length.
struct ascon_sponge ascon_sponge_t
Internal cipher sponge state (320 bits).
ASCON_API void ascon_aead128_encrypt(uint8_t *ciphertext, uint8_t *tag, const uint8_t key[ASCON_AEAD128_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN], const uint8_t *assoc_data, const uint8_t *plaintext, size_t assoc_data_len, size_t plaintext_len, size_t tag_len)
Offline symmetric encryption using Ascon128.
ASCON_API size_t ascon_aead80pq_decrypt_final(ascon_aead_ctx_t *ctx, uint8_t *plaintext, bool *is_tag_valid, const uint8_t *expected_tag, size_t expected_tag_len)
Online symmetric decryption using Ascon80pq, finalisation and tag validation.
ASCON_API void ascon_aead128a_encrypt(uint8_t *ciphertext, uint8_t *tag, const uint8_t key[ASCON_AEAD128_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN], const uint8_t *assoc_data, const uint8_t *plaintext, size_t assoc_data_len, size_t plaintext_len, size_t tag_len)
Offline symmetric encryption using Ascon128a, which uses a double data rate compared to Ascon128.
ASCON_API void ascon_hasha_xof(uint8_t *digest, const uint8_t *data, size_t digest_len, size_t data_len)
Offline Ascon-Hasha with custom digest length (eXtendable Output Function, XOF).
ASCON_API void ascon_hasha_init(ascon_hash_ctx_t *ctx)
Online Ascon-Hasha with fixed digest length, initialisation.
ASCON_API void ascon_hash_final(ascon_hash_ctx_t *ctx, uint8_t digest[ASCON_HASH_DIGEST_LEN])
Online Ascon-Hash with fixed digest length, finalisation and digest generation.
ASCON_API bool ascon_hasha_matches(const uint8_t expected_digest[ASCON_HASHA_DIGEST_LEN], const uint8_t *data, size_t data_len)
Offline Ascon-Hasha with fixed digest length, finalisation and digest validation of the expected one.
ASCON_API void ascon_aead80pq_assoc_data_update(ascon_aead_ctx_t *ctx, const uint8_t *assoc_data, size_t assoc_data_len)
Online symmetric encryption/decryption using Ascon80pq, feeding associated data.
ASCON_API void ascon_hash_xof(uint8_t *digest, const uint8_t *data, size_t digest_len, size_t data_len)
Offline Ascon-Hash with custom digest length (eXtendable Output Function, XOF).
ASCON_API void ascon_aead_cleanup(ascon_aead_ctx_t *ctx)
Security cleanup of the AEAD context, in case the online processing is not completed to the end.
ASCON_API void ascon_hasha_update(ascon_hash_ctx_t *ctx, const uint8_t *data, size_t data_len)
Online Ascon-Hasha with fixed digest length, feeding data to hash.
ASCON_API size_t ascon_aead128_decrypt_final(ascon_aead_ctx_t *ctx, uint8_t *plaintext, bool *is_tag_valid, const uint8_t *expected_tag, size_t expected_tag_len)
Online symmetric decryption using Ascon128, finalisation and tag validation.
ASCON_API size_t ascon_aead128a_decrypt_update(ascon_aead_ctx_t *ctx, uint8_t *plaintext, const uint8_t *ciphertext, size_t ciphertext_len)
Online symmetric decryption using Ascon128a, feeding ciphertext and getting plaintext.
ASCON_API void ascon_hasha_xof_init(ascon_hash_ctx_t *ctx)
Online Ascon-Hasha with custom digest length (eXtendable Output Function, XOF), initialisation.
struct ascon_bufstate ascon_bufstate_t
Internal cipher sponge state associated with a buffer holding for less-than-rate updates.
ASCON_API void ascon_aead128a_init(ascon_aead_ctx_t *ctx, const uint8_t key[ASCON_AEAD128a_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN])
Online symmetric encryption/decryption using Ascon128a, initialisation.
ASCON_API void ascon_hash_update(ascon_hash_ctx_t *ctx, const uint8_t *data, size_t data_len)
Online Ascon-Hash with fixed digest length, feeding data to hash.
#define ASCON_AEAD80pq_KEY_LEN
Length in bytes of the secret symmetric key used for the Ascon80pq cipher.
Definition: ascon.h:119
ASCON_API bool ascon_hash_matches(const uint8_t expected_digest[ASCON_HASH_DIGEST_LEN], const uint8_t *data, size_t data_len)
Offline Ascon-Hash with fixed digest length, finalisation and digest validation of the expected one.
struct ascon_aead_ctx ascon_aead_ctx_t
Cipher context for authenticated encryption and validated decryption.
#define ASCON_AEAD_NONCE_LEN
Length in bytes of the public nonce used for authenticated encryption and decryption.
Definition: ascon.h:125
ASCON_API void ascon_hash_xof_final(ascon_hash_ctx_t *ctx, uint8_t *digest, size_t digest_len)
Online Ascon-Hash with custom digest length (eXtendable Output Function, XOF), finalisation and diges...
ASCON_API void ascon_aead80pq_encrypt(uint8_t *ciphertext, uint8_t *tag, const uint8_t key[ASCON_AEAD80pq_KEY_LEN], const uint8_t nonce[ASCON_AEAD_NONCE_LEN], const uint8_t *assoc_data, const uint8_t *plaintext, size_t assoc_data_len, size_t plaintext_len, size_t tag_len)
Offline symmetric encryption using Ascon80pq, which uses a larger key.
Cipher context for authenticated encryption and validated decryption.
Definition: ascon.h:230
uint64_t k2
Copy of the secret key, to be used in the final step, third part, used only in the Ascon80pq cipher.
Definition: ascon.h:242
uint64_t k0
Copy of the secret key, to be used in the final step, first part.
Definition: ascon.h:235
uint64_t k1
Copy of the secret key, to be used in the final step, second part.
Definition: ascon.h:238
ascon_bufstate_t bufstate
Cipher buffered sponge state.
Definition: ascon.h:232
Internal cipher sponge state associated with a buffer holding for less-than-rate updates.
Definition: ascon.h:190
uint8_t buffer[ASCON_DOUBLE_RATE]
Buffer caching the less-than-rate long input between update calls.
Definition: ascon.h:195
uint8_t buffer_len
Currently used bytes of the buffer.
Definition: ascon.h:198
ascon_sponge_t sponge
Cipher sponge state.
Definition: ascon.h:192
uint8_t pad[6]
Unused padding to the next uint64_t (sponge.x0 or ctx.k0) to avoid errors when compiling with -Wpaddi...
Definition: ascon.h:217
uint8_t flow_state
State of the order of Init-Update-Final function calls, checked to know when to finalise the associat...
Definition: ascon.h:213
Internal cipher sponge state (320 bits).
Definition: ascon.h:172
uint64_t x2
Sponge's third field.
Definition: ascon.h:178
uint64_t x3
Sponge's fourth field.
Definition: ascon.h:180
uint64_t x1
Sponge's second field.
Definition: ascon.h:176
uint64_t x0
Sponge's first field.
Definition: ascon.h:174
uint64_t x4
Sponge's fifth field.
Definition: ascon.h:182