[openssl-commits] [openssl] master update

Dr. Stephen Henson steve at openssl.org
Fri May 19 20:06:03 UTC 2017


The branch master has been updated
       via  a0a760ccf04c05b9a7b8b7a5b3a06a626a297362 (commit)
       via  1bb6b50d4cac1c68877b823e69b5aa82e2518b02 (commit)
       via  c3fc7d9ac5d1f424119dd44ce9565735931f452a (commit)
      from  aabe3a359197d99867abaab8a4beb42003ee7d79 (commit)


- Log -----------------------------------------------------------------
commit a0a760ccf04c05b9a7b8b7a5b3a06a626a297362
Author: Dr. Stephen Henson <steve at openssl.org>
Date:   Fri May 12 00:31:18 2017 +0100

    remove duplicate tests
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3451)

commit 1bb6b50d4cac1c68877b823e69b5aa82e2518b02
Author: Dr. Stephen Henson <steve at openssl.org>
Date:   Fri May 12 01:11:00 2017 +0100

    Add tests
    
    Import test data from sha1test.c, sha256t.c and sha512t.c which is
    from RFC6234 section 8.5
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3451)

commit c3fc7d9ac5d1f424119dd44ce9565735931f452a
Author: Dr. Stephen Henson <steve at openssl.org>
Date:   Thu May 11 19:28:09 2017 +0100

    Add support for multiple update calls in evp_test
    
    Allow multiple "Input" lines to call the update function multiple times.
    Add "Ncopy" keyword to copy the input buffer. So for example:
    
    Input = "a"
    Ncopy = 1024
    
    Will create a buffer consisting of 1024 "a" characters.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3451)

-----------------------------------------------------------------------

Summary of changes:
 test/build.info                          |  15 +--
 test/evp_test.c                          | 165 +++++++++++++++++++++++----
 test/{testutil/tu_local.h => evp_test.h} |   6 +-
 test/evpdigest.txt                       |  74 +++++++++++-
 test/recipes/05-test_sha1.t              |  12 --
 test/recipes/05-test_sha256.t            |  12 --
 test/recipes/05-test_sha512.t            |  12 --
 test/sha1test.c                          | 105 -----------------
 test/sha256t.c                           | 167 ---------------------------
 test/sha512t.c                           | 189 -------------------------------
 10 files changed, 219 insertions(+), 538 deletions(-)
 copy test/{testutil/tu_local.h => evp_test.h} (71%)
 delete mode 100644 test/recipes/05-test_sha1.t
 delete mode 100644 test/recipes/05-test_sha256.t
 delete mode 100644 test/recipes/05-test_sha512.t
 delete mode 100644 test/sha1test.c
 delete mode 100644 test/sha256t.c
 delete mode 100644 test/sha512t.c

diff --git a/test/build.info b/test/build.info
index 42dc1d6..8e94dca 100644
--- a/test/build.info
+++ b/test/build.info
@@ -30,8 +30,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
           md2test \
           hmactest \
           rc2test rc4test rc5test \
-          destest sha1test sha256t sha512t \
-          mdc2test \
+          destest mdc2test \
           randtest dhtest enginetest casttest \
           bftest ssltest_old dsatest exptest rsa_test \
           evp_test evp_extra_test igetest v3nametest v3ext \
@@ -109,18 +108,6 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
   INCLUDE[destest]=../include
   DEPEND[destest]=../libcrypto libtestutil.a
 
-  SOURCE[sha1test]=sha1test.c
-  INCLUDE[sha1test]=../include
-  DEPEND[sha1test]=../libcrypto libtestutil.a
-
-  SOURCE[sha256t]=sha256t.c
-  INCLUDE[sha256t]=../include
-  DEPEND[sha256t]=../libcrypto libtestutil.a
-
-  SOURCE[sha512t]=sha512t.c
-  INCLUDE[sha512t]=../include
-  DEPEND[sha512t]=../libcrypto libtestutil.a
-
   SOURCE[mdc2test]=mdc2test.c
   INCLUDE[mdc2test]=../include
   DEPEND[mdc2test]=../libcrypto libtestutil.a
diff --git a/test/evp_test.c b/test/evp_test.c
index d042a4e..3c64849 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -19,6 +19,7 @@
 #include <openssl/kdf.h>
 #include "internal/numbers.h"
 #include "testutil.h"
+#include "evp_test.h"
 
 static const char *current_test_file = "???";
 
@@ -168,6 +169,131 @@ static int test_bin(const char *value, unsigned char **buf, size_t *buflen)
     *buflen = len;
     return 1;
 }
+
+/*
+ * Structure used to hold a list of blocks of memory to test
+ * calls to "update" like functions.
+ */
+
+struct evp_test_buffer_st {
+    unsigned char *buf;
+    size_t buflen;
+    size_t count;
+    int count_set;
+};
+
+static void evp_test_buffer_free(EVP_TEST_BUFFER *db)
+{
+    if (db != NULL) {
+        OPENSSL_free(db->buf);
+        OPENSSL_free(db);
+    }
+}
+
+/* append buffer to a list */
+
+static int evp_test_buffer_append(const char *value,
+                                  STACK_OF(EVP_TEST_BUFFER) **sk)
+{
+    EVP_TEST_BUFFER *db = NULL;
+
+    if (!TEST_ptr(db = OPENSSL_malloc(sizeof(*db))))
+        goto err;
+
+    if (!test_bin(value, &db->buf, &db->buflen))
+        goto err;
+    db->count = 1;
+    db->count_set = 0;
+
+    if (*sk == NULL && !TEST_ptr(*sk = sk_EVP_TEST_BUFFER_new_null()))
+            goto err;
+
+    if (!sk_EVP_TEST_BUFFER_push(*sk, db))
+        goto err;
+
+    return 1;
+
+    err:
+    evp_test_buffer_free(db);
+
+    return 0;
+}
+
+/*
+ * replace last buffer in list with copies of itself
+ */
+static int evp_test_buffer_ncopy(const char *value,
+                                 STACK_OF(EVP_TEST_BUFFER) *sk)
+{
+    EVP_TEST_BUFFER *db;
+    unsigned char *tbuf, *p;
+    size_t tbuflen;
+    int ncopy = atoi(value);
+    int i;
+
+    if (ncopy <= 0)
+        return 0;
+    if (sk == NULL || sk_EVP_TEST_BUFFER_num(sk) == 0)
+        return 0;
+    db = sk_EVP_TEST_BUFFER_value(sk, sk_EVP_TEST_BUFFER_num(sk) - 1);
+
+    tbuflen = db->buflen * ncopy;
+    if (!TEST_ptr(tbuf = OPENSSL_malloc(tbuflen)))
+        return 0;
+    for (i = 0, p = tbuf; i < ncopy; i++, p += db->buflen)
+        memcpy(p, db->buf, db->buflen);
+
+    OPENSSL_free(db->buf);
+    db->buf = tbuf;
+    db->buflen = tbuflen;
+    return 1;
+}
+
+/* set repeat count for last buffer in list */
+static int evp_test_buffer_set_count(const char *value,
+                                     STACK_OF(EVP_TEST_BUFFER) *sk)
+{
+    EVP_TEST_BUFFER *db;
+    int count = atoi(value);
+
+    if (count <= 0)
+        return 0;
+
+    if (sk == NULL || sk_EVP_TEST_BUFFER_num(sk) == 0)
+        return 0;
+
+    db = sk_EVP_TEST_BUFFER_value(sk, sk_EVP_TEST_BUFFER_num(sk) - 1);
+    if (db->count_set)
+        return 0;
+
+    db->count = (size_t)count;
+    db->count_set = 1;
+    return 1;
+}
+
+/*
+ * call "fn" with each element of the list in turn
+ */
+static int evp_test_buffer_do(STACK_OF(EVP_TEST_BUFFER) *sk,
+                              int (*fn)(void *ctx,
+                                        const unsigned char *buf,
+                                        size_t buflen),
+                              void *ctx)
+{
+    int i;
+
+    for (i = 0; i < sk_EVP_TEST_BUFFER_num(sk); i++) {
+        EVP_TEST_BUFFER *tb = sk_EVP_TEST_BUFFER_value(sk, i);
+        size_t j;
+
+        for (j = 0; j < tb->count; j++) {
+            if (fn(ctx, tb->buf, tb->buflen) <= 0)
+                return 0;
+        }
+    }
+    return 1;
+}
+
 #ifndef OPENSSL_NO_SCRYPT
 /* Currently only used by scrypt tests */
 /* Parse unsigned decimal 64 bit integer value */
@@ -611,10 +737,7 @@ typedef struct digest_data_st {
     /* Digest this test is for */
     const EVP_MD *digest;
     /* Input to digest */
-    unsigned char *input;
-    size_t input_len;
-    /* Repeat count for input */
-    size_t nrpt;
+    STACK_OF(EVP_TEST_BUFFER) *input;
     /* Expected output */
     unsigned char *output;
     size_t output_len;
@@ -636,7 +759,6 @@ static int digest_test_init(EVP_TEST *t, const char *alg)
     }
     mdat = OPENSSL_zalloc(sizeof(*mdat));
     mdat->digest = digest;
-    mdat->nrpt = 1;
     t->data = mdat;
     return 1;
 }
@@ -645,7 +767,7 @@ static void digest_test_cleanup(EVP_TEST *t)
 {
     DIGEST_DATA *mdat = t->data;
 
-    OPENSSL_free(mdat->input);
+    sk_EVP_TEST_BUFFER_pop_free(mdat->input, evp_test_buffer_free);
     OPENSSL_free(mdat->output);
 }
 
@@ -655,23 +777,24 @@ static int digest_test_parse(EVP_TEST *t,
     DIGEST_DATA *mdata = t->data;
 
     if (strcmp(keyword, "Input") == 0)
-        return test_bin(value, &mdata->input, &mdata->input_len);
+        return evp_test_buffer_append(value, &mdata->input);
     if (strcmp(keyword, "Output") == 0)
         return test_bin(value, &mdata->output, &mdata->output_len);
-    if (strcmp(keyword, "Count") == 0) {
-        long nrpt = atoi(value);
-        if (nrpt <= 0)
-            return 0;
-        mdata->nrpt = (size_t)nrpt;
-        return 1;
-    }
+    if (strcmp(keyword, "Count") == 0)
+        return evp_test_buffer_set_count(value, mdata->input);
+    if (strcmp(keyword, "Ncopy") == 0)
+        return evp_test_buffer_ncopy(value, mdata->input);
     return 0;
 }
 
+static int digest_update_fn(void *ctx, const unsigned char *buf, size_t buflen)
+{
+    return EVP_DigestUpdate(ctx, buf, buflen);
+}
+
 static int digest_test_run(EVP_TEST *t)
 {
     DIGEST_DATA *mdata = t->data;
-    size_t i;
     EVP_MD_CTX *mctx;
     unsigned char md[EVP_MAX_MD_SIZE];
     unsigned int md_len;
@@ -684,11 +807,11 @@ static int digest_test_run(EVP_TEST *t)
         t->err = "DIGESTINIT_ERROR";
         goto err;
     }
-    for (i = 0; i < mdata->nrpt; i++)
-        if (!EVP_DigestUpdate(mctx, mdata->input, mdata->input_len)) {
-            t->err = "DIGESTUPDATE_ERROR";
-            goto err;
-        }
+    if (!evp_test_buffer_do(mdata->input, digest_update_fn, mctx)) {
+        t->err = "DIGESTUPDATE_ERROR";
+        goto err;
+    }
+
     if (!EVP_DigestFinal(mctx, md, &md_len)) {
         t->err = "DIGESTFINAL_ERROR";
         goto err;
@@ -1962,7 +2085,7 @@ static const EVP_TEST_METHOD kdf_test_method = {
     kdf_test_run
 };
 
-typedef struct keypair_test_data_st {
+typedef struct keypair_test_buffer_st {
     EVP_PKEY *privk;
     EVP_PKEY *pubk;
 } KEYPAIR_TEST_DATA;
diff --git a/test/testutil/tu_local.h b/test/evp_test.h
similarity index 71%
copy from test/testutil/tu_local.h
copy to test/evp_test.h
index ad50fca..5402e1e 100644
--- a/test/testutil/tu_local.h
+++ b/test/evp_test.h
@@ -7,7 +7,5 @@
  * https://www.openssl.org/source/license.html
  */
 
-#include <stdlib.h>              /* size_t */
-
-int subtest_level(void);
-int openssl_error_cb(const char *str, size_t len, void *u);
+typedef struct evp_test_buffer_st EVP_TEST_BUFFER;
+DEFINE_STACK_OF(EVP_TEST_BUFFER)
diff --git a/test/evpdigest.txt b/test/evpdigest.txt
index 38ea7ac..7103356 100644
--- a/test/evpdigest.txt
+++ b/test/evpdigest.txt
@@ -90,11 +90,81 @@ Digest = BLAKE2b512
 Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F8081
 Output = DF0A9D0C212843A6A934E3902B2DD30D17FBA5F969D2030B12A546D8A6A45E80CF5635F071F0452E9C919275DA99BED51EB1173C1AF0518726B75B0EC3BAE2B5
 
-# SHA(1) tests (from shatest.c)
+# SHA tests from RFC6234 section 8.5
 Digest = SHA1
-Input = 616263
+Input = "abc"
 Output = a9993e364706816aba3e25717850c26c9cd0d89d
 
+Digest = SHA1
+Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+Output = 84983e441c3bd26ebaae4aa1f95129e5e54670f1
+
+Digest = SHA1
+Input = "a"
+Ncopy = 1000
+Count = 1000
+Output = 34aa973cd4c4daa4f61eeb2bdbad27316534016f
+
+Digest = SHA224
+Input = "abc"
+Output = 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7
+
+Digest = SHA224
+Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+Output = 75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525
+
+Digest = SHA224
+Input = "a"
+Ncopy = 64
+Count = 15625
+Output = 20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67
+
+Digest = SHA256
+Input = "abc"
+Output = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
+
+Digest = SHA256
+Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+Output = 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1
+
+Digest = SHA256
+Input = "a"
+Ncopy = 288
+Count = 3472
+Input = "a"
+Ncopy = 64
+Output = cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0
+
+Digest = SHA384
+Input = "abc"
+Output = cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7
+
+Digest = SHA384
+Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+Output = 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039
+
+Digest = SHA384
+Input = "a"
+Ncopy = 64
+Count = 15625
+Output = 9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985
+
+Digest = SHA512
+Input = "abc"
+Output = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
+
+Digest = SHA512
+Input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+Output = 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909
+
+Digest = SHA512
+Input = "a"
+Ncopy = 288
+Count = 3472
+Input = "a"
+Ncopy = 64
+Output = e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b
+
 # MD5 tests
 Digest = MD5
 Input =
diff --git a/test/recipes/05-test_sha1.t b/test/recipes/05-test_sha1.t
deleted file mode 100644
index 21bb74e..0000000
--- a/test/recipes/05-test_sha1.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#! /usr/bin/env perl
-# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
-#
-# Licensed under the OpenSSL license (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
-
-
-use OpenSSL::Test::Simple;
-
-simple_test("test_sha1", "sha1test", "sha");
diff --git a/test/recipes/05-test_sha256.t b/test/recipes/05-test_sha256.t
deleted file mode 100644
index 071a45c..0000000
--- a/test/recipes/05-test_sha256.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#! /usr/bin/env perl
-# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
-#
-# Licensed under the OpenSSL license (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
-
-
-use OpenSSL::Test::Simple;
-
-simple_test("test_sha256", "sha256t", "sha");
diff --git a/test/recipes/05-test_sha512.t b/test/recipes/05-test_sha512.t
deleted file mode 100644
index 4ce585c..0000000
--- a/test/recipes/05-test_sha512.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#! /usr/bin/env perl
-# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
-#
-# Licensed under the OpenSSL license (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
-
-
-use OpenSSL::Test::Simple;
-
-simple_test("test_sha512", "sha512t", "sha");
diff --git a/test/sha1test.c b/test/sha1test.c
deleted file mode 100644
index 6a8b304..0000000
--- a/test/sha1test.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (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
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include "../e_os.h"
-#include "testutil.h"
-
-#include <openssl/evp.h>
-#include <openssl/sha.h>
-
-#ifdef CHARSET_EBCDIC
-# include <openssl/ebcdic.h>
-#endif
-
-static char test[][80] = {
-    { "abc" },
-    { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" }
-};
-
-static char *ret[] = {
-    "a9993e364706816aba3e25717850c26c9cd0d89d",
-    "84983e441c3bd26ebaae4aa1f95129e5e54670f1",
-};
-
-static char *bigret = "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
-
-static char *pt(unsigned char *md)
-{
-    int i;
-    static char buf[80];
-
-    for (i = 0; i < SHA_DIGEST_LENGTH; i++)
-        sprintf(&(buf[i * 2]), "%02x", md[i]);
-    return buf;
-}
-
-static int test_sha1(int i)
-{
-    EVP_MD_CTX *c;
-    unsigned char md[SHA_DIGEST_LENGTH];
-    const size_t tlen = strlen(test[i]);
-    int testresult = 0;
-
-    c = EVP_MD_CTX_new();
-    if (!TEST_ptr(c))
-        goto end;
-
-# ifdef CHARSET_EBCDIC
-    ebcdic2ascii(test[i], test[i], tlen);
-# endif
-    if (!TEST_true(EVP_Digest(test[i], tlen, md, NULL, EVP_sha1(), NULL))
-        || !TEST_str_eq(pt(md), ret[i]))
-        goto end;
-
-    testresult = 1;
- end:
-    EVP_MD_CTX_free(c);
-    return testresult;
-}
-
-static int test_sha1_big(void)
-{
-    static unsigned char buf[1000];
-    EVP_MD_CTX *c;
-    unsigned char md[SHA_DIGEST_LENGTH];
-    int i, testresult = 0;
-
-    c = EVP_MD_CTX_new();
-    if (!TEST_ptr(c))
-        goto end;
-
-    memset(buf, 'a', 1000);
-#ifdef CHARSET_EBCDIC
-    ebcdic2ascii(buf, buf, 1000);
-#endif                         /* CHARSET_EBCDIC */
-    if (!TEST_true(EVP_DigestInit_ex(c, EVP_sha1(), NULL)))
-        goto end;
-    for (i = 0; i < 1000; i++)
-        if (!TEST_true(EVP_DigestUpdate(c, buf, 1000)))
-            goto end;
-    if (!TEST_true(EVP_DigestFinal_ex(c, md, NULL)))
-        goto end;
-
-    if (!TEST_str_eq(pt(md), bigret))
-        goto end;
-
-    testresult = 1;
- end:
-    EVP_MD_CTX_free(c);
-    return testresult;
-}
-
-void register_tests(void)
-{
-    ADD_ALL_TESTS(test_sha1, OSSL_NELEM(test));
-    ADD_TEST(test_sha1_big);
-}
diff --git a/test/sha256t.c b/test/sha256t.c
deleted file mode 100644
index c6ce1ae..0000000
--- a/test/sha256t.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2004-2017 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (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
- */
-
-#include <openssl/sha.h>
-#include <openssl/evp.h>
-
-#include "testutil.h"
-
-static const unsigned char app_b1[SHA256_DIGEST_LENGTH] = {
-    0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
-    0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
-    0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
-    0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
-};
-
-static const unsigned char app_b2[SHA256_DIGEST_LENGTH] = {
-    0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8,
-    0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39,
-    0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67,
-    0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1
-};
-
-static const unsigned char app_b3[SHA256_DIGEST_LENGTH] = {
-    0xcd, 0xc7, 0x6e, 0x5c, 0x99, 0x14, 0xfb, 0x92,
-    0x81, 0xa1, 0xc7, 0xe2, 0x84, 0xd7, 0x3e, 0x67,
-    0xf1, 0x80, 0x9a, 0x48, 0xa4, 0x97, 0x20, 0x0e,
-    0x04, 0x6d, 0x39, 0xcc, 0xc7, 0x11, 0x2c, 0xd0
-};
-
-static const unsigned char addenum_1[SHA224_DIGEST_LENGTH] = {
-    0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, 0x22,
-    0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, 0x55, 0xb3,
-    0x2a, 0xad, 0xbc, 0xe4, 0xbd, 0xa0, 0xb3, 0xf7,
-    0xe3, 0x6c, 0x9d, 0xa7
-};
-
-static const unsigned char addenum_2[SHA224_DIGEST_LENGTH] = {
-    0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, 0xcc,
-    0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, 0x01, 0x50,
-    0xb0, 0xc6, 0x45, 0x5c, 0xb4, 0xf5, 0x8b, 0x19,
-    0x52, 0x52, 0x25, 0x25
-};
-
-static const unsigned char addenum_3[SHA224_DIGEST_LENGTH] = {
-    0x20, 0x79, 0x46, 0x55, 0x98, 0x0c, 0x91, 0xd8,
-    0xbb, 0xb4, 0xc1, 0xea, 0x97, 0x61, 0x8a, 0x4b,
-    0xf0, 0x3f, 0x42, 0x58, 0x19, 0x48, 0xb2, 0xee,
-    0x4e, 0xe7, 0xad, 0x67
-};
-
-static int test_sha256_short(void)
-{
-    unsigned char md[SHA256_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abc", 3, md, NULL, EVP_sha256(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), app_b1, sizeof(app_b1));
-}
-
-static int test_sha256_long(void)
-{
-    unsigned char md[SHA256_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abcdbcde" "cdefdefg" "efghfghi" "ghijhijk"
-                              "ijkljklm" "klmnlmno" "mnopnopq", 56, md,
-                               NULL, EVP_sha256(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), app_b2, sizeof(app_b2));
-}
-
-static int test_sha256_multi(void)
-{
-    unsigned char md[SHA256_DIGEST_LENGTH];
-    int i, testresult = 0;
-    EVP_MD_CTX *evp;
-    static const char *updstr = "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa";
-
-    evp = EVP_MD_CTX_new();
-    if (!TEST_ptr(evp))
-        return 0;
-    if (!TEST_true(EVP_DigestInit_ex(evp, EVP_sha256(), NULL)))
-        goto end;
-    for (i = 0; i < 1000000; i += 288)
-        if (!TEST_true(EVP_DigestUpdate(evp, updstr,
-                                        (1000000 - i) < 288 ? 1000000 - i
-                                                            : 288)))
-            goto end;
-    if (!TEST_true(EVP_DigestFinal_ex(evp, md, NULL))
-        || !TEST_mem_eq(md, sizeof(md), app_b3, sizeof(app_b3)))
-        goto end;
-
-    testresult = 1;
- end:
-    EVP_MD_CTX_free(evp);
-    return testresult;
-}
-
-static int test_sha224_short(void)
-{
-    unsigned char md[SHA224_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abc", 3, md, NULL, EVP_sha224(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), addenum_1, sizeof(addenum_1));
-}
-
-static int test_sha224_long(void)
-{
-    unsigned char md[SHA224_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abcdbcde" "cdefdefg" "efghfghi" "ghijhijk"
-                              "ijkljklm" "klmnlmno" "mnopnopq", 56, md,
-                              NULL, EVP_sha224(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), addenum_2, sizeof(addenum_2));
-}
-
-static int test_sha224_multi(void)
-{
-    unsigned char md[SHA224_DIGEST_LENGTH];
-    int i, testresult = 0;
-    EVP_MD_CTX *evp;
-    static const char *updstr = "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa";
-
-    evp = EVP_MD_CTX_new();
-    if (!TEST_ptr(evp))
-        return 0;
-    if (!TEST_true(EVP_DigestInit_ex(evp, EVP_sha224(), NULL)))
-        goto end;
-    for (i = 0; i < 1000000; i += 64)
-        if (!TEST_true(EVP_DigestUpdate(evp, updstr,
-                                        (1000000 - i) < 64 ? 1000000 - i : 64)))
-            goto end;
-    if (!TEST_true(EVP_DigestFinal_ex(evp, md, NULL))
-        || !TEST_mem_eq(md, sizeof(md), addenum_3, sizeof(addenum_3)))
-        goto end;
-
-    testresult = 1;
- end:
-    EVP_MD_CTX_free(evp);
-    return testresult;
-}
-
-void register_tests(void)
-{
-    ADD_TEST(test_sha256_short);
-    ADD_TEST(test_sha256_long);
-    ADD_TEST(test_sha256_multi);
-    ADD_TEST(test_sha224_short);
-    ADD_TEST(test_sha224_long);
-    ADD_TEST(test_sha224_multi);
-}
diff --git a/test/sha512t.c b/test/sha512t.c
deleted file mode 100644
index 2a1bd1b..0000000
--- a/test/sha512t.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2004-2017 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the OpenSSL license (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
- */
-
-#include <openssl/sha.h>
-#include <openssl/evp.h>
-
-#include "testutil.h"
-
-static const unsigned char app_c1[SHA512_DIGEST_LENGTH] = {
-    0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
-    0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
-    0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
-    0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a,
-    0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8,
-    0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd,
-    0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
-    0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f
-};
-
-static const unsigned char app_c2[SHA512_DIGEST_LENGTH] = {
-    0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda,
-    0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f,
-    0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1,
-    0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18,
-    0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4,
-    0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a,
-    0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54,
-    0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09
-};
-
-static const unsigned char app_c3[SHA512_DIGEST_LENGTH] = {
-    0xe7, 0x18, 0x48, 0x3d, 0x0c, 0xe7, 0x69, 0x64,
-    0x4e, 0x2e, 0x42, 0xc7, 0xbc, 0x15, 0xb4, 0x63,
-    0x8e, 0x1f, 0x98, 0xb1, 0x3b, 0x20, 0x44, 0x28,
-    0x56, 0x32, 0xa8, 0x03, 0xaf, 0xa9, 0x73, 0xeb,
-    0xde, 0x0f, 0xf2, 0x44, 0x87, 0x7e, 0xa6, 0x0a,
-    0x4c, 0xb0, 0x43, 0x2c, 0xe5, 0x77, 0xc3, 0x1b,
-    0xeb, 0x00, 0x9c, 0x5c, 0x2c, 0x49, 0xaa, 0x2e,
-    0x4e, 0xad, 0xb2, 0x17, 0xad, 0x8c, 0xc0, 0x9b
-};
-
-static const unsigned char app_d1[SHA384_DIGEST_LENGTH] = {
-    0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b,
-    0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07,
-    0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63,
-    0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed,
-    0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23,
-    0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7
-};
-
-static const unsigned char app_d2[SHA384_DIGEST_LENGTH] = {
-    0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8,
-    0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47,
-    0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2,
-    0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12,
-    0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9,
-    0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39
-};
-
-static const unsigned char app_d3[SHA384_DIGEST_LENGTH] = {
-    0x9d, 0x0e, 0x18, 0x09, 0x71, 0x64, 0x74, 0xcb,
-    0x08, 0x6e, 0x83, 0x4e, 0x31, 0x0a, 0x4a, 0x1c,
-    0xed, 0x14, 0x9e, 0x9c, 0x00, 0xf2, 0x48, 0x52,
-    0x79, 0x72, 0xce, 0xc5, 0x70, 0x4c, 0x2a, 0x5b,
-    0x07, 0xb8, 0xb3, 0xdc, 0x38, 0xec, 0xc4, 0xeb,
-    0xae, 0x97, 0xdd, 0xd8, 0x7f, 0x3d, 0x89, 0x85
-};
-
-static int test_sha512_short(void)
-{
-    unsigned char md[SHA512_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abc", 3, md, NULL, EVP_sha512(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), app_c1, sizeof(app_c1));
-}
-
-static int test_sha512_long(void)
-{
-    unsigned char md[SHA512_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abcdefgh" "bcdefghi" "cdefghij" "defghijk"
-                              "efghijkl" "fghijklm" "ghijklmn" "hijklmno"
-                              "ijklmnop" "jklmnopq" "klmnopqr" "lmnopqrs"
-                              "mnopqrst" "nopqrstu", 112, md, NULL,
-                              EVP_sha512(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), app_c2, sizeof(app_c2));
-}
-
-static int test_sha512_multi(void)
-{
-    unsigned char md[SHA512_DIGEST_LENGTH];
-    int i, testresult = 0;
-    EVP_MD_CTX *evp;
-    static const char *updstr = "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa";
-
-    evp = EVP_MD_CTX_new();
-    if (!TEST_ptr(evp))
-        return 0;
-    if (!TEST_true(EVP_DigestInit_ex(evp, EVP_sha512(), NULL)))
-        goto end;
-    for (i = 0; i < 1000000; i += 288)
-        if (!TEST_true(EVP_DigestUpdate(evp, updstr,
-                                        (1000000 - i) < 288 ? 1000000 - i
-                                                            : 288)))
-            goto end;
-    if (!TEST_true(EVP_DigestFinal_ex(evp, md, NULL))
-        || !TEST_mem_eq(md, sizeof(md), app_c3, sizeof(app_c3)))
-        goto end;
-
-    testresult = 1;
- end:
-    EVP_MD_CTX_free(evp);
-    return testresult;
-}
-
-static int test_sha384_short(void)
-{
-    unsigned char md[SHA384_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abc", 3, md, NULL, EVP_sha384(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), app_d1, sizeof(app_d1));
-}
-
-static int test_sha384_long(void)
-{
-    unsigned char md[SHA384_DIGEST_LENGTH];
-
-    if (!TEST_true(EVP_Digest("abcdefgh" "bcdefghi" "cdefghij" "defghijk"
-                              "efghijkl" "fghijklm" "ghijklmn" "hijklmno"
-                              "ijklmnop" "jklmnopq" "klmnopqr" "lmnopqrs"
-                              "mnopqrst" "nopqrstu", 112, md, NULL,
-                              EVP_sha384(), NULL)))
-        return 0;
-    return TEST_mem_eq(md, sizeof(md), app_d2, sizeof(app_d2));
-}
-
-static int test_sha384_multi(void)
-{
-    unsigned char md[SHA384_DIGEST_LENGTH];
-    int i, testresult = 0;
-    EVP_MD_CTX *evp;
-    static const char *updstr = "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
-                                "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa";
-
-    evp = EVP_MD_CTX_new();
-    if (!TEST_ptr(evp))
-        return 0;
-    if (!TEST_true(EVP_DigestInit_ex(evp, EVP_sha384(), NULL)))
-        goto end;
-    for (i = 0; i < 1000000; i += 64)
-        if (!TEST_true(EVP_DigestUpdate(evp, updstr,
-                                        (1000000 - i) < 64 ? 1000000 - i : 64)))
-            goto end;
-    if (!TEST_true(EVP_DigestFinal_ex(evp, md, NULL))
-        || !TEST_mem_eq(md, sizeof(md), app_d3, sizeof(app_d3)))
-        goto end;
-
-    testresult = 1;
- end:
-    EVP_MD_CTX_free(evp);
-    return testresult;
-}
-
-void register_tests(void)
-{
-    ADD_TEST(test_sha512_short);
-    ADD_TEST(test_sha512_long);
-    ADD_TEST(test_sha512_multi);
-    ADD_TEST(test_sha384_short);
-    ADD_TEST(test_sha384_long);
-    ADD_TEST(test_sha384_multi);
-}


More information about the openssl-commits mailing list