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
178WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_ecdsa_sign_hash_256(unsigned int derivation_mode,
179 cx_curve_t curve,
180 const uint32_t *path,
181 size_t path_len,
182 uint32_t sign_mode,
183 cx_md_t hashID,
184 const uint8_t *hash,
185 size_t hash_len,
186 uint8_t *sig,
187 size_t *sig_len,
188 uint32_t *info,
189 unsigned char *seed,
190 size_t seed_len);
191
227WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_ecdsa_sign_hash_256(cx_curve_t curve,
228 const uint32_t *path,
229 size_t path_len,
230 uint32_t sign_mode,
231 cx_md_t hashID,
232 const uint8_t *hash,
233 size_t hash_len,
234 uint8_t *sig,
235 size_t *sig_len,
236 uint32_t *info)
237{
239 curve,
240 path,
241 path_len,
242 sign_mode,
243 hashID,
244 hash,
245 hash_len,
246 sig,
247 sig_len,
248 info,
249 NULL,
250 0);
251}
252
291WARN_UNUSED_RESULT cx_err_t
292bip32_derive_with_seed_ecdsa_sign_rs_hash_256(unsigned int derivation_mode,
293 cx_curve_t curve,
294 const uint32_t *path,
295 size_t path_len,
296 uint32_t sign_mode,
297 cx_md_t hashID,
298 const uint8_t *hash,
299 size_t hash_len,
300 uint8_t sig_r[static 32],
301 uint8_t sig_s[static 32],
302 uint32_t *info,
303 unsigned char *seed,
304 size_t seed_len);
305
340WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_ecdsa_sign_rs_hash_256(
341 cx_curve_t curve,
342 const uint32_t *path,
343 size_t path_len,
344 uint32_t sign_mode,
345 cx_md_t hashID,
346 const uint8_t *hash,
347 size_t hash_len,
348 uint8_t sig_r[static 32],
349 uint8_t sig_s[static 32],
350 uint32_t *info)
351{
353 curve,
354 path,
355 path_len,
356 sign_mode,
357 hashID,
358 hash,
359 hash_len,
360 sig_r,
361 sig_s,
362 info,
363 NULL,
364 0);
365}
366
400WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_eddsa_sign_hash_256(unsigned int derivation_mode,
401 cx_curve_t curve,
402 const uint32_t *path,
403 size_t path_len,
404 cx_md_t hashID,
405 const uint8_t *hash,
406 size_t hash_len,
407 uint8_t *sig,
408 size_t *sig_len,
409 unsigned char *seed,
410 size_t seed_len);
411
438WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_eddsa_sign_hash_256(cx_curve_t curve,
439 const uint32_t *path,
440 size_t path_len,
441 cx_md_t hashID,
442 const uint8_t *hash,
443 size_t hash_len,
444 uint8_t *sig,
445 size_t *sig_len)
446{
448 HDW_NORMAL, curve, path, path_len, hashID, hash, hash_len, sig, sig_len, NULL, 0);
449}
static WARN_UNUSED_RESULT cx_err_t bip32_derive_ecdsa_sign_rs_hash_256(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)
Sign a hash with ecdsa using the device seed derived from the specified bip32 path,...
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.
static WARN_UNUSED_RESULT cx_err_t bip32_derive_init_privkey_256(cx_curve_t curve, const uint32_t *path, size_t path_len, cx_ecfp_256_private_key_t *privkey, uint8_t *chain_code)
Gets the private key from the device seed using the specified bip32 path.
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.
static WARN_UNUSED_RESULT cx_err_t bip32_derive_ecdsa_sign_hash_256(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)
Sign a hash with ecdsa using the device seed derived from the specified bip32 path....
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.
static WARN_UNUSED_RESULT cx_err_t bip32_derive_get_pubkey_256(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)
Gets the public key from the device seed using the specified bip32 path.
static WARN_UNUSED_RESULT cx_err_t bip32_derive_eddsa_sign_hash_256(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)
Sign a hash with eddsa using the device seed derived from the specified bip32 path.