Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
crypto_helpers.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h> // uint*_t
4
5#include "os.h"
6#include "cx.h"
7
32WARN_UNUSED_RESULT cx_err_t
33bip32_derive_with_seed_init_privkey_256(unsigned int derivation_mode,
34 cx_curve_t curve,
35 const uint32_t *path,
36 size_t path_len,
37 cx_ecfp_256_private_key_t *privkey,
38 uint8_t *chain_code,
39 unsigned char *seed,
40 size_t seed_len);
41
60WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_init_privkey_256(
61 cx_curve_t curve,
62 const uint32_t *path,
63 size_t path_len,
64 cx_ecfp_256_private_key_t *privkey,
65 uint8_t *chain_code)
66{
68 HDW_NORMAL, curve, path, path_len, privkey, chain_code, NULL, 0);
69}
70
97WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_get_pubkey_256(unsigned int derivation_mode,
98 cx_curve_t curve,
99 const uint32_t *path,
100 size_t path_len,
101 uint8_t raw_pubkey[static 65],
102 uint8_t *chain_code,
103 cx_md_t hashID,
104 unsigned char *seed,
105 size_t seed_len);
106
127WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_get_pubkey_256(cx_curve_t curve,
128 const uint32_t *path,
129 size_t path_len,
130 uint8_t raw_pubkey[static 65],
131 uint8_t *chain_code,
132 cx_md_t hashID)
133{
135 HDW_NORMAL, curve, path, path_len, raw_pubkey, chain_code, hashID, NULL, 0);
136}
137
176WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_ecdsa_sign_hash_256(unsigned int derivation_mode,
177 cx_curve_t curve,
178 const uint32_t *path,
179 size_t path_len,
180 uint32_t sign_mode,
181 cx_md_t hashID,
182 const uint8_t *hash,
183 size_t hash_len,
184 uint8_t *sig,
185 size_t *sig_len,
186 uint32_t *info,
187 unsigned char *seed,
188 size_t seed_len);
189
223WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_ecdsa_sign_hash_256(cx_curve_t curve,
224 const uint32_t *path,
225 size_t path_len,
226 uint32_t sign_mode,
227 cx_md_t hashID,
228 const uint8_t *hash,
229 size_t hash_len,
230 uint8_t *sig,
231 size_t *sig_len,
232 uint32_t *info)
233{
235 curve,
236 path,
237 path_len,
238 sign_mode,
239 hashID,
240 hash,
241 hash_len,
242 sig,
243 sig_len,
244 info,
245 NULL,
246 0);
247}
248
285WARN_UNUSED_RESULT cx_err_t
286bip32_derive_with_seed_ecdsa_sign_rs_hash_256(unsigned int derivation_mode,
287 cx_curve_t curve,
288 const uint32_t *path,
289 size_t path_len,
290 uint32_t sign_mode,
291 cx_md_t hashID,
292 const uint8_t *hash,
293 size_t hash_len,
294 uint8_t sig_r[static 32],
295 uint8_t sig_s[static 32],
296 uint32_t *info,
297 unsigned char *seed,
298 size_t seed_len);
299
329WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_ecdsa_sign_rs_hash_256(
330 cx_curve_t curve,
331 const uint32_t *path,
332 size_t path_len,
333 uint32_t sign_mode,
334 cx_md_t hashID,
335 const uint8_t *hash,
336 size_t hash_len,
337 uint8_t sig_r[static 32],
338 uint8_t sig_s[static 32],
339 uint32_t *info)
340{
342 curve,
343 path,
344 path_len,
345 sign_mode,
346 hashID,
347 hash,
348 hash_len,
349 sig_r,
350 sig_s,
351 info,
352 NULL,
353 0);
354}
355
389WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_eddsa_sign_hash_256(unsigned int derivation_mode,
390 cx_curve_t curve,
391 const uint32_t *path,
392 size_t path_len,
393 cx_md_t hashID,
394 const uint8_t *hash,
395 size_t hash_len,
396 uint8_t *sig,
397 size_t *sig_len,
398 unsigned char *seed,
399 size_t seed_len);
400
427WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_eddsa_sign_hash_256(cx_curve_t curve,
428 const uint32_t *path,
429 size_t path_len,
430 cx_md_t hashID,
431 const uint8_t *hash,
432 size_t hash_len,
433 uint8_t *sig,
434 size_t *sig_len)
435{
437 HDW_NORMAL, curve, path, path_len, hashID, hash, hash_len, sig, sig_len, NULL, 0);
438}
WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_ecdsa_sign_hash_256(unsigned int derivation_mode, cx_curve_t curve, const uint32_t *path, size_t path_len, uint32_t sign_mode, cx_md_t hashID, const uint8_t *hash, size_t hash_len, uint8_t *sig, size_t *sig_len, uint32_t *info, unsigned char *seed, size_t seed_len)
Sign a hash with ecdsa using the device seed derived from the specified bip32 path and seed key.
WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_init_privkey_256(unsigned int derivation_mode, cx_curve_t curve, const uint32_t *path, size_t path_len, cx_ecfp_256_private_key_t *privkey, uint8_t *chain_code, unsigned char *seed, size_t seed_len)
Gets the private key from the device seed using the specified bip32 path and seed key.
WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_eddsa_sign_hash_256(unsigned int derivation_mode, cx_curve_t curve, const uint32_t *path, size_t path_len, cx_md_t hashID, const uint8_t *hash, size_t hash_len, uint8_t *sig, size_t *sig_len, unsigned char *seed, size_t seed_len)
Sign a hash with eddsa using the device seed derived from the specified bip32 path and seed key.
WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_ecdsa_sign_rs_hash_256(unsigned int derivation_mode, cx_curve_t curve, const uint32_t *path, size_t path_len, uint32_t sign_mode, cx_md_t hashID, const uint8_t *hash, size_t hash_len, uint8_t sig_r[static 32], uint8_t sig_s[static 32], uint32_t *info, unsigned char *seed, size_t seed_len)
Sign a hash with ecdsa using the device seed derived from the specified bip32 path and seed key.
WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_get_pubkey_256(unsigned int derivation_mode, cx_curve_t curve, const uint32_t *path, size_t path_len, uint8_t raw_pubkey[static 65], uint8_t *chain_code, cx_md_t hashID, unsigned char *seed, size_t seed_len)
Gets the public key from the device seed using the specified bip32 path and seed key.
unsigned char uint8_t
Definition usbd_conf.h:53