From 9f52b0f0e9c3b2602c9bce627526d3176554f7af Mon Sep 17 00:00:00 2001 From: Jan Varho Date: Fri, 23 May 2014 10:23:15 +0300 Subject: [PATCH] Change crypto_box_seed_keypair to use SHA-512 of the seed This makes it compatible with what js-nacl and racl do. --- .../ref/keypair_curve25519xsalsa20poly1305.c | 5 ++++- test/default/box_seed.exp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c index 9774915f..88183ea6 100644 --- a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c @@ -1,5 +1,6 @@ #include +#include "crypto_hash_sha512.h" #include "crypto_scalarmult_curve25519.h" #include "api.h" #include "randombytes.h" @@ -10,7 +11,9 @@ int crypto_box_seed_keypair( const unsigned char *seed ) { - memmove(sk, seed, 32); + unsigned char hash[64]; + crypto_hash_sha512(hash,seed,32); + memmove(sk,hash,32); return crypto_scalarmult_curve25519_base(pk,sk); } diff --git a/test/default/box_seed.exp b/test/default/box_seed.exp index 8a3803e4..20e6806f 100644 --- a/test/default/box_seed.exp +++ b/test/default/box_seed.exp @@ -1,8 +1,8 @@ -,0x85,0x20,0xf0,0x09,0x89,0x30,0xa7,0x54 -,0x74,0x8b,0x7d,0xdc,0xb4,0x3e,0xf7,0x5a -,0x0d,0xbf,0x3a,0x0d,0x26,0x38,0x1a,0xf4 -,0xeb,0xa4,0xa9,0x8e,0xaa,0x9b,0x4e,0x6a -,0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d -,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45 -,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a -,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a +,0xed,0x77,0x49,0xb4,0xd9,0x89,0xf6,0x95 +,0x7f,0x3b,0xfd,0xe6,0xc5,0x67,0x67,0xe9 +,0x88,0xe2,0x1c,0x9f,0x87,0x84,0xd9,0x1d +,0x61,0x00,0x11,0xcd,0x55,0x3f,0x9b,0x06 +,0xac,0xcd,0x44,0xeb,0x8e,0x93,0x31,0x9c +,0x05,0x70,0xbc,0x11,0x00,0x5c,0x0e,0x01 +,0x89,0xd3,0x4f,0xf0,0x2f,0x6c,0x17,0x77 +,0x34,0x11,0xad,0x19,0x12,0x93,0xc9,0x8f