Embedded SDK
Embedded SDK
lcx_groestl.h
Go to the documentation of this file.
1 
2 /*******************************************************************************
3  * Ledger Nano S - Secure firmware
4  * (c) 2022 Ledger
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  ********************************************************************************/
18 
26 #ifdef HAVE_GROESTL
27 
28 #ifndef LCX_GROESTL_H
29 #define LCX_GROESTL_H
30 
31 #include <stdint.h>
32 
33 #include "lcx_wrappers.h"
34 
35 #define ROWS 8
36 #define COLS1024 16
37 #define SIZE1024 (ROWS * COLS1024)
38 typedef unsigned char BitSequence;
40 struct hashState_s {
41  uint8_t chaining[ROWS][COLS1024];
42  uint64_t block_counter;
43  unsigned int hashlen;
44  BitSequence buffer[SIZE1024];
45  unsigned int buf_ptr;
46  unsigned int columns;
47  unsigned int rounds;
48  unsigned int statesize;
49 };
51 typedef struct hashState_s hashState;
52 
56 struct cx_groestl_s {
57  unsigned int output_size;
58  struct hashState_s ctx;
59 };
61 typedef struct cx_groestl_s cx_groestl_t;
62 
63 size_t cx_groestl_get_output_size(const cx_groestl_t *ctx);
64 
76 WARN_UNUSED_RESULT cx_err_t cx_groestl_init_no_throw(cx_groestl_t *hash, size_t size);
77 
82 DEPRECATED static inline void cx_groestl_init(cx_groestl_t *hash, unsigned int size)
83 {
84  CX_THROW(cx_groestl_init_no_throw(hash, size));
85 }
86 
114 WARN_UNUSED_RESULT cx_err_t cx_groestl(cx_groestl_t *hash,
115  uint32_t mode,
116  const uint8_t *in,
117  size_t len,
118  uint8_t *out,
119  size_t out_len);
120 
137 WARN_UNUSED_RESULT cx_err_t cx_groestl_update(cx_groestl_t *ctx, const uint8_t *data, size_t len);
138 
152 // No need to add WARN_UNUSED_RESULT to cx_groestl_final(), it always returns CX_OK
153 cx_err_t cx_groestl_final(cx_groestl_t *ctx, uint8_t *digest);
154 
155 #endif
156 
157 #endif // HAVE_GROESTL
#define CX_THROW(call)
Definition: lcx_wrappers.h:15
unsigned char uint8_t
Definition: usbd_conf.h:53