32 #if ASCON_MASKED_MAX_SHARES < 4
36 #if ASCON_MASKED_KEY_SHARES == 2
41 #elif ASCON_MASKED_KEY_SHARES == 3
64 #if ASCON_MASKED_KEY_SHARES == 2
71 #elif ASCON_MASKED_KEY_SHARES == 3
99 #if ASCON_MASKED_KEY_SHARES == 2
104 #elif ASCON_MASKED_KEY_SHARES == 3
120 static unsigned char const zeroes[4] = {0, 0, 0, 0};
122 #if ASCON_MASKED_MAX_SHARES < 4
126 #if ASCON_MASKED_KEY_SHARES == 2
140 #elif ASCON_MASKED_KEY_SHARES == 3
180 #if ASCON_MASKED_KEY_SHARES == 2
181 for (index = 0; index < 6; ++index) {
186 #elif ASCON_MASKED_KEY_SHARES == 3
187 for (index = 0; index < 6; ++index) {
193 for (index = 0; index < 6; ++index) {
212 #if ASCON_MASKED_KEY_SHARES == 2
219 #elif ASCON_MASKED_KEY_SHARES == 3
void ascon_masked_key_128_free(ascon_masked_key_128_t *masked)
Frees a masked 128-bit key and destroys all sensitive material.
void ascon_masked_key_160_free(ascon_masked_key_160_t *masked)
Frees a masked 160-bit key and destroys all sensitive material.
void ascon_masked_key_128_init(ascon_masked_key_128_t *masked, const unsigned char *key)
Initializes a masked 128-bit key for ASCON.
void ascon_masked_key_128_randomize_with_trng(ascon_masked_key_128_t *masked, ascon_trng_state_t *trng)
Randomizes a masked 128-bit key by mixing in fresh random material from a caller-supplied TRNG.
void ascon_masked_key_160_randomize_with_trng(ascon_masked_key_160_t *masked, ascon_trng_state_t *trng)
Randomizes a masked 160-bit key by mixing in fresh random material from a caller-supplied TRNG.
void ascon_masked_key_160_extract(const ascon_masked_key_160_t *masked, unsigned char *key)
Extracts the plain version of a 160-bit key from its masked version.
void ascon_masked_key_128_extract(const ascon_masked_key_128_t *masked, unsigned char *key)
Extracts the plain version of a 128-bit key from its masked version.
void ascon_masked_key_160_randomize(ascon_masked_key_160_t *masked)
Randomizes a masked 160-bit key by mixing in fresh random material.
void ascon_masked_key_128_randomize(ascon_masked_key_128_t *masked)
Randomizes a masked 128-bit key by mixing in fresh random material.
void ascon_masked_key_160_init(ascon_masked_key_160_t *masked, const unsigned char *key)
Initializes a masked 160-bit key for ASCON.
void ascon_masked_word_x4_load_32(ascon_masked_word_t *word, const uint8_t *data1, const uint8_t *data2, ascon_trng_state_t *trng)
Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x4 masked wor...
void ascon_masked_word_x2_store_partial(uint8_t *data, unsigned size, const ascon_masked_word_t *word)
Unmasks and stores the contents of a x2 masked word structure to a partial buffer.
void ascon_masked_word_x2_load(ascon_masked_word_t *word, const uint8_t *data, ascon_trng_state_t *trng)
Loads a 64-bit big endian value from buffer, masks it, and writes it to a x2 masked word structure.
void ascon_masked_word_x2_store(uint8_t *data, const ascon_masked_word_t *word)
Unmasks and stores the contents of a x2 masked word structure.
void ascon_masked_word_x3_store_partial(uint8_t *data, unsigned size, const ascon_masked_word_t *word)
Unmasks and stores the contents of a x3 masked word structure to a partial buffer.
void ascon_masked_word_x4_load(ascon_masked_word_t *word, const uint8_t *data, ascon_trng_state_t *trng)
Loads a 64-bit big endian value from buffer, masks it, and writes it to a x4 masked word structure.
void ascon_masked_word_x3_load(ascon_masked_word_t *word, const uint8_t *data, ascon_trng_state_t *trng)
Loads a 64-bit big endian value from buffer, masks it, and writes it to a x3 masked word structure.
void ascon_masked_word_x3_load_32(ascon_masked_word_t *word, const uint8_t *data1, const uint8_t *data2, ascon_trng_state_t *trng)
Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x3 masked wor...
void ascon_masked_word_x4_store_partial(uint8_t *data, unsigned size, const ascon_masked_word_t *word)
Unmasks and stores the contents of a x4 masked word structure to a partial buffer.
void ascon_masked_word_x3_randomize(ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
Randomizes a x3 masked word by incorporating fresh randomness.
void ascon_masked_word_x2_load_32(ascon_masked_word_t *word, const uint8_t *data1, const uint8_t *data2, ascon_trng_state_t *trng)
Loads two 32-bit big endian values from buffers, masks them, and writes the result to a x2 masked wor...
void ascon_masked_word_x4_randomize(ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
Randomizes a x4 masked word by incorporating fresh randomness.
void ascon_masked_word_x4_store(uint8_t *data, const ascon_masked_word_t *word)
Unmasks and stores the contents of a x4 masked word structure.
void ascon_masked_word_x3_store(uint8_t *data, const ascon_masked_word_t *word)
Unmasks and stores the contents of a x3 masked word structure.
void ascon_masked_word_x2_randomize(ascon_masked_word_t *dest, const ascon_masked_word_t *src, ascon_trng_state_t *trng)
Randomizes a x2 masked word by incorporating fresh randomness.
Utility functions for operating on masked words.
int ascon_trng_init(ascon_trng_state_t *state)
Initializes the random number source for generating a sequence of masking material at high speed.
void ascon_trng_free(ascon_trng_state_t *state)
Frees the random number source and destroys any sensitive material.
Definitions to support masked ASCON ciphers.
128-bit key that has been masked to hide its value when the code is operating on it.
ascon_masked_key_word_t k[2]
160-bit key that has been masked to hide its value when the code is operating on it.
ascon_masked_key_word_t k[6]
State of the random number source.
Masked 64-bit word with up to ASCON_MASKED_MAX_SHARES shares.
System utilities of use to applications that use ASCON.
void ascon_clean(void *buf, unsigned size)
Cleans a buffer that contains sensitive material.