Embedded SDK
Embedded SDK
lcx_chacha.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 
33 #ifndef LCX_CHACHA_H
34 #define LCX_CHACHA_H
35 
36 #if defined(HAVE_CHACHA)
37 
38 #include "ox.h"
39 #include <stddef.h>
40 
44 typedef struct {
45  uint32_t nrounds;
46  uint32_t state[16];
47  uint32_t block[16];
48  uint32_t pos;
49 } cx_chacha_context_t;
50 
65 void cx_chacha_init(cx_chacha_context_t *ctx, uint32_t nrounds);
66 
83 WARN_UNUSED_RESULT cx_err_t cx_chacha_set_key(cx_chacha_context_t *ctx,
84  const uint8_t *key,
85  size_t key_len);
86 
107 WARN_UNUSED_RESULT cx_err_t cx_chacha_start(cx_chacha_context_t *ctx,
108  const uint8_t *iv,
109  size_t iv_len);
110 
130 WARN_UNUSED_RESULT cx_err_t cx_chacha_update(cx_chacha_context_t *ctx,
131  const uint8_t *input,
132  uint8_t *output,
133  size_t len);
134 
158 WARN_UNUSED_RESULT cx_err_t cx_chacha_cipher(uint32_t nrounds,
159  const uint8_t *key,
160  size_t key_len,
161  const uint8_t *iv,
162  size_t iv_len,
163  const uint8_t *input,
164  uint8_t *output,
165  size_t len);
166 
167 #endif // HAVE_CHACHA
168 
169 #endif // LCX_CHACHA_H
unsigned char uint8_t
Definition: usbd_conf.h:53