.PHONY: all library static-library dynamic-library \
install install-doc pkg-config-libhydrogen \
- check test ctgrind \
+ check test tis-ci ctgrind \
speed speed-sodium speed-tweetnacl speed-hydrogen speed-c25519 \
speed-donna \
clean uninstall \
check: test
test : test.out
+tis-ci : tis-ci.out
speed : speed.out
speed-sodium : speed-sodium.out
speed-tweetnacl: speed-tweetnacl.out
speed-hydrogen : speed-hydrogen.out
speed-c25519 : speed-c25519.out
speed-donna : speed-donna.out
-test speed speed-sodium speed-tweetnacl speed-hydrogen speed-c25519 speed-donna:
+test tis-ci:
+ ./$<
+speed speed-sodium speed-tweetnacl speed-hydrogen speed-c25519 speed-donna:
./$<
ctgrind: ctgrind.out
TEST_COMMON = tests/utils.h src/monocypher.h src/optional/monocypher-ed25519.h
SPEED = tests/speed
lib/utils.o :tests/utils.c
+lib/tis-ci.o :tests/tis-ci.c $(TEST_COMMON) tests/tis-ci-vectors.h
lib/test.o :tests/test.c $(TEST_COMMON) tests/vectors.h
lib/ctgrind.o :tests/ctgrind.c $(TEST_COMMON)
lib/speed.o :$(SPEED)/speed.c $(TEST_COMMON) $(SPEED)/speed.h
lib/speed-tweetnacl.o:$(SPEED)/speed-tweetnacl.c $(TEST_COMMON) $(SPEED)/speed.h
-lib/utils.o lib/test.o lib/speed.o:
+lib/utils.o lib/test.o lib/tis-ci.o lib/speed.o:
@mkdir -p $(@D)
$(CC) $(CFLAGS) \
-I src -I src/optional -I tests \
-DED25519_FORCE_32BIT
# test & speed executables
-TEST_OBJ= lib/utils.o lib/monocypher.o
-test.out : lib/test.o $(TEST_OBJ) lib/monocypher-ed25519.o
-ctgrind.out : lib/ctgrind.o $(TEST_OBJ) lib/monocypher-ed25519.o
-speed.out : lib/speed.o $(TEST_OBJ) lib/monocypher-ed25519.o
-test.out speed.out:
+TEST_OBJ= lib/utils.o lib/monocypher.o lib/monocypher-ed25519.o
+test.out : lib/test.o $(TEST_OBJ)
+tis-ci.out : lib/tis-ci.o $(TEST_OBJ)
+ctgrind.out : lib/ctgrind.o $(TEST_OBJ)
+speed.out : lib/speed.o $(TEST_OBJ)
+test.out speed.out tis-ci.out:
$(CC) $(CFLAGS) -I src -I src/optional -o $@ $^
ctgrind.out:
$(CC) $(CFLAGS) -O0 -I src -I src/optional -o $@ $^
vector public_k = next_input(reader);
vector msg = next_input(reader);
vector out = next_output(reader);
- u8 out2[64];
-
- // Sign with cached public key, then by reconstructing the key
- crypto_sign(out.buf, secret_k.buf, public_k.buf, msg.buf, msg.size);
- crypto_sign(out2 , secret_k.buf, 0 , msg.buf, msg.size);
- // Compare signatures (must be the same)
- if (memcmp(out.buf, out2, out.size)) {
- printf("FAILURE: reconstructing public key"
- " yields different signature\n");
- exit(1);
- }
+ u8 fat_secret_key[64];
+ memcpy(fat_secret_key , secret_k.buf, 32);
+ memcpy(fat_secret_key + 32, public_k.buf, 32);
+ crypto_eddsa_sign(out.buf, fat_secret_key, msg.buf, msg.size);
}
static void ed_25519(vector_reader *reader)
vector public_k = next_input(reader);
vector msg = next_input(reader);
vector out = next_output(reader);
- u8 out2[64];
-
- // Sign with cached public key, then by reconstructing the key
- crypto_ed25519_sign(out.buf, secret_k.buf, public_k.buf, msg.buf, msg.size);
- crypto_ed25519_sign(out2 , secret_k.buf, 0 , msg.buf, msg.size);
- // Compare signatures (must be the same)
- if (memcmp(out.buf, out2, out.size)) {
- printf("FAILURE: reconstructing public key"
- " yields different signature\n");
- exit(1);
- }
+ u8 fat_secret_key[64];
+ memcpy(fat_secret_key , secret_k.buf, 32);
+ memcpy(fat_secret_key + 32, public_k.buf, 32);
+ crypto_ed25519_sign(out.buf, fat_secret_key, msg.buf, msg.size);
}
static void ed_25519_check(vector_reader *reader)
static int p_from_eddsa()
{
int status = 0;
- RANDOM_INPUT(ed_private, 32);
- u8 ed_public[32]; crypto_sign_public_key (ed_public, ed_private);
- u8 x_private[32]; crypto_from_eddsa_private(x_private, ed_private);
- u8 x_public1[32]; crypto_from_eddsa_public (x_public1, ed_public);
+ RANDOM_INPUT(ed_seed, 32);
+ u8 secret [64];
+ u8 public [32]; crypto_eddsa_key_pair(secret, public, ed_seed);
+ u8 x_private[32]; crypto_from_eddsa_private(x_private, secret);
+ u8 x_public1[32]; crypto_from_eddsa_public (x_public1, public);
u8 x_public2[32]; crypto_x25519_public_key (x_public2, x_private);
status |= memcmp(x_public1, x_public2, 32);
printf("%s: from_eddsa\n", status != 0 ? "FAILED" : "OK");
static int p_from_ed25519()
{
int status = 0;
- RANDOM_INPUT(ed_private, 32);
- u8 ed_public[32]; crypto_ed25519_public_key (ed_public, ed_private);
- u8 x_private[32]; crypto_from_ed25519_private(x_private, ed_private);
- u8 x_public1[32]; crypto_from_ed25519_public (x_public1, ed_public);
- u8 x_public2[32]; crypto_x25519_public_key (x_public2, x_private);
+ RANDOM_INPUT(ed_seed, 32);
+ u8 secret [64];
+ u8 public [32]; crypto_ed25519_key_pair(secret, public, ed_seed);
+ u8 x_private[32]; crypto_from_ed25519_private(x_private, secret);
+ u8 x_public1[32]; crypto_from_ed25519_public (x_public1, public);
+ u8 x_public2[32]; crypto_x25519_public_key (x_public2, x_private);
status |= memcmp(x_public1, x_public2, 32);
printf("%s: from_ed25519\n", status != 0 ? "FAILED" : "OK");
return status;