Merge f_field.h into field.h
[openssl.git] / crypto / ec / curve448 / curve448_test.c
index 7469a30..c63bded 100644 (file)
@@ -72,24 +72,31 @@ const uint8_t in_u3[56] = {
 
 const uint8_t out_u3[3][56] = {
     {
-        0x3f, 0x48, 0x2c, 0x8a, 0x9f, 0x19, 0xb0, 0x1e, 0x6c, 0x46, 0xee, 0x97,
-        0x11, 0xd9, 0xdc, 0x14, 0xfd, 0x4b, 0xf6, 0x7a, 0xf3, 0x07, 0x65, 0xc2,
-        0xae, 0x2b, 0x84, 0x6a, 0x4d, 0x23, 0xa8, 0xcd, 0x0d, 0xb8, 0x97, 0x08,
-        0x62, 0x39, 0x49, 0x2c, 0xaf, 0x35, 0x0b, 0x51, 0xf8, 0x33, 0x86, 0x8b,
-        0x9b, 0xc2, 0xb3, 0xbc, 0xa9, 0xcf, 0x41, 0x13
-    }, {
-        0xaa, 0x3b, 0x47, 0x49, 0xd5, 0x5b, 0x9d, 0xaf, 0x1e, 0x5b, 0x00, 0x28,
-        0x88, 0x26, 0xc4, 0x67, 0x27, 0x4c, 0xe3, 0xeb, 0xbd, 0xd5, 0xc1, 0x7b,
-        0x97, 0x5e, 0x09, 0xd4, 0xaf, 0x6c, 0x67, 0xcf, 0x10, 0xd0, 0x87, 0x20,
-        0x2d, 0xb8, 0x82, 0x86, 0xe2, 0xb7, 0x9f, 0xce, 0xea, 0x3e, 0xc3, 0x53,
-        0xef, 0x54, 0xfa, 0xa2, 0x6e, 0x21, 0x9f, 0x38
-    }, {
-        0x07, 0x7f, 0x45, 0x36, 0x81, 0xca, 0xca, 0x36, 0x93, 0x19, 0x84, 0x20,
-        0xbb, 0xe5, 0x15, 0xca, 0xe0, 0x00, 0x24, 0x72, 0x51, 0x9b, 0x3e, 0x67,
-        0x66, 0x1a, 0x7e, 0x89, 0xca, 0xb9, 0x46, 0x95, 0xc8, 0xf4, 0xbc, 0xd6,
-        0x6e, 0x61, 0xb9, 0xb9, 0xc9, 0x46, 0xda, 0x8d, 0x52, 0x4d, 0xe3, 0xd6,
-        0x9b, 0xd9, 0xd9, 0xd6, 0x6b, 0x99, 0x7e, 0x37
-    }
+     0x3f, 0x48, 0x2c, 0x8a, 0x9f, 0x19, 0xb0, 0x1e, 0x6c, 0x46, 0xee, 0x97,
+     0x11, 0xd9, 0xdc, 0x14, 0xfd, 0x4b, 0xf6, 0x7a, 0xf3, 0x07, 0x65, 0xc2,
+     0xae, 0x2b, 0x84, 0x6a, 0x4d, 0x23, 0xa8, 0xcd, 0x0d, 0xb8, 0x97, 0x08,
+     0x62, 0x39, 0x49, 0x2c, 0xaf, 0x35, 0x0b, 0x51, 0xf8, 0x33, 0x86, 0x8b,
+     0x9b, 0xc2, 0xb3, 0xbc, 0xa9, 0xcf, 0x41, 0x13}, {
+                                                       0xaa, 0x3b, 0x47, 0x49,
+                                                       0xd5, 0x5b, 0x9d, 0xaf,
+                                                       0x1e, 0x5b, 0x00, 0x28,
+                                                       0x88, 0x26, 0xc4, 0x67,
+                                                       0x27, 0x4c, 0xe3, 0xeb,
+                                                       0xbd, 0xd5, 0xc1, 0x7b,
+                                                       0x97, 0x5e, 0x09, 0xd4,
+                                                       0xaf, 0x6c, 0x67, 0xcf,
+                                                       0x10, 0xd0, 0x87, 0x20,
+                                                       0x2d, 0xb8, 0x82, 0x86,
+                                                       0xe2, 0xb7, 0x9f, 0xce,
+                                                       0xea, 0x3e, 0xc3, 0x53,
+                                                       0xef, 0x54, 0xfa, 0xa2,
+                                                       0x6e, 0x21, 0x9f, 0x38},
+    {
+     0x07, 0x7f, 0x45, 0x36, 0x81, 0xca, 0xca, 0x36, 0x93, 0x19, 0x84, 0x20,
+     0xbb, 0xe5, 0x15, 0xca, 0xe0, 0x00, 0x24, 0x72, 0x51, 0x9b, 0x3e, 0x67,
+     0x66, 0x1a, 0x7e, 0x89, 0xca, 0xb9, 0x46, 0x95, 0xc8, 0xf4, 0xbc, 0xd6,
+     0x6e, 0x61, 0xb9, 0xb9, 0xc9, 0x46, 0xda, 0x8d, 0x52, 0x4d, 0xe3, 0xd6,
+     0x9b, 0xd9, 0xd9, 0xd6, 0x6b, 0x99, 0x7e, 0x37}
 };
 
 /* Test vectors from RFC8032 for Ed448 */
@@ -583,14 +590,13 @@ static const uint8_t *dohash(EVP_MD_CTX *hashctx, const uint8_t *msg,
     static uint8_t hashout[64];
 
     if (!EVP_DigestInit_ex(hashctx, EVP_shake256(), NULL)
-            || !EVP_DigestUpdate(hashctx, msg, msglen)
-            || !EVP_DigestFinalXOF(hashctx, hashout, sizeof(hashout)))
+        || !EVP_DigestUpdate(hashctx, msg, msglen)
+        || !EVP_DigestFinalXOF(hashctx, hashout, sizeof(hashout)))
         return NULL;
 
     return hashout;
 }
 
-
 static int test_eddsa(void)
 {
     uint8_t outsig[114];
@@ -614,7 +620,8 @@ static int test_eddsa(void)
         goto err;
     }
 
-    ED448_sign(outsig, msg3, sizeof(msg3), pubkey3, privkey3, context3, sizeof(context3));
+    ED448_sign(outsig, msg3, sizeof(msg3), pubkey3, privkey3, context3,
+               sizeof(context3));
     if (memcmp(sig3, outsig, sizeof(sig3)) != 0) {
         printf("Calculated sig and expected sig differ (3)\n");
         goto err;
@@ -683,7 +690,7 @@ int main(int argc, char *argv[])
     int j = -1;
 
     if (argc != 1 && (argc != 2 || strcmp(argv[1], "-f") != 0)) {
-        printf ("Usage: curve448_test [-f]\n");
+        printf("Usage: curve448_test [-f]\n");
         return 1;
     }
 
@@ -725,8 +732,9 @@ int main(int argc, char *argv[])
         if (i == 1 || i == 1000 || i == 1000000) {
             j++;
             if (memcmp(out, out_u3[j], sizeof(out)) != 0) {
-                printf("Calculated output and expected output differ (3, %ud)\n",
-                       i);
+                printf
+                    ("Calculated output and expected output differ (3, %ud)\n",
+                     i);
                 return 1;
             }
         }