Make crypto_box functions actual functions, not macros.

This commit is contained in:
Frank Denis 2013-04-19 17:50:41 +02:00
parent 1cbe55f9bd
commit 7d916fb0b1
3 changed files with 63 additions and 6 deletions

View File

@ -10,6 +10,7 @@ libsodium_la_SOURCES = \
crypto_auth/hmacsha512256/ref/api.h \ crypto_auth/hmacsha512256/ref/api.h \
crypto_auth/hmacsha512256/ref/hmac_hmacsha512256.c \ crypto_auth/hmacsha512256/ref/hmac_hmacsha512256.c \
crypto_auth/hmacsha512256/ref/verify_hmacsha512256.c \ crypto_auth/hmacsha512256/ref/verify_hmacsha512256.c \
crypto_box/crypto_box.c \
crypto_box/curve25519xsalsa20poly1305/ref/api.h \ crypto_box/curve25519xsalsa20poly1305/ref/api.h \
crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c \ crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c \
crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c \ crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c \

View File

@ -0,0 +1,41 @@
#include "crypto_box.h"
int crypto_box_keypair(unsigned char *pk, unsigned char *sk)
{
return crypto_box_curve25519xsalsa20poly1305_keypair(pk, sk);
}
int crypto_box_beforenm(unsigned char *k, const unsigned char *pk,
const unsigned char *sk)
{
return crypto_box_curve25519xsalsa20poly1305_beforenm(k, pk, sk);
}
int crypto_box_afternm(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
const unsigned char *k)
{
return crypto_box_curve25519xsalsa20poly1305_afternm(c, m, mlen, n, k);
}
int crypto_box_open_afternm(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n,
const unsigned char *k)
{
return crypto_box_curve25519xsalsa20poly1305_open_afternm(m, c, clen, m, k);
}
int crypto_box(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk)
{
return crypto_box_curve25519xsalsa20poly1305(c, m, mlen, n, pk, sk);
}
int crypto_box_open(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk)
{
return crypto_box_curve25519xsalsa20poly1305_open(m, c, clen, n, pk, sk);
}

View File

@ -3,12 +3,6 @@
#include "crypto_box_curve25519xsalsa20poly1305.h" #include "crypto_box_curve25519xsalsa20poly1305.h"
#define crypto_box crypto_box_curve25519xsalsa20poly1305
#define crypto_box_open crypto_box_curve25519xsalsa20poly1305_open
#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_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES #define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
#define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES #define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES
#define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES #define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES
@ -18,4 +12,25 @@
#define crypto_box_MACBYTES crypto_box_curve25519xsalsa20poly1305_MACBYTES #define crypto_box_MACBYTES crypto_box_curve25519xsalsa20poly1305_MACBYTES
#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305" #define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305"
int crypto_box_keypair(unsigned char *pk, unsigned char *sk);
int crypto_box_beforenm(unsigned char *k, const unsigned char *pk,
const unsigned char *sk);
int crypto_box_afternm(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
const unsigned char *k);
int crypto_box_open_afternm(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n,
const unsigned char *k);
int crypto_box(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk);
int crypto_box_open(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk);
#endif #endif