Swap from included nacl to host libsodium

This commit is contained in:
Jeremy Lakeman 2016-04-12 15:43:56 +09:30
parent 7f5f71aec8
commit e15e332072
223 changed files with 190 additions and 11954 deletions

View File

@ -99,9 +99,8 @@ A successful session should appear something like:
config.status: creating Makefile
config.status: creating testconfig.sh
$ make
CC nacl/src/crypto_auth_hmacsha256_ref/hmac.c
CC nacl/src/crypto_auth_hmacsha256_ref/verify.c
CC nacl/src/crypto_auth_hmacsha512256_ref/hmac.c
SERVALD CC conf.c
SERVALD CC cli.c
...
CC cli.c
CC commandline.c

View File

@ -7,8 +7,6 @@ sbindir=@sbindir@
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
NACL_BASE= nacl/src
include $(NACL_BASE)/nacl.mk
include sourcefiles.mk
include headerfiles.mk
@ -22,7 +20,6 @@ ALL_SOURCES = \
$(SERVAL_CLIENT_SOURCES) \
$(MDP_CLIENT_SOURCES) \
$(SERVAL_DAEMON_SOURCES) \
$(NACL_SOURCES) \
$(TEST_SOURCES) \
$(SERVAL_LIB_SOURCES) \
$(MONITOR_CLIENT_SRCS) \
@ -35,11 +32,9 @@ SERVAL_DAEMON_OBJS = \
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_DAEMON_SOURCES:.c=.o))
SERVALD_OBJS = \
$(addprefix $(OBJSDIR_SERVALD)/, $(notdir $(SQLITE3_SOURCES:.c=.o))) \
$(addprefix $(OBJSDIR_SERVALD)/, $(NACL_SOURCES:.c=.o)) \
$(SERVAL_DAEMON_OBJS)
TEST_OBJS = \
$(addprefix $(OBJSDIR_SERVALD)/, $(TEST_SOURCES:.c=.o)) \
$(addprefix $(OBJSDIR_SERVALD)/, $(NACL_SOURCES:.c=.o)) \
$(addprefix $(OBJSDIR_SERVALD)/, $(SERVAL_CLIENT_SOURCES:.c=.o))
LIB_SERVAL_OBJS = \
$(addprefix $(OBJSDIR_LIB)/, $(SERVAL_CLIENT_SOURCES:.c=.o)) \
@ -56,7 +51,7 @@ CC= @CC@
LDFLAGS=@LDFLAGS@ @LIBS@
CFLAGS= -Isqlite-amalgamation-3100200 @CPPFLAGS@ @CFLAGS@ -Inacl/include
CFLAGS= -Isqlite-amalgamation-3100200 @CPPFLAGS@ @CFLAGS@
CFLAGS+=-DSYSCONFDIR="\"$(sysconfdir)\"" -DLOCALSTATEDIR="\"$(localstatedir)\""
CFLAGS+=-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_DATETIME_FUNCS -DSQLITE_OMIT_COMPILEOPTION_DIAGS -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_VIRTUALTABLE -DSQLITE_OMIT_AUTHORIZATION
CFLAGS+=-fPIC

View File

@ -139,6 +139,7 @@ AC_CHECK_LIB(m,sqrtf,[LDFLAGS="$LDFLAGS -lm"])
AC_CHECK_LIB(nsl,callrpc,[LDFLAGS="$LDFLAGS -lnsl"])
AC_CHECK_LIB(socket,socket,[LDFLAGS="$LDFLAGS -lsocket"])
AC_CHECK_LIB(dl,dlopen,[LDFLAGS="$LDFLAGS -ldl"])
AC_CHECK_LIB(sodium,sodium_init,[LDFLAGS="$LDFLAGS -lsodium"])
AC_CACHE_CHECK([linker -z relro option], libc_cv_z_relro, [dnl
libc_cv_z_relro=no

View File

@ -17,46 +17,14 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "crypto_sign_edwards25519sha512batch.h"
#include "nacl/src/crypto_sign_edwards25519sha512batch_ref/ge.h"
#include "serval.h"
#include "overlay_address.h"
#include "crypto.h"
#include "keyring.h"
// verify a signature against a public sas key.
int crypto_verify_signature(unsigned char *sas_key,
unsigned char *content, int content_len,
unsigned char *signature_block, int signature_len)
{
IN();
if (signature_len!=SIGNATURE_BYTES)
RETURN(WHY("Invalid signature length"));
/* reconstitute signed message by putting hash at end of signature */
unsigned char reassembled[signature_len + content_len];
bcopy(signature_block, reassembled, signature_len);
bcopy(content, &reassembled[signature_len], content_len);
/* verify signature.
Note that crypto_sign_open requires m to be as large as signature, even
though it will not need the whole length eventually -- it does use the
full length and will overwrite the end of a short buffer. */
unsigned char message[sizeof(reassembled)+64];
unsigned long long mlen=0;
int result
=crypto_sign_edwards25519sha512batch_open(message,&mlen,
reassembled,sizeof(reassembled),
sas_key);
if (result)
RETURN(WHY("Signature verification failed"));
RETURN(0);
}
// verify the signature at the end of a message, on return message_len will be reduced by the length of the signature.
int crypto_verify_message(struct subscriber *subscriber, unsigned char *message, int *message_len)
int crypto_verify_message(struct subscriber *subscriber, unsigned char *message, size_t *message_len)
{
if (!subscriber->sas_valid){
keyring_send_sas_request(subscriber);
@ -71,33 +39,9 @@ int crypto_verify_message(struct subscriber *subscriber, unsigned char *message,
unsigned char hash[crypto_hash_sha512_BYTES];
crypto_hash_sha512(hash,message,*message_len);
return crypto_verify_signature(subscriber->sas_public, hash,
crypto_hash_sha512_BYTES, &message[*message_len], SIGNATURE_BYTES);
}
if (crypto_sign_verify_detached(&message[*message_len], hash, crypto_hash_sha512_BYTES, subscriber->sas_public))
return WHY("Signature verification failed");
// generate a signature for this raw content, copy the signature to the address requested.
int crypto_create_signature(unsigned char *key,
unsigned char *content, int content_len,
unsigned char *signature, int *sig_length)
{
IN();
if (*sig_length < SIGNATURE_BYTES)
RETURN(WHY("Not enough space to store signature"));
unsigned char sig[content_len + SIGNATURE_BYTES];
/* Why does this primitive copy the whole input message? We don't want that message format, it just seems like a waste of effor to me. */
unsigned long long int length = 0;
crypto_sign_edwards25519sha512batch(sig,&length,
content,content_len,
key);
if (length != sizeof(sig))
RETURN(WHYF("Signing seems to have failed (%d, expected %d)",(int)length,(int)sizeof(sig)));
bcopy(sig, signature, SIGNATURE_BYTES);
*sig_length=SIGNATURE_BYTES;
OUT();
return 0;
}
@ -114,26 +58,10 @@ int crypto_sign_message(struct keyring_identity *identity, unsigned char *conten
unsigned char hash[crypto_hash_sha512_BYTES];
crypto_hash_sha512(hash, content, *content_len);
int sig_length = SIGNATURE_BYTES;
int ret=crypto_create_signature(key->private_key, hash, crypto_hash_sha512_BYTES, &content[*content_len], &sig_length);
*content_len+=sig_length;
return ret;
if (crypto_sign_detached(&content[*content_len], NULL, hash, crypto_hash_sha512_BYTES, key->private_key))
return WHY("Signing failed");
*content_len += SIGNATURE_BYTES;
return 0;
}
void crypto_sign_compute_public_key(const unsigned char *skin, unsigned char *pk)
{
IN();
unsigned char h[64];
ge_p3 A;
crypto_hash_sha512(h,skin,32);
h[0] &= 248;
h[31] &= 63;
h[31] |= 64;
ge_scalarmult_base(&A,h);
ge_p3_tobytes(pk,&A);
OUT();
}

View File

@ -20,18 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __SERVAL_DNA__CRYPTO_H
#define __SERVAL_DNA__CRYPTO_H
#include "nacl.h"
#define SIGNATURE_BYTES crypto_sign_edwards25519sha512batch_BYTES
#include "sodium.h"
#define SIGNATURE_BYTES crypto_sign_BYTES
struct keyring_identity;
int crypto_verify_signature(unsigned char *sas_key,
unsigned char *content, int content_len,
unsigned char *signature_block, int signature_len);
int crypto_verify_message(struct subscriber *subscriber, unsigned char *message, int *message_len);
int crypto_create_signature(unsigned char *key,
unsigned char *content, int content_len,
unsigned char *signature, int *sig_length);
int crypto_verify_message(struct subscriber *subscriber, unsigned char *message, size_t *message_len);
int crypto_sign_message(struct keyring_identity *identity, unsigned char *content, size_t buffer_len, size_t *content_len);
void crypto_sign_compute_public_key(const unsigned char *skin, unsigned char *pk);
#endif

View File

@ -27,7 +27,6 @@ HDRS= fifo.h \
sighandlers.h \
strbuf.h \
strbuf_helpers.h \
sha2.h \
conf.h \
conf_schema.h \
crypto.h \

237
jni.c
View File

@ -1,237 +0,0 @@
/*
Serval Distributed Numbering Architecture (DNA)
Copyright (C) 2010 Paul Gardner-Stephen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <jni.h>
#include "crypto_box_curve25519xsalsa20poly1305.h"
#include "crypto_sign_edwards25519sha512batch.h"
// Lto/yp/cr/NaCl;.moose ()I
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_moose
(JNIEnv *env, jobject obj)
{
return 1;
}
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeRandomBytes
(JNIEnv *env, jobject obj, jbyteArray bytes)
{
int l=(*env)->GetArrayLength(env, bytes);
if (l<1) return -1;
jbyte *b = (*env)->GetPrimitiveArrayCritical(env, bytes, NULL);
urandombytes(b,l);
if (b) (*env)->ReleasePrimitiveArrayCritical(env, bytes, b, 0);
return 0;
}
/* ------------------------------------------------------------------------
crypto_box functions : Diffie-Hellman negotiated symmetric cryptography
CryptoBoxKeypair - generate key pair.
CryptoBox - Create authenticated an encrypted message.
CryptoBoxOpen - Decode and verify an en encrypted message.
------------------------------------------------------------------------ */
// Lto/yp/cr/NaCl$CryptoBoxKeypair;.method ([B[B)I
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeCryptoBoxKeypair
(JNIEnv *env, jobject obj, jbyteArray jsk, jbyteArray jpk)
{
unsigned char pk[crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES];
unsigned char sk[crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES];
if (crypto_box_curve25519xsalsa20poly1305_keypair(pk,sk)) return 1;
/* Set java side versions of pk and sk */
(*env)->SetByteArrayRegion(env, jpk, 0, crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES, pk);
(*env)->SetByteArrayRegion(env, jsk, 0, crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES, sk);
return 0;
}
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeCryptoBox
(JNIEnv *env, jobject obj, jbyteArray jpk, jbyteArray jsk,jbyteArray jn,jbyteArray jm,jint jmlen,jbyteArray jc)
{
int i;
if ((*env)->GetArrayLength(env, jpk)!=crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) return -2;
if ((*env)->GetArrayLength(env, jsk)!=crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) return -3;
if ((*env)->GetArrayLength(env, jn)!=crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) return -4;
if ((*env)->GetArrayLength(env, jm)!=jmlen) return -5;
if ((*env)->GetArrayLength(env, jc)!=jmlen) return -6;
/* Get inputs */
jbyte *pk = (*env)->GetPrimitiveArrayCritical(env, jpk, NULL);
jbyte *sk = (*env)->GetPrimitiveArrayCritical(env, jsk, NULL);
jbyte *n = (*env)->GetPrimitiveArrayCritical(env, jn, NULL);
jbyte *m = (*env)->GetPrimitiveArrayCritical(env, jm, NULL);
jbyte *c = (*env)->GetPrimitiveArrayCritical(env, jc, NULL);
int r=-1;
if (pk&&sk&&n&&m&&c&&(jmlen>=0&&jmlen<=1048576))
{
/* Make sure that space for authenticator is zeroed */
for(i=0;i<crypto_box_curve25519xsalsa20poly1305_ZEROBYTES;i++)
{ if (m[i]) return -7; }
r=crypto_box_curve25519xsalsa20poly1305(c,m,jmlen,n,pk,sk);
}
/* do these really keep any changes made? */
if (pk) (*env)->ReleasePrimitiveArrayCritical(env, jpk, pk, 0);
if (sk) (*env)->ReleasePrimitiveArrayCritical(env, jsk, sk, 0);
if (n) (*env)->ReleasePrimitiveArrayCritical(env, jn, n, 0);
if (m) (*env)->ReleasePrimitiveArrayCritical(env, jm, m, 0);
if (c) (*env)->ReleasePrimitiveArrayCritical(env, jc, c, 0);
return r;
}
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeCryptoBoxOpen
(JNIEnv *env, jobject obj, jbyteArray jpk, jbyteArray jsk,jbyteArray jn,jbyteArray jm,jint jclen,jbyteArray jc)
{
int i;
if ((*env)->GetArrayLength(env, jpk)!=crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) return -2;
if ((*env)->GetArrayLength(env, jsk)!=crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) return -3;
if ((*env)->GetArrayLength(env, jn)!=crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) return -4;
if ((*env)->GetArrayLength(env, jm)!=jclen) return -5;
if ((*env)->GetArrayLength(env, jc)!=jclen) return -6;
/* Get inputs */
jbyte *pk = (*env)->GetPrimitiveArrayCritical(env, jpk, NULL);
jbyte *sk = (*env)->GetPrimitiveArrayCritical(env, jsk, NULL);
jbyte *n = (*env)->GetPrimitiveArrayCritical(env, jn, NULL);
jbyte *m = (*env)->GetPrimitiveArrayCritical(env, jm, NULL);
jbyte *c = (*env)->GetPrimitiveArrayCritical(env, jc, NULL);
int r=-1;
if (pk&&sk&&n&&m&&c&&(jclen>=0&&jclen<=1048576))
{
/* Make sure that space for authenticator is free */
for(i=0;i<crypto_box_curve25519xsalsa20poly1305_ZEROBYTES;i++)
{ if (m[i]) return -7; }
r=crypto_box_curve25519xsalsa20poly1305_open(m,c,jclen,n,pk,sk);
}
/* do these really keep any changes made? */
if (pk) (*env)->ReleasePrimitiveArrayCritical(env, jpk, pk, 0);
if (sk) (*env)->ReleasePrimitiveArrayCritical(env, jsk, sk, 0);
if (n) (*env)->ReleasePrimitiveArrayCritical(env, jn, n, 0);
if (m) (*env)->ReleasePrimitiveArrayCritical(env, jm, m, 0);
if (c) (*env)->ReleasePrimitiveArrayCritical(env, jc, c, 0);
return r;
}
/* ------------------------------------------------------------------------
crypto_sign functions : Public key cryptography functions
------------------------------------------------------------------------ */
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeCryptoSignKeypair
(JNIEnv *env, jobject obj, jbyteArray jsk, jbyteArray jpk)
{
unsigned char pk[crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES];
unsigned char sk[crypto_sign_edwards25519sha512batch_SECRETKEYBYTES];
if (crypto_sign_edwards25519sha512batch_keypair(pk,sk)) return 1;
/* Set java side versions of pk and sk */
(*env)->SetByteArrayRegion(env, jpk, 0, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES, pk);
(*env)->SetByteArrayRegion(env, jsk, 0, crypto_sign_edwards25519sha512batch_SECRETKEYBYTES, sk);
return 0;
}
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeCryptoSign
(JNIEnv *env, jobject obj, jbyteArray jsk,jbyteArray jm,jbyteArray jsm)
{
long long mlen,smlen,smlen_in;
smlen=(*env)->GetArrayLength(env, jsm);
smlen_in=smlen;
mlen=(*env)->GetArrayLength(env, jm);
if ((smlen-mlen)!=crypto_sign_edwards25519sha512batch_BYTES) return -4;
if ((*env)->GetArrayLength(env, jsk)!=crypto_sign_edwards25519sha512batch_SECRETKEYBYTES) return -3;
/* Get inputs */
jbyte *sk = (*env)->GetPrimitiveArrayCritical(env, jsk, NULL);
jbyte *m = (*env)->GetPrimitiveArrayCritical(env, jm, NULL);
jbyte *sm = (*env)->GetPrimitiveArrayCritical(env, jsm, NULL);
int r=-1;
if (sk&&m&&sm)
{
r=crypto_sign_edwards25519sha512batch_ref(sm,&smlen,m,mlen,sk);
if (smlen!=smlen_in) return -5;
}
/* do these really keep any changes made? */
if (sk) (*env)->ReleasePrimitiveArrayCritical(env, jsk, sk, 0);
if (m) (*env)->ReleasePrimitiveArrayCritical(env, jm, m, 0);
if (sm) (*env)->ReleasePrimitiveArrayCritical(env, jsm, sm, 0);
return r;
}
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeCryptoSignOpen
(JNIEnv *env, jobject obj, jbyteArray jpk,jbyteArray jsm,jbyteArray jm)
{
long long mlen,smlen,mlen_in;
smlen=(*env)->GetArrayLength(env, jsm);
mlen=(*env)->GetArrayLength(env, jm); mlen_in=mlen;
if (smlen>mlen) return -4;
if ((*env)->GetArrayLength(env, jpk)!=crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES) return -3;
/* Get inputs */
jbyte *pk = (*env)->GetPrimitiveArrayCritical(env, jpk, NULL);
jbyte *m = (*env)->GetPrimitiveArrayCritical(env, jm, NULL);
jbyte *sm = (*env)->GetPrimitiveArrayCritical(env, jsm, NULL);
int r=-1;
if (pk&&m&&sm)
{
r=crypto_sign_edwards25519sha512batch_open(m,&mlen,sm,smlen,pk);
if (mlen!=mlen_in) return -5;
}
/* do these really keep any changes made? */
if (pk) (*env)->ReleasePrimitiveArrayCritical(env, jpk, pk, 0);
if (m) (*env)->ReleasePrimitiveArrayCritical(env, jm, m, 0);
if (sm) (*env)->ReleasePrimitiveArrayCritical(env, jsm, sm, 0);
return r;
}

View File

@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "rhizome.h"
#include "conf.h"
#include "constants.h"
#include "nacl.h"
#include "overlay_address.h"
#include "crypto.h"
#include "overlay_interface.h"
@ -49,6 +48,8 @@ static int keyring_identity_mac(const keyring_identity *id, unsigned char *pkrsa
static int _keyring_open(keyring_file *k, const char *path, const char *mode)
{
DEBUGF(keyring, "opening %s in \"%s\" mode", alloca_str_toprint(path), mode);
if (sodium_init()==-1)
return WHY("Failed to initialise libsodium");
k->file = fopen(path, mode);
if (!k->file) {
if (errno != EPERM && errno != ENOENT)
@ -377,10 +378,10 @@ static int keyring_munge_block(
unsigned char *PKRSalt=&block[0];
int PKRSaltLen=32;
#if crypto_stream_xsalsa20_KEYBYTES>crypto_hash_sha512_BYTES
#if crypto_box_SECRETKEYBYTES>crypto_hash_sha512_BYTES
#error crypto primitive key size too long -- hash needs to be expanded
#endif
#if crypto_stream_xsalsa20_NONCEBYTES>crypto_hash_sha512_BYTES
#if crypto_box_NONCEBYTES>crypto_hash_sha512_BYTES
#error crypto primitive nonce size too long -- hash needs to be expanded
#endif
@ -458,7 +459,7 @@ static void create_cryptobox(keypair *kp)
/* Filter out public keys that start with 0x0, as they are reserved for address
abbreviation. */
do {
crypto_box_curve25519xsalsa20poly1305_keypair(kp->public_key, kp->private_key);
crypto_box_keypair(kp->public_key, kp->private_key);
} while (kp->public_key[0] < 0x10);
}
@ -475,12 +476,12 @@ static void create_cryptobox(keypair *kp)
*/
static void _derive_scalarmult_public(unsigned char *public, const unsigned char *private)
{
crypto_scalarmult_curve25519_base(public, private);
crypto_scalarmult_base(public, private);
}
static void create_cryptosign(keypair *kp)
{
crypto_sign_edwards25519sha512batch_keypair(kp->public_key, kp->private_key);
crypto_sign_keypair(kp->public_key, kp->private_key);
}
static void create_rhizome(keypair *kp)
@ -747,9 +748,9 @@ const struct keytype keytypes[] = {
/* Only the private key is stored, and the public key (SID) is derived from the private key
* when the keyring is read.
*/
.private_key_size = crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES,
.public_key_size = crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES,
.packed_size = crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES,
.private_key_size = crypto_box_SECRETKEYBYTES,
.public_key_size = crypto_box_PUBLICKEYBYTES,
.packed_size = crypto_box_SECRETKEYBYTES,
.creator = create_cryptobox,
.packer = pack_private_only,
.unpacker = unpack_cryptobox,
@ -762,9 +763,9 @@ const struct keytype keytypes[] = {
* invoke that function risks incompatibility with future releases of NaCl, so instead the
* public key is stored redundantly in the keyring.
*/
.private_key_size = crypto_sign_edwards25519sha512batch_SECRETKEYBYTES,
.public_key_size = crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES,
.packed_size = crypto_sign_edwards25519sha512batch_SECRETKEYBYTES + crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES,
.private_key_size = crypto_sign_SECRETKEYBYTES,
.public_key_size = crypto_sign_PUBLICKEYBYTES,
.packed_size = crypto_sign_SECRETKEYBYTES + crypto_sign_PUBLICKEYBYTES,
.creator = create_cryptosign,
.packer = pack_private_public,
.unpacker = unpack_private_public,
@ -1562,7 +1563,7 @@ struct keypair *keyring_find_sas_private(keyring_file *k, keyring_identity *iden
/* SAS key is invalid (perhaps because it was a pre 0.90 format one),
so replace it */
WARN("SAS key is invalid -- regenerating.");
crypto_sign_edwards25519sha512batch_keypair(kp->public_key, kp->private_key);
crypto_sign_keypair(kp->public_key, kp->private_key);
keyring_commit(k);
}
kp->verified=1;
@ -1584,34 +1585,14 @@ static int keyring_store_sas(struct internal_mdp_header *header, struct overlay_
DEBUGF(keyring, "Received SID:SAS mapping, %zd bytes", len);
#define SIG_BYTES crypto_sign_edwards25519sha512batch_BYTES
if (ob_remaining(payload) < SAS_SIZE + SIG_BYTES)
if (ob_remaining(payload) < SAS_SIZE + crypto_sign_BYTES)
return WHY("Truncated key mapping announcement?");
uint8_t plain[len];
unsigned long long plain_len = 0;
const uint8_t *sas_public = ob_get_bytes_ptr(payload, SAS_SIZE);
const uint8_t *compactsignature = ob_get_bytes_ptr(payload, SIG_BYTES);
size_t siglen=SID_SIZE+SIG_BYTES;
uint8_t signature[siglen];
/* reconstitute signed SID for verification */
bcopy(compactsignature, signature, SIG_BYTES);
bcopy(header->source->sid.binary, signature + SIG_BYTES, SID_SIZE);
int r=crypto_sign_edwards25519sha512batch_open(plain,&plain_len,
signature,siglen,
sas_public);
const uint8_t *compactsignature = ob_get_bytes_ptr(payload, crypto_sign_BYTES);
#undef SIG_BYTES
if (r)
if (crypto_sign_verify_detached(compactsignature, header->source->sid.binary, SID_SIZE, sas_public))
return WHY("SID:SAS mapping verification signature does not verify");
/* These next two tests should never be able to fail, but let's just check anyway. */
if (plain_len != SID_SIZE)
return WHY("SID:SAS mapping signed block is wrong length");
if (memcmp(plain, header->source->sid.binary, SID_SIZE) != 0)
return WHY("SID:SAS mapping signed block is for wrong SID");
/* now store it */
bcopy(sas_public, header->source->sas_public, SAS_SIZE);
@ -1644,26 +1625,11 @@ static int keyring_respond_sas(keyring_file *k, struct internal_mdp_header *head
ob_append_byte(response_payload, kp->type);
ob_append_bytes(response_payload, kp->public_key, kp->public_key_len);
unsigned long long slen;
/* and a signature of the SID using the SAS key, to prove possession of
the key. Possession of the SID has already been established by the
decrypting of the surrounding MDP packet.
XXX - We could chop the SID out of the middle of the signed block here,
just as we do for signed MDP packets to save 32 bytes. We won't worry
about doing this, however, as the mapping process is only once per session,
not once per packet. Unless I get excited enough to do it, that is.
*/
if (crypto_sign_edwards25519sha512batch(ob_current_ptr(response_payload), &slen,
header->destination->sid.binary, SID_SIZE, kp->private_key))
uint8_t *sig = ob_append_space(response_payload, crypto_sign_BYTES);
if (crypto_sign_detached(sig, NULL, header->destination->sid.binary, SID_SIZE, kp->private_key))
return WHY("crypto_sign() failed");
/* chop the SID from the end of the signature, since it can be reinserted on reception */
slen-=SID_SIZE;
ob_append_space(response_payload, slen);
DEBUGF(keyring, "Sending SID:SAS mapping, %zd bytes, %s:%"PRImdp_port_t" -> %s:%"PRImdp_port_t,
ob_position(response_payload),
alloca_tohex_sid_t(header->destination->sid), header->destination_port,
@ -1804,7 +1770,7 @@ static int keyring_mapping_request(struct internal_mdp_header *header, struct ov
break;
case UNLOCK_REQUEST:
{
int len = ob_remaining(payload) +1;
size_t len = ob_remaining(payload) +1;
if (crypto_verify_message(header->destination, ob_current_ptr(payload) -1, &len))
return WHY("Signature check failed");
}
@ -1813,7 +1779,7 @@ static int keyring_mapping_request(struct internal_mdp_header *header, struct ov
return keyring_respond_challenge(header->source, payload);
case UNLOCK_RESPONSE:
{
int len = ob_remaining(payload)+1;
size_t len = ob_remaining(payload)+1;
if (crypto_verify_message(header->destination, ob_current_ptr(payload) -1, &len))
return WHY("Signature check failed");
ob_limitsize(payload, ob_position(payload)+len -1);
@ -1974,7 +1940,7 @@ struct nm_record {
/* 96 bytes per record */
sid_t known_key;
sid_t unknown_key;
unsigned char nm_bytes[crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES];
unsigned char nm_bytes[crypto_box_BEFORENMBYTES];
};
unsigned nm_slots_used=0;
@ -2014,9 +1980,10 @@ unsigned char *keyring_get_nm_bytes(const sid_t *known_sidp, const sid_t *unknow
/* calculate and store */
nm_cache[i].known_key = *known_sidp;
nm_cache[i].unknown_key = *unknown_sidp;
crypto_box_curve25519xsalsa20poly1305_beforenm(nm_cache[i].nm_bytes,
unknown_sidp->binary,
it.keypair->private_key);
if (crypto_box_beforenm(nm_cache[i].nm_bytes, unknown_sidp->binary, it.keypair->private_key)){
WHY("crypto_box_beforenm failed");
RETURN(NULL);
}
RETURN(nm_cache[i].nm_bytes);
OUT();
}

View File

@ -57,7 +57,7 @@ static enum meshms_status get_my_conversation_bundle(const sid_t *my_sidp, rhizo
strbuf sb = strbuf_alloca(1024);
strbuf_puts(sb, "incorrection");
strbuf_tohex(sb, crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES * 2, it.keypair->private_key);
strbuf_tohex(sb, crypto_box_SECRETKEYBYTES * 2, it.keypair->private_key);
strbuf_puts(sb, "concentrativeness");
assert(!strbuf_overrun(sb));
if (rhizome_get_bundle_from_seed(m, strbuf_str(sb)) == -1)

View File

@ -1,3 +0,0 @@
#define CRYPTO_SECRETKEYBYTES 64
#define CRYPTO_PUBLICKEYBYTES 32
#define CRYPTO_BYTES 64

View File

@ -1,32 +0,0 @@
#ifndef crypto_auth_hmacsha256_H
#define crypto_auth_hmacsha256_H
#define crypto_auth_hmacsha256_ref_BYTES 32
#define crypto_auth_hmacsha256_ref_KEYBYTES 32
#ifdef __cplusplus
#include <string>
extern std::string crypto_auth_hmacsha256_ref(const std::string &,const std::string &);
extern void crypto_auth_hmacsha256_ref_verify(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_auth_hmacsha256_ref(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_auth_hmacsha256_ref_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_auth_hmacsha256 crypto_auth_hmacsha256_ref
/* POTATO crypto_auth_hmacsha256_ref crypto_auth_hmacsha256_ref crypto_auth_hmacsha256 */
#define crypto_auth_hmacsha256_verify crypto_auth_hmacsha256_ref_verify
/* POTATO crypto_auth_hmacsha256_ref_verify crypto_auth_hmacsha256_ref crypto_auth_hmacsha256 */
#define crypto_auth_hmacsha256_BYTES crypto_auth_hmacsha256_ref_BYTES
/* POTATO crypto_auth_hmacsha256_ref_BYTES crypto_auth_hmacsha256_ref crypto_auth_hmacsha256 */
#define crypto_auth_hmacsha256_KEYBYTES crypto_auth_hmacsha256_ref_KEYBYTES
/* POTATO crypto_auth_hmacsha256_ref_KEYBYTES crypto_auth_hmacsha256_ref crypto_auth_hmacsha256 */
#define crypto_auth_hmacsha256_IMPLEMENTATION "crypto_auth/hmacsha256/ref"
#ifndef crypto_auth_hmacsha256_ref_VERSION
#define crypto_auth_hmacsha256_ref_VERSION "-"
#endif
#define crypto_auth_hmacsha256_VERSION crypto_auth_hmacsha256_ref_VERSION
#endif

View File

@ -1,32 +0,0 @@
#ifndef crypto_auth_hmacsha512256_H
#define crypto_auth_hmacsha512256_H
#define crypto_auth_hmacsha512256_ref_BYTES 32
#define crypto_auth_hmacsha512256_ref_KEYBYTES 32
#ifdef __cplusplus
#include <string>
extern std::string crypto_auth_hmacsha512256_ref(const std::string &,const std::string &);
extern void crypto_auth_hmacsha512256_ref_verify(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_auth_hmacsha512256_ref(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_auth_hmacsha512256_ref_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_auth_hmacsha512256 crypto_auth_hmacsha512256_ref
/* POTATO crypto_auth_hmacsha512256_ref crypto_auth_hmacsha512256_ref crypto_auth_hmacsha512256 */
#define crypto_auth_hmacsha512256_verify crypto_auth_hmacsha512256_ref_verify
/* POTATO crypto_auth_hmacsha512256_ref_verify crypto_auth_hmacsha512256_ref crypto_auth_hmacsha512256 */
#define crypto_auth_hmacsha512256_BYTES crypto_auth_hmacsha512256_ref_BYTES
/* POTATO crypto_auth_hmacsha512256_ref_BYTES crypto_auth_hmacsha512256_ref crypto_auth_hmacsha512256 */
#define crypto_auth_hmacsha512256_KEYBYTES crypto_auth_hmacsha512256_ref_KEYBYTES
/* POTATO crypto_auth_hmacsha512256_ref_KEYBYTES crypto_auth_hmacsha512256_ref crypto_auth_hmacsha512256 */
#define crypto_auth_hmacsha512256_IMPLEMENTATION "crypto_auth/hmacsha512256/ref"
#ifndef crypto_auth_hmacsha512256_ref_VERSION
#define crypto_auth_hmacsha512256_ref_VERSION "-"
#endif
#define crypto_auth_hmacsha512256_VERSION crypto_auth_hmacsha512256_ref_VERSION
#endif

View File

@ -1,57 +0,0 @@
#ifndef crypto_box_curve25519xsalsa20poly1305_H
#define crypto_box_curve25519xsalsa20poly1305_H
#define crypto_box_curve25519xsalsa20poly1305_ref_PUBLICKEYBYTES 32
#define crypto_box_curve25519xsalsa20poly1305_ref_SECRETKEYBYTES 32
#define crypto_box_curve25519xsalsa20poly1305_ref_BEFORENMBYTES 32
#define crypto_box_curve25519xsalsa20poly1305_ref_NONCEBYTES 24
#define crypto_box_curve25519xsalsa20poly1305_ref_ZEROBYTES 32
#define crypto_box_curve25519xsalsa20poly1305_ref_BOXZEROBYTES 16
#ifdef __cplusplus
#include <string>
extern std::string crypto_box_curve25519xsalsa20poly1305_ref(const std::string &,const std::string &,const std::string &,const std::string &);
extern std::string crypto_box_curve25519xsalsa20poly1305_ref_open(const std::string &,const std::string &,const std::string &,const std::string &);
extern std::string crypto_box_curve25519xsalsa20poly1305_ref_keypair(std::string *);
extern "C" {
#endif
extern int crypto_box_curve25519xsalsa20poly1305_ref(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_curve25519xsalsa20poly1305_ref_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_curve25519xsalsa20poly1305_ref_keypair(unsigned char *,unsigned char *);
extern int crypto_box_curve25519xsalsa20poly1305_ref_beforenm(unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_curve25519xsalsa20poly1305_ref_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_box_curve25519xsalsa20poly1305_ref_open_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_box_curve25519xsalsa20poly1305 crypto_box_curve25519xsalsa20poly1305_ref
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_open crypto_box_curve25519xsalsa20poly1305_ref_open
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_open crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_keypair crypto_box_curve25519xsalsa20poly1305_ref_keypair
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_keypair crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_beforenm crypto_box_curve25519xsalsa20poly1305_ref_beforenm
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_beforenm crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_afternm crypto_box_curve25519xsalsa20poly1305_ref_afternm
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_afternm crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_open_afternm crypto_box_curve25519xsalsa20poly1305_ref_open_afternm
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_open_afternm crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_ref_PUBLICKEYBYTES
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_ref_SECRETKEYBYTES
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_ref_BEFORENMBYTES
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_ref_NONCEBYTES
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ref_ZEROBYTES
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_ref_BOXZEROBYTES
/* POTATO crypto_box_curve25519xsalsa20poly1305_ref_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_ref crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_curve25519xsalsa20poly1305_IMPLEMENTATION "crypto_box/curve25519xsalsa20poly1305/ref"
#ifndef crypto_box_curve25519xsalsa20poly1305_ref_VERSION
#define crypto_box_curve25519xsalsa20poly1305_ref_VERSION "-"
#endif
#define crypto_box_curve25519xsalsa20poly1305_VERSION crypto_box_curve25519xsalsa20poly1305_ref_VERSION
#endif

View File

@ -1,33 +0,0 @@
#ifndef crypto_core_hsalsa20_H
#define crypto_core_hsalsa20_H
#define crypto_core_hsalsa20_ref_OUTPUTBYTES 32
#define crypto_core_hsalsa20_ref_INPUTBYTES 16
#define crypto_core_hsalsa20_ref_KEYBYTES 32
#define crypto_core_hsalsa20_ref_CONSTBYTES 16
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_core_hsalsa20_ref(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_core_hsalsa20 crypto_core_hsalsa20_ref
/* POTATO crypto_core_hsalsa20_ref crypto_core_hsalsa20_ref crypto_core_hsalsa20 */
#define crypto_core_hsalsa20_OUTPUTBYTES crypto_core_hsalsa20_ref_OUTPUTBYTES
/* POTATO crypto_core_hsalsa20_ref_OUTPUTBYTES crypto_core_hsalsa20_ref crypto_core_hsalsa20 */
#define crypto_core_hsalsa20_INPUTBYTES crypto_core_hsalsa20_ref_INPUTBYTES
/* POTATO crypto_core_hsalsa20_ref_INPUTBYTES crypto_core_hsalsa20_ref crypto_core_hsalsa20 */
#define crypto_core_hsalsa20_KEYBYTES crypto_core_hsalsa20_ref_KEYBYTES
/* POTATO crypto_core_hsalsa20_ref_KEYBYTES crypto_core_hsalsa20_ref crypto_core_hsalsa20 */
#define crypto_core_hsalsa20_CONSTBYTES crypto_core_hsalsa20_ref_CONSTBYTES
/* POTATO crypto_core_hsalsa20_ref_CONSTBYTES crypto_core_hsalsa20_ref crypto_core_hsalsa20 */
#define crypto_core_hsalsa20_IMPLEMENTATION "crypto_core/hsalsa20/ref"
#ifndef crypto_core_hsalsa20_ref_VERSION
#define crypto_core_hsalsa20_ref_VERSION "-"
#endif
#define crypto_core_hsalsa20_VERSION crypto_core_hsalsa20_ref_VERSION
#endif

View File

@ -1,33 +0,0 @@
#ifndef crypto_core_salsa20_H
#define crypto_core_salsa20_H
#define crypto_core_salsa20_ref_OUTPUTBYTES 64
#define crypto_core_salsa20_ref_INPUTBYTES 16
#define crypto_core_salsa20_ref_KEYBYTES 32
#define crypto_core_salsa20_ref_CONSTBYTES 16
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_core_salsa20_ref(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_core_salsa20 crypto_core_salsa20_ref
/* POTATO crypto_core_salsa20_ref crypto_core_salsa20_ref crypto_core_salsa20 */
#define crypto_core_salsa20_OUTPUTBYTES crypto_core_salsa20_ref_OUTPUTBYTES
/* POTATO crypto_core_salsa20_ref_OUTPUTBYTES crypto_core_salsa20_ref crypto_core_salsa20 */
#define crypto_core_salsa20_INPUTBYTES crypto_core_salsa20_ref_INPUTBYTES
/* POTATO crypto_core_salsa20_ref_INPUTBYTES crypto_core_salsa20_ref crypto_core_salsa20 */
#define crypto_core_salsa20_KEYBYTES crypto_core_salsa20_ref_KEYBYTES
/* POTATO crypto_core_salsa20_ref_KEYBYTES crypto_core_salsa20_ref crypto_core_salsa20 */
#define crypto_core_salsa20_CONSTBYTES crypto_core_salsa20_ref_CONSTBYTES
/* POTATO crypto_core_salsa20_ref_CONSTBYTES crypto_core_salsa20_ref crypto_core_salsa20 */
#define crypto_core_salsa20_IMPLEMENTATION "crypto_core/salsa20/ref"
#ifndef crypto_core_salsa20_ref_VERSION
#define crypto_core_salsa20_ref_VERSION "-"
#endif
#define crypto_core_salsa20_VERSION crypto_core_salsa20_ref_VERSION
#endif

View File

@ -1,33 +0,0 @@
#ifndef crypto_core_salsa2012_H
#define crypto_core_salsa2012_H
#define crypto_core_salsa2012_ref_OUTPUTBYTES 64
#define crypto_core_salsa2012_ref_INPUTBYTES 16
#define crypto_core_salsa2012_ref_KEYBYTES 32
#define crypto_core_salsa2012_ref_CONSTBYTES 16
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_core_salsa2012_ref(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_core_salsa2012 crypto_core_salsa2012_ref
/* POTATO crypto_core_salsa2012_ref crypto_core_salsa2012_ref crypto_core_salsa2012 */
#define crypto_core_salsa2012_OUTPUTBYTES crypto_core_salsa2012_ref_OUTPUTBYTES
/* POTATO crypto_core_salsa2012_ref_OUTPUTBYTES crypto_core_salsa2012_ref crypto_core_salsa2012 */
#define crypto_core_salsa2012_INPUTBYTES crypto_core_salsa2012_ref_INPUTBYTES
/* POTATO crypto_core_salsa2012_ref_INPUTBYTES crypto_core_salsa2012_ref crypto_core_salsa2012 */
#define crypto_core_salsa2012_KEYBYTES crypto_core_salsa2012_ref_KEYBYTES
/* POTATO crypto_core_salsa2012_ref_KEYBYTES crypto_core_salsa2012_ref crypto_core_salsa2012 */
#define crypto_core_salsa2012_CONSTBYTES crypto_core_salsa2012_ref_CONSTBYTES
/* POTATO crypto_core_salsa2012_ref_CONSTBYTES crypto_core_salsa2012_ref crypto_core_salsa2012 */
#define crypto_core_salsa2012_IMPLEMENTATION "crypto_core/salsa2012/ref"
#ifndef crypto_core_salsa2012_ref_VERSION
#define crypto_core_salsa2012_ref_VERSION "-"
#endif
#define crypto_core_salsa2012_VERSION crypto_core_salsa2012_ref_VERSION
#endif

View File

@ -1,33 +0,0 @@
#ifndef crypto_core_salsa208_H
#define crypto_core_salsa208_H
#define crypto_core_salsa208_ref_OUTPUTBYTES 64
#define crypto_core_salsa208_ref_INPUTBYTES 16
#define crypto_core_salsa208_ref_KEYBYTES 32
#define crypto_core_salsa208_ref_CONSTBYTES 16
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_core_salsa208_ref(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_core_salsa208 crypto_core_salsa208_ref
/* POTATO crypto_core_salsa208_ref crypto_core_salsa208_ref crypto_core_salsa208 */
#define crypto_core_salsa208_OUTPUTBYTES crypto_core_salsa208_ref_OUTPUTBYTES
/* POTATO crypto_core_salsa208_ref_OUTPUTBYTES crypto_core_salsa208_ref crypto_core_salsa208 */
#define crypto_core_salsa208_INPUTBYTES crypto_core_salsa208_ref_INPUTBYTES
/* POTATO crypto_core_salsa208_ref_INPUTBYTES crypto_core_salsa208_ref crypto_core_salsa208 */
#define crypto_core_salsa208_KEYBYTES crypto_core_salsa208_ref_KEYBYTES
/* POTATO crypto_core_salsa208_ref_KEYBYTES crypto_core_salsa208_ref crypto_core_salsa208 */
#define crypto_core_salsa208_CONSTBYTES crypto_core_salsa208_ref_CONSTBYTES
/* POTATO crypto_core_salsa208_ref_CONSTBYTES crypto_core_salsa208_ref crypto_core_salsa208 */
#define crypto_core_salsa208_IMPLEMENTATION "crypto_core/salsa208/ref"
#ifndef crypto_core_salsa208_ref_VERSION
#define crypto_core_salsa208_ref_VERSION "-"
#endif
#define crypto_core_salsa208_VERSION crypto_core_salsa208_ref_VERSION
#endif

View File

@ -1,25 +0,0 @@
#ifndef crypto_hash_sha256_H
#define crypto_hash_sha256_H
#define crypto_hash_sha256_ref_BYTES 32
#ifdef __cplusplus
#include <string>
extern std::string crypto_hash_sha256_ref(const std::string &);
extern "C" {
#endif
extern int crypto_hash_sha256_ref(unsigned char *,const unsigned char *,unsigned long long);
#ifdef __cplusplus
}
#endif
#define crypto_hash_sha256 crypto_hash_sha256_ref
/* POTATO crypto_hash_sha256_ref crypto_hash_sha256_ref crypto_hash_sha256 */
#define crypto_hash_sha256_BYTES crypto_hash_sha256_ref_BYTES
/* POTATO crypto_hash_sha256_ref_BYTES crypto_hash_sha256_ref crypto_hash_sha256 */
#define crypto_hash_sha256_IMPLEMENTATION "crypto_hash/sha256/ref"
#ifndef crypto_hash_sha256_ref_VERSION
#define crypto_hash_sha256_ref_VERSION "-"
#endif
#define crypto_hash_sha256_VERSION crypto_hash_sha256_ref_VERSION
#endif

View File

@ -1,25 +0,0 @@
#ifndef crypto_hash_sha512_H
#define crypto_hash_sha512_H
#define crypto_hash_sha512_ref_BYTES 64
#ifdef __cplusplus
#include <string>
extern std::string crypto_hash_sha512_ref(const std::string &);
extern "C" {
#endif
extern int crypto_hash_sha512_ref(unsigned char *,const unsigned char *,unsigned long long);
#ifdef __cplusplus
}
#endif
#define crypto_hash_sha512 crypto_hash_sha512_ref
/* POTATO crypto_hash_sha512_ref crypto_hash_sha512_ref crypto_hash_sha512 */
#define crypto_hash_sha512_BYTES crypto_hash_sha512_ref_BYTES
/* POTATO crypto_hash_sha512_ref_BYTES crypto_hash_sha512_ref crypto_hash_sha512 */
#define crypto_hash_sha512_IMPLEMENTATION "crypto_hash/sha512/ref"
#ifndef crypto_hash_sha512_ref_VERSION
#define crypto_hash_sha512_ref_VERSION "-"
#endif
#define crypto_hash_sha512_VERSION crypto_hash_sha512_ref_VERSION
#endif

View File

@ -1,27 +0,0 @@
#ifndef crypto_hashblocks_sha256_H
#define crypto_hashblocks_sha256_H
#define crypto_hashblocks_sha256_ref_STATEBYTES 32
#define crypto_hashblocks_sha256_ref_BLOCKBYTES 64
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_hashblocks_sha256_ref(unsigned char *,const unsigned char *,unsigned long long);
#ifdef __cplusplus
}
#endif
#define crypto_hashblocks_sha256 crypto_hashblocks_sha256_ref
/* POTATO crypto_hashblocks_sha256_ref crypto_hashblocks_sha256_ref crypto_hashblocks_sha256 */
#define crypto_hashblocks_sha256_STATEBYTES crypto_hashblocks_sha256_ref_STATEBYTES
/* POTATO crypto_hashblocks_sha256_ref_STATEBYTES crypto_hashblocks_sha256_ref crypto_hashblocks_sha256 */
#define crypto_hashblocks_sha256_BLOCKBYTES crypto_hashblocks_sha256_ref_BLOCKBYTES
/* POTATO crypto_hashblocks_sha256_ref_BLOCKBYTES crypto_hashblocks_sha256_ref crypto_hashblocks_sha256 */
#define crypto_hashblocks_sha256_IMPLEMENTATION "crypto_hashblocks/sha256/ref"
#ifndef crypto_hashblocks_sha256_ref_VERSION
#define crypto_hashblocks_sha256_ref_VERSION "-"
#endif
#define crypto_hashblocks_sha256_VERSION crypto_hashblocks_sha256_ref_VERSION
#endif

View File

@ -1,27 +0,0 @@
#ifndef crypto_hashblocks_sha512_H
#define crypto_hashblocks_sha512_H
#define crypto_hashblocks_sha512_ref_STATEBYTES 64
#define crypto_hashblocks_sha512_ref_BLOCKBYTES 128
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_hashblocks_sha512_ref(unsigned char *,const unsigned char *,unsigned long long);
#ifdef __cplusplus
}
#endif
#define crypto_hashblocks_sha512 crypto_hashblocks_sha512_ref
/* POTATO crypto_hashblocks_sha512_ref crypto_hashblocks_sha512_ref crypto_hashblocks_sha512 */
#define crypto_hashblocks_sha512_STATEBYTES crypto_hashblocks_sha512_ref_STATEBYTES
/* POTATO crypto_hashblocks_sha512_ref_STATEBYTES crypto_hashblocks_sha512_ref crypto_hashblocks_sha512 */
#define crypto_hashblocks_sha512_BLOCKBYTES crypto_hashblocks_sha512_ref_BLOCKBYTES
/* POTATO crypto_hashblocks_sha512_ref_BLOCKBYTES crypto_hashblocks_sha512_ref crypto_hashblocks_sha512 */
#define crypto_hashblocks_sha512_IMPLEMENTATION "crypto_hashblocks/sha512/ref"
#ifndef crypto_hashblocks_sha512_ref_VERSION
#define crypto_hashblocks_sha512_ref_VERSION "-"
#endif
#define crypto_hashblocks_sha512_VERSION crypto_hashblocks_sha512_ref_VERSION
#endif

View File

@ -1,32 +0,0 @@
#ifndef crypto_onetimeauth_poly1305_H
#define crypto_onetimeauth_poly1305_H
#define crypto_onetimeauth_poly1305_ref_BYTES 16
#define crypto_onetimeauth_poly1305_ref_KEYBYTES 32
#ifdef __cplusplus
#include <string>
extern std::string crypto_onetimeauth_poly1305_ref(const std::string &,const std::string &);
extern void crypto_onetimeauth_poly1305_ref_verify(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_onetimeauth_poly1305_ref(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_onetimeauth_poly1305_ref_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_onetimeauth_poly1305 crypto_onetimeauth_poly1305_ref
/* POTATO crypto_onetimeauth_poly1305_ref crypto_onetimeauth_poly1305_ref crypto_onetimeauth_poly1305 */
#define crypto_onetimeauth_poly1305_verify crypto_onetimeauth_poly1305_ref_verify
/* POTATO crypto_onetimeauth_poly1305_ref_verify crypto_onetimeauth_poly1305_ref crypto_onetimeauth_poly1305 */
#define crypto_onetimeauth_poly1305_BYTES crypto_onetimeauth_poly1305_ref_BYTES
/* POTATO crypto_onetimeauth_poly1305_ref_BYTES crypto_onetimeauth_poly1305_ref crypto_onetimeauth_poly1305 */
#define crypto_onetimeauth_poly1305_KEYBYTES crypto_onetimeauth_poly1305_ref_KEYBYTES
/* POTATO crypto_onetimeauth_poly1305_ref_KEYBYTES crypto_onetimeauth_poly1305_ref crypto_onetimeauth_poly1305 */
#define crypto_onetimeauth_poly1305_IMPLEMENTATION "crypto_onetimeauth/poly1305/ref"
#ifndef crypto_onetimeauth_poly1305_ref_VERSION
#define crypto_onetimeauth_poly1305_ref_VERSION "-"
#endif
#define crypto_onetimeauth_poly1305_VERSION crypto_onetimeauth_poly1305_ref_VERSION
#endif

View File

@ -1,32 +0,0 @@
#ifndef crypto_scalarmult_curve25519_H
#define crypto_scalarmult_curve25519_H
#define crypto_scalarmult_curve25519_ref_BYTES 32
#define crypto_scalarmult_curve25519_ref_SCALARBYTES 32
#ifdef __cplusplus
#include <string>
extern std::string crypto_scalarmult_curve25519_ref(const std::string &,const std::string &);
extern std::string crypto_scalarmult_curve25519_ref_base(const std::string &);
extern "C" {
#endif
extern int crypto_scalarmult_curve25519_ref(unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_scalarmult_curve25519_ref_base(unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_scalarmult_curve25519 crypto_scalarmult_curve25519_ref
/* POTATO crypto_scalarmult_curve25519_ref crypto_scalarmult_curve25519_ref crypto_scalarmult_curve25519 */
#define crypto_scalarmult_curve25519_base crypto_scalarmult_curve25519_ref_base
/* POTATO crypto_scalarmult_curve25519_ref_base crypto_scalarmult_curve25519_ref crypto_scalarmult_curve25519 */
#define crypto_scalarmult_curve25519_BYTES crypto_scalarmult_curve25519_ref_BYTES
/* POTATO crypto_scalarmult_curve25519_ref_BYTES crypto_scalarmult_curve25519_ref crypto_scalarmult_curve25519 */
#define crypto_scalarmult_curve25519_SCALARBYTES crypto_scalarmult_curve25519_ref_SCALARBYTES
/* POTATO crypto_scalarmult_curve25519_ref_SCALARBYTES crypto_scalarmult_curve25519_ref crypto_scalarmult_curve25519 */
#define crypto_scalarmult_curve25519_IMPLEMENTATION "crypto_scalarmult/curve25519/ref"
#ifndef crypto_scalarmult_curve25519_ref_VERSION
#define crypto_scalarmult_curve25519_ref_VERSION "-"
#endif
#define crypto_scalarmult_curve25519_VERSION crypto_scalarmult_curve25519_ref_VERSION
#endif

View File

@ -1,38 +0,0 @@
#ifndef crypto_secretbox_xsalsa20poly1305_H
#define crypto_secretbox_xsalsa20poly1305_H
#define crypto_secretbox_xsalsa20poly1305_ref_KEYBYTES 32
#define crypto_secretbox_xsalsa20poly1305_ref_NONCEBYTES 24
#define crypto_secretbox_xsalsa20poly1305_ref_ZEROBYTES 32
#define crypto_secretbox_xsalsa20poly1305_ref_BOXZEROBYTES 16
#ifdef __cplusplus
#include <string>
extern std::string crypto_secretbox_xsalsa20poly1305_ref(const std::string &,const std::string &,const std::string &);
extern std::string crypto_secretbox_xsalsa20poly1305_ref_open(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_secretbox_xsalsa20poly1305_ref(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_secretbox_xsalsa20poly1305_ref_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_secretbox_xsalsa20poly1305 crypto_secretbox_xsalsa20poly1305_ref
/* POTATO crypto_secretbox_xsalsa20poly1305_ref crypto_secretbox_xsalsa20poly1305_ref crypto_secretbox_xsalsa20poly1305 */
#define crypto_secretbox_xsalsa20poly1305_open crypto_secretbox_xsalsa20poly1305_ref_open
/* POTATO crypto_secretbox_xsalsa20poly1305_ref_open crypto_secretbox_xsalsa20poly1305_ref crypto_secretbox_xsalsa20poly1305 */
#define crypto_secretbox_xsalsa20poly1305_KEYBYTES crypto_secretbox_xsalsa20poly1305_ref_KEYBYTES
/* POTATO crypto_secretbox_xsalsa20poly1305_ref_KEYBYTES crypto_secretbox_xsalsa20poly1305_ref crypto_secretbox_xsalsa20poly1305 */
#define crypto_secretbox_xsalsa20poly1305_NONCEBYTES crypto_secretbox_xsalsa20poly1305_ref_NONCEBYTES
/* POTATO crypto_secretbox_xsalsa20poly1305_ref_NONCEBYTES crypto_secretbox_xsalsa20poly1305_ref crypto_secretbox_xsalsa20poly1305 */
#define crypto_secretbox_xsalsa20poly1305_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ref_ZEROBYTES
/* POTATO crypto_secretbox_xsalsa20poly1305_ref_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ref crypto_secretbox_xsalsa20poly1305 */
#define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_ref_BOXZEROBYTES
/* POTATO crypto_secretbox_xsalsa20poly1305_ref_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_ref crypto_secretbox_xsalsa20poly1305 */
#define crypto_secretbox_xsalsa20poly1305_IMPLEMENTATION "crypto_secretbox/xsalsa20poly1305/ref"
#ifndef crypto_secretbox_xsalsa20poly1305_ref_VERSION
#define crypto_secretbox_xsalsa20poly1305_ref_VERSION "-"
#endif
#define crypto_secretbox_xsalsa20poly1305_VERSION crypto_secretbox_xsalsa20poly1305_ref_VERSION
#endif

View File

@ -1,39 +0,0 @@
#ifndef crypto_sign_edwards25519sha512batch_H
#define crypto_sign_edwards25519sha512batch_H
#define crypto_sign_edwards25519sha512batch_ref_SECRETKEYBYTES 64
#define crypto_sign_edwards25519sha512batch_ref_PUBLICKEYBYTES 32
#define crypto_sign_edwards25519sha512batch_ref_BYTES 64
#ifdef __cplusplus
#include <string>
extern std::string crypto_sign_edwards25519sha512batch_ref(const std::string &,const std::string &);
extern std::string crypto_sign_edwards25519sha512batch_ref_open(const std::string &,const std::string &);
extern std::string crypto_sign_edwards25519sha512batch_ref_keypair(std::string *);
extern "C" {
#endif
extern int crypto_sign_edwards25519sha512batch_ref(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_sign_edwards25519sha512batch_ref_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_sign_edwards25519sha512batch_ref_keypair(unsigned char *,unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_sign_edwards25519sha512batch crypto_sign_edwards25519sha512batch_ref
/* POTATO crypto_sign_edwards25519sha512batch_ref crypto_sign_edwards25519sha512batch_ref crypto_sign_edwards25519sha512batch */
#define crypto_sign_edwards25519sha512batch_open crypto_sign_edwards25519sha512batch_ref_open
/* POTATO crypto_sign_edwards25519sha512batch_ref_open crypto_sign_edwards25519sha512batch_ref crypto_sign_edwards25519sha512batch */
#define crypto_sign_edwards25519sha512batch_keypair crypto_sign_edwards25519sha512batch_ref_keypair
/* POTATO crypto_sign_edwards25519sha512batch_ref_keypair crypto_sign_edwards25519sha512batch_ref crypto_sign_edwards25519sha512batch */
#define crypto_sign_edwards25519sha512batch_BYTES crypto_sign_edwards25519sha512batch_ref_BYTES
/* POTATO crypto_sign_edwards25519sha512batch_ref_BYTES crypto_sign_edwards25519sha512batch_ref crypto_sign_edwards25519sha512batch */
#define crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES crypto_sign_edwards25519sha512batch_ref_PUBLICKEYBYTES
/* POTATO crypto_sign_edwards25519sha512batch_ref_PUBLICKEYBYTES crypto_sign_edwards25519sha512batch_ref crypto_sign_edwards25519sha512batch */
#define crypto_sign_edwards25519sha512batch_SECRETKEYBYTES crypto_sign_edwards25519sha512batch_ref_SECRETKEYBYTES
/* POTATO crypto_sign_edwards25519sha512batch_ref_SECRETKEYBYTES crypto_sign_edwards25519sha512batch_ref crypto_sign_edwards25519sha512batch */
#define crypto_sign_edwards25519sha512batch_IMPLEMENTATION "crypto_sign/edwards25519sha512batch/ref"
#ifndef crypto_sign_edwards25519sha512batch_ref_VERSION
#define crypto_sign_edwards25519sha512batch_ref_VERSION "-"
#endif
#define crypto_sign_edwards25519sha512batch_VERSION crypto_sign_edwards25519sha512batch_ref_VERSION
#endif

View File

@ -1,43 +0,0 @@
#ifndef crypto_stream_salsa20_H
#define crypto_stream_salsa20_H
#define crypto_stream_salsa20_ref_KEYBYTES 32
#define crypto_stream_salsa20_ref_NONCEBYTES 8
#ifdef __cplusplus
#include <string>
extern std::string crypto_stream_salsa20_ref(size_t,const std::string &,const std::string &);
extern std::string crypto_stream_salsa20_ref_xor(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_stream_salsa20_ref(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa20_ref_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa20_ref_beforenm(unsigned char *,const unsigned char *);
extern int crypto_stream_salsa20_ref_afternm(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa20_ref_xor_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_stream_salsa20 crypto_stream_salsa20_ref
/* POTATO crypto_stream_salsa20_ref crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_xor crypto_stream_salsa20_ref_xor
/* POTATO crypto_stream_salsa20_ref_xor crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_beforenm crypto_stream_salsa20_ref_beforenm
/* POTATO crypto_stream_salsa20_ref_beforenm crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_afternm crypto_stream_salsa20_ref_afternm
/* POTATO crypto_stream_salsa20_ref_afternm crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_xor_afternm crypto_stream_salsa20_ref_xor_afternm
/* POTATO crypto_stream_salsa20_ref_xor_afternm crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_KEYBYTES crypto_stream_salsa20_ref_KEYBYTES
/* POTATO crypto_stream_salsa20_ref_KEYBYTES crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_NONCEBYTES crypto_stream_salsa20_ref_NONCEBYTES
/* POTATO crypto_stream_salsa20_ref_NONCEBYTES crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_BEFORENMBYTES crypto_stream_salsa20_ref_BEFORENMBYTES
/* POTATO crypto_stream_salsa20_ref_BEFORENMBYTES crypto_stream_salsa20_ref crypto_stream_salsa20 */
#define crypto_stream_salsa20_IMPLEMENTATION "crypto_stream/salsa20/ref"
#ifndef crypto_stream_salsa20_ref_VERSION
#define crypto_stream_salsa20_ref_VERSION "-"
#endif
#define crypto_stream_salsa20_VERSION crypto_stream_salsa20_ref_VERSION
#endif

View File

@ -1,43 +0,0 @@
#ifndef crypto_stream_salsa2012_H
#define crypto_stream_salsa2012_H
#define crypto_stream_salsa2012_ref_KEYBYTES 32
#define crypto_stream_salsa2012_ref_NONCEBYTES 8
#ifdef __cplusplus
#include <string>
extern std::string crypto_stream_salsa2012_ref(size_t,const std::string &,const std::string &);
extern std::string crypto_stream_salsa2012_ref_xor(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_stream_salsa2012_ref(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa2012_ref_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa2012_ref_beforenm(unsigned char *,const unsigned char *);
extern int crypto_stream_salsa2012_ref_afternm(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa2012_ref_xor_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_stream_salsa2012 crypto_stream_salsa2012_ref
/* POTATO crypto_stream_salsa2012_ref crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_xor crypto_stream_salsa2012_ref_xor
/* POTATO crypto_stream_salsa2012_ref_xor crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_beforenm crypto_stream_salsa2012_ref_beforenm
/* POTATO crypto_stream_salsa2012_ref_beforenm crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_afternm crypto_stream_salsa2012_ref_afternm
/* POTATO crypto_stream_salsa2012_ref_afternm crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_xor_afternm crypto_stream_salsa2012_ref_xor_afternm
/* POTATO crypto_stream_salsa2012_ref_xor_afternm crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_KEYBYTES crypto_stream_salsa2012_ref_KEYBYTES
/* POTATO crypto_stream_salsa2012_ref_KEYBYTES crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_NONCEBYTES crypto_stream_salsa2012_ref_NONCEBYTES
/* POTATO crypto_stream_salsa2012_ref_NONCEBYTES crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_BEFORENMBYTES crypto_stream_salsa2012_ref_BEFORENMBYTES
/* POTATO crypto_stream_salsa2012_ref_BEFORENMBYTES crypto_stream_salsa2012_ref crypto_stream_salsa2012 */
#define crypto_stream_salsa2012_IMPLEMENTATION "crypto_stream/salsa2012/ref"
#ifndef crypto_stream_salsa2012_ref_VERSION
#define crypto_stream_salsa2012_ref_VERSION "-"
#endif
#define crypto_stream_salsa2012_VERSION crypto_stream_salsa2012_ref_VERSION
#endif

View File

@ -1,43 +0,0 @@
#ifndef crypto_stream_salsa208_H
#define crypto_stream_salsa208_H
#define crypto_stream_salsa208_ref_KEYBYTES 32
#define crypto_stream_salsa208_ref_NONCEBYTES 8
#ifdef __cplusplus
#include <string>
extern std::string crypto_stream_salsa208_ref(size_t,const std::string &,const std::string &);
extern std::string crypto_stream_salsa208_ref_xor(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_stream_salsa208_ref(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa208_ref_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa208_ref_beforenm(unsigned char *,const unsigned char *);
extern int crypto_stream_salsa208_ref_afternm(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_salsa208_ref_xor_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_stream_salsa208 crypto_stream_salsa208_ref
/* POTATO crypto_stream_salsa208_ref crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_xor crypto_stream_salsa208_ref_xor
/* POTATO crypto_stream_salsa208_ref_xor crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_beforenm crypto_stream_salsa208_ref_beforenm
/* POTATO crypto_stream_salsa208_ref_beforenm crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_afternm crypto_stream_salsa208_ref_afternm
/* POTATO crypto_stream_salsa208_ref_afternm crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_xor_afternm crypto_stream_salsa208_ref_xor_afternm
/* POTATO crypto_stream_salsa208_ref_xor_afternm crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_KEYBYTES crypto_stream_salsa208_ref_KEYBYTES
/* POTATO crypto_stream_salsa208_ref_KEYBYTES crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_NONCEBYTES crypto_stream_salsa208_ref_NONCEBYTES
/* POTATO crypto_stream_salsa208_ref_NONCEBYTES crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_BEFORENMBYTES crypto_stream_salsa208_ref_BEFORENMBYTES
/* POTATO crypto_stream_salsa208_ref_BEFORENMBYTES crypto_stream_salsa208_ref crypto_stream_salsa208 */
#define crypto_stream_salsa208_IMPLEMENTATION "crypto_stream/salsa208/ref"
#ifndef crypto_stream_salsa208_ref_VERSION
#define crypto_stream_salsa208_ref_VERSION "-"
#endif
#define crypto_stream_salsa208_VERSION crypto_stream_salsa208_ref_VERSION
#endif

View File

@ -1,43 +0,0 @@
#ifndef crypto_stream_xsalsa20_H
#define crypto_stream_xsalsa20_H
#define crypto_stream_xsalsa20_ref_KEYBYTES 32
#define crypto_stream_xsalsa20_ref_NONCEBYTES 24
#ifdef __cplusplus
#include <string>
extern std::string crypto_stream_xsalsa20_ref(size_t,const std::string &,const std::string &);
extern std::string crypto_stream_xsalsa20_ref_xor(const std::string &,const std::string &,const std::string &);
extern "C" {
#endif
extern int crypto_stream_xsalsa20_ref(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_xsalsa20_ref_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_xsalsa20_ref_beforenm(unsigned char *,const unsigned char *);
extern int crypto_stream_xsalsa20_ref_afternm(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_xsalsa20_ref_xor_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_stream_xsalsa20 crypto_stream_xsalsa20_ref
/* POTATO crypto_stream_xsalsa20_ref crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_xor crypto_stream_xsalsa20_ref_xor
/* POTATO crypto_stream_xsalsa20_ref_xor crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_beforenm crypto_stream_xsalsa20_ref_beforenm
/* POTATO crypto_stream_xsalsa20_ref_beforenm crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_afternm crypto_stream_xsalsa20_ref_afternm
/* POTATO crypto_stream_xsalsa20_ref_afternm crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_xor_afternm crypto_stream_xsalsa20_ref_xor_afternm
/* POTATO crypto_stream_xsalsa20_ref_xor_afternm crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_KEYBYTES crypto_stream_xsalsa20_ref_KEYBYTES
/* POTATO crypto_stream_xsalsa20_ref_KEYBYTES crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_NONCEBYTES crypto_stream_xsalsa20_ref_NONCEBYTES
/* POTATO crypto_stream_xsalsa20_ref_NONCEBYTES crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_BEFORENMBYTES crypto_stream_xsalsa20_ref_BEFORENMBYTES
/* POTATO crypto_stream_xsalsa20_ref_BEFORENMBYTES crypto_stream_xsalsa20_ref crypto_stream_xsalsa20 */
#define crypto_stream_xsalsa20_IMPLEMENTATION "crypto_stream/xsalsa20/ref"
#ifndef crypto_stream_xsalsa20_ref_VERSION
#define crypto_stream_xsalsa20_ref_VERSION "-"
#endif
#define crypto_stream_xsalsa20_VERSION crypto_stream_xsalsa20_ref_VERSION
#endif

View File

@ -1,6 +0,0 @@
#ifndef CRYPTO_UINT32
#define CRYPTO_UINT32
typedef unsigned int crypto_uint32;
#endif

View File

@ -1,24 +0,0 @@
#ifndef crypto_verify_16_H
#define crypto_verify_16_H
#define crypto_verify_16_ref_BYTES 16
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_verify_16_ref(const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_verify_16 crypto_verify_16_ref
/* POTATO crypto_verify_16_ref crypto_verify_16_ref crypto_verify_16 */
#define crypto_verify_16_BYTES crypto_verify_16_ref_BYTES
/* POTATO crypto_verify_16_ref_BYTES crypto_verify_16_ref crypto_verify_16 */
#define crypto_verify_16_IMPLEMENTATION "crypto_verify/16/ref"
#ifndef crypto_verify_16_ref_VERSION
#define crypto_verify_16_ref_VERSION "-"
#endif
#define crypto_verify_16_VERSION crypto_verify_16_ref_VERSION
#endif

View File

@ -1,24 +0,0 @@
#ifndef crypto_verify_32_H
#define crypto_verify_32_H
#define crypto_verify_32_ref_BYTES 32
#ifdef __cplusplus
#include <string>
extern "C" {
#endif
extern int crypto_verify_32_ref(const unsigned char *,const unsigned char *);
#ifdef __cplusplus
}
#endif
#define crypto_verify_32 crypto_verify_32_ref
/* POTATO crypto_verify_32_ref crypto_verify_32_ref crypto_verify_32 */
#define crypto_verify_32_BYTES crypto_verify_32_ref_BYTES
/* POTATO crypto_verify_32_ref_BYTES crypto_verify_32_ref crypto_verify_32 */
#define crypto_verify_32_IMPLEMENTATION "crypto_verify/32/ref"
#ifndef crypto_verify_32_ref_VERSION
#define crypto_verify_32_ref_VERSION "-"
#endif
#define crypto_verify_32_VERSION crypto_verify_32_ref_VERSION
#endif

View File

@ -1,24 +0,0 @@
#include <api.h>
#include <crypto_auth_hmacsha256.h>
#include <crypto_auth_hmacsha512256.h>
#include <crypto_box_curve25519xsalsa20poly1305.h>
#include <crypto_core_hsalsa20.h>
#include <crypto_core_salsa20.h>
#include <crypto_core_salsa2012.h>
#include <crypto_core_salsa208.h>
#include <crypto_hash_sha256.h>
#include <crypto_hash_sha512.h>
#include <crypto_hashblocks_sha256.h>
#include <crypto_hashblocks_sha512.h>
#include <crypto_onetimeauth_poly1305.h>
#include <crypto_scalarmult_curve25519.h>
#include <crypto_secretbox_xsalsa20poly1305.h>
#include <crypto_sign_edwards25519sha512batch.h>
#include <crypto_stream_salsa20.h>
#include <crypto_stream_salsa2012.h>
#include <crypto_stream_salsa208.h>
#include <crypto_stream_xsalsa20.h>
#include <crypto_uint32.h>
#include <crypto_verify_16.h>
#include <crypto_verify_32.h>
#include <randombytes.h>

View File

@ -1,24 +0,0 @@
/*
randombytes/devurandom.h version 20080713
D. J. Bernstein
Public domain.
*/
#ifndef randombytes_devurandom_H
#define randombytes_devurandom_H
#ifdef __cplusplus
extern "C" {
#endif
extern void randombytes(unsigned char *,unsigned long long);
#ifdef __cplusplus
}
#endif
#ifndef randombytes_implementation
#define randombytes_implementation "devurandom"
#endif
#endif

View File

@ -1,2 +0,0 @@
NACL_SOURCES := \
$(NACL_BASE)/crypto_auth_hmacsha256_ref/hmac.c $(NACL_BASE)/crypto_auth_hmacsha256_ref/verify.c $(NACL_BASE)/crypto_auth_hmacsha512256_ref/hmac.c $(NACL_BASE)/crypto_auth_hmacsha512256_ref/verify.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/after.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/before.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/box.c $(NACL_BASE)/crypto_box_curve25519xsalsa20poly1305_ref/keypair.c $(NACL_BASE)/crypto_core_hsalsa20_ref/core.c $(NACL_BASE)/crypto_core_salsa2012_ref/core.c $(NACL_BASE)/crypto_core_salsa208_ref/core.c $(NACL_BASE)/crypto_core_salsa20_ref/core.c $(NACL_BASE)/crypto_hash_sha256_ref/hash.c $(NACL_BASE)/crypto_hash_sha512_ref/hash.c $(NACL_BASE)/crypto_hashblocks_sha256_ref/blocks.c $(NACL_BASE)/crypto_hashblocks_sha512_ref/blocks.c $(NACL_BASE)/crypto_onetimeauth_poly1305_ref/auth.c $(NACL_BASE)/crypto_onetimeauth_poly1305_ref/verify.c $(NACL_BASE)/crypto_scalarmult_curve25519_ref/base.c $(NACL_BASE)/crypto_scalarmult_curve25519_ref/smult.c $(NACL_BASE)/crypto_secretbox_xsalsa20poly1305_ref/box.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe25519.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_0.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_1.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_add.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_cmov.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_copy.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_frombytes.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_invert.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_isnegative.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_isnonzero.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_mul.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_neg.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_pow22523.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_sq.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_sq2.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_sub.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/fe_tobytes.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge25519.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_add.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_double_scalarmult.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_frombytes.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_madd.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_msub.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p1p1_to_p2.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p1p1_to_p3.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p2_0.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p2_dbl.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p3_0.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p3_dbl.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p3_to_cached.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p3_to_p2.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_p3_tobytes.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_precomp_0.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_scalarmult_base.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_sub.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/ge_tobytes.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/keypair.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/open.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/sc25519.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/sc_muladd.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/sc_reduce.c $(NACL_BASE)/crypto_sign_edwards25519sha512batch_ref/sign.c $(NACL_BASE)/crypto_stream_salsa2012_ref/stream.c $(NACL_BASE)/crypto_stream_salsa2012_ref/xor.c $(NACL_BASE)/crypto_stream_salsa208_ref/stream.c $(NACL_BASE)/crypto_stream_salsa208_ref/xor.c $(NACL_BASE)/crypto_stream_salsa20_ref/stream.c $(NACL_BASE)/crypto_stream_salsa20_ref/xor.c $(NACL_BASE)/crypto_stream_xsalsa20_ref/stream.c $(NACL_BASE)/crypto_stream_xsalsa20_ref/xor.c $(NACL_BASE)/crypto_verify_16_ref/verify.c $(NACL_BASE)/crypto_verify_32_ref/verify.c

View File

@ -1,56 +0,0 @@
crypto_verify
crypto_verify_BYTES
crypto_core
crypto_core_OUTPUTBYTES
crypto_core_INPUTBYTES
crypto_core_KEYBYTES
crypto_core_CONSTBYTES
crypto_hashblocks
crypto_hashblocks_STATEBYTES
crypto_hashblocks_BLOCKBYTES
crypto_hash
crypto_hash_BYTES
crypto_stream
crypto_stream_xor
crypto_stream_beforenm
crypto_stream_afternm
crypto_stream_xor_afternm
crypto_stream_KEYBYTES
crypto_stream_NONCEBYTES
crypto_stream_BEFORENMBYTES
crypto_onetimeauth
crypto_onetimeauth_verify
crypto_onetimeauth_BYTES
crypto_onetimeauth_KEYBYTES
crypto_auth
crypto_auth_verify
crypto_auth_BYTES
crypto_auth_KEYBYTES
crypto_secretbox
crypto_secretbox_open
crypto_secretbox_KEYBYTES
crypto_secretbox_NONCEBYTES
crypto_secretbox_ZEROBYTES
crypto_secretbox_BOXZEROBYTES
crypto_scalarmult
crypto_scalarmult_base
crypto_scalarmult_BYTES
crypto_scalarmult_SCALARBYTES
crypto_box
crypto_box_open
crypto_box_keypair
crypto_box_beforenm
crypto_box_afternm
crypto_box_open_afternm
crypto_box_PUBLICKEYBYTES
crypto_box_SECRETKEYBYTES
crypto_box_BEFORENMBYTES
crypto_box_NONCEBYTES
crypto_box_ZEROBYTES
crypto_box_BOXZEROBYTES
crypto_sign
crypto_sign_open
crypto_sign_keypair
crypto_sign_BYTES
crypto_sign_PUBLICKEYBYTES
crypto_sign_SECRETKEYBYTES

View File

@ -1,26 +0,0 @@
extern int crypto_verify(const unsigned char *,const unsigned char *);
extern int crypto_core(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_hashblocks(unsigned char *,const unsigned char *,unsigned long long);
extern int crypto_hash(unsigned char *,const unsigned char *,unsigned long long);
extern int crypto_stream(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_beforenm(unsigned char *,const unsigned char *);
extern int crypto_stream_afternm(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_stream_xor_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_onetimeauth(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_onetimeauth_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_auth(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_auth_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_secretbox(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_secretbox_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_scalarmult(unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_scalarmult_base(unsigned char *,const unsigned char *);
extern int crypto_box(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_keypair(unsigned char *,unsigned char *);
extern int crypto_box_beforenm(unsigned char *,const unsigned char *,const unsigned char *);
extern int crypto_box_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_box_open_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
extern int crypto_sign(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_sign_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
extern int crypto_sign_keypair(unsigned char *,unsigned char *);

View File

@ -1,17 +0,0 @@
extern std::string crypto_auth(const std::string &,const std::string &);
extern void crypto_auth_verify(const std::string &,const std::string &,const std::string &);
extern std::string crypto_box(const std::string &,const std::string &,const std::string &,const std::string &);
extern std::string crypto_box_open(const std::string &,const std::string &,const std::string &,const std::string &);
extern std::string crypto_box_keypair(std::string *);
extern std::string crypto_hash(const std::string &);
extern std::string crypto_onetimeauth(const std::string &,const std::string &);
extern void crypto_onetimeauth_verify(const std::string &,const std::string &,const std::string &);
extern std::string crypto_scalarmult(const std::string &,const std::string &);
extern std::string crypto_scalarmult_base(const std::string &);
extern std::string crypto_secretbox(const std::string &,const std::string &,const std::string &);
extern std::string crypto_secretbox_open(const std::string &,const std::string &,const std::string &);
extern std::string crypto_stream(size_t,const std::string &,const std::string &);
extern std::string crypto_stream_xor(const std::string &,const std::string &,const std::string &);
extern std::string crypto_sign(const std::string &,const std::string &);
extern std::string crypto_sign_open(const std::string &,const std::string &);
extern std::string crypto_sign_keypair(std::string *);

View File

@ -1,2 +0,0 @@
#define CRYPTO_BYTES 32
#define CRYPTO_KEYBYTES 32

View File

@ -1,18 +0,0 @@
#ifndef crypto_auth_H
#define crypto_auth_H
#include "crypto_auth_hmacsha256.h"
#define crypto_auth crypto_auth_hmacsha256
/* CHEESEBURGER crypto_auth_hmacsha256 */
#define crypto_auth_verify crypto_auth_hmacsha256_verify
/* CHEESEBURGER crypto_auth_hmacsha256_verify */
#define crypto_auth_BYTES crypto_auth_hmacsha256_BYTES
/* CHEESEBURGER crypto_auth_hmacsha256_BYTES */
#define crypto_auth_KEYBYTES crypto_auth_hmacsha256_KEYBYTES
/* CHEESEBURGER crypto_auth_hmacsha256_KEYBYTES */
#define crypto_auth_PRIMITIVE "hmacsha256"
#define crypto_auth_IMPLEMENTATION crypto_auth_hmacsha256_IMPLEMENTATION
#define crypto_auth_VERSION crypto_auth_hmacsha256_VERSION
#endif

View File

@ -1,83 +0,0 @@
/*
* 20080913
* D. J. Bernstein
* Public domain.
* */
#include "crypto_hashblocks_sha256.h"
#include "crypto_auth.h"
#define blocks crypto_hashblocks_sha256
typedef unsigned int uint32;
static const char iv[32] = {
0x6a,0x09,0xe6,0x67,
0xbb,0x67,0xae,0x85,
0x3c,0x6e,0xf3,0x72,
0xa5,0x4f,0xf5,0x3a,
0x51,0x0e,0x52,0x7f,
0x9b,0x05,0x68,0x8c,
0x1f,0x83,0xd9,0xab,
0x5b,0xe0,0xcd,0x19,
} ;
int crypto_auth(unsigned char *out,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
{
unsigned char h[32];
unsigned char padded[128];
unsigned i;
unsigned long long bits = 512 + (inlen << 3);
for (i = 0;i < 32;++i) h[i] = iv[i];
for (i = 0;i < 32;++i) padded[i] = k[i] ^ 0x36;
for (i = 32;i < 64;++i) padded[i] = 0x36;
blocks(h,padded,64);
blocks(h,in,inlen);
in += inlen;
inlen &= 63;
in -= inlen;
for (i = 0;i < inlen;++i) padded[i] = in[i];
padded[inlen] = 0x80;
if (inlen < 56) {
for (i = inlen + 1;i < 56;++i) padded[i] = 0;
padded[56] = bits >> 56;
padded[57] = bits >> 48;
padded[58] = bits >> 40;
padded[59] = bits >> 32;
padded[60] = bits >> 24;
padded[61] = bits >> 16;
padded[62] = bits >> 8;
padded[63] = bits;
blocks(h,padded,64);
} else {
for (i = inlen + 1;i < 120;++i) padded[i] = 0;
padded[120] = bits >> 56;
padded[121] = bits >> 48;
padded[122] = bits >> 40;
padded[123] = bits >> 32;
padded[124] = bits >> 24;
padded[125] = bits >> 16;
padded[126] = bits >> 8;
padded[127] = bits;
blocks(h,padded,128);
}
for (i = 0;i < 32;++i) padded[i] = k[i] ^ 0x5c;
for (i = 32;i < 64;++i) padded[i] = 0x5c;
for (i = 0;i < 32;++i) padded[64 + i] = h[i];
for (i = 0;i < 32;++i) out[i] = iv[i];
for (i = 32;i < 64;++i) padded[64 + i] = 0;
padded[64 + 32] = 0x80;
padded[64 + 62] = 3;
blocks(out,padded,128);
return 0;
}

View File

@ -1,9 +0,0 @@
#include "crypto_verify_32.h"
#include "crypto_auth.h"
int crypto_auth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
{
unsigned char correct[32];
crypto_auth(correct,in,inlen,k);
return crypto_verify_32(h,correct);
}

View File

@ -1,2 +0,0 @@
#define CRYPTO_BYTES 32
#define CRYPTO_KEYBYTES 32

View File

@ -1,18 +0,0 @@
#ifndef crypto_auth_H
#define crypto_auth_H
#include "crypto_auth_hmacsha512256.h"
#define crypto_auth crypto_auth_hmacsha512256
/* CHEESEBURGER crypto_auth_hmacsha512256 */
#define crypto_auth_verify crypto_auth_hmacsha512256_verify
/* CHEESEBURGER crypto_auth_hmacsha512256_verify */
#define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES
/* CHEESEBURGER crypto_auth_hmacsha512256_BYTES */
#define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES
/* CHEESEBURGER crypto_auth_hmacsha512256_KEYBYTES */
#define crypto_auth_PRIMITIVE "hmacsha512256"
#define crypto_auth_IMPLEMENTATION crypto_auth_hmacsha512256_IMPLEMENTATION
#define crypto_auth_VERSION crypto_auth_hmacsha512256_VERSION
#endif

View File

@ -1,86 +0,0 @@
/*
* 20080913
* D. J. Bernstein
* Public domain.
* */
#include "crypto_hashblocks_sha512.h"
#include "crypto_auth.h"
#define blocks crypto_hashblocks_sha512
typedef unsigned long long uint64;
static const unsigned char iv[64] = {
0x6a,0x09,0xe6,0x67,0xf3,0xbc,0xc9,0x08,
0xbb,0x67,0xae,0x85,0x84,0xca,0xa7,0x3b,
0x3c,0x6e,0xf3,0x72,0xfe,0x94,0xf8,0x2b,
0xa5,0x4f,0xf5,0x3a,0x5f,0x1d,0x36,0xf1,
0x51,0x0e,0x52,0x7f,0xad,0xe6,0x82,0xd1,
0x9b,0x05,0x68,0x8c,0x2b,0x3e,0x6c,0x1f,
0x1f,0x83,0xd9,0xab,0xfb,0x41,0xbd,0x6b,
0x5b,0xe0,0xcd,0x19,0x13,0x7e,0x21,0x79
} ;
int crypto_auth(unsigned char *out,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
{
unsigned char h[64];
unsigned char padded[256];
unsigned i;
unsigned long long bytes = 128 + inlen;
for (i = 0;i < 64;++i) h[i] = iv[i];
for (i = 0;i < 32;++i) padded[i] = k[i] ^ 0x36;
for (i = 32;i < 128;++i) padded[i] = 0x36;
blocks(h,padded,128);
blocks(h,in,inlen);
in += inlen;
inlen &= 127;
in -= inlen;
for (i = 0;i < inlen;++i) padded[i] = in[i];
padded[inlen] = 0x80;
if (inlen < 112) {
for (i = inlen + 1;i < 119;++i) padded[i] = 0;
padded[119] = bytes >> 61;
padded[120] = bytes >> 53;
padded[121] = bytes >> 45;
padded[122] = bytes >> 37;
padded[123] = bytes >> 29;
padded[124] = bytes >> 21;
padded[125] = bytes >> 13;
padded[126] = bytes >> 5;
padded[127] = bytes << 3;
blocks(h,padded,128);
} else {
for (i = inlen + 1;i < 247;++i) padded[i] = 0;
padded[247] = bytes >> 61;
padded[248] = bytes >> 53;
padded[249] = bytes >> 45;
padded[250] = bytes >> 37;
padded[251] = bytes >> 29;
padded[252] = bytes >> 21;
padded[253] = bytes >> 13;
padded[254] = bytes >> 5;
padded[255] = bytes << 3;
blocks(h,padded,256);
}
for (i = 0;i < 32;++i) padded[i] = k[i] ^ 0x5c;
for (i = 32;i < 128;++i) padded[i] = 0x5c;
for (i = 0;i < 64;++i) padded[128 + i] = h[i];
for (i = 0;i < 64;++i) h[i] = iv[i];
for (i = 64;i < 128;++i) padded[128 + i] = 0;
padded[128 + 64] = 0x80;
padded[128 + 126] = 6;
blocks(h,padded,256);
for (i = 0;i < 32;++i) out[i] = h[i];
return 0;
}

View File

@ -1,9 +0,0 @@
#include "crypto_verify_32.h"
#include "crypto_auth.h"
int crypto_auth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
{
unsigned char correct[32];
crypto_auth(correct,in,inlen,k);
return crypto_verify_32(h,correct);
}

View File

@ -1,22 +0,0 @@
#include "crypto_secretbox_xsalsa20poly1305.h"
#include "crypto_box.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);
}

View File

@ -1,6 +0,0 @@
#define CRYPTO_PUBLICKEYBYTES 32
#define CRYPTO_SECRETKEYBYTES 32
#define CRYPTO_BEFORENMBYTES 32
#define CRYPTO_NONCEBYTES 24
#define CRYPTO_ZEROBYTES 32
#define CRYPTO_BOXZEROBYTES 16

View File

@ -1,17 +0,0 @@
#include "crypto_core_hsalsa20.h"
#include "crypto_scalarmult_curve25519.h"
#include "crypto_box.h"
static const unsigned char sigma[16] = "expand 32-byte 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);
}

View File

@ -1,27 +0,0 @@
#include "crypto_box.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);
}

View File

@ -1,34 +0,0 @@
#ifndef crypto_box_H
#define crypto_box_H
#include "crypto_box_curve25519xsalsa20poly1305.h"
#define crypto_box crypto_box_curve25519xsalsa20poly1305
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305 */
#define crypto_box_open crypto_box_curve25519xsalsa20poly1305_open
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_open */
#define crypto_box_keypair crypto_box_curve25519xsalsa20poly1305_keypair
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_keypair */
#define crypto_box_beforenm crypto_box_curve25519xsalsa20poly1305_beforenm
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_beforenm */
#define crypto_box_afternm crypto_box_curve25519xsalsa20poly1305_afternm
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_afternm */
#define crypto_box_open_afternm crypto_box_curve25519xsalsa20poly1305_open_afternm
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_open_afternm */
#define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES */
#define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES */
#define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES */
#define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_NONCEBYTES */
#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_ZEROBYTES */
#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
/* CHEESEBURGER crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES */
#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305"
#define crypto_box_IMPLEMENTATION crypto_box_curve25519xsalsa20poly1305_IMPLEMENTATION
#define crypto_box_VERSION crypto_box_curve25519xsalsa20poly1305_VERSION
#endif

View File

@ -1,12 +0,0 @@
#include "crypto_scalarmult_curve25519.h"
#include "crypto_box.h"
#include "randombytes.h"
int crypto_box_keypair(
unsigned char *pk,
unsigned char *sk
)
{
randombytes(sk,32);
return crypto_scalarmult_curve25519_base(pk,sk);
}

View File

@ -1,4 +0,0 @@
#define CRYPTO_OUTPUTBYTES 32
#define CRYPTO_INPUTBYTES 16
#define CRYPTO_KEYBYTES 32
#define CRYPTO_CONSTBYTES 16

View File

@ -1,135 +0,0 @@
/*
version 20080912
D. J. Bernstein
Public domain.
*/
#include "crypto_core.h"
#define ROUNDS 20
typedef unsigned int uint32;
static uint32 rotate(uint32 u,int c)
{
return (u << c) | (u >> (32 - c));
}
static uint32 load_littleendian(const unsigned char *x)
{
return
(uint32) (x[0]) \
| (((uint32) (x[1])) << 8) \
| (((uint32) (x[2])) << 16) \
| (((uint32) (x[3])) << 24)
;
}
static void store_littleendian(unsigned char *x,uint32 u)
{
x[0] = u; u >>= 8;
x[1] = u; u >>= 8;
x[2] = u; u >>= 8;
x[3] = u;
}
int crypto_core(
unsigned char *out,
const unsigned char *in,
const unsigned char *k,
const unsigned char *c
)
{
uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
uint32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
int i;
j0 = x0 = load_littleendian(c + 0);
j1 = x1 = load_littleendian(k + 0);
j2 = x2 = load_littleendian(k + 4);
j3 = x3 = load_littleendian(k + 8);
j4 = x4 = load_littleendian(k + 12);
j5 = x5 = load_littleendian(c + 4);
j6 = x6 = load_littleendian(in + 0);
j7 = x7 = load_littleendian(in + 4);
j8 = x8 = load_littleendian(in + 8);
j9 = x9 = load_littleendian(in + 12);
j10 = x10 = load_littleendian(c + 8);
j11 = x11 = load_littleendian(k + 16);
j12 = x12 = load_littleendian(k + 20);
j13 = x13 = load_littleendian(k + 24);
j14 = x14 = load_littleendian(k + 28);
j15 = x15 = load_littleendian(c + 12);
for (i = ROUNDS;i > 0;i -= 2) {
x4 ^= rotate( x0+x12, 7);
x8 ^= rotate( x4+ x0, 9);
x12 ^= rotate( x8+ x4,13);
x0 ^= rotate(x12+ x8,18);
x9 ^= rotate( x5+ x1, 7);
x13 ^= rotate( x9+ x5, 9);
x1 ^= rotate(x13+ x9,13);
x5 ^= rotate( x1+x13,18);
x14 ^= rotate(x10+ x6, 7);
x2 ^= rotate(x14+x10, 9);
x6 ^= rotate( x2+x14,13);
x10 ^= rotate( x6+ x2,18);
x3 ^= rotate(x15+x11, 7);
x7 ^= rotate( x3+x15, 9);
x11 ^= rotate( x7+ x3,13);
x15 ^= rotate(x11+ x7,18);
x1 ^= rotate( x0+ x3, 7);
x2 ^= rotate( x1+ x0, 9);
x3 ^= rotate( x2+ x1,13);
x0 ^= rotate( x3+ x2,18);
x6 ^= rotate( x5+ x4, 7);
x7 ^= rotate( x6+ x5, 9);
x4 ^= rotate( x7+ x6,13);
x5 ^= rotate( x4+ x7,18);
x11 ^= rotate(x10+ x9, 7);
x8 ^= rotate(x11+x10, 9);
x9 ^= rotate( x8+x11,13);
x10 ^= rotate( x9+ x8,18);
x12 ^= rotate(x15+x14, 7);
x13 ^= rotate(x12+x15, 9);
x14 ^= rotate(x13+x12,13);
x15 ^= rotate(x14+x13,18);
}
x0 += j0;
x1 += j1;
x2 += j2;
x3 += j3;
x4 += j4;
x5 += j5;
x6 += j6;
x7 += j7;
x8 += j8;
x9 += j9;
x10 += j10;
x11 += j11;
x12 += j12;
x13 += j13;
x14 += j14;
x15 += j15;
x0 -= load_littleendian(c + 0);
x5 -= load_littleendian(c + 4);
x10 -= load_littleendian(c + 8);
x15 -= load_littleendian(c + 12);
x6 -= load_littleendian(in + 0);
x7 -= load_littleendian(in + 4);
x8 -= load_littleendian(in + 8);
x9 -= load_littleendian(in + 12);
store_littleendian(out + 0,x0);
store_littleendian(out + 4,x5);
store_littleendian(out + 8,x10);
store_littleendian(out + 12,x15);
store_littleendian(out + 16,x6);
store_littleendian(out + 20,x7);
store_littleendian(out + 24,x8);
store_littleendian(out + 28,x9);
return 0;
}

View File

@ -1,20 +0,0 @@
#ifndef crypto_core_H
#define crypto_core_H
#include "crypto_core_hsalsa20.h"
#define crypto_core crypto_core_hsalsa20
/* CHEESEBURGER crypto_core_hsalsa20 */
#define crypto_core_OUTPUTBYTES crypto_core_hsalsa20_OUTPUTBYTES
/* CHEESEBURGER crypto_core_hsalsa20_OUTPUTBYTES */
#define crypto_core_INPUTBYTES crypto_core_hsalsa20_INPUTBYTES
/* CHEESEBURGER crypto_core_hsalsa20_INPUTBYTES */
#define crypto_core_KEYBYTES crypto_core_hsalsa20_KEYBYTES
/* CHEESEBURGER crypto_core_hsalsa20_KEYBYTES */
#define crypto_core_CONSTBYTES crypto_core_hsalsa20_CONSTBYTES
/* CHEESEBURGER crypto_core_hsalsa20_CONSTBYTES */
#define crypto_core_PRIMITIVE "hsalsa20"
#define crypto_core_IMPLEMENTATION crypto_core_hsalsa20_IMPLEMENTATION
#define crypto_core_VERSION crypto_core_hsalsa20_VERSION
#endif

View File

@ -1 +0,0 @@
Daniel J. Bernstein

View File

@ -1,4 +0,0 @@
#define CRYPTO_OUTPUTBYTES 64
#define CRYPTO_INPUTBYTES 16
#define CRYPTO_KEYBYTES 32
#define CRYPTO_CONSTBYTES 16

View File

@ -1,134 +0,0 @@
/*
version 20080913
D. J. Bernstein
Public domain.
*/
#include "crypto_core.h"
#define ROUNDS 12
typedef unsigned int uint32;
static uint32 rotate(uint32 u,int c)
{
return (u << c) | (u >> (32 - c));
}
static uint32 load_littleendian(const unsigned char *x)
{
return
(uint32) (x[0]) \
| (((uint32) (x[1])) << 8) \
| (((uint32) (x[2])) << 16) \
| (((uint32) (x[3])) << 24)
;
}
static void store_littleendian(unsigned char *x,uint32 u)
{
x[0] = u; u >>= 8;
x[1] = u; u >>= 8;
x[2] = u; u >>= 8;
x[3] = u;
}
int crypto_core(
unsigned char *out,
const unsigned char *in,
const unsigned char *k,
const unsigned char *c
)
{
uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
uint32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
int i;
j0 = x0 = load_littleendian(c + 0);
j1 = x1 = load_littleendian(k + 0);
j2 = x2 = load_littleendian(k + 4);
j3 = x3 = load_littleendian(k + 8);
j4 = x4 = load_littleendian(k + 12);
j5 = x5 = load_littleendian(c + 4);
j6 = x6 = load_littleendian(in + 0);
j7 = x7 = load_littleendian(in + 4);
j8 = x8 = load_littleendian(in + 8);
j9 = x9 = load_littleendian(in + 12);
j10 = x10 = load_littleendian(c + 8);
j11 = x11 = load_littleendian(k + 16);
j12 = x12 = load_littleendian(k + 20);
j13 = x13 = load_littleendian(k + 24);
j14 = x14 = load_littleendian(k + 28);
j15 = x15 = load_littleendian(c + 12);
for (i = ROUNDS;i > 0;i -= 2) {
x4 ^= rotate( x0+x12, 7);
x8 ^= rotate( x4+ x0, 9);
x12 ^= rotate( x8+ x4,13);
x0 ^= rotate(x12+ x8,18);
x9 ^= rotate( x5+ x1, 7);
x13 ^= rotate( x9+ x5, 9);
x1 ^= rotate(x13+ x9,13);
x5 ^= rotate( x1+x13,18);
x14 ^= rotate(x10+ x6, 7);
x2 ^= rotate(x14+x10, 9);
x6 ^= rotate( x2+x14,13);
x10 ^= rotate( x6+ x2,18);
x3 ^= rotate(x15+x11, 7);
x7 ^= rotate( x3+x15, 9);
x11 ^= rotate( x7+ x3,13);
x15 ^= rotate(x11+ x7,18);
x1 ^= rotate( x0+ x3, 7);
x2 ^= rotate( x1+ x0, 9);
x3 ^= rotate( x2+ x1,13);
x0 ^= rotate( x3+ x2,18);
x6 ^= rotate( x5+ x4, 7);
x7 ^= rotate( x6+ x5, 9);
x4 ^= rotate( x7+ x6,13);
x5 ^= rotate( x4+ x7,18);
x11 ^= rotate(x10+ x9, 7);
x8 ^= rotate(x11+x10, 9);
x9 ^= rotate( x8+x11,13);
x10 ^= rotate( x9+ x8,18);
x12 ^= rotate(x15+x14, 7);
x13 ^= rotate(x12+x15, 9);
x14 ^= rotate(x13+x12,13);
x15 ^= rotate(x14+x13,18);
}
x0 += j0;
x1 += j1;
x2 += j2;
x3 += j3;
x4 += j4;
x5 += j5;
x6 += j6;
x7 += j7;
x8 += j8;
x9 += j9;
x10 += j10;
x11 += j11;
x12 += j12;
x13 += j13;
x14 += j14;
x15 += j15;
store_littleendian(out + 0,x0);
store_littleendian(out + 4,x1);
store_littleendian(out + 8,x2);
store_littleendian(out + 12,x3);
store_littleendian(out + 16,x4);
store_littleendian(out + 20,x5);
store_littleendian(out + 24,x6);
store_littleendian(out + 28,x7);
store_littleendian(out + 32,x8);
store_littleendian(out + 36,x9);
store_littleendian(out + 40,x10);
store_littleendian(out + 44,x11);
store_littleendian(out + 48,x12);
store_littleendian(out + 52,x13);
store_littleendian(out + 56,x14);
store_littleendian(out + 60,x15);
return 0;
}

View File

@ -1,20 +0,0 @@
#ifndef crypto_core_H
#define crypto_core_H
#include "crypto_core_salsa2012.h"
#define crypto_core crypto_core_salsa2012
/* CHEESEBURGER crypto_core_salsa2012 */
#define crypto_core_OUTPUTBYTES crypto_core_salsa2012_OUTPUTBYTES
/* CHEESEBURGER crypto_core_salsa2012_OUTPUTBYTES */
#define crypto_core_INPUTBYTES crypto_core_salsa2012_INPUTBYTES
/* CHEESEBURGER crypto_core_salsa2012_INPUTBYTES */
#define crypto_core_KEYBYTES crypto_core_salsa2012_KEYBYTES
/* CHEESEBURGER crypto_core_salsa2012_KEYBYTES */
#define crypto_core_CONSTBYTES crypto_core_salsa2012_CONSTBYTES
/* CHEESEBURGER crypto_core_salsa2012_CONSTBYTES */
#define crypto_core_PRIMITIVE "salsa2012"
#define crypto_core_IMPLEMENTATION crypto_core_salsa2012_IMPLEMENTATION
#define crypto_core_VERSION crypto_core_salsa2012_VERSION
#endif

View File

@ -1 +0,0 @@
Daniel J. Bernstein

View File

@ -1,4 +0,0 @@
#define CRYPTO_OUTPUTBYTES 64
#define CRYPTO_INPUTBYTES 16
#define CRYPTO_KEYBYTES 32
#define CRYPTO_CONSTBYTES 16

View File

@ -1,134 +0,0 @@
/*
version 20080913
D. J. Bernstein
Public domain.
*/
#include "crypto_core.h"
#define ROUNDS 8
typedef unsigned int uint32;
static uint32 rotate(uint32 u,int c)
{
return (u << c) | (u >> (32 - c));
}
static uint32 load_littleendian(const unsigned char *x)
{
return
(uint32) (x[0]) \
| (((uint32) (x[1])) << 8) \
| (((uint32) (x[2])) << 16) \
| (((uint32) (x[3])) << 24)
;
}
static void store_littleendian(unsigned char *x,uint32 u)
{
x[0] = u; u >>= 8;
x[1] = u; u >>= 8;
x[2] = u; u >>= 8;
x[3] = u;
}
int crypto_core(
unsigned char *out,
const unsigned char *in,
const unsigned char *k,
const unsigned char *c
)
{
uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
uint32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
int i;
j0 = x0 = load_littleendian(c + 0);
j1 = x1 = load_littleendian(k + 0);
j2 = x2 = load_littleendian(k + 4);
j3 = x3 = load_littleendian(k + 8);
j4 = x4 = load_littleendian(k + 12);
j5 = x5 = load_littleendian(c + 4);
j6 = x6 = load_littleendian(in + 0);
j7 = x7 = load_littleendian(in + 4);
j8 = x8 = load_littleendian(in + 8);
j9 = x9 = load_littleendian(in + 12);
j10 = x10 = load_littleendian(c + 8);
j11 = x11 = load_littleendian(k + 16);
j12 = x12 = load_littleendian(k + 20);
j13 = x13 = load_littleendian(k + 24);
j14 = x14 = load_littleendian(k + 28);
j15 = x15 = load_littleendian(c + 12);
for (i = ROUNDS;i > 0;i -= 2) {
x4 ^= rotate( x0+x12, 7);
x8 ^= rotate( x4+ x0, 9);
x12 ^= rotate( x8+ x4,13);
x0 ^= rotate(x12+ x8,18);
x9 ^= rotate( x5+ x1, 7);
x13 ^= rotate( x9+ x5, 9);
x1 ^= rotate(x13+ x9,13);
x5 ^= rotate( x1+x13,18);
x14 ^= rotate(x10+ x6, 7);
x2 ^= rotate(x14+x10, 9);
x6 ^= rotate( x2+x14,13);
x10 ^= rotate( x6+ x2,18);
x3 ^= rotate(x15+x11, 7);
x7 ^= rotate( x3+x15, 9);
x11 ^= rotate( x7+ x3,13);
x15 ^= rotate(x11+ x7,18);
x1 ^= rotate( x0+ x3, 7);
x2 ^= rotate( x1+ x0, 9);
x3 ^= rotate( x2+ x1,13);
x0 ^= rotate( x3+ x2,18);
x6 ^= rotate( x5+ x4, 7);
x7 ^= rotate( x6+ x5, 9);
x4 ^= rotate( x7+ x6,13);
x5 ^= rotate( x4+ x7,18);
x11 ^= rotate(x10+ x9, 7);
x8 ^= rotate(x11+x10, 9);
x9 ^= rotate( x8+x11,13);
x10 ^= rotate( x9+ x8,18);
x12 ^= rotate(x15+x14, 7);
x13 ^= rotate(x12+x15, 9);
x14 ^= rotate(x13+x12,13);
x15 ^= rotate(x14+x13,18);
}
x0 += j0;
x1 += j1;
x2 += j2;
x3 += j3;
x4 += j4;
x5 += j5;
x6 += j6;
x7 += j7;
x8 += j8;
x9 += j9;
x10 += j10;
x11 += j11;
x12 += j12;
x13 += j13;
x14 += j14;
x15 += j15;
store_littleendian(out + 0,x0);
store_littleendian(out + 4,x1);
store_littleendian(out + 8,x2);
store_littleendian(out + 12,x3);
store_littleendian(out + 16,x4);
store_littleendian(out + 20,x5);
store_littleendian(out + 24,x6);
store_littleendian(out + 28,x7);
store_littleendian(out + 32,x8);
store_littleendian(out + 36,x9);
store_littleendian(out + 40,x10);
store_littleendian(out + 44,x11);
store_littleendian(out + 48,x12);
store_littleendian(out + 52,x13);
store_littleendian(out + 56,x14);
store_littleendian(out + 60,x15);
return 0;
}

View File

@ -1,20 +0,0 @@
#ifndef crypto_core_H
#define crypto_core_H
#include "crypto_core_salsa208.h"
#define crypto_core crypto_core_salsa208
/* CHEESEBURGER crypto_core_salsa208 */
#define crypto_core_OUTPUTBYTES crypto_core_salsa208_OUTPUTBYTES
/* CHEESEBURGER crypto_core_salsa208_OUTPUTBYTES */
#define crypto_core_INPUTBYTES crypto_core_salsa208_INPUTBYTES
/* CHEESEBURGER crypto_core_salsa208_INPUTBYTES */
#define crypto_core_KEYBYTES crypto_core_salsa208_KEYBYTES
/* CHEESEBURGER crypto_core_salsa208_KEYBYTES */
#define crypto_core_CONSTBYTES crypto_core_salsa208_CONSTBYTES
/* CHEESEBURGER crypto_core_salsa208_CONSTBYTES */
#define crypto_core_PRIMITIVE "salsa208"
#define crypto_core_IMPLEMENTATION crypto_core_salsa208_IMPLEMENTATION
#define crypto_core_VERSION crypto_core_salsa208_VERSION
#endif

View File

@ -1 +0,0 @@
Daniel J. Bernstein

View File

@ -1,4 +0,0 @@
#define CRYPTO_OUTPUTBYTES 64
#define CRYPTO_INPUTBYTES 16
#define CRYPTO_KEYBYTES 32
#define CRYPTO_CONSTBYTES 16

View File

@ -1,134 +0,0 @@
/*
version 20080912
D. J. Bernstein
Public domain.
*/
#include "crypto_core.h"
#define ROUNDS 20
typedef unsigned int uint32;
static uint32 rotate(uint32 u,int c)
{
return (u << c) | (u >> (32 - c));
}
static uint32 load_littleendian(const unsigned char *x)
{
return
(uint32) (x[0]) \
| (((uint32) (x[1])) << 8) \
| (((uint32) (x[2])) << 16) \
| (((uint32) (x[3])) << 24)
;
}
static void store_littleendian(unsigned char *x,uint32 u)
{
x[0] = u; u >>= 8;
x[1] = u; u >>= 8;
x[2] = u; u >>= 8;
x[3] = u;
}
int crypto_core(
unsigned char *out,
const unsigned char *in,
const unsigned char *k,
const unsigned char *c
)
{
uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
uint32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
int i;
j0 = x0 = load_littleendian(c + 0);
j1 = x1 = load_littleendian(k + 0);
j2 = x2 = load_littleendian(k + 4);
j3 = x3 = load_littleendian(k + 8);
j4 = x4 = load_littleendian(k + 12);
j5 = x5 = load_littleendian(c + 4);
j6 = x6 = load_littleendian(in + 0);
j7 = x7 = load_littleendian(in + 4);
j8 = x8 = load_littleendian(in + 8);
j9 = x9 = load_littleendian(in + 12);
j10 = x10 = load_littleendian(c + 8);
j11 = x11 = load_littleendian(k + 16);
j12 = x12 = load_littleendian(k + 20);
j13 = x13 = load_littleendian(k + 24);
j14 = x14 = load_littleendian(k + 28);
j15 = x15 = load_littleendian(c + 12);
for (i = ROUNDS;i > 0;i -= 2) {
x4 ^= rotate( x0+x12, 7);
x8 ^= rotate( x4+ x0, 9);
x12 ^= rotate( x8+ x4,13);
x0 ^= rotate(x12+ x8,18);
x9 ^= rotate( x5+ x1, 7);
x13 ^= rotate( x9+ x5, 9);
x1 ^= rotate(x13+ x9,13);
x5 ^= rotate( x1+x13,18);
x14 ^= rotate(x10+ x6, 7);
x2 ^= rotate(x14+x10, 9);
x6 ^= rotate( x2+x14,13);
x10 ^= rotate( x6+ x2,18);
x3 ^= rotate(x15+x11, 7);
x7 ^= rotate( x3+x15, 9);
x11 ^= rotate( x7+ x3,13);
x15 ^= rotate(x11+ x7,18);
x1 ^= rotate( x0+ x3, 7);
x2 ^= rotate( x1+ x0, 9);
x3 ^= rotate( x2+ x1,13);
x0 ^= rotate( x3+ x2,18);
x6 ^= rotate( x5+ x4, 7);
x7 ^= rotate( x6+ x5, 9);
x4 ^= rotate( x7+ x6,13);
x5 ^= rotate( x4+ x7,18);
x11 ^= rotate(x10+ x9, 7);
x8 ^= rotate(x11+x10, 9);
x9 ^= rotate( x8+x11,13);
x10 ^= rotate( x9+ x8,18);
x12 ^= rotate(x15+x14, 7);
x13 ^= rotate(x12+x15, 9);
x14 ^= rotate(x13+x12,13);
x15 ^= rotate(x14+x13,18);
}
x0 += j0;
x1 += j1;
x2 += j2;
x3 += j3;
x4 += j4;
x5 += j5;
x6 += j6;
x7 += j7;
x8 += j8;
x9 += j9;
x10 += j10;
x11 += j11;
x12 += j12;
x13 += j13;
x14 += j14;
x15 += j15;
store_littleendian(out + 0,x0);
store_littleendian(out + 4,x1);
store_littleendian(out + 8,x2);
store_littleendian(out + 12,x3);
store_littleendian(out + 16,x4);
store_littleendian(out + 20,x5);
store_littleendian(out + 24,x6);
store_littleendian(out + 28,x7);
store_littleendian(out + 32,x8);
store_littleendian(out + 36,x9);
store_littleendian(out + 40,x10);
store_littleendian(out + 44,x11);
store_littleendian(out + 48,x12);
store_littleendian(out + 52,x13);
store_littleendian(out + 56,x14);
store_littleendian(out + 60,x15);
return 0;
}

View File

@ -1,20 +0,0 @@
#ifndef crypto_core_H
#define crypto_core_H
#include "crypto_core_salsa20.h"
#define crypto_core crypto_core_salsa20
/* CHEESEBURGER crypto_core_salsa20 */
#define crypto_core_OUTPUTBYTES crypto_core_salsa20_OUTPUTBYTES
/* CHEESEBURGER crypto_core_salsa20_OUTPUTBYTES */
#define crypto_core_INPUTBYTES crypto_core_salsa20_INPUTBYTES
/* CHEESEBURGER crypto_core_salsa20_INPUTBYTES */
#define crypto_core_KEYBYTES crypto_core_salsa20_KEYBYTES
/* CHEESEBURGER crypto_core_salsa20_KEYBYTES */
#define crypto_core_CONSTBYTES crypto_core_salsa20_CONSTBYTES
/* CHEESEBURGER crypto_core_salsa20_CONSTBYTES */
#define crypto_core_PRIMITIVE "salsa20"
#define crypto_core_IMPLEMENTATION crypto_core_salsa20_IMPLEMENTATION
#define crypto_core_VERSION crypto_core_salsa20_VERSION
#endif

View File

@ -1 +0,0 @@
Daniel J. Bernstein

View File

@ -1 +0,0 @@
#define CRYPTO_BYTES 32

View File

@ -1,14 +0,0 @@
#ifndef crypto_hash_H
#define crypto_hash_H
#include "crypto_hash_sha256.h"
#define crypto_hash crypto_hash_sha256
/* CHEESEBURGER crypto_hash_sha256 */
#define crypto_hash_BYTES crypto_hash_sha256_BYTES
/* CHEESEBURGER crypto_hash_sha256_BYTES */
#define crypto_hash_PRIMITIVE "sha256"
#define crypto_hash_IMPLEMENTATION crypto_hash_sha256_IMPLEMENTATION
#define crypto_hash_VERSION crypto_hash_sha256_VERSION
#endif

View File

@ -1,69 +0,0 @@
/*
20080913
D. J. Bernstein
Public domain.
*/
#include "crypto_hashblocks_sha256.h"
#include "crypto_hash.h"
#define blocks crypto_hashblocks_sha256
typedef unsigned int uint32;
static const char iv[32] = {
0x6a,0x09,0xe6,0x67,
0xbb,0x67,0xae,0x85,
0x3c,0x6e,0xf3,0x72,
0xa5,0x4f,0xf5,0x3a,
0x51,0x0e,0x52,0x7f,
0x9b,0x05,0x68,0x8c,
0x1f,0x83,0xd9,0xab,
0x5b,0xe0,0xcd,0x19,
} ;
int crypto_hash(unsigned char *out,const unsigned char *in,unsigned long long inlen)
{
unsigned char h[32];
unsigned char padded[128];
unsigned i;
unsigned long long bits = inlen << 3;
for (i = 0;i < 32;++i) h[i] = iv[i];
blocks(h,in,inlen);
in += inlen;
inlen &= 63;
in -= inlen;
for (i = 0;i < inlen;++i) padded[i] = in[i];
padded[inlen] = 0x80;
if (inlen < 56) {
for (i = inlen + 1;i < 56;++i) padded[i] = 0;
padded[56] = bits >> 56;
padded[57] = bits >> 48;
padded[58] = bits >> 40;
padded[59] = bits >> 32;
padded[60] = bits >> 24;
padded[61] = bits >> 16;
padded[62] = bits >> 8;
padded[63] = bits;
blocks(h,padded,64);
} else {
for (i = inlen + 1;i < 120;++i) padded[i] = 0;
padded[120] = bits >> 56;
padded[121] = bits >> 48;
padded[122] = bits >> 40;
padded[123] = bits >> 32;
padded[124] = bits >> 24;
padded[125] = bits >> 16;
padded[126] = bits >> 8;
padded[127] = bits;
blocks(h,padded,128);
}
for (i = 0;i < 32;++i) out[i] = h[i];
return 0;
}

View File

@ -1 +0,0 @@
Daniel J. Bernstein (wrapper around crypto_hashblocks/sha256)

View File

@ -1 +0,0 @@
#define CRYPTO_BYTES 64

View File

@ -1,14 +0,0 @@
#ifndef crypto_hash_H
#define crypto_hash_H
#include "crypto_hash_sha512.h"
#define crypto_hash crypto_hash_sha512
/* CHEESEBURGER crypto_hash_sha512 */
#define crypto_hash_BYTES crypto_hash_sha512_BYTES
/* CHEESEBURGER crypto_hash_sha512_BYTES */
#define crypto_hash_PRIMITIVE "sha512"
#define crypto_hash_IMPLEMENTATION crypto_hash_sha512_IMPLEMENTATION
#define crypto_hash_VERSION crypto_hash_sha512_VERSION
#endif

View File

@ -1,71 +0,0 @@
/*
20080913
D. J. Bernstein
Public domain.
*/
#include "crypto_hashblocks_sha512.h"
#include "crypto_hash.h"
#define blocks crypto_hashblocks_sha512
static const unsigned char iv[64] = {
0x6a,0x09,0xe6,0x67,0xf3,0xbc,0xc9,0x08,
0xbb,0x67,0xae,0x85,0x84,0xca,0xa7,0x3b,
0x3c,0x6e,0xf3,0x72,0xfe,0x94,0xf8,0x2b,
0xa5,0x4f,0xf5,0x3a,0x5f,0x1d,0x36,0xf1,
0x51,0x0e,0x52,0x7f,0xad,0xe6,0x82,0xd1,
0x9b,0x05,0x68,0x8c,0x2b,0x3e,0x6c,0x1f,
0x1f,0x83,0xd9,0xab,0xfb,0x41,0xbd,0x6b,
0x5b,0xe0,0xcd,0x19,0x13,0x7e,0x21,0x79
} ;
typedef unsigned long long uint64;
int crypto_hash(unsigned char *out,const unsigned char *in,unsigned long long inlen)
{
unsigned char h[64];
unsigned char padded[256];
unsigned i;
unsigned long long bytes = inlen;
for (i = 0;i < 64;++i) h[i] = iv[i];
blocks(h,in,inlen);
in += inlen;
inlen &= 127;
in -= inlen;
for (i = 0;i < inlen;++i) padded[i] = in[i];
padded[inlen] = 0x80;
if (inlen < 112) {
for (i = inlen + 1;i < 119;++i) padded[i] = 0;
padded[119] = bytes >> 61;
padded[120] = bytes >> 53;
padded[121] = bytes >> 45;
padded[122] = bytes >> 37;
padded[123] = bytes >> 29;
padded[124] = bytes >> 21;
padded[125] = bytes >> 13;
padded[126] = bytes >> 5;
padded[127] = bytes << 3;
blocks(h,padded,128);
} else {
for (i = inlen + 1;i < 247;++i) padded[i] = 0;
padded[247] = bytes >> 61;
padded[248] = bytes >> 53;
padded[249] = bytes >> 45;
padded[250] = bytes >> 37;
padded[251] = bytes >> 29;
padded[252] = bytes >> 21;
padded[253] = bytes >> 13;
padded[254] = bytes >> 5;
padded[255] = bytes << 3;
blocks(h,padded,256);
}
for (i = 0;i < 64;++i) out[i] = h[i];
return 0;
}

View File

@ -1 +0,0 @@
Daniel J. Bernstein (wrapper around crypto_hashblocks/sha512)

View File

@ -1,2 +0,0 @@
#define CRYPTO_STATEBYTES 32
#define CRYPTO_BLOCKBYTES 64

View File

@ -1,212 +0,0 @@
#include "crypto_hashblocks.h"
typedef unsigned int uint32;
static uint32 load_bigendian(const unsigned char *x)
{
return
(uint32) (x[3]) \
| (((uint32) (x[2])) << 8) \
| (((uint32) (x[1])) << 16) \
| (((uint32) (x[0])) << 24)
;
}
static void store_bigendian(unsigned char *x,uint32 u)
{
x[3] = u; u >>= 8;
x[2] = u; u >>= 8;
x[1] = u; u >>= 8;
x[0] = u;
}
#define SHR(x,c) ((x) >> (c))
#define ROTR(x,c) (((x) >> (c)) | ((x) << (32 - (c))))
#define Ch(x,y,z) ((x & y) ^ (~x & z))
#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z))
#define Sigma0(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22))
#define Sigma1(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25))
#define sigma0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3))
#define sigma1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10))
#define M(w0,w14,w9,w1) w0 = sigma1(w14) + w9 + sigma0(w1) + w0;
#define EXPAND \
M(w0 ,w14,w9 ,w1 ) \
M(w1 ,w15,w10,w2 ) \
M(w2 ,w0 ,w11,w3 ) \
M(w3 ,w1 ,w12,w4 ) \
M(w4 ,w2 ,w13,w5 ) \
M(w5 ,w3 ,w14,w6 ) \
M(w6 ,w4 ,w15,w7 ) \
M(w7 ,w5 ,w0 ,w8 ) \
M(w8 ,w6 ,w1 ,w9 ) \
M(w9 ,w7 ,w2 ,w10) \
M(w10,w8 ,w3 ,w11) \
M(w11,w9 ,w4 ,w12) \
M(w12,w10,w5 ,w13) \
M(w13,w11,w6 ,w14) \
M(w14,w12,w7 ,w15) \
M(w15,w13,w8 ,w0 )
#define F(w,k) \
T1 = h + Sigma1(e) + Ch(e,f,g) + k + w; \
T2 = Sigma0(a) + Maj(a,b,c); \
h = g; \
g = f; \
f = e; \
e = d + T1; \
d = c; \
c = b; \
b = a; \
a = T1 + T2;
int crypto_hashblocks(unsigned char *statebytes,const unsigned char *in,unsigned long long inlen)
{
uint32 state[8];
uint32 a;
uint32 b;
uint32 c;
uint32 d;
uint32 e;
uint32 f;
uint32 g;
uint32 h;
uint32 T1;
uint32 T2;
a = load_bigendian(statebytes + 0); state[0] = a;
b = load_bigendian(statebytes + 4); state[1] = b;
c = load_bigendian(statebytes + 8); state[2] = c;
d = load_bigendian(statebytes + 12); state[3] = d;
e = load_bigendian(statebytes + 16); state[4] = e;
f = load_bigendian(statebytes + 20); state[5] = f;
g = load_bigendian(statebytes + 24); state[6] = g;
h = load_bigendian(statebytes + 28); state[7] = h;
while (inlen >= 64) {
uint32 w0 = load_bigendian(in + 0);
uint32 w1 = load_bigendian(in + 4);
uint32 w2 = load_bigendian(in + 8);
uint32 w3 = load_bigendian(in + 12);
uint32 w4 = load_bigendian(in + 16);
uint32 w5 = load_bigendian(in + 20);
uint32 w6 = load_bigendian(in + 24);
uint32 w7 = load_bigendian(in + 28);
uint32 w8 = load_bigendian(in + 32);
uint32 w9 = load_bigendian(in + 36);
uint32 w10 = load_bigendian(in + 40);
uint32 w11 = load_bigendian(in + 44);
uint32 w12 = load_bigendian(in + 48);
uint32 w13 = load_bigendian(in + 52);
uint32 w14 = load_bigendian(in + 56);
uint32 w15 = load_bigendian(in + 60);
F(w0 ,0x428a2f98)
F(w1 ,0x71374491)
F(w2 ,0xb5c0fbcf)
F(w3 ,0xe9b5dba5)
F(w4 ,0x3956c25b)
F(w5 ,0x59f111f1)
F(w6 ,0x923f82a4)
F(w7 ,0xab1c5ed5)
F(w8 ,0xd807aa98)
F(w9 ,0x12835b01)
F(w10,0x243185be)
F(w11,0x550c7dc3)
F(w12,0x72be5d74)
F(w13,0x80deb1fe)
F(w14,0x9bdc06a7)
F(w15,0xc19bf174)
EXPAND
F(w0 ,0xe49b69c1)
F(w1 ,0xefbe4786)
F(w2 ,0x0fc19dc6)
F(w3 ,0x240ca1cc)
F(w4 ,0x2de92c6f)
F(w5 ,0x4a7484aa)
F(w6 ,0x5cb0a9dc)
F(w7 ,0x76f988da)
F(w8 ,0x983e5152)
F(w9 ,0xa831c66d)
F(w10,0xb00327c8)
F(w11,0xbf597fc7)
F(w12,0xc6e00bf3)
F(w13,0xd5a79147)
F(w14,0x06ca6351)
F(w15,0x14292967)
EXPAND
F(w0 ,0x27b70a85)
F(w1 ,0x2e1b2138)
F(w2 ,0x4d2c6dfc)
F(w3 ,0x53380d13)
F(w4 ,0x650a7354)
F(w5 ,0x766a0abb)
F(w6 ,0x81c2c92e)
F(w7 ,0x92722c85)
F(w8 ,0xa2bfe8a1)
F(w9 ,0xa81a664b)
F(w10,0xc24b8b70)
F(w11,0xc76c51a3)
F(w12,0xd192e819)
F(w13,0xd6990624)
F(w14,0xf40e3585)
F(w15,0x106aa070)
EXPAND
F(w0 ,0x19a4c116)
F(w1 ,0x1e376c08)
F(w2 ,0x2748774c)
F(w3 ,0x34b0bcb5)
F(w4 ,0x391c0cb3)
F(w5 ,0x4ed8aa4a)
F(w6 ,0x5b9cca4f)
F(w7 ,0x682e6ff3)
F(w8 ,0x748f82ee)
F(w9 ,0x78a5636f)
F(w10,0x84c87814)
F(w11,0x8cc70208)
F(w12,0x90befffa)
F(w13,0xa4506ceb)
F(w14,0xbef9a3f7)
F(w15,0xc67178f2)
a += state[0];
b += state[1];
c += state[2];
d += state[3];
e += state[4];
f += state[5];
g += state[6];
h += state[7];
state[0] = a;
state[1] = b;
state[2] = c;
state[3] = d;
state[4] = e;
state[5] = f;
state[6] = g;
state[7] = h;
in += 64;
inlen -= 64;
}
store_bigendian(statebytes + 0,state[0]);
store_bigendian(statebytes + 4,state[1]);
store_bigendian(statebytes + 8,state[2]);
store_bigendian(statebytes + 12,state[3]);
store_bigendian(statebytes + 16,state[4]);
store_bigendian(statebytes + 20,state[5]);
store_bigendian(statebytes + 24,state[6]);
store_bigendian(statebytes + 28,state[7]);
return 0;
}

View File

@ -1,16 +0,0 @@
#ifndef crypto_hashblocks_H
#define crypto_hashblocks_H
#include "crypto_hashblocks_sha256.h"
#define crypto_hashblocks crypto_hashblocks_sha256
/* CHEESEBURGER crypto_hashblocks_sha256 */
#define crypto_hashblocks_STATEBYTES crypto_hashblocks_sha256_STATEBYTES
/* CHEESEBURGER crypto_hashblocks_sha256_STATEBYTES */
#define crypto_hashblocks_BLOCKBYTES crypto_hashblocks_sha256_BLOCKBYTES
/* CHEESEBURGER crypto_hashblocks_sha256_BLOCKBYTES */
#define crypto_hashblocks_PRIMITIVE "sha256"
#define crypto_hashblocks_IMPLEMENTATION crypto_hashblocks_sha256_IMPLEMENTATION
#define crypto_hashblocks_VERSION crypto_hashblocks_sha256_VERSION
#endif

View File

@ -1 +0,0 @@
Daniel J. Bernstein

View File

@ -1,2 +0,0 @@
#define CRYPTO_STATEBYTES 64
#define CRYPTO_BLOCKBYTES 128

View File

@ -1,239 +0,0 @@
#include "crypto_hashblocks.h"
typedef unsigned long long uint64;
static uint64 load_bigendian(const unsigned char *x)
{
return
(uint64) (x[7]) \
| (((uint64) (x[6])) << 8) \
| (((uint64) (x[5])) << 16) \
| (((uint64) (x[4])) << 24) \
| (((uint64) (x[3])) << 32) \
| (((uint64) (x[2])) << 40) \
| (((uint64) (x[1])) << 48) \
| (((uint64) (x[0])) << 56)
;
}
static void store_bigendian(unsigned char *x,uint64 u)
{
x[7] = u; u >>= 8;
x[6] = u; u >>= 8;
x[5] = u; u >>= 8;
x[4] = u; u >>= 8;
x[3] = u; u >>= 8;
x[2] = u; u >>= 8;
x[1] = u; u >>= 8;
x[0] = u;
}
#define SHR(x,c) ((x) >> (c))
#define ROTR(x,c) (((x) >> (c)) | ((x) << (64 - (c))))
#define Ch(x,y,z) ((x & y) ^ (~x & z))
#define Maj(x,y,z) ((x & y) ^ (x & z) ^ (y & z))
#define Sigma0(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39))
#define Sigma1(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41))
#define sigma0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x,7))
#define sigma1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x,6))
#define M(w0,w14,w9,w1) w0 = sigma1(w14) + w9 + sigma0(w1) + w0;
#define EXPAND \
M(w0 ,w14,w9 ,w1 ) \
M(w1 ,w15,w10,w2 ) \
M(w2 ,w0 ,w11,w3 ) \
M(w3 ,w1 ,w12,w4 ) \
M(w4 ,w2 ,w13,w5 ) \
M(w5 ,w3 ,w14,w6 ) \
M(w6 ,w4 ,w15,w7 ) \
M(w7 ,w5 ,w0 ,w8 ) \
M(w8 ,w6 ,w1 ,w9 ) \
M(w9 ,w7 ,w2 ,w10) \
M(w10,w8 ,w3 ,w11) \
M(w11,w9 ,w4 ,w12) \
M(w12,w10,w5 ,w13) \
M(w13,w11,w6 ,w14) \
M(w14,w12,w7 ,w15) \
M(w15,w13,w8 ,w0 )
#define F(w,k) \
T1 = h + Sigma1(e) + Ch(e,f,g) + k + w; \
T2 = Sigma0(a) + Maj(a,b,c); \
h = g; \
g = f; \
f = e; \
e = d + T1; \
d = c; \
c = b; \
b = a; \
a = T1 + T2;
int crypto_hashblocks(unsigned char *statebytes,const unsigned char *in,unsigned long long inlen)
{
uint64 state[8];
uint64 a;
uint64 b;
uint64 c;
uint64 d;
uint64 e;
uint64 f;
uint64 g;
uint64 h;
uint64 T1;
uint64 T2;
a = load_bigendian(statebytes + 0); state[0] = a;
b = load_bigendian(statebytes + 8); state[1] = b;
c = load_bigendian(statebytes + 16); state[2] = c;
d = load_bigendian(statebytes + 24); state[3] = d;
e = load_bigendian(statebytes + 32); state[4] = e;
f = load_bigendian(statebytes + 40); state[5] = f;
g = load_bigendian(statebytes + 48); state[6] = g;
h = load_bigendian(statebytes + 56); state[7] = h;
while (inlen >= 128) {
uint64 w0 = load_bigendian(in + 0);
uint64 w1 = load_bigendian(in + 8);
uint64 w2 = load_bigendian(in + 16);
uint64 w3 = load_bigendian(in + 24);
uint64 w4 = load_bigendian(in + 32);
uint64 w5 = load_bigendian(in + 40);
uint64 w6 = load_bigendian(in + 48);
uint64 w7 = load_bigendian(in + 56);
uint64 w8 = load_bigendian(in + 64);
uint64 w9 = load_bigendian(in + 72);
uint64 w10 = load_bigendian(in + 80);
uint64 w11 = load_bigendian(in + 88);
uint64 w12 = load_bigendian(in + 96);
uint64 w13 = load_bigendian(in + 104);
uint64 w14 = load_bigendian(in + 112);
uint64 w15 = load_bigendian(in + 120);
F(w0 ,0x428a2f98d728ae22ULL)
F(w1 ,0x7137449123ef65cdULL)
F(w2 ,0xb5c0fbcfec4d3b2fULL)
F(w3 ,0xe9b5dba58189dbbcULL)
F(w4 ,0x3956c25bf348b538ULL)
F(w5 ,0x59f111f1b605d019ULL)
F(w6 ,0x923f82a4af194f9bULL)
F(w7 ,0xab1c5ed5da6d8118ULL)
F(w8 ,0xd807aa98a3030242ULL)
F(w9 ,0x12835b0145706fbeULL)
F(w10,0x243185be4ee4b28cULL)
F(w11,0x550c7dc3d5ffb4e2ULL)
F(w12,0x72be5d74f27b896fULL)
F(w13,0x80deb1fe3b1696b1ULL)
F(w14,0x9bdc06a725c71235ULL)
F(w15,0xc19bf174cf692694ULL)
EXPAND
F(w0 ,0xe49b69c19ef14ad2ULL)
F(w1 ,0xefbe4786384f25e3ULL)
F(w2 ,0x0fc19dc68b8cd5b5ULL)
F(w3 ,0x240ca1cc77ac9c65ULL)
F(w4 ,0x2de92c6f592b0275ULL)
F(w5 ,0x4a7484aa6ea6e483ULL)
F(w6 ,0x5cb0a9dcbd41fbd4ULL)
F(w7 ,0x76f988da831153b5ULL)
F(w8 ,0x983e5152ee66dfabULL)
F(w9 ,0xa831c66d2db43210ULL)
F(w10,0xb00327c898fb213fULL)
F(w11,0xbf597fc7beef0ee4ULL)
F(w12,0xc6e00bf33da88fc2ULL)
F(w13,0xd5a79147930aa725ULL)
F(w14,0x06ca6351e003826fULL)
F(w15,0x142929670a0e6e70ULL)
EXPAND
F(w0 ,0x27b70a8546d22ffcULL)
F(w1 ,0x2e1b21385c26c926ULL)
F(w2 ,0x4d2c6dfc5ac42aedULL)
F(w3 ,0x53380d139d95b3dfULL)
F(w4 ,0x650a73548baf63deULL)
F(w5 ,0x766a0abb3c77b2a8ULL)
F(w6 ,0x81c2c92e47edaee6ULL)
F(w7 ,0x92722c851482353bULL)
F(w8 ,0xa2bfe8a14cf10364ULL)
F(w9 ,0xa81a664bbc423001ULL)
F(w10,0xc24b8b70d0f89791ULL)
F(w11,0xc76c51a30654be30ULL)
F(w12,0xd192e819d6ef5218ULL)
F(w13,0xd69906245565a910ULL)
F(w14,0xf40e35855771202aULL)
F(w15,0x106aa07032bbd1b8ULL)
EXPAND
F(w0 ,0x19a4c116b8d2d0c8ULL)
F(w1 ,0x1e376c085141ab53ULL)
F(w2 ,0x2748774cdf8eeb99ULL)
F(w3 ,0x34b0bcb5e19b48a8ULL)
F(w4 ,0x391c0cb3c5c95a63ULL)
F(w5 ,0x4ed8aa4ae3418acbULL)
F(w6 ,0x5b9cca4f7763e373ULL)
F(w7 ,0x682e6ff3d6b2b8a3ULL)
F(w8 ,0x748f82ee5defb2fcULL)
F(w9 ,0x78a5636f43172f60ULL)
F(w10,0x84c87814a1f0ab72ULL)
F(w11,0x8cc702081a6439ecULL)
F(w12,0x90befffa23631e28ULL)
F(w13,0xa4506cebde82bde9ULL)
F(w14,0xbef9a3f7b2c67915ULL)
F(w15,0xc67178f2e372532bULL)
EXPAND
F(w0 ,0xca273eceea26619cULL)
F(w1 ,0xd186b8c721c0c207ULL)
F(w2 ,0xeada7dd6cde0eb1eULL)
F(w3 ,0xf57d4f7fee6ed178ULL)
F(w4 ,0x06f067aa72176fbaULL)
F(w5 ,0x0a637dc5a2c898a6ULL)
F(w6 ,0x113f9804bef90daeULL)
F(w7 ,0x1b710b35131c471bULL)
F(w8 ,0x28db77f523047d84ULL)
F(w9 ,0x32caab7b40c72493ULL)
F(w10,0x3c9ebe0a15c9bebcULL)
F(w11,0x431d67c49c100d4cULL)
F(w12,0x4cc5d4becb3e42b6ULL)
F(w13,0x597f299cfc657e2aULL)
F(w14,0x5fcb6fab3ad6faecULL)
F(w15,0x6c44198c4a475817ULL)
a += state[0];
b += state[1];
c += state[2];
d += state[3];
e += state[4];
f += state[5];
g += state[6];
h += state[7];
state[0] = a;
state[1] = b;
state[2] = c;
state[3] = d;
state[4] = e;
state[5] = f;
state[6] = g;
state[7] = h;
in += 128;
inlen -= 128;
}
store_bigendian(statebytes + 0,state[0]);
store_bigendian(statebytes + 8,state[1]);
store_bigendian(statebytes + 16,state[2]);
store_bigendian(statebytes + 24,state[3]);
store_bigendian(statebytes + 32,state[4]);
store_bigendian(statebytes + 40,state[5]);
store_bigendian(statebytes + 48,state[6]);
store_bigendian(statebytes + 56,state[7]);
return 0;
}

View File

@ -1,16 +0,0 @@
#ifndef crypto_hashblocks_H
#define crypto_hashblocks_H
#include "crypto_hashblocks_sha512.h"
#define crypto_hashblocks crypto_hashblocks_sha512
/* CHEESEBURGER crypto_hashblocks_sha512 */
#define crypto_hashblocks_STATEBYTES crypto_hashblocks_sha512_STATEBYTES
/* CHEESEBURGER crypto_hashblocks_sha512_STATEBYTES */
#define crypto_hashblocks_BLOCKBYTES crypto_hashblocks_sha512_BLOCKBYTES
/* CHEESEBURGER crypto_hashblocks_sha512_BLOCKBYTES */
#define crypto_hashblocks_PRIMITIVE "sha512"
#define crypto_hashblocks_IMPLEMENTATION crypto_hashblocks_sha512_IMPLEMENTATION
#define crypto_hashblocks_VERSION crypto_hashblocks_sha512_VERSION
#endif

View File

@ -1 +0,0 @@
Daniel J. Bernstein

View File

@ -1,2 +0,0 @@
#define CRYPTO_BYTES 16
#define CRYPTO_KEYBYTES 32

View File

@ -1,104 +0,0 @@
/*
20080912
D. J. Bernstein
Public domain.
*/
#include "crypto_onetimeauth.h"
static void add(unsigned int h[17],const unsigned int c[17])
{
unsigned int j;
unsigned int u;
u = 0;
for (j = 0;j < 17;++j) { u += h[j] + c[j]; h[j] = u & 255; u >>= 8; }
}
static void squeeze(unsigned int h[17])
{
unsigned int j;
unsigned int u;
u = 0;
for (j = 0;j < 16;++j) { u += h[j]; h[j] = u & 255; u >>= 8; }
u += h[16]; h[16] = u & 3;
u = 5 * (u >> 2);
for (j = 0;j < 16;++j) { u += h[j]; h[j] = u & 255; u >>= 8; }
u += h[16]; h[16] = u;
}
static const unsigned int minusp[17] = {
5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 252
} ;
static void freeze(unsigned int h[17])
{
unsigned int horig[17];
unsigned int j;
unsigned int negative;
for (j = 0;j < 17;++j) horig[j] = h[j];
add(h,minusp);
negative = -(h[16] >> 7);
for (j = 0;j < 17;++j) h[j] ^= negative & (horig[j] ^ h[j]);
}
static void mulmod(unsigned int h[17],const unsigned int r[17])
{
unsigned int hr[17];
unsigned int i;
unsigned int j;
unsigned int u;
for (i = 0;i < 17;++i) {
u = 0;
for (j = 0;j <= i;++j) u += h[j] * r[i - j];
for (j = i + 1;j < 17;++j) u += 320 * h[j] * r[i + 17 - j];
hr[i] = u;
}
for (i = 0;i < 17;++i) h[i] = hr[i];
squeeze(h);
}
int crypto_onetimeauth(unsigned char *out,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
{
unsigned int j;
unsigned int r[17];
unsigned int h[17];
unsigned int c[17];
r[0] = k[0];
r[1] = k[1];
r[2] = k[2];
r[3] = k[3] & 15;
r[4] = k[4] & 252;
r[5] = k[5];
r[6] = k[6];
r[7] = k[7] & 15;
r[8] = k[8] & 252;
r[9] = k[9];
r[10] = k[10];
r[11] = k[11] & 15;
r[12] = k[12] & 252;
r[13] = k[13];
r[14] = k[14];
r[15] = k[15] & 15;
r[16] = 0;
for (j = 0;j < 17;++j) h[j] = 0;
while (inlen > 0) {
for (j = 0;j < 17;++j) c[j] = 0;
for (j = 0;(j < 16) && (j < inlen);++j) c[j] = in[j];
c[j] = 1;
in += j; inlen -= j;
add(h,c);
mulmod(h,r);
}
freeze(h);
for (j = 0;j < 16;++j) c[j] = k[j + 16];
c[16] = 0;
add(h,c);
for (j = 0;j < 16;++j) out[j] = h[j];
return 0;
}

View File

@ -1,18 +0,0 @@
#ifndef crypto_onetimeauth_H
#define crypto_onetimeauth_H
#include "crypto_onetimeauth_poly1305.h"
#define crypto_onetimeauth crypto_onetimeauth_poly1305
/* CHEESEBURGER crypto_onetimeauth_poly1305 */
#define crypto_onetimeauth_verify crypto_onetimeauth_poly1305_verify
/* CHEESEBURGER crypto_onetimeauth_poly1305_verify */
#define crypto_onetimeauth_BYTES crypto_onetimeauth_poly1305_BYTES
/* CHEESEBURGER crypto_onetimeauth_poly1305_BYTES */
#define crypto_onetimeauth_KEYBYTES crypto_onetimeauth_poly1305_KEYBYTES
/* CHEESEBURGER crypto_onetimeauth_poly1305_KEYBYTES */
#define crypto_onetimeauth_PRIMITIVE "poly1305"
#define crypto_onetimeauth_IMPLEMENTATION crypto_onetimeauth_poly1305_IMPLEMENTATION
#define crypto_onetimeauth_VERSION crypto_onetimeauth_poly1305_VERSION
#endif

View File

@ -1,9 +0,0 @@
#include "crypto_verify_16.h"
#include "crypto_onetimeauth.h"
int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
{
unsigned char correct[16];
crypto_onetimeauth(correct,in,inlen,k);
return crypto_verify_16(h,correct);
}

View File

@ -1,2 +0,0 @@
#define CRYPTO_BYTES 32
#define CRYPTO_SCALARBYTES 32

View File

@ -1,16 +0,0 @@
/*
version 20081011
Matthew Dempsky
Public domain.
Derived from public domain code by D. J. Bernstein.
*/
#include "crypto_scalarmult.h"
const unsigned char base[32] = {9};
int crypto_scalarmult_base(unsigned char *q,
const unsigned char *n)
{
return crypto_scalarmult(q,n,base);
}

View File

@ -1,18 +0,0 @@
#ifndef crypto_scalarmult_H
#define crypto_scalarmult_H
#include "crypto_scalarmult_curve25519.h"
#define crypto_scalarmult crypto_scalarmult_curve25519
/* CHEESEBURGER crypto_scalarmult_curve25519 */
#define crypto_scalarmult_base crypto_scalarmult_curve25519_base
/* CHEESEBURGER crypto_scalarmult_curve25519_base */
#define crypto_scalarmult_BYTES crypto_scalarmult_curve25519_BYTES
/* CHEESEBURGER crypto_scalarmult_curve25519_BYTES */
#define crypto_scalarmult_SCALARBYTES crypto_scalarmult_curve25519_SCALARBYTES
/* CHEESEBURGER crypto_scalarmult_curve25519_SCALARBYTES */
#define crypto_scalarmult_PRIMITIVE "curve25519"
#define crypto_scalarmult_IMPLEMENTATION crypto_scalarmult_curve25519_IMPLEMENTATION
#define crypto_scalarmult_VERSION crypto_scalarmult_curve25519_VERSION
#endif

View File

@ -1 +0,0 @@
Matthew Dempsky (Mochi Media)

View File

@ -1,293 +0,0 @@
/*
version 20081011
Matthew Dempsky
Public domain.
Derived from public domain code by D. J. Bernstein.
*/
/*
Portions Copyright (C) 2013 Petter Reinholdtsen
Some rights reserved
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "crypto_scalarmult.h"
static void add(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
{
unsigned int j;
unsigned int u;
u = 0;
for (j = 0;j < 31;++j) { u += a[j] + b[j]; out[j] = u & 255; u >>= 8; }
u += a[31] + b[31]; out[31] = u;
}
static void sub(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
{
unsigned int j;
unsigned int u;
u = 218;
for (j = 0;j < 31;++j) {
u += a[j] + 65280 - b[j];
out[j] = u & 255;
u >>= 8;
}
u += a[31] - b[31];
out[31] = u;
}
static void squeeze(unsigned int a[32])
{
unsigned int j;
unsigned int u;
u = 0;
for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
u += a[31]; a[31] = u & 127;
u = 19 * (u >> 7);
for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
u += a[31]; a[31] = u;
}
static const unsigned int minusp[32] = {
19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128
} ;
static void freeze(unsigned int a[32])
{
unsigned int aorig[32];
unsigned int j;
unsigned int negative;
for (j = 0;j < 32;++j) aorig[j] = a[j];
add(a,a,minusp);
negative = -((a[31] >> 7) & 1);
for (j = 0;j < 32;++j) a[j] ^= negative & (aorig[j] ^ a[j]);
}
static void mult(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
{
unsigned int i;
unsigned int j;
unsigned int u;
for (i = 0;i < 32;++i) {
u = 0;
for (j = 0;j <= i;++j) u += a[j] * b[i - j];
for (j = i + 1;j < 32;++j) u += 38 * a[j] * b[i + 32 - j];
out[i] = u;
}
squeeze(out);
}
static void mult121665(unsigned int out[32],const unsigned int a[32])
{
unsigned int j;
unsigned int u;
u = 0;
for (j = 0;j < 31;++j) { u += 121665 * a[j]; out[j] = u & 255; u >>= 8; }
u += 121665 * a[31]; out[31] = u & 127;
u = 19 * (u >> 7);
for (j = 0;j < 31;++j) { u += out[j]; out[j] = u & 255; u >>= 8; }
u += out[j]; out[j] = u;
}
static void square(unsigned int out[32],const unsigned int a[32])
{
unsigned int i;
unsigned int j;
unsigned int u;
for (i = 0;i < 32;++i) {
u = 0;
for (j = 0;j < i - j;++j) u += a[j] * a[i - j];
for (j = i + 1;j < i + 32 - j;++j) u += 38 * a[j] * a[i + 32 - j];
u *= 2;
if ((i & 1) == 0) {
u += a[i / 2] * a[i / 2];
u += 38 * a[i / 2 + 16] * a[i / 2 + 16];
}
out[i] = u;
}
squeeze(out);
}
static void select(unsigned int p[64],unsigned int q[64],const unsigned int r[64],const unsigned int s[64],unsigned int b)
{
unsigned int j;
unsigned int t;
unsigned int bminus1;
bminus1 = b - 1;
for (j = 0;j < 64;++j) {
t = bminus1 & (r[j] ^ s[j]);
p[j] = s[j] ^ t;
q[j] = r[j] ^ t;
}
}
static void mainloop(unsigned int work[64],const unsigned char e[32])
{
unsigned int xzm1[64];
unsigned int xzm[64];
unsigned int xzmb[64];
unsigned int xzm1b[64];
unsigned int xznb[64];
unsigned int xzn1b[64];
unsigned int a0[64];
unsigned int a1[64];
unsigned int b0[64];
unsigned int b1[64];
unsigned int c1[64];
unsigned int r[32];
unsigned int s[32];
unsigned int t[32];
unsigned int u[32];
unsigned int j;
unsigned int b;
int pos;
for (j = 0;j < 32;++j) xzm1[j] = work[j];
xzm1[32] = 1;
for (j = 33;j < 64;++j) xzm1[j] = 0;
xzm[0] = 1;
for (j = 1;j < 64;++j) xzm[j] = 0;
for (pos = 254;pos >= 0;--pos) {
b = e[pos / 8] >> (pos & 7);
b &= 1;
select(xzmb,xzm1b,xzm,xzm1,b);
add(a0,xzmb,xzmb + 32);
sub(a0 + 32,xzmb,xzmb + 32);
add(a1,xzm1b,xzm1b + 32);
sub(a1 + 32,xzm1b,xzm1b + 32);
square(b0,a0);
square(b0 + 32,a0 + 32);
mult(b1,a1,a0 + 32);
mult(b1 + 32,a1 + 32,a0);
add(c1,b1,b1 + 32);
sub(c1 + 32,b1,b1 + 32);
square(r,c1 + 32);
sub(s,b0,b0 + 32);
mult121665(t,s);
add(u,t,b0);
mult(xznb,b0,b0 + 32);
mult(xznb + 32,s,u);
square(xzn1b,c1);
mult(xzn1b + 32,r,work);
select(xzm,xzm1,xznb,xzn1b,b);
}
for (j = 0;j < 64;++j) work[j] = xzm[j];
}
static void recip(unsigned int out[32],const unsigned int z[32])
{
unsigned int z2[32];
unsigned int z9[32];
unsigned int z11[32];
unsigned int z2_5_0[32];
unsigned int z2_10_0[32];
unsigned int z2_20_0[32];
unsigned int z2_50_0[32];
unsigned int z2_100_0[32];
unsigned int t0[32];
unsigned int t1[32];
int i;
/* 2 */ square(z2,z);
/* 4 */ square(t1,z2);
/* 8 */ square(t0,t1);
/* 9 */ mult(z9,t0,z);
/* 11 */ mult(z11,z9,z2);
/* 22 */ square(t0,z11);
/* 2^5 - 2^0 = 31 */ mult(z2_5_0,t0,z9);
/* 2^6 - 2^1 */ square(t0,z2_5_0);
/* 2^7 - 2^2 */ square(t1,t0);
/* 2^8 - 2^3 */ square(t0,t1);
/* 2^9 - 2^4 */ square(t1,t0);
/* 2^10 - 2^5 */ square(t0,t1);
/* 2^10 - 2^0 */ mult(z2_10_0,t0,z2_5_0);
/* 2^11 - 2^1 */ square(t0,z2_10_0);
/* 2^12 - 2^2 */ square(t1,t0);
/* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t0,t1); square(t1,t0); }
/* 2^20 - 2^0 */ mult(z2_20_0,t1,z2_10_0);
/* 2^21 - 2^1 */ square(t0,z2_20_0);
/* 2^22 - 2^2 */ square(t1,t0);
/* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { square(t0,t1); square(t1,t0); }
/* 2^40 - 2^0 */ mult(t0,t1,z2_20_0);
/* 2^41 - 2^1 */ square(t1,t0);
/* 2^42 - 2^2 */ square(t0,t1);
/* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t1,t0); square(t0,t1); }
/* 2^50 - 2^0 */ mult(z2_50_0,t0,z2_10_0);
/* 2^51 - 2^1 */ square(t0,z2_50_0);
/* 2^52 - 2^2 */ square(t1,t0);
/* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
/* 2^100 - 2^0 */ mult(z2_100_0,t1,z2_50_0);
/* 2^101 - 2^1 */ square(t1,z2_100_0);
/* 2^102 - 2^2 */ square(t0,t1);
/* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { square(t1,t0); square(t0,t1); }
/* 2^200 - 2^0 */ mult(t1,t0,z2_100_0);
/* 2^201 - 2^1 */ square(t0,t1);
/* 2^202 - 2^2 */ square(t1,t0);
/* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
/* 2^250 - 2^0 */ mult(t0,t1,z2_50_0);
/* 2^251 - 2^1 */ square(t1,t0);
/* 2^252 - 2^2 */ square(t0,t1);
/* 2^253 - 2^3 */ square(t1,t0);
/* 2^254 - 2^4 */ square(t0,t1);
/* 2^255 - 2^5 */ square(t1,t0);
/* 2^255 - 21 */ mult(out,t1,z11);
}
int crypto_scalarmult(unsigned char *q,
const unsigned char *n,
const unsigned char *p)
{
unsigned int work[96];
unsigned char e[32];
unsigned int i;
for (i = 0;i < 32;++i) e[i] = n[i];
e[0] &= 248;
e[31] &= 127;
e[31] |= 64;
for (i = 0;i < 32;++i) work[i] = p[i];
mainloop(work,e);
recip(work + 32,work + 32);
mult(work + 64,work,work + 32);
freeze(work + 64);
for (i = 0;i < 32;++i) q[i] = work[64 + i];
return 0;
}

View File

@ -1,4 +0,0 @@
#define CRYPTO_KEYBYTES 32
#define CRYPTO_NONCEBYTES 24
#define CRYPTO_ZEROBYTES 32
#define CRYPTO_BOXZEROBYTES 16

View File

@ -1,35 +0,0 @@
#include "crypto_onetimeauth_poly1305.h"
#include "crypto_stream_xsalsa20.h"
#include "crypto_secretbox.h"
int crypto_secretbox(
unsigned char *c,
const unsigned char *m,unsigned long long mlen,
const unsigned char *n,
const unsigned char *k
)
{
int i;
if (mlen < 32) return -1;
crypto_stream_xsalsa20_xor(c,m,mlen,n,k);
crypto_onetimeauth_poly1305(c + 16,c + 32,mlen - 32,c);
for (i = 0;i < 16;++i) c[i] = 0;
return 0;
}
int crypto_secretbox_open(
unsigned char *m,
const unsigned char *c,unsigned long long clen,
const unsigned char *n,
const unsigned char *k
)
{
int i;
unsigned char subkey[32];
if (clen < 32) return -1;
crypto_stream_xsalsa20(subkey,32,n,k);
if (crypto_onetimeauth_poly1305_verify(c + 16,c + 32,clen - 32,subkey) != 0) return -1;
crypto_stream_xsalsa20_xor(m,c,clen,n,k);
for (i = 0;i < 32;++i) m[i] = 0;
return 0;
}

View File

@ -1,22 +0,0 @@
#ifndef crypto_secretbox_H
#define crypto_secretbox_H
#include "crypto_secretbox_xsalsa20poly1305.h"
#define crypto_secretbox crypto_secretbox_xsalsa20poly1305
/* CHEESEBURGER crypto_secretbox_xsalsa20poly1305 */
#define crypto_secretbox_open crypto_secretbox_xsalsa20poly1305_open
/* CHEESEBURGER crypto_secretbox_xsalsa20poly1305_open */
#define crypto_secretbox_KEYBYTES crypto_secretbox_xsalsa20poly1305_KEYBYTES
/* CHEESEBURGER crypto_secretbox_xsalsa20poly1305_KEYBYTES */
#define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES
/* CHEESEBURGER crypto_secretbox_xsalsa20poly1305_NONCEBYTES */
#define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES
/* CHEESEBURGER crypto_secretbox_xsalsa20poly1305_ZEROBYTES */
#define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
/* CHEESEBURGER crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES */
#define crypto_secretbox_PRIMITIVE "xsalsa20poly1305"
#define crypto_secretbox_IMPLEMENTATION crypto_secretbox_xsalsa20poly1305_IMPLEMENTATION
#define crypto_secretbox_VERSION crypto_secretbox_xsalsa20poly1305_VERSION
#endif

View File

@ -1,3 +0,0 @@
#define CRYPTO_SECRETKEYBYTES 64
#define CRYPTO_PUBLICKEYBYTES 32
#define CRYPTO_BYTES 64

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +0,0 @@
b = 256
q = 2**255 - 19
l = 2**252 + 27742317777372353535851937790883648493
def expmod(b,e,m):
if e == 0: return 1
t = expmod(b,e/2,m)**2 % m
if e & 1: t = (t*b) % m
return t
def inv(x):
return expmod(x,q-2,q)
d = -121665 * inv(121666)
I = expmod(2,(q-1)/4,q)
def xrecover(y):
xx = (y*y-1) * inv(d*y*y+1)
x = expmod(xx,(q+3)/8,q)
if (x*x - xx) % q != 0: x = (x*I) % q
if x % 2 != 0: x = q-x
return x
By = 4 * inv(5)
Bx = xrecover(By)
B = [Bx % q,By % q]
def edwards(P,Q):
x1 = P[0]
y1 = P[1]
x2 = Q[0]
y2 = Q[1]
x3 = (x1*y2+x2*y1) * inv(1+d*x1*x2*y1*y2)
y3 = (y1*y2+x1*x2) * inv(1-d*x1*x2*y1*y2)
return [x3 % q,y3 % q]
def radix255(x):
x = x % q
if x + x > q: x -= q
x = [x,0,0,0,0,0,0,0,0,0]
bits = [26,25,26,25,26,25,26,25,26,25]
for i in range(9):
carry = (x[i] + 2**(bits[i]-1)) / 2**bits[i]
x[i] -= carry * 2**bits[i]
x[i + 1] += carry
result = ""
for i in range(9):
result = result+str(x[i])+","
result = result+str(x[9])
return result
Bi = B
for i in range(32):
print "{"
Bij = Bi
for j in range(8):
print " {"
print " {",radix255(Bij[1]+Bij[0]),"},"
print " {",radix255(Bij[1]-Bij[0]),"},"
print " {",radix255(2*d*Bij[0]*Bij[1]),"},"
Bij = edwards(Bij,Bi)
print " },"
print "},"
for k in range(8):
Bi = edwards(Bi,Bi)

View File

@ -1,40 +0,0 @@
{
{ 25967493,-14356035,29566456,3660896,-12694345,4014787,27544626,-11754271,-6079156,2047605 },
{ -12545711,934262,-2722910,3049990,-727428,9406986,12720692,5043384,19500929,-15469378 },
{ -8738181,4489570,9688441,-14785194,10184609,-12363380,29287919,11864899,-24514362,-4438546 },
},
{
{ 15636291,-9688557,24204773,-7912398,616977,-16685262,27787600,-14772189,28944400,-1550024 },
{ 16568933,4717097,-11556148,-1102322,15682896,-11807043,16354577,-11775962,7689662,11199574 },
{ 30464156,-5976125,-11779434,-15670865,23220365,15915852,7512774,10017326,-17749093,-9920357 },
},
{
{ 10861363,11473154,27284546,1981175,-30064349,12577861,32867885,14515107,-15438304,10819380 },
{ 4708026,6336745,20377586,9066809,-11272109,6594696,-25653668,12483688,-12668491,5581306 },
{ 19563160,16186464,-29386857,4097519,10237984,-4348115,28542350,13850243,-23678021,-15815942 },
},
{
{ 5153746,9909285,1723747,-2777874,30523605,5516873,19480852,5230134,-23952439,-15175766 },
{ -30269007,-3463509,7665486,10083793,28475525,1649722,20654025,16520125,30598449,7715701 },
{ 28881845,14381568,9657904,3680757,-20181635,7843316,-31400660,1370708,29794553,-1409300 },
},
{
{ -22518993,-6692182,14201702,-8745502,-23510406,8844726,18474211,-1361450,-13062696,13821877 },
{ -6455177,-7839871,3374702,-4740862,-27098617,-10571707,31655028,-7212327,18853322,-14220951 },
{ 4566830,-12963868,-28974889,-12240689,-7602672,-2830569,-8514358,-10431137,2207753,-3209784 },
},
{
{ -25154831,-4185821,29681144,7868801,-6854661,-9423865,-12437364,-663000,-31111463,-16132436 },
{ 25576264,-2703214,7349804,-11814844,16472782,9300885,3844789,15725684,171356,6466918 },
{ 23103977,13316479,9739013,-16149481,817875,-15038942,8965339,-14088058,-30714912,16193877 },
},
{
{ -33521811,3180713,-2394130,14003687,-16903474,-16270840,17238398,4729455,-18074513,9256800 },
{ -25182317,-4174131,32336398,5036987,-21236817,11360617,22616405,9761698,-19827198,630305 },
{ -13720693,2639453,-24237460,-7406481,9494427,-5774029,-6554551,-15960994,-2449256,-14291300 },
},
{
{ -3151181,-5046075,9282714,6866145,-31907062,-863023,-18940575,15033784,25105118,-7894876 },
{ -24326370,15950226,-31801215,-14592823,-11662737,-5090925,1573892,-2625887,2198790,-15804619 },
{ -3099351,10324967,-2241613,7453183,-5446979,-2735503,-13812022,-16236442,-32461234,-12290683 },
},

Some files were not shown because too many files have changed in this diff Show More