]> git.codecow.com Git - Monocypher.git/commitdiff
Fix tis-ci
authorLoup Vaillant <loup@loup-vaillant.fr>
Sat, 3 Dec 2022 11:26:17 +0000 (12:26 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sat, 3 Dec 2022 11:26:17 +0000 (12:26 +0100)
Also integrated tis-ci tests into github CI

.github/workflows/ci.yml
makefile
tests/test.sh
tests/tis-ci-vectors.h
tests/tis-ci.c

index 3a5df1d57e53cc4163401a7d11175fd3eddebde7..756e8171364ace5465591d15e07903ac6a94de39 100644 (file)
@@ -98,6 +98,9 @@ jobs:
       - name: Run tests
         run: make clean && make test -j4
 
+      - name: Run tis-ci tests
+        run: make clean && make tis-ci -j4
+
       - name: Run speed tests
         run: |
           make clean && make speed -j4
index ce00b4df812f77441a6d7da7e71c02d0a7b32069..0eb0c3f39331024183aa01e72b76ab6258dfd093 100644 (file)
--- a/makefile
+++ b/makefile
@@ -68,7 +68,7 @@ endif
 
 .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                                                \
@@ -116,13 +116,16 @@ 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
@@ -150,11 +153,12 @@ lib/monocypher.o lib/monocypher-ed25519.o lib/chacha20.o lib/aead-incr.o:
 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 \
@@ -223,11 +227,12 @@ lib/speed-ed25519.o: tests/externals/ed25519-donna/ed25519.c \
             -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 $@ $^
index 42f2a9872121ba74fda34a5d5bf1c27338bd10cb..7d2207d4129f0059a46fff8bdf9060010e2bff8f 100755 (executable)
@@ -53,6 +53,8 @@
 
 set -e
 
+make clean;  make tis-ci
+make clean;  make test
 make clean;  make test CFLAGS="-DBLAKE2_NO_UNROLLING -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"
index f3146a339dd5cef3ffe230fcb1af92326b3701b7..04f5a102ac171860a42ece948877328a5568f4b9 100644 (file)
@@ -390,13 +390,6 @@ static const char *ed_25519_check_vectors[]={
   "ff",
 };
 static size_t nb_ed_25519_check_vectors=12;
-static const char *x25519_pk_vectors[]={
-  "e4e4c4054fe35a75d9c0f679ad8770d8227e68e4c1e68ce67ee88e6be251a207",
-  "e5410cf8d4524fe8b010158cf7c541420e996b6b1378d4ed88deaaee29263b12",
-  "0000000000000000000000000000000000000000000000000000000000000000",
-  "2fe57da347cd62431528daac5fbb290730fff684afc4cfc2ed90995f58cb3b74",
-};
-static size_t nb_x25519_pk_vectors=4;
 static const char *key_exchange_vectors[]={
   "77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a",
   "de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f",
index b43405418298b3dda566cfe380d39b9f5609ee32..c936b1b66feb66ec1a5b008ab3b468753e5d4b45 100644 (file)
@@ -191,17 +191,10 @@ static void edDSA(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_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)
@@ -210,17 +203,10 @@ 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)
@@ -260,10 +246,11 @@ static void elligator_inv(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");
@@ -274,11 +261,12 @@ static int p_from_eddsa()
 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;