1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 15:28:10 +00:00

test_check: Add MARK_SECRET_DATA to test_ed25519{,_cosi}

This commit is contained in:
Saleem Rashid 2017-06-03 16:07:30 +01:00 committed by Pavol Rusnak
parent edb31b89a8
commit 9da2e2440a

View File

@ -2688,13 +2688,21 @@ START_TEST(test_ed25519) {
ed25519_signature sig; ed25519_signature sig;
while (*ssk && *spk && *ssig) { while (*ssk && *spk && *ssig) {
memcpy(sk, fromhex(*ssk), 32); memcpy(sk, fromhex(*ssk), 32);
MARK_SECRET_DATA(sk, sizeof(sk));
ed25519_publickey(sk, pk); ed25519_publickey(sk, pk);
UNMARK_SECRET_DATA(pk, sizeof(pk));
ck_assert_mem_eq(pk, fromhex(*spk), 32); ck_assert_mem_eq(pk, fromhex(*spk), 32);
ed25519_sign(pk, 32, sk, pk, sig); ed25519_sign(pk, 32, sk, pk, sig);
UNMARK_SECRET_DATA(sig, sizeof(sig));
ck_assert_mem_eq(sig, fromhex(*ssig), 64); ck_assert_mem_eq(sig, fromhex(*ssig), 64);
ssk += 3; ssk += 3;
spk += 3; spk += 3;
ssig += 3; ssig += 3;
UNMARK_SECRET_DATA(sk, sizeof(sk));
} }
} }
END_TEST END_TEST
@ -2735,10 +2743,13 @@ START_TEST(test_ed25519_cosi) {
res = ed25519_cosi_combine_publickeys(R, Rs, N); res = ed25519_cosi_combine_publickeys(R, Rs, N);
ck_assert_int_eq(res, 0); ck_assert_int_eq(res, 0);
MARK_SECRET_DATA(keys, sizeof(keys));
/* phase 2: sign and combine signatures */ /* phase 2: sign and combine signatures */
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
ed25519_cosi_sign(msg, sizeof(msg), keys[j], nonces[j], R, pk, sigs[j]); ed25519_cosi_sign(msg, sizeof(msg), keys[j], nonces[j], R, pk, sigs[j]);
} }
UNMARK_SECRET_DATA(keys, sizeof(keys));
UNMARK_SECRET_DATA(sigs, sizeof(sigs));
ed25519_cosi_combine_signatures(sig, R, sigs, N); ed25519_cosi_combine_signatures(sig, R, sigs, N);