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
335WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_ecdsa_sign_rs_hash_256(
336 cx_curve_t curve,
337 const uint32_t *path,
338 size_t path_len,
339 uint32_t sign_mode,
340 cx_md_t hashID,
341 const uint8_t *hash,
342 size_t hash_len,
343 uint8_t sig_r[static 32],
344 uint8_t sig_s[static 32],
345 uint32_t *info)
346{
348 curve,
349 path,
350 path_len,
351 sign_mode,
352 hashID,
353 hash,
354 hash_len,
355 sig_r,
356 sig_s,
357 info,
358 NULL,
359 0);
360}
361
395WARN_UNUSED_RESULT cx_err_t bip32_derive_with_seed_eddsa_sign_hash_256(unsigned int derivation_mode,
396 cx_curve_t curve,
397 const uint32_t *path,
398 size_t path_len,
399 cx_md_t hashID,
400 const uint8_t *hash,
401 size_t hash_len,
402 uint8_t *sig,
403 size_t *sig_len,
404 unsigned char *seed,
405 size_t seed_len);
406
433WARN_UNUSED_RESULT static inline cx_err_t bip32_derive_eddsa_sign_hash_256(cx_curve_t curve,
434 const uint32_t *path,
435 size_t path_len,
436 cx_md_t hashID,
437 const uint8_t *hash,
438 size_t hash_len,
439 uint8_t *sig,
440 size_t *sig_len)
441{
443 HDW_NORMAL, curve, path, path_len, hashID, hash, hash_len, sig, sig_len, NULL, 0);
444}
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.