From 5ca15fa3e820339840dc836130c5a672566b43e3 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 19 Apr 2013 21:39:13 +0200 Subject: [PATCH] Change some crypto_sign macros to functions. --- src/libsodium/Makefile.am | 1 + src/libsodium/crypto_sign/crypto_sign.c | 31 +++++++++++++++++++ src/libsodium/include/sodium/crypto_sign.h | 17 +++++++--- .../include/sodium/crypto_sign_ed25519.h | 2 +- 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 src/libsodium/crypto_sign/crypto_sign.c diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index 44a2a37d..de8d84b7 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -54,6 +54,7 @@ libsodium_la_SOURCES = \ crypto_shorthash/crypto_shorthash.c \ crypto_shorthash/siphash24/ref/api.h \ crypto_shorthash/siphash24/ref/shorthash_siphash24.c \ + crypto_sign/crypto_sign.c \ crypto_sign/ed25519/ref10/base.h \ crypto_sign/ed25519/ref10/base2.h \ crypto_sign/ed25519/ref10/api.h \ diff --git a/src/libsodium/crypto_sign/crypto_sign.c b/src/libsodium/crypto_sign/crypto_sign.c new file mode 100644 index 00000000..187f7d6e --- /dev/null +++ b/src/libsodium/crypto_sign/crypto_sign.c @@ -0,0 +1,31 @@ + +#include "crypto_sign.h" + +int +crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk, + const unsigned char *seed) +{ + return crypto_sign_ed25519_seed_keypair(pk, sk, seed); +} + +int +crypto_sign_keypair(unsigned char *pk, unsigned char *sk) +{ + return crypto_sign_ed25519_keypair(pk, sk); +} + +int +crypto_sign(unsigned char *sm, unsigned long long *smlen, + const unsigned char *m, unsigned long long mlen, + const unsigned char *sk) +{ + return crypto_sign_ed25519(sm, smlen, m, mlen, sk); +} + +int +crypto_sign_open(unsigned char *m, unsigned long long *mlen, + const unsigned char *sm, unsigned long long smlen, + const unsigned char *pk) +{ + return crypto_sign_ed25519_open(m, mlen, sm, smlen, pk); +} diff --git a/src/libsodium/include/sodium/crypto_sign.h b/src/libsodium/include/sodium/crypto_sign.h index 59403943..29b921ed 100644 --- a/src/libsodium/include/sodium/crypto_sign.h +++ b/src/libsodium/include/sodium/crypto_sign.h @@ -3,13 +3,22 @@ #include "crypto_sign_ed25519.h" -#define crypto_sign crypto_sign_ed25519 -#define crypto_sign_open crypto_sign_ed25519_open -#define crypto_sign_keypair crypto_sign_ed25519_keypair -#define crypto_sign_seed_keypair crypto_sign_ed25519_seed_keypair #define crypto_sign_BYTES crypto_sign_ed25519_BYTES #define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES #define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES #define crypto_sign_PRIMITIVE "ed25519" +int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk, + const unsigned char *seed); + +int crypto_sign_keypair(unsigned char *pk, unsigned char *sk); + +int crypto_sign(unsigned char *sm, unsigned long long *smlen, + const unsigned char *m, unsigned long long mlen, + const unsigned char *sk); + +int crypto_sign_open(unsigned char *m, unsigned long long *mlen, + const unsigned char *sm, unsigned long long smlen, + const unsigned char *pk); + #endif diff --git a/src/libsodium/include/sodium/crypto_sign_ed25519.h b/src/libsodium/include/sodium/crypto_sign_ed25519.h index 94471184..9c1d73af 100644 --- a/src/libsodium/include/sodium/crypto_sign_ed25519.h +++ b/src/libsodium/include/sodium/crypto_sign_ed25519.h @@ -11,7 +11,7 @@ extern "C" { extern int crypto_sign_ed25519_ref10(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); extern int crypto_sign_ed25519_ref10_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); extern int crypto_sign_ed25519_ref10_keypair(unsigned char *,unsigned char *); -extern int crypto_sign_ed25519_ref10_seed_keypair(unsigned char *,unsigned char *,unsigned char *); +extern int crypto_sign_ed25519_ref10_seed_keypair(unsigned char *,unsigned char *,const unsigned char *); #ifdef __cplusplus } #endif