mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-17 19:00:58 +00:00
refactor(crypto,legacy): extend parameters of init_rfc6979 by curve
This commit is contained in:
parent
db0da196a8
commit
ea5886026f
@ -687,7 +687,7 @@ int ecdsa_sign_digest(const ecdsa_curve *curve, const uint8_t *priv_key,
|
||||
|
||||
#if USE_RFC6979
|
||||
rfc6979_state rng = {0};
|
||||
init_rfc6979(priv_key, digest, &rng);
|
||||
init_rfc6979(priv_key, digest, curve, &rng);
|
||||
#endif
|
||||
|
||||
bn_read_be(digest, &z);
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "memzero.h"
|
||||
|
||||
void init_rfc6979(const uint8_t *priv_key, const uint8_t *hash,
|
||||
rfc6979_state *state) {
|
||||
const ecdsa_curve *curve, rfc6979_state *state) {
|
||||
hmac_drbg_init(state, priv_key, 32, hash, 32);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
typedef HMAC_DRBG_CTX rfc6979_state;
|
||||
|
||||
void init_rfc6979(const uint8_t *priv_key, const uint8_t *hash,
|
||||
rfc6979_state *rng);
|
||||
const ecdsa_curve *curve, rfc6979_state *rng);
|
||||
void generate_rfc6979(uint8_t rnd[32], rfc6979_state *rng);
|
||||
void generate_k_rfc6979(bignum256 *k, rfc6979_state *rng);
|
||||
|
||||
|
@ -3757,7 +3757,7 @@ END_TEST
|
||||
#define test_deterministic(KEY, MSG, K) \
|
||||
do { \
|
||||
sha256_Raw((uint8_t *)MSG, strlen(MSG), buf); \
|
||||
init_rfc6979(fromhex(KEY), buf, &rng); \
|
||||
init_rfc6979(fromhex(KEY), buf, NULL, &rng); \
|
||||
generate_k_rfc6979(&k, &rng); \
|
||||
bn_write_be(&k, buf); \
|
||||
ck_assert_mem_eq(buf, fromhex(K), 32); \
|
||||
@ -6790,7 +6790,7 @@ START_TEST(test_ed25519_cosi) {
|
||||
"26c76712d89d906e6672dafa614c42e5cb1caac8c6568e4d2493087db51f0d36"),
|
||||
fromhex(
|
||||
"26659c1cf7321c178c07437150639ff0c5b7679c7ea195253ed9abda2e081a37"),
|
||||
&rng);
|
||||
NULL, &rng);
|
||||
|
||||
for (int N = 1; N < 11; N++) {
|
||||
ed25519_public_key pk;
|
||||
|
@ -259,7 +259,7 @@ void fsm_msgCosiCommit(const CosiCommit *msg) {
|
||||
uint8_t nonce[32];
|
||||
sha256_Raw(msg->data.bytes, msg->data.size, nonce);
|
||||
rfc6979_state rng;
|
||||
init_rfc6979(node->private_key, nonce, &rng);
|
||||
init_rfc6979(node->private_key, nonce, NULL, &rng);
|
||||
generate_rfc6979(nonce, &rng);
|
||||
|
||||
resp->has_commitment = true;
|
||||
@ -302,7 +302,7 @@ void fsm_msgCosiSign(const CosiSign *msg) {
|
||||
uint8_t nonce[32];
|
||||
sha256_Raw(msg->data.bytes, msg->data.size, nonce);
|
||||
rfc6979_state rng;
|
||||
init_rfc6979(node->private_key, nonce, &rng);
|
||||
init_rfc6979(node->private_key, nonce, NULL, &rng);
|
||||
generate_rfc6979(nonce, &rng);
|
||||
|
||||
resp->signature.size = 32;
|
||||
|
Loading…
Reference in New Issue
Block a user