Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
lcx_ecdsa.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
28#ifndef LCX_ECDSA_H
29#define LCX_ECDSA_H
30
31#ifdef HAVE_ECDSA
32
33#include "lcx_wrappers.h"
34#include "lcx_ecfp.h"
35
37#define cx_ecdsa_init_public_key cx_ecfp_init_public_key_no_throw
39#define cx_ecdsa_init_private_key cx_ecfp_init_private_key_no_throw
40
83WARN_UNUSED_RESULT cx_err_t cx_ecdsa_sign_no_throw(const cx_ecfp_private_key_t *pvkey,
84 uint32_t mode,
85 cx_md_t hashID,
86 const uint8_t *hash,
87 size_t hash_len,
88 uint8_t *sig,
89 size_t *sig_len,
90 uint32_t *info);
91
96DEPRECATED static inline size_t cx_ecdsa_sign(const cx_ecfp_private_key_t *pvkey,
97 uint32_t mode,
98 cx_md_t hashID,
99 const unsigned char *hash,
100 unsigned int hash_len,
101 unsigned char *sig,
102 unsigned int sig_len,
103 unsigned int *info)
104{
105 size_t sig_len_ = sig_len;
106 uint32_t info_;
107 CX_THROW(cx_ecdsa_sign_no_throw(pvkey, mode, hashID, hash, hash_len, sig, &sig_len_, &info_));
108 if (info) {
109 *info = (uint32_t) info_;
110 }
111 return sig_len_;
112}
113
155WARN_UNUSED_RESULT cx_err_t cx_ecdsa_sign_rs_no_throw(const cx_ecfp_private_key_t *key,
156 uint32_t mode,
157 cx_md_t hashID,
158 const uint8_t *hash,
159 size_t hash_len,
160 size_t rs_len,
161 uint8_t *sig_r,
162 uint8_t *sig_s,
163 uint32_t *info);
164
183WARN_UNUSED_RESULT bool cx_ecdsa_verify_no_throw(const cx_ecfp_public_key_t *pukey,
184 const uint8_t *hash,
185 size_t hash_len,
186 const uint8_t *sig,
187 size_t sig_len);
188
193DEPRECATED static inline bool cx_ecdsa_verify(const cx_ecfp_public_key_t *pukey,
194 int mode,
195 cx_md_t hashID,
196 const unsigned char *hash,
197 unsigned int hash_len,
198 const unsigned char *sig,
199 unsigned int sig_len)
200{
201 UNUSED(mode);
202 UNUSED(hashID);
203 return cx_ecdsa_verify_no_throw(pukey, hash, hash_len, sig, sig_len);
204}
205
206#endif // HAVE_ECDSA
207
208#endif // LCX_ECDSA_H
Key pair generation based on elliptic curves.
#define CX_THROW(call)
unsigned char uint8_t
Definition usbd_conf.h:53