Commit 24c9769b authored by Niels Möller's avatar Niels Möller

ecc_ecdsa_sign: Use mul_g and h_to_a function pointers.

Implies (obscure) support for curve25519. Also added a testcase for this.
parent 0276b45a
2014-08-28 Niels Möller <nisse@lysator.liu.se>
* testsuite/ecdsa-sign-test.c (test_main): Added test for the
obscure case of ecdsa using curve25519.
* ecc-ecdsa-sign.c (ecc_ecdsa_sign): Use mul_g and h_to_a function
pointers. Implies (obscure) support for curve25519.
* ecc-25519.c (ecc_25519_modq): Access q via the ecc struct.
* ecc-eh-to-a.c (ecc_eh_to_a): Analogous change as for ecc_j_to_a.
......
/* ecc-ecdsa-sign.c
Copyright (C) 2013 Niels Möller
Copyright (C) 2013, 2014 Niels Möller
This file is part of GNU Nettle.
......@@ -46,7 +46,8 @@
mp_size_t
ecc_ecdsa_sign_itch (const struct ecc_curve *ecc)
{
/* Needs 3*ecc->size + scratch for ecc_mul_g. */
/* Needs 3*ecc->size + scratch for ecc->mul_g. Currently same for
ecc_mul_g and ecc_mul_g_eh. */
return ECC_ECDSA_SIGN_ITCH (ecc->size);
}
......@@ -77,9 +78,9 @@ ecc_ecdsa_sign (const struct ecc_curve *ecc,
4. s2 <-- (h + z*s1)/k mod q.
*/
ecc_mul_g (ecc, P, kp, P + 3*ecc->size);
ecc->mul_g (ecc, P, kp, P + 3*ecc->size);
/* x coordinate only, modulo q */
ecc_j_to_a (ecc, 2, rp, P, P + 3*ecc->size);
ecc->h_to_a (ecc, 2, rp, P, P + 3*ecc->size);
/* Invert k, uses 5 * ecc->size including scratch */
mpn_copyi (hp, kp, ecc->size);
......
......@@ -156,5 +156,18 @@ test_main (void)
"97536710 1F67D1CF 9BCCBF2F 3D239534"
"FA509E70 AAC851AE 01AAC68D 62F86647"
"2660"); /* s */
}
/* Non-standard ecdsa using curve25519. Not interop-tested with
anything else. */
test_ecdsa (&nettle_curve25519,
"1db511101b8fd16f e0212c5679ef53f3"
"323bde77f9efa442 617314d576d1dbcb", /* z */
"aa2fa8facfdc3a99 ec466d41a2c9211c"
"e62e1706f54037ff 8486e26153b0fa79", /* k */
SHEX("e99df2a098c3c590 ea1e1db6d9547339"
"ae760d5331496119 5d967fd881e3b0f5"), /* h */
" 62cbc248a549765 3641d1cbedda2733"
"a7357821dca43727 d8081448d608030d", /* r */
" 14726f472f44f84 63fe82c2712231cd"
"937f2aecdcfe9c39 e2ab0d68c390ccf4"); /* s */
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment