[openssl] master update

Dr. Paul Dale pauli at openssl.org
Fri Jun 25 04:51:50 UTC 2021


The branch master has been updated
       via  0f7a4ca5d6eba03d0bcd18bcc0c6705b8dd8f0b0 (commit)
       via  4d7c39f40f89e0920d0a60e6cf5bf4f346bef757 (commit)
      from  e86b2e78a4b7b618824c4e5cdf7f5d32feacd8b6 (commit)


- Log -----------------------------------------------------------------
commit 0f7a4ca5d6eba03d0bcd18bcc0c6705b8dd8f0b0
Author: Pauli <pauli at openssl.org>
Date:   Thu Jun 24 11:47:48 2021 +1000

    test: add EVP_Q_mac tests to evp_test
    
    Fixes #15837
    
    Reviewed-by: David von Oheimb <david.von.oheimb at siemens.com>
    Reviewed-by: Nicola Tuveri <nic.tuv at gmail.com>
    (Merged from https://github.com/openssl/openssl/pull/15888)

commit 4d7c39f40f89e0920d0a60e6cf5bf4f346bef757
Author: Pauli <pauli at openssl.org>
Date:   Thu Jun 24 11:32:50 2021 +1000

    test: add EVP_Q_digest tests to evp_test
    
    Fixes #15837
    
    Reviewed-by: David von Oheimb <david.von.oheimb at siemens.com>
    Reviewed-by: Nicola Tuveri <nic.tuv at gmail.com>
    (Merged from https://github.com/openssl/openssl/pull/15888)

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

Summary of changes:
 test/evp_test.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/test/evp_test.c b/test/evp_test.c
index d8ddf27eaf..2310fb7907 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -399,9 +399,12 @@ static int digest_update_fn(void *ctx, const unsigned char *buf, size_t buflen)
 static int digest_test_run(EVP_TEST *t)
 {
     DIGEST_DATA *expected = t->data;
+    EVP_TEST_BUFFER *inbuf;
     EVP_MD_CTX *mctx;
     unsigned char *got = NULL;
     unsigned int got_len;
+    size_t size = 0;
+    int xof = 0;
     OSSL_PARAM params[2];
 
     t->err = "TEST_FAILURE";
@@ -431,7 +434,8 @@ static int digest_test_run(EVP_TEST *t)
         goto err;
     }
 
-    if (EVP_MD_get_flags(expected->digest) & EVP_MD_FLAG_XOF) {
+    xof = (EVP_MD_get_flags(expected->digest) & EVP_MD_FLAG_XOF) != 0;
+    if (xof) {
         EVP_MD_CTX *mctx_cpy;
         char dont[] = "touch";
 
@@ -476,6 +480,24 @@ static int digest_test_run(EVP_TEST *t)
 
     t->err = NULL;
 
+    /* Test the EVP_Q_digest interface as well */
+    if (sk_EVP_TEST_BUFFER_num(expected->input) == 1
+            && !xof
+            /* This should never fail but we need the returned pointer now */
+            && !TEST_ptr(inbuf = sk_EVP_TEST_BUFFER_value(expected->input, 0))
+            && !inbuf->count_set) {
+        OPENSSL_cleanse(got, sizeof(got));
+        if (!TEST_true(EVP_Q_digest(libctx,
+                                    EVP_MD_get0_name(expected->fetched_digest),
+                                    NULL, inbuf->buf, inbuf->buflen,
+                                    got, &size))
+                || !TEST_mem_eq(got, size,
+                                expected->output, expected->output_len)) {
+            t->err = "EVP_Q_digest failed";
+            goto err;
+        }
+    }
+
  err:
     OPENSSL_free(got);
     EVP_MD_CTX_free(mctx);
@@ -1365,13 +1387,14 @@ static int mac_test_run_mac(EVP_TEST *t)
     MAC_DATA *expected = t->data;
     EVP_MAC_CTX *ctx = NULL;
     unsigned char *got = NULL;
-    size_t got_len;
+    size_t got_len = 0, size = 0;
     int i, block_size = -1, output_size = -1;
     OSSL_PARAM params[21], sizes[3], *psizes = sizes;
     size_t params_n = 0;
     size_t params_n_allocstart = 0;
     const OSSL_PARAM *defined_params =
         EVP_MAC_settable_ctx_params(expected->mac);
+    int xof;
 
     if (expected->alg == NULL)
         TEST_info("Trying the EVP_MAC %s test", expected->mac_name);
@@ -1486,7 +1509,8 @@ static int mac_test_run_mac(EVP_TEST *t)
         t->err = "MAC_UPDATE_ERROR";
         goto err;
     }
-    if (expected->xof) {
+    xof = expected->xof;
+    if (xof) {
         if (!TEST_ptr(got = OPENSSL_malloc(expected->output_len))) {
             t->err = "TEST_FAILURE";
             goto err;
@@ -1516,6 +1540,21 @@ static int mac_test_run_mac(EVP_TEST *t)
         }
     }
     t->err = NULL;
+
+    /* Test the EVP_Q_mac interface as well */
+    if (!xof) {
+        OPENSSL_cleanse(got, sizeof(got));
+        if (!TEST_true(EVP_Q_mac(libctx, expected->mac_name, NULL,
+                                 expected->alg, params,
+                                 expected->key, expected->key_len,
+                                 expected->input, expected->input_len,
+                                 got, got_len, &size))
+                || !TEST_mem_eq(got, size,
+                                expected->output, expected->output_len)) {
+            t->err = "EVP_Q_mac failed";
+            goto err;
+        }
+    }
  err:
     while (params_n-- > params_n_allocstart) {
         OPENSSL_free(params[params_n].data);


More information about the openssl-commits mailing list