Lightweight Cryptography Primitives
 All Data Structures Files Functions Variables Typedefs Macros Pages
internal-ghash.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_GHASH_H
24 #define LW_INTERNAL_GHASH_H
25 
37 #include "internal-util.h"
38 #include <stddef.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
49 #if defined(__AVR__)
50 #define GHASH_SHOUP_4BIT 0
51 #else
52 #define GHASH_SHOUP_4BIT 1
53 #endif
54 
58 typedef struct
59 {
60  uint64_t c[2];
63 
67 typedef struct
68 {
69 #if GHASH_SHOUP_4BIT
70  gf128_value_t H[16];
71 #else
72  gf128_value_t H;
73 #endif
74  uint8_t Y[16];
75  uint32_t posn;
78 
85 void ghash_init(ghash_state_t *state, const unsigned char *key);
86 
94 void ghash_update(ghash_state_t *state, const unsigned char *data, size_t size);
95 
101 void ghash_pad(ghash_state_t *state);
102 
109 void ghash_finalize(ghash_state_t *state, unsigned char *hash);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif
void ghash_update(ghash_state_t *state, const unsigned char *data, size_t size)
Updates a GHASH state with more data.
Definition: internal-ghash.c:235
void ghash_pad(ghash_state_t *state)
Pads a GHASH state with zeroes to the next block boundary.
Definition: internal-ghash.c:264
State information for GHASH.
Definition: internal-ghash.h:67
void ghash_finalize(ghash_state_t *state, unsigned char *hash)
Finalizes a GHASH state.
Definition: internal-ghash.c:272
uint32_t posn
Definition: internal-ghash.h:75
Representation of a value in the GF(2^128) field.
Definition: internal-ghash.h:58
void ghash_init(ghash_state_t *state, const unsigned char *key)
Initializes the GHASH state.
Definition: internal-ghash.c:176