Update copyright year
[openssl.git] / test / ecdsatest.c
index 95b642b1955dbbaf22a27548de7a8d210fb72b21..531562ed68332a7a7886cb727d51307e842a05fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
@@ -25,6 +25,7 @@
 # ifndef OPENSSL_NO_ENGINE
 #  include <openssl/engine.h>
 # endif
+# include <openssl/sha.h>
 # include <openssl/err.h>
 # include <openssl/rand.h>
 
@@ -135,7 +136,7 @@ static int x9_62_test_internal(int nid, const char *r_in, const char *s_in)
     /* Use ECDSA_sign_setup to avoid use of ECDSA nonces */
     if (!TEST_true(ECDSA_sign_setup(key, NULL, &kinv, &rp)))
         goto x962_int_err;
-       if (!TEST_ptr(signature =
+    if (!TEST_ptr(signature =
                   ECDSA_do_sign_ex(digest, SHA_DIGEST_LENGTH, kinv, rp, key)))
         goto x962_int_err;
 
@@ -151,7 +152,7 @@ static int x9_62_test_internal(int nid, const char *r_in, const char *s_in)
 
     /* verify the signature */
     if (!TEST_int_eq(ECDSA_do_verify(digest, SHA_DIGEST_LENGTH,
-               signature, key), 1))
+                                     signature, key), 1))
         goto x962_int_err;
 
     ret = 1;
@@ -213,8 +214,8 @@ static int test_builtin(void)
     EC_KEY *eckey = NULL, *wrong_eckey = NULL;
     EC_GROUP *group;
     ECDSA_SIG *ecdsa_sig = NULL, *modified_sig = NULL;
-    unsigned char digest[SHA512_DIGEST_LENGTH],
-             wrong_digest[SHA512_DIGEST_LENGTH];
+    unsigned char digest[SHA512_DIGEST_LENGTH];
+    unsigned char wrong_digest[SHA512_DIGEST_LENGTH];
     unsigned char *signature = NULL;
     const unsigned char *sig_ptr;
     unsigned char *sig_ptr2;
@@ -222,7 +223,7 @@ static int test_builtin(void)
     const BIGNUM *sig_r, *sig_s;
     BIGNUM *modified_r = NULL, *modified_s = NULL;
     BIGNUM *unmodified_r = NULL, *unmodified_s = NULL;
-    unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len;
+    unsigned int sig_len, order, r_len, s_len, bn_len, buf_len;
     int nid, ret = 0;
 
     /* fill digest values with some random data */
@@ -250,7 +251,7 @@ static int test_builtin(void)
                 || !TEST_true(EC_KEY_set_group(eckey, group)))
             goto builtin_err;
         EC_GROUP_free(group);
-        degree = EC_GROUP_get_degree(EC_KEY_get0_group(eckey));
+        order = EC_GROUP_order_bits(EC_KEY_get0_group(eckey));
 
         TEST_info("testing %s", OBJ_nid2sn(nid));
 
@@ -273,8 +274,8 @@ static int test_builtin(void)
         /* create signature */
         sig_len = ECDSA_size(eckey);
         if (!TEST_ptr(signature = OPENSSL_malloc(sig_len))
-                       || !TEST_true(ECDSA_sign(0, digest, SHA512_DIGEST_LENGTH,
-                                      signature, &sig_len, eckey)))
+                || !TEST_true(ECDSA_sign(0, digest, SHA512_DIGEST_LENGTH,
+                                         signature, &sig_len, eckey)))
             goto builtin_err;
 
         /* verify signature */
@@ -315,7 +316,7 @@ static int test_builtin(void)
         /* Store the two BIGNUMs in raw_buf. */
         r_len = BN_num_bytes(sig_r);
         s_len = BN_num_bytes(sig_s);
-        bn_len = (degree + 7) / 8;
+        bn_len = (order + 7) / 8;
         if (!TEST_false(r_len > bn_len)
                 || !TEST_false(s_len > bn_len))
             goto builtin_err;
@@ -335,7 +336,7 @@ static int test_builtin(void)
             goto builtin_err;
         if (!TEST_ptr(modified_r = BN_bin2bn(raw_buf, bn_len, NULL))
                 || !TEST_ptr(modified_s = BN_bin2bn(raw_buf + bn_len,
-                                          bn_len, NULL))
+                                                    bn_len, NULL))
                 || !TEST_true(ECDSA_SIG_set0(modified_sig,
                                              modified_r, modified_s))) {
             BN_free(modified_r);
@@ -352,7 +353,7 @@ static int test_builtin(void)
         raw_buf[offset] ^= dirt;
         if (!TEST_ptr(unmodified_r = BN_bin2bn(raw_buf, bn_len, NULL))
                 || !TEST_ptr(unmodified_s = BN_bin2bn(raw_buf + bn_len,
-                                            bn_len, NULL))
+                                                      bn_len, NULL))
                 || !TEST_true(ECDSA_SIG_set0(modified_sig, unmodified_r,
                                              unmodified_s))) {
             BN_free(unmodified_r);