Fix grammar in certificates.txt
[openssl.git] / test / curve448_internal_test.c
index f0f10790739c94f238b832220a2417748d244b12..c0b3ae3c80c3b6c7bba32cb1b8375984f12f0fb2 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2023 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -10,7 +10,8 @@
 #include <string.h>
 #include <openssl/e_os2.h>
 #include <openssl/evp.h>
-#include "curve448_lcl.h"
+#include "crypto/ecx.h"
+#include "curve448_local.h"
 #include "testutil.h"
 
 static unsigned int max = 1000;
@@ -600,40 +601,44 @@ static int test_ed448(void)
     EVP_MD_CTX *hashctx = EVP_MD_CTX_new();
 
     if (!TEST_ptr(hashctx)
-            || !TEST_true(ED448_sign(outsig, NULL, 0, pubkey1, privkey1, NULL,
-                                     0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, NULL, 0, pubkey1,
+                                          privkey1, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig1, outsig, sizeof(sig1)), 0)
-            || !TEST_true(ED448_sign(outsig, msg2, sizeof(msg2), pubkey2,
-                                     privkey2, NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg2, sizeof(msg2),
+                                          pubkey2, privkey2, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig2, outsig, sizeof(sig2)), 0)
-            || !TEST_true(ED448_sign(outsig, msg3, sizeof(msg3), pubkey3,
-                                     privkey3, context3, sizeof(context3)))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg3, sizeof(msg3),
+                                          pubkey3, privkey3, context3,
+                                          sizeof(context3), 0, NULL))
             || !TEST_int_eq(memcmp(sig3, outsig, sizeof(sig3)), 0)
-            || !TEST_true(ED448_sign(outsig, msg4, sizeof(msg4), pubkey4,
-                                     privkey4, NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg4, sizeof(msg4),
+                                          pubkey4, privkey4, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig4, outsig, sizeof(sig4)), 0)
-            || !TEST_true(ED448_sign(outsig, msg5, sizeof(msg5), pubkey5,
-                                     privkey5, NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg5, sizeof(msg5),
+                                          pubkey5, privkey5, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig5, outsig, sizeof(sig5)), 0)
-            || !TEST_true(ED448_sign(outsig, msg6, sizeof(msg6), pubkey6,
-                                     privkey6, NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg6, sizeof(msg6),
+                                          pubkey6, privkey6, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig6, outsig, sizeof(sig6)), 0)
-            || !TEST_true(ED448_sign(outsig, msg7, sizeof(msg7), pubkey7,
-                                     privkey7, NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg7, sizeof(msg7),
+                                          pubkey7, privkey7, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig7, outsig, sizeof(sig7)), 0)
-            || !TEST_true(ED448_sign(outsig, msg8, sizeof(msg8), pubkey8,
-                                     privkey8, NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg8, sizeof(msg8),
+                                          pubkey8, privkey8, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig8, outsig, sizeof(sig8)), 0)
-            || !TEST_true(ED448_sign(outsig, msg9, sizeof(msg9), pubkey9,
-                                     privkey9, NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig, msg9, sizeof(msg9),
+                                          pubkey9, privkey9, NULL, 0, 0, NULL))
             || !TEST_int_eq(memcmp(sig9, outsig, sizeof(sig9)), 0)
-            || !TEST_true(ED448ph_sign(outsig, dohash(hashctx, phmsg1,
-                                       sizeof(phmsg1)), phpubkey1, phprivkey1,
-                                       NULL, 0))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig,
+                                          dohash(hashctx, phmsg1,
+                                                 sizeof(phmsg1)), 64, phpubkey1,
+                                                 phprivkey1, NULL, 0, 1, NULL))
             || !TEST_int_eq(memcmp(phsig1, outsig, sizeof(phsig1)), 0)
-            || !TEST_true(ED448ph_sign(outsig, dohash(hashctx, phmsg2,
-                                       sizeof(phmsg2)), phpubkey2, phprivkey2,
-                                       phcontext2, sizeof(phcontext2)))
+            || !TEST_true(ossl_ed448_sign(NULL, outsig,
+                                          dohash(hashctx, phmsg2,
+                                                 sizeof(phmsg2)), 64, phpubkey2,
+                                                 phprivkey2, phcontext2,
+                                                 sizeof(phcontext2), 1, NULL))
             || !TEST_int_eq(memcmp(phsig2, outsig, sizeof(phsig2)), 0)) {
         EVP_MD_CTX_free(hashctx);
         return 0;
@@ -651,9 +656,9 @@ static int test_x448(void)
 
     /* Curve448 tests */
 
-    if (!TEST_true(X448(out, in_scalar1, in_u1))
+    if (!TEST_true(ossl_x448(out, in_scalar1, in_u1))
           || !TEST_int_eq(memcmp(out, out_u1, sizeof(out)), 0)
-          || !TEST_true(X448(out, in_scalar2, in_u2))
+          || !TEST_true(ossl_x448(out, in_scalar2, in_u2))
           || !TEST_int_eq(memcmp(out, out_u2, sizeof(out)), 0))
         return 0;
 
@@ -665,7 +670,7 @@ static int test_x448(void)
             fflush(stdout);
         }
 
-        if (!TEST_true(X448(out, k, u)))
+        if (!TEST_true(ossl_x448(out, k, u)))
             return 0;
 
         if (i == 1 || i == 1000 || i == 1000000) {
@@ -682,19 +687,49 @@ static int test_x448(void)
     return 1;
 }
 
+typedef enum OPTION_choice {
+    OPT_ERR = -1,
+    OPT_EOF = 0,
+    OPT_PROGRESS,
+    OPT_SLOW,
+    OPT_TEST_ENUM
+} OPTION_CHOICE;
+
+const OPTIONS *test_get_options(void)
+{
+    static const OPTIONS test_options[] = {
+        OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("conf_file\n"),
+        { "f", OPT_SLOW, '-', "Enables a slow test" },
+        { "v", OPT_PROGRESS, '-',
+              "Enables verbose mode (prints progress dots)" },
+        { NULL }
+    };
+    return test_options;
+}
+
 int setup_tests(void)
 {
-    /*
-     * The test vectors contain one test which takes a very long time to run,
-     * so we don't do that be default. Using the -f option will cause it to be
-     * run.
-     */
-    if (test_has_option("-f"))
-        max = 1000000;
-
-    /* Print progress dots */
-    if (test_has_option("-v"))
-        verbose = 1;
+    OPTION_CHOICE o;
+
+    while ((o = opt_next()) != OPT_EOF) {
+        switch (o) {
+        case OPT_TEST_CASES:
+            break;
+        default:
+            return 0;
+        /*
+         * The test vectors contain one test which takes a very long time to run
+         * so we don't do that be default. Using the -f option will cause it to
+         * be run.
+         */
+        case OPT_SLOW:
+            max = 1000000;
+            break;
+        case OPT_PROGRESS:
+            verbose = 1; /* Print progress dots */
+            break;
+        }
+    }
 
     ADD_TEST(test_x448);
     ADD_TEST(test_ed448);