summaryrefslogtreecommitdiff
path: root/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2014-08-11 13:49:21 -0400
committerMicah Anderson <micah@riseup.net>2014-08-11 13:49:21 -0400
commit2e59f9740a29439df7c7a56cf0ae83dec3081d31 (patch)
treed5e7c4e74c9a0f1ea999327d2e68b1dd27be00e0 /src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref
initial import of debian version from mentors0.6.1
Diffstat (limited to 'src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref')
-rw-r--r--src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c22
-rw-r--r--src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h20
-rw-r--r--src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c19
-rw-r--r--src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c27
-rw-r--r--src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c27
5 files changed, 115 insertions, 0 deletions
diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c
new file mode 100644
index 0000000..a830936
--- /dev/null
+++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c
@@ -0,0 +1,22 @@
+#include "api.h"
+#include "crypto_secretbox_xsalsa20poly1305.h"
+
+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_secretbox_xsalsa20poly1305(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_secretbox_xsalsa20poly1305_open(m,c,clen,n,k);
+}
diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h
new file mode 100644
index 0000000..7f320c6
--- /dev/null
+++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h
@@ -0,0 +1,20 @@
+
+#include "crypto_box_curve25519xsalsa20poly1305.h"
+
+#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
+#define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES
+#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
+#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
+#define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
+#define crypto_box_IMPLEMENTATION crypto_box_curve25519xsalsa20poly1305_IMPLEMENTATION
+#define crypto_box_VERSION crypto_box_curve25519xsalsa20poly1305_VERSION
diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c
new file mode 100644
index 0000000..40d4300
--- /dev/null
+++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c
@@ -0,0 +1,19 @@
+#include "api.h"
+#include "crypto_core_hsalsa20.h"
+#include "crypto_scalarmult_curve25519.h"
+
+static const unsigned char sigma[16] = {
+ 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k'
+};
+static const unsigned char n[16] = {0};
+
+int crypto_box_beforenm(
+ unsigned char *k,
+ const unsigned char *pk,
+ const unsigned char *sk
+)
+{
+ unsigned char s[32];
+ crypto_scalarmult_curve25519(s,sk,pk);
+ return crypto_core_hsalsa20(k,n,s,sigma);
+}
diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c
new file mode 100644
index 0000000..4b75ece
--- /dev/null
+++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c
@@ -0,0 +1,27 @@
+#include "api.h"
+
+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
+)
+{
+ unsigned char k[crypto_box_BEFORENMBYTES];
+ crypto_box_beforenm(k,pk,sk);
+ return crypto_box_afternm(c,m,mlen,n,k);
+}
+
+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
+)
+{
+ unsigned char k[crypto_box_BEFORENMBYTES];
+ crypto_box_beforenm(k,pk,sk);
+ return crypto_box_open_afternm(m,c,clen,n,k);
+}
diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c
new file mode 100644
index 0000000..88183ea
--- /dev/null
+++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c
@@ -0,0 +1,27 @@
+#include <string.h>
+
+#include "crypto_hash_sha512.h"
+#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
+)
+{
+ unsigned char hash[64];
+ crypto_hash_sha512(hash,seed,32);
+ memmove(sk,hash,32);
+ return crypto_scalarmult_curve25519_base(pk,sk);
+}
+
+int crypto_box_keypair(
+ unsigned char *pk,
+ unsigned char *sk
+)
+{
+ randombytes(sk,32);
+ return crypto_scalarmult_curve25519_base(pk,sk);
+}