Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
internal-ascon-m2.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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 LW_INTERNAL_ASCON_M2_H
24 #define LW_INTERNAL_ASCON_M2_H
25 
26 #include "internal-ascon.h"
27 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
44 typedef struct
45 {
50 
54 typedef union
55 {
56  uint64_t S[6];
57  uint32_t W[12];
60 
70  (ascon_masked_state_x2_t *state, uint8_t first_round);
71 
80  (ascon_masked_key_x2_t *mk, uint64_t iv, const unsigned char *k);
81 
90  (ascon_masked_key_x2_t *mk, uint32_t iv, const unsigned char *k);
91 
103  const unsigned char *npub, int is_160_bit);
104 
115  unsigned char tag[16]);
116 
127  unsigned char tag[16]);
128 
139  unsigned char tag[16]);
140 
154  (ascon_masked_state_x2_t *state, const unsigned char *data,
155  size_t len, uint8_t first_round);
156 
170  (ascon_masked_state_x2_t *state, const unsigned char *data,
171  size_t len, uint8_t first_round);
172 
184  (ascon_masked_state_x2_t *state, unsigned char *dest,
185  const unsigned char *src, size_t len, uint8_t first_round);
186 
198  (ascon_masked_state_x2_t *state, unsigned char *dest,
199  const unsigned char *src, size_t len, uint8_t first_round);
200 
212  (ascon_masked_state_x2_t *state, unsigned char *dest,
213  const unsigned char *src, size_t len, uint8_t first_round);
214 
226  (ascon_masked_state_x2_t *state, unsigned char *dest,
227  const unsigned char *src, size_t len, uint8_t first_round);
228 
235 #if ASCON_SLICED
236 #define ascon_masked_separator_x2(state) ((state)->a.W[8] ^= 0x01)
237 #else
238 #define ascon_masked_separator_x2(state) ((state)->a.S[4] ^= 0x01)
239 #endif
240 
247 
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #endif
void ascon_masked_encrypt_16_x2(ascon_masked_state_x2_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round)
Encrypts a block of data with a 2-share masked ASCON state and a 16-byte block rate.
Definition: internal-ascon-m2.c:1231
Structure of the internal state of the ASCON permutation.
Definition: internal-ascon.h:67
ascon_state_t b
Definition: internal-ascon-m2.h:47
void ascon_permute_masked_x2(ascon_masked_state_x2_t *state, uint8_t first_round)
Permutes the 2-share version of the masked ASCON state.
Definition: internal-ascon-m2.c:600
ascon_state_t a
Definition: internal-ascon-m2.h:46
Structure of an ASCON key that has been masked with 2 shares.
Definition: internal-ascon-m2.h:54
void ascon_masked_init_key_x2(ascon_masked_state_x2_t *state, const ascon_masked_key_x2_t *mk, const unsigned char *npub, int is_160_bit)
Initializes the 2-share version of a masked ASCON state with a 128-bit key and a 128-bit nonce...
Definition: internal-ascon-m2.c:821
void ascon_mask_key_160_x2(ascon_masked_key_x2_t *mk, uint32_t iv, const unsigned char *k)
Masks a 160-bit key plus a 32-bit initialization vector.
Definition: internal-ascon-m2.c:808
void ascon_masked_absorb_16_x2(ascon_masked_state_x2_t *state, const unsigned char *data, size_t len, uint8_t first_round)
Absorbs data into a 2-share masked ASCON state with a 16-byte block rate.
Definition: internal-ascon-m2.c:1059
void ascon_masked_key_refresh_x2(ascon_masked_key_x2_t *mk)
Refreshes the randomness in aa 2-share masked ASCON key.
Definition: internal-ascon-m2.c:1424
void ascon_masked_decrypt_16_x2(ascon_masked_state_x2_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round)
Decrypts a block of data with a 2-share masked ASCON state and a 16-byte block rate.
Definition: internal-ascon-m2.c:1322
void ascon_masked_decrypt_8_x2(ascon_masked_state_x2_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round)
Decrypts a block of data with a 2-share masked ASCON state and an 8-byte block rate.
Definition: internal-ascon-m2.c:1175
void ascon_masked_finalize_128_x2(ascon_masked_state_x2_t *state, const ascon_masked_key_x2_t *mk, unsigned char tag[16])
Finalizes the 2-share version of a masked ASCON state and computes the final authentication tag for A...
Definition: internal-ascon-m2.c:867
void ascon_masked_encrypt_8_x2(ascon_masked_state_x2_t *state, unsigned char *dest, const unsigned char *src, size_t len, uint8_t first_round)
Encrypts a block of data with a 2-share masked ASCON state and an 8-byte block rate.
Definition: internal-ascon-m2.c:1116
void ascon_masked_finalize_80pq_x2(ascon_masked_state_x2_t *state, const ascon_masked_key_x2_t *mk, unsigned char tag[16])
Finalizes the 2-share version of a masked ASCON state and computes the final authentication tag for A...
Definition: internal-ascon-m2.c:969
Structure of the internal state of the masked ASCON permutation with two shares.
Definition: internal-ascon-m2.h:44
void ascon_masked_finalize_128a_x2(ascon_masked_state_x2_t *state, const ascon_masked_key_x2_t *mk, unsigned char tag[16])
Finalizes the 2-share version of a masked ASCON state and computes the final authentication tag for A...
Definition: internal-ascon-m2.c:918
void ascon_masked_refresh_x2(ascon_masked_state_x2_t *state)
Refreshes the randomness in a 2-share masked ASCON state.
Definition: internal-ascon-m2.c:1413
void ascon_mask_key_128_x2(ascon_masked_key_x2_t *mk, uint64_t iv, const unsigned char *k)
Masks a 128-bit key plus a 64-bit initialization vector.
Definition: internal-ascon-m2.c:795
void ascon_masked_absorb_8_x2(ascon_masked_state_x2_t *state, const unsigned char *data, size_t len, uint8_t first_round)
Absorbs data into a 2-share masked ASCON state with an 8-byte block rate.
Definition: internal-ascon-m2.c:1020
Internal implementation of the ASCON permutation.