Monocypher failed to compile with -DED25519_SHA512 since we added the
incremental interface. The error has been corrected by the #95 Pull
Request by @vbmithr.
To make sure this doesn't happen again, the test suite has been expanded
to include the official
Ed25519 construction. You can test it thus:
$ make clean
$ make test CFLAGS="-DED25519_SHA512 -O3"
Or just run `tests/test.sh` to have the whole shebang.
--- /dev/null
+#include <sodium.h>
+#include "utils.h"
+
+void test(size_t msg_size)
+{
+ RANDOM_INPUT(seed, 32);
+ RANDOM_INPUT(msg , 256);
+ u8 pk[32], sk[64], sig[64];
+
+ crypto_sign_seed_keypair(pk, sk, seed);
+ crypto_sign_detached(sig, 0, msg, msg_size, sk);
+
+ print_vector(sk , 32 );
+ print_vector(pk , 32 );
+ print_vector(msg, msg_size);
+ print_vector(sig, 64 );
+}
+
+int main(void)
+{
+ SODIUM_INIT;
+ FOR (msg_size, 0, 256) { test(msg_size); }
+ return 0;
+}
.PHONY: all clean
VEC = chacha20.vec xchacha20.vec aead_ietf.vec poly1305.vec blake2b.vec \
- sha512.vec argon2i.vec edDSA.vec x25519.vec
+ sha512.vec argon2i.vec edDSA.vec ed_25519.vec x25519.vec
VEC2 = $(patsubst %.vec, %.all.vec, $(VEC)) key_exchange.all.vec
HEADERS = $(patsubst %.all.vec, %.h.vec, $(VEC2))
VECTORS = ../vectors.h
sha512.all.vec : sha512.vec
argon2i.all.vec : argon2i.vec ../vectors/argon2i
edDSA.all.vec : edDSA.vec
+ed_25519.all.vec : ed_25519.vec
key_exchange.all.vec: ../vectors/key_exchange
$(VEC2):
mkdir -p $(@D)
}
}
+#ifdef ED25519_SHA512
+static void (*ed_25519)(const vector[], vector*) = edDSA;
+#endif
+
static void iterate_x25519(u8 k[32], u8 u[32])
{
u8 tmp[32];
status |= TEST(argon2i , 6);
status |= TEST(x25519 , 2);
status |= TEST(key_exchange, 2);
+#ifdef ED25519_SHA512
+ status |= TEST(ed_25519 , 3);
+#else
status |= TEST(edDSA , 3);
+#endif
status |= test_x25519();
printf("\nProperty based tests");
set -e
make clean; make test
+make clean; make test CFLAGS="-DED25519_SHA512 -O3"
make clean; make test CC="clang -std=c99" CFLAGS="-g -fsanitize=address"
make clean; make test CC="clang -std=c99" CFLAGS="-g -fsanitize=memory"
make clean; make test CC="clang -std=c99" CFLAGS="-g -fsanitize=undefined"