2015-03-19 Niels Möller <nisse@diamant.hack.org>
+ * ecc-curve.h (nettle_curve25519): Removed public declaration.
+ * ecc-internal.h (_nettle_curve25519): New location, new name.
+ Updated all users.
+
* nettle.texinfo: Updated EdDSA documentation.
* Makefile.in (DISTFILES): Added version.h.in, libnettle.map.in,
#define t1 (scratch + ecc->p.size)
#define t2 (scratch + 2*ecc->p.size)
- const struct ecc_curve *ecc = &nettle_curve25519;
+ const struct ecc_curve *ecc = &_nettle_curve25519;
mp_limb_t cy;
/* If u = U/W and v = V/W are the coordiantes of the point on the
void
curve25519_mul_g (uint8_t *r, const uint8_t *n)
{
- const struct ecc_curve *ecc = &nettle_curve25519;
+ const struct ecc_curve *ecc = &_nettle_curve25519;
uint8_t t[CURVE25519_SIZE];
mp_limb_t *scratch;
mp_size_t itch;
void
curve25519_mul (uint8_t *q, const uint8_t *n, const uint8_t *p)
{
- const struct ecc_curve *ecc = &nettle_curve25519;
+ const struct ecc_curve *ecc = &_nettle_curve25519;
mp_size_t itch;
mp_limb_t *scratch;
int i;
#undef t0
}
-const struct ecc_curve nettle_curve25519 =
+const struct ecc_curve _nettle_curve25519 =
{
{
255,
extern const struct ecc_curve nettle_secp_256r1;
extern const struct ecc_curve nettle_secp_384r1;
extern const struct ecc_curve nettle_secp_521r1;
-extern const struct ecc_curve nettle_curve25519;
#ifdef __cplusplus
}
#define sec_modinv _nettle_sec_modinv
#define curve25519_eh_to_x _nettle_curve25519_eh_to_x
+/* Keep this structure internal for now. It's misnamed (since it's
+ really implementing the equivalent twisted Edwards curve, with
+ different coordinates). And we're not quite ready to provide
+ general ecc operations over an arbitrary type of curve. */
+extern const struct ecc_curve _nettle_curve25519;
+
#define ECC_MAX_SIZE ((521 + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)
/* Window size for ecc_mul_a. Using 4 bits seems like a good choice,
void
ed25519_sha512_public_key (uint8_t *pub, const uint8_t *priv)
{
- const struct ecc_curve *ecc = &nettle_curve25519;
+ const struct ecc_curve *ecc = &_nettle_curve25519;
struct sha512_ctx ctx;
uint8_t digest[ED25519_KEY_SIZE];
mp_size_t itch = ecc->q.size + _eddsa_public_key_itch (ecc);
size_t length, const uint8_t *msg,
uint8_t *signature)
{
- const struct ecc_curve *ecc = &nettle_curve25519;
- mp_size_t itch = ecc->q.size + _eddsa_sign_itch (&nettle_curve25519);
+ const struct ecc_curve *ecc = &_nettle_curve25519;
+ mp_size_t itch = ecc->q.size + _eddsa_sign_itch (ecc);
mp_limb_t *scratch = gmp_alloc_limbs (itch);
#define k2 scratch
#define scratch_out (scratch + ecc->q.size)
_eddsa_expand_key (ecc, &nettle_sha512, &ctx, priv, digest, k2);
sha512_update (&ctx, ED25519_KEY_SIZE, k1);
- _eddsa_sign (&nettle_curve25519, &nettle_sha512, pub,
+ _eddsa_sign (ecc, &nettle_sha512, pub,
&ctx,
k2, length, msg, signature, scratch_out);
size_t length, const uint8_t *msg,
const uint8_t *signature)
{
- const struct ecc_curve *ecc = &nettle_curve25519;
- mp_size_t itch = 3*ecc->p.size + _eddsa_verify_itch (&nettle_curve25519);
+ const struct ecc_curve *ecc = &_nettle_curve25519;
+ mp_size_t itch = 3*ecc->p.size + _eddsa_verify_itch (ecc);
mp_limb_t *scratch = gmp_alloc_limbs (itch);
struct sha512_ctx ctx;
int res;
#define A scratch
#define scratch_out (scratch + 3*ecc->p.size)
- res = (_eddsa_decompress (&nettle_curve25519,
+ res = (_eddsa_decompress (ecc,
A, pub, scratch_out)
&& _eddsa_verify (ecc, &nettle_sha512,
pub, A, &ctx,
const struct ecc_curve * const curves[] = {
&nettle_secp_192r1,
&nettle_secp_224r1,
- &nettle_curve25519,
+ &_nettle_curve25519,
&nettle_secp_256r1,
&nettle_secp_384r1,
&nettle_secp_521r1,
/* NOTE: This isn't the standard way to do curve25519
diffie-hellman, but it tests that the ecc_point interface works
also with curve25519. */
- test_dh ("curve25519", &nettle_curve25519,
+ test_dh ("curve25519", &_nettle_curve25519,
"238301186166219052901200372289459967515481170332211409964804596991365959539",
"14283836751943535877833976277675258994717521964638468784408792140505262281235",
"43912344711849354965202408139054167824861850336739416536288592824181793690574",
/* Non-standard ecdsa using curve25519. Not interop-tested with
anything else. */
- test_ecdsa (&nettle_curve25519,
+ test_ecdsa (&_nettle_curve25519,
"1db511101b8fd16f e0212c5679ef53f3"
"323bde77f9efa442 617314d576d1dbcb", /* z */
"aa2fa8facfdc3a99 ec466d41a2c9211c"
"FA509E70 AAC851AE 01AAC68D 62F86647"
"2660"); /* s */
- test_ecdsa (&nettle_curve25519,
+ test_ecdsa (&_nettle_curve25519,
/* Public key corresponding to the key in ecdsa-sign-test */
"59f8f317fd5f4e82 c02f8d4dec665fe1"
"230f83b8572638e1 b2ac34a30028e24d", /* x */
void test_main (void)
{
- const struct ecc_curve *ecc = &nettle_curve25519;
+ const struct ecc_curve *ecc = &_nettle_curve25519;
gmp_randstate_t rands;
mp_size_t size, itch;
mpz_t zp, t;
{
/* Based on a few of the test vectors at
http://ed25519.cr.yp.to/python/sign.input */
- test_eddsa_sign (&nettle_curve25519, &nettle_sha512,
+ test_eddsa_sign (&_nettle_curve25519, &nettle_sha512,
SHEX("d75a980182b10ab7 d54bfed3c964073a"
"0ee172f3daa62325 af021a68f707511a"),
SHEX("9d61b19deffd5a60 ba844af492ec2cc4"
"84877f1eb8e5d974 d873e06522490155"
"5fb8821590a33bac c61e39701cf9b46b"
"d25bf5f0595bbe24 655141438e7a100b"));
- test_eddsa_sign (&nettle_curve25519, &nettle_sha512,
+ test_eddsa_sign (&_nettle_curve25519, &nettle_sha512,
SHEX("3d4017c3e843895a 92b70aa74d1b7ebc"
"9c982ccf2ec4968c c0cd55f12af4660c"),
SHEX("4ccd089b28ff96da 9db6c346ec114e0f"
"a2b27b5416503f8f b3762223ebdb69da"
"085ac1e43e15996e 458f3613d0f11d8c"
"387b2eaeb4302aee b00d291612bb0c00"));
- test_eddsa_sign (&nettle_curve25519, &nettle_sha512,
+ test_eddsa_sign (&_nettle_curve25519, &nettle_sha512,
SHEX("1ed506485b09a645 0be7c9337d9fe87e"
"f99c96f8bd11cd63 1ca160d0fd73067e"),
SHEX("f215d34fe2d757cf f9cf5c05430994de"
void
test_main (void)
{
- test_eddsa (&nettle_curve25519, &nettle_sha512,
+ test_eddsa (&_nettle_curve25519, &nettle_sha512,
H("d75a980182b10ab7 d54bfed3c964073a"
"0ee172f3daa62325 af021a68f707511a"),
SHEX(""),
"84877f1eb8e5d974 d873e06522490155"
"5fb8821590a33bac c61e39701cf9b46b"
"d25bf5f0595bbe24 655141438e7a100b"));
- test_eddsa (&nettle_curve25519, &nettle_sha512,
+ test_eddsa (&_nettle_curve25519, &nettle_sha512,
H("3d4017c3e843895a 92b70aa74d1b7ebc"
"9c982ccf2ec4968c c0cd55f12af4660c"),
SHEX("72"),
"a2b27b5416503f8f b3762223ebdb69da"
"085ac1e43e15996e 458f3613d0f11d8c"
"387b2eaeb4302aee b00d291612bb0c00"));
- test_eddsa (&nettle_curve25519, &nettle_sha512,
+ test_eddsa (&_nettle_curve25519, &nettle_sha512,
H("1ed506485b09a645 0be7c9337d9fe87e"
"f99c96f8bd11cd63 1ca160d0fd73067e"),
SHEX("fbed2a7df418ec0e 8036312ec239fcee"
&nettle_secp_256r1,
&nettle_secp_384r1,
&nettle_secp_521r1,
- &nettle_curve25519,
+ &_nettle_curve25519,
NULL
};