Add digest_test with tests for all existing EVP_MDs.
Remove the existing md5_test and sha1_test. They now are all covered by
digest_test. For good measure, test the one-shot functions too.
Change-Id: I8e144cc563fb8817144e26cbd2e10c15642464ba
Reviewed-on: https://boringssl-review.googlesource.com/2211
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/digest/CMakeLists.txt b/crypto/digest/CMakeLists.txt
index a7ea708..697892b 100644
--- a/crypto/digest/CMakeLists.txt
+++ b/crypto/digest/CMakeLists.txt
@@ -9,3 +9,11 @@
digests.c
digest_error.c
)
+
+add_executable(
+ digest_test
+
+ digest_test.c
+)
+
+target_link_libraries(digest_test crypto)
diff --git a/crypto/digest/digest_test.c b/crypto/digest/digest_test.c
new file mode 100644
index 0000000..7c37cb5
--- /dev/null
+++ b/crypto/digest/digest_test.c
@@ -0,0 +1,240 @@
+/* Copyright (c) 2014, Google Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <openssl/crypto.h>
+#include <openssl/digest.h>
+#include <openssl/err.h>
+#include <openssl/md4.h>
+#include <openssl/md5.h>
+#include <openssl/sha.h>
+
+
+typedef struct {
+ /* md_func is the digest to test. */
+ const EVP_MD *(*md_func)(void);
+ /* one_shot_func is the convenience one-shot version of the
+ * digest. */
+ uint8_t *(*one_shot_func)(const uint8_t *, size_t, uint8_t *);
+ /* input is a NUL-terminated string to hash. */
+ const char *input;
+ /* repeat is the number of times to repeat input. */
+ size_t repeat;
+ /* expected_hex is the expected digest in hexadecimal. */
+ const char *expected_hex;
+} TEST_VECTOR;
+
+static const TEST_VECTOR kTestVectors[] = {
+ /* MD4 tests, from RFC 1320. (crypto/md4 does not provide a
+ * one-shot MD4 function.) */
+ { &EVP_md4, NULL, "", 1, "31d6cfe0d16ae931b73c59d7e0c089c0" },
+ { &EVP_md4, NULL, "a", 1, "bde52cb31de33e46245e05fbdbd6fb24" },
+ { &EVP_md4, NULL, "abc", 1, "a448017aaf21d8525fc10ae87aa6729d" },
+ { &EVP_md4, NULL, "message digest", 1,
+ "d9130a8164549fe818874806e1c7014b" },
+ { &EVP_md4, NULL, "abcdefghijklmnopqrstuvwxyz", 1,
+ "d79e1c308aa5bbcdeea8ed63df412da9" },
+ { &EVP_md4, NULL,
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 1,
+ "043f8582f241db351ce627e153e7f0e4" },
+ { &EVP_md4, NULL, "1234567890", 8, "e33b4ddc9c38f2199c3e7b164fcc0536" },
+
+ /* MD5 tests, from RFC 1321. */
+ { &EVP_md5, &MD5, "", 1, "d41d8cd98f00b204e9800998ecf8427e" },
+ { &EVP_md5, &MD5, "a", 1, "0cc175b9c0f1b6a831c399e269772661" },
+ { &EVP_md5, &MD5, "abc", 1, "900150983cd24fb0d6963f7d28e17f72" },
+ { &EVP_md5, &MD5, "message digest", 1, "f96b697d7cb7938d525a2f31aaf161d0" },
+ { &EVP_md5, &MD5, "abcdefghijklmnopqrstuvwxyz", 1,
+ "c3fcd3d76192e4007dfb496cca67e13b" },
+ { &EVP_md5, &MD5,
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 1,
+ "d174ab98d277d9f5a5611c2c9f419d9f" },
+ { &EVP_md5, &MD5, "1234567890", 8, "57edf4a22be3c955ac49da2e2107b67a" },
+
+ /* SHA-1 tests, from RFC 3174. */
+ { &EVP_sha1, &SHA1, "abc", 1, "a9993e364706816aba3e25717850c26c9cd0d89d" },
+ { &EVP_sha1, &SHA1,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 1,
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1" },
+ { &EVP_sha1, &SHA1, "a", 1000000,
+ "34aa973cd4c4daa4f61eeb2bdbad27316534016f" },
+ { &EVP_sha1, &SHA1,
+ "0123456701234567012345670123456701234567012345670123456701234567", 10,
+ "dea356a2cddd90c7a7ecedc5ebb563934f460452" },
+
+ /* SHA-224 tests, from RFC 3874. */
+ { &EVP_sha224, &SHA224, "abc", 1,
+ "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" },
+ { &EVP_sha224, &SHA224,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 1,
+ "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" },
+ { &EVP_sha224, &SHA224,
+ "a", 1000000,
+ "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" },
+
+ /* SHA-256 tests, from NIST. */
+ { &EVP_sha256, &SHA256, "abc", 1,
+ "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" },
+ { &EVP_sha256, &SHA256,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 1,
+ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" },
+
+ /* SHA-384 tests, from NIST. */
+ { &EVP_sha384, &SHA384, "abc", 1,
+ "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed"
+ "8086072ba1e7cc2358baeca134c825a7" },
+ { &EVP_sha384, &SHA384,
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 1,
+ "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712"
+ "fcc7c71a557e2db966c3e9fa91746039" },
+
+ /* SHA-512 tests, from NIST. */
+ { &EVP_sha512, &SHA512, "abc", 1,
+ "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"
+ "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" },
+ { &EVP_sha512, &SHA512,
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
+ "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", 1,
+ "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"
+ "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909" },
+};
+
+static int compare_digest(const TEST_VECTOR *test,
+ const uint8_t *digest,
+ size_t digest_len) {
+ static const char kHexTable[] = "0123456789abcdef";
+ size_t i;
+ char digest_hex[2*EVP_MAX_MD_SIZE + 1];
+
+ for (i = 0; i < digest_len; i++) {
+ digest_hex[2*i] = kHexTable[digest[i] >> 4];
+ digest_hex[2*i + 1] = kHexTable[digest[i] & 0xf];
+ }
+ digest_hex[2*digest_len] = '\0';
+
+ if (strcmp(digest_hex, test->expected_hex) != 0) {
+ fprintf(stderr, "%s(\"%s\" * %d) = %s; want %s\n",
+ EVP_MD_name(test->md_func()), test->input, (int)test->repeat,
+ digest_hex, test->expected_hex);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int test_digest(const TEST_VECTOR *test) {
+ int ret = 0;
+ EVP_MD_CTX ctx;
+ size_t i;
+ uint8_t digest[EVP_MAX_MD_SIZE];
+ unsigned digest_len;
+
+ EVP_MD_CTX_init(&ctx);
+
+ /* Test the input provided. */
+ if (!EVP_DigestInit_ex(&ctx, test->md_func(), NULL)) {
+ fprintf(stderr, "EVP_DigestInit_ex failed\n");
+ goto done;
+ }
+ for (i = 0; i < test->repeat; i++) {
+ if (!EVP_DigestUpdate(&ctx, test->input, strlen(test->input))) {
+ fprintf(stderr, "EVP_DigestUpdate failed\n");
+ goto done;
+ }
+ }
+ if (!EVP_DigestFinal_ex(&ctx, digest, &digest_len)) {
+ fprintf(stderr, "EVP_DigestFinal_ex failed\n");
+ goto done;
+ }
+ if (!compare_digest(test, digest, digest_len)) {
+ goto done;
+ }
+
+ /* Test the input one character at a time. */
+ if (!EVP_DigestInit_ex(&ctx, test->md_func(), NULL)) {
+ fprintf(stderr, "EVP_DigestInit_ex failed\n");
+ goto done;
+ }
+ if (!EVP_DigestUpdate(&ctx, NULL, 0)) {
+ fprintf(stderr, "EVP_DigestUpdate failed\n");
+ goto done;
+ }
+ for (i = 0; i < test->repeat; i++) {
+ const char *p;
+ for (p = test->input; *p; p++) {
+ if (!EVP_DigestUpdate(&ctx, p, 1)) {
+ fprintf(stderr, "EVP_DigestUpdate failed\n");
+ goto done;
+ }
+ }
+ }
+ if (!EVP_DigestFinal_ex(&ctx, digest, &digest_len)) {
+ fprintf(stderr, "EVP_DigestFinal_ex failed\n");
+ goto done;
+ }
+ if (digest_len != EVP_MD_size(test->md_func())) {
+ fprintf(stderr, "EVP_MD_size output incorrect\n");
+ goto done;
+ }
+ if (!compare_digest(test, digest, digest_len)) {
+ goto done;
+ }
+
+ /* Test the one-shot function. */
+ if (test->one_shot_func && test->repeat == 1) {
+ uint8_t *out = test->one_shot_func((const uint8_t *)test->input,
+ strlen(test->input), digest);
+ if (out != digest) {
+ fprintf(stderr, "one_shot_func gave incorrect return\n");
+ goto done;
+ }
+ if (!compare_digest(test, digest, EVP_MD_size(test->md_func()))) {
+ goto done;
+ }
+
+ /* Test the deprecated static buffer variant, until it's removed. */
+ out = test->one_shot_func((const uint8_t *)test->input, strlen(test->input),
+ NULL);
+ if (!compare_digest(test, out, EVP_MD_size(test->md_func()))) {
+ goto done;
+ }
+ }
+
+ ret = 1;
+
+done:
+ EVP_MD_CTX_cleanup(&ctx);
+ return ret;
+}
+
+int main(void) {
+ size_t i;
+
+ CRYPTO_library_init();
+ ERR_load_crypto_strings();
+
+ for (i = 0; i < sizeof(kTestVectors) / sizeof(kTestVectors[0]); i++) {
+ if (!test_digest(&kTestVectors[i])) {
+ fprintf(stderr, "Test %d failed\n", (int)i);
+ return 1;
+ }
+ }
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/crypto/md5/CMakeLists.txt b/crypto/md5/CMakeLists.txt
index ce2f8dc..256588c 100644
--- a/crypto/md5/CMakeLists.txt
+++ b/crypto/md5/CMakeLists.txt
@@ -28,11 +28,3 @@
perlasm(md5-x86_64.${ASM_EXT} asm/md5-x86_64.pl)
perlasm(md5-586.${ASM_EXT} asm/md5-586.pl)
-
-add_executable(
- md5_test
-
- md5_test.c
-)
-
-target_link_libraries(md5_test crypto)
diff --git a/crypto/md5/md5_test.c b/crypto/md5/md5_test.c
deleted file mode 100644
index fd24341..0000000
--- a/crypto/md5/md5_test.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.] */
-
-#include <stdio.h>
-
-#include <openssl/crypto.h>
-#include <openssl/digest.h>
-#include <openssl/md5.h>
-
-
-static const char *const test[] = {
- "", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "12345678901234567890123456789012345678901234567890123456789012345678901234"
- "567890",
- NULL, };
-
-static const char *const expected[] = {
- "d41d8cd98f00b204e9800998ecf8427e", "0cc175b9c0f1b6a831c399e269772661",
- "900150983cd24fb0d6963f7d28e17f72", "f96b697d7cb7938d525a2f31aaf161d0",
- "c3fcd3d76192e4007dfb496cca67e13b", "d174ab98d277d9f5a5611c2c9f419d9f",
- "57edf4a22be3c955ac49da2e2107b67a", };
-
-int main(int argc, char **argv) {
- size_t i, j;
- uint8_t md[MD5_DIGEST_LENGTH];
- char md_hex[sizeof(md) * 2 + 1];
- int ok = 1;
-
- CRYPTO_library_init();
-
- for (i = 0; test[i] != NULL; i++) {
- EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_md5(), NULL);
- for (j = 0; j < sizeof(md); j++) {
- sprintf(&md_hex[j * 2], "%02x", md[j]);
- }
- md_hex[MD5_DIGEST_LENGTH * 2] = 0;
-
- if (strcmp(md_hex, expected[i]) != 0) {
- fprintf(stderr, "#%u: got %s, wanted %s\n", (unsigned)i, md_hex,
- expected[i]);
- ok = 0;
- }
- }
-
- if (ok) {
- printf("PASS\n");
- }
-
- return ok ? 0 : 1;
-}
diff --git a/crypto/sha/CMakeLists.txt b/crypto/sha/CMakeLists.txt
index 848c048..1a597d9 100644
--- a/crypto/sha/CMakeLists.txt
+++ b/crypto/sha/CMakeLists.txt
@@ -51,11 +51,3 @@
perlasm(sha1-armv4-large.${ASM_EXT} asm/sha1-armv4-large.pl)
perlasm(sha256-armv4.${ASM_EXT} asm/sha256-armv4.pl)
perlasm(sha512-armv4.${ASM_EXT} asm/sha512-armv4.pl)
-
-add_executable(
- sha1_test
-
- sha1_test.c
-)
-
-target_link_libraries(sha1_test crypto)
diff --git a/crypto/sha/sha1_test.c b/crypto/sha/sha1_test.c
deleted file mode 100644
index d723e40..0000000
--- a/crypto/sha/sha1_test.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.] */
-
-#include <stdio.h>
-
-#include <openssl/crypto.h>
-#include <openssl/digest.h>
-#include <openssl/sha.h>
-
-
-static const char *const test[] = {
- "abc", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", NULL, };
-
-static const char *const expected[] = {
- "a9993e364706816aba3e25717850c26c9cd0d89d",
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1", };
-
-static int test_incremental(void) {
- EVP_MD_CTX ctx;
- char buf[1000];
- uint8_t md[SHA_DIGEST_LENGTH];
- char md_hex[sizeof(md) * 2 + 1];
- size_t i;
- static const char expected[] = "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
-
- memset(buf, 'a', sizeof(buf));
- EVP_MD_CTX_init(&ctx);
- EVP_DigestInit_ex(&ctx, EVP_sha1(), NULL);
- for (i = 0; i < 1000; i++) {
- EVP_DigestUpdate(&ctx, buf, sizeof(buf));
- }
- EVP_DigestFinal_ex(&ctx, md, NULL);
- EVP_MD_CTX_cleanup(&ctx);
-
- for (i = 0; i < sizeof(md); i++) {
- sprintf(&md_hex[i * 2], "%02x", md[i]);
- }
-
- if (strcmp(md_hex, expected) != 0) {
- fprintf(stderr, "test_incremental: got %s, wanted %s\n", md_hex, expected);
- return 0;
- }
-
- return 1;
-}
-
-int main(int argc, char **argv) {
- size_t i, j;
- uint8_t md[SHA_DIGEST_LENGTH];
- char md_hex[sizeof(md) * 2 + 1];
- int ok = 1;
-
- CRYPTO_library_init();
-
- for (i = 0; test[i] != NULL; i++) {
- EVP_Digest(test[i], strlen(test[i]), md, NULL, EVP_sha1(), NULL);
- for (j = 0; j < sizeof(md); j++) {
- sprintf(&md_hex[j * 2], "%02x", md[j]);
- }
-
- if (strcmp(md_hex, expected[i]) != 0) {
- fprintf(stderr, "#%u: got %s, wanted %s\n", (unsigned)i, md_hex,
- expected[i]);
- ok = 0;
- }
- }
-
- ok &= test_incremental();
-
- if (ok) {
- printf("PASS\n");
- }
-
- return ok ? 0 : 1;
-}
diff --git a/include/openssl/digest.h b/include/openssl/digest.h
index 6d8a165..a453ea3 100644
--- a/include/openssl/digest.h
+++ b/include/openssl/digest.h
@@ -142,7 +142,7 @@
* |md_out|. At most |EVP_MAX_MD_SIZE| bytes are written. If |out_size| is not
* NULL then |*out_size| is set to the number of bytes written. It returns one
* on success and zero otherwise. After this call, the hash cannot be updated
- * or finished again until |EVP_DigestFinal_ex| is called to start another
+ * or finished again until |EVP_DigestInit_ex| is called to start another
* hashing operation. */
OPENSSL_EXPORT int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, uint8_t *md_out,
unsigned int *out_size);
diff --git a/include/openssl/md4.h b/include/openssl/md4.h
index 715adab..ce4fa99 100644
--- a/include/openssl/md4.h
+++ b/include/openssl/md4.h
@@ -82,10 +82,6 @@
* returns one. */
OPENSSL_EXPORT int MD4_Final(uint8_t *md, MD4_CTX *md4);
-/* MD4 writes the digest of |len| bytes from |data| to |out| and returns |out|.
- * There must be at least |MD4_DIGEST_LENGTH| bytes of space in |out|. */
-OPENSSL_EXPORT uint8_t *MD4(const uint8_t *data, size_t len, uint8_t *out);
-
/* MD4_Transform is a low-level function that performs a single, MD4 block
* transformation using the state from |md4| and 64 bytes from |block|. */
OPENSSL_EXPORT void MD4_Transform(MD4_CTX *md4, const uint8_t *block);
diff --git a/util/all_tests.sh b/util/all_tests.sh
index f6188d1..0f2abe9 100644
--- a/util/all_tests.sh
+++ b/util/all_tests.sh
@@ -32,6 +32,7 @@
./crypto/cipher/aead_test rc4-md5 $SRC/crypto/cipher/rc4_md5_tests.txt
./crypto/cipher/cipher_test $SRC/crypto/cipher/cipher_test.txt
./crypto/dh/dh_test
+./crypto/digest/digest_test
./crypto/dsa/dsa_test
./crypto/ec/example_mul
./crypto/ecdsa/ecdsa_test
@@ -39,11 +40,9 @@
./crypto/evp/evp_test
./crypto/hmac/hmac_test
./crypto/lhash/lhash_test
-./crypto/md5/md5_test
./crypto/modes/gcm_test
./crypto/pkcs8/pkcs12_test
./crypto/rsa/rsa_test
-./crypto/sha/sha1_test
./crypto/x509/pkcs7_test
./crypto/x509v3/tab_test
./crypto/x509v3/v3name_test