diff --git a/src/libsodium/crypto_box/crypto_box.c b/src/libsodium/crypto_box/crypto_box.c index 7ec820a4..7ae4297c 100644 --- a/src/libsodium/crypto_box/crypto_box.c +++ b/src/libsodium/crypto_box/crypto_box.c @@ -1,6 +1,12 @@ #include "crypto_box.h" +size_t +crypto_box_seedbytes(void) +{ + return crypto_box_SEEDBYTES; +} + size_t crypto_box_publickeybytes(void) { @@ -49,6 +55,13 @@ crypto_box_primitive(void) return crypto_box_PRIMITIVE; } +int +crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk, + const unsigned char *seed) +{ + return crypto_box_curve25519xsalsa20poly1305_seed_keypair(pk, sk, seed); +} + int crypto_box_keypair(unsigned char *pk, unsigned char *sk) { diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c index 6df56a17..1c002d2d 100644 --- a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c @@ -1,5 +1,10 @@ #include "crypto_box_curve25519xsalsa20poly1305.h" +size_t +crypto_box_curve25519xsalsa20poly1305_seedbytes(void) { + return crypto_box_curve25519xsalsa20poly1305_SEEDBYTES; +} + size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void) { return crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES; diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h index aa39d90f..7f320c6f 100644 --- a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h @@ -3,10 +3,12 @@ #define crypto_box crypto_box_curve25519xsalsa20poly1305 #define crypto_box_open crypto_box_curve25519xsalsa20poly1305_open +#define crypto_box_seed_keypair crypto_box_curve25519xsalsa20poly1305_seed_keypair #define crypto_box_keypair crypto_box_curve25519xsalsa20poly1305_keypair #define crypto_box_beforenm crypto_box_curve25519xsalsa20poly1305_beforenm #define crypto_box_afternm crypto_box_curve25519xsalsa20poly1305_afternm #define crypto_box_open_afternm crypto_box_curve25519xsalsa20poly1305_open_afternm +#define crypto_box_SEEDBYTES crypto_box_curve25519xsalsa20poly1305_SEEDBYTES #define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES #define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES #define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c index 69fb1cfc..9774915f 100644 --- a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c @@ -1,7 +1,19 @@ +#include + #include "crypto_scalarmult_curve25519.h" #include "api.h" #include "randombytes.h" +int crypto_box_seed_keypair( + unsigned char *pk, + unsigned char *sk, + const unsigned char *seed +) +{ + memmove(sk, seed, 32); + return crypto_scalarmult_curve25519_base(pk,sk); +} + int crypto_box_keypair( unsigned char *pk, unsigned char *sk diff --git a/src/libsodium/include/sodium/crypto_box.h b/src/libsodium/include/sodium/crypto_box.h index e65db71b..9c1a64bf 100644 --- a/src/libsodium/include/sodium/crypto_box.h +++ b/src/libsodium/include/sodium/crypto_box.h @@ -20,6 +20,10 @@ extern "C" { #endif +#define crypto_box_SEEDBYTES crypto_box_curve25519xsalsa20poly1305_SEEDBYTES +SODIUM_EXPORT +size_t crypto_box_seedbytes(void); + #define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES SODIUM_EXPORT size_t crypto_box_publickeybytes(void); @@ -52,6 +56,10 @@ size_t crypto_box_macbytes(void); SODIUM_EXPORT const char *crypto_box_primitive(void); +SODIUM_EXPORT +int crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk, + const unsigned char *seed); + SODIUM_EXPORT int crypto_box_keypair(unsigned char *pk, unsigned char *sk); diff --git a/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h b/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h index 54e73005..865602fa 100644 --- a/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +++ b/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h @@ -11,6 +11,10 @@ extern "C" { #endif +#define crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_seedbytes(void); + #define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U SODIUM_EXPORT size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void); @@ -58,7 +62,13 @@ int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m, const unsigned char *sk); SODIUM_EXPORT -int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk, unsigned char *sk); +int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk, + unsigned char *sk, + const unsigned char *seed); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk, + unsigned char *sk); SODIUM_EXPORT int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,