[openssl] master update

Richard Levitte levitte at openssl.org
Thu Mar 11 16:22:51 UTC 2021


The branch master has been updated
       via  92e9359b24660228fa8fbf9129837ce5ab287715 (commit)
       via  c9d01f4186817612e8afa401951e0968aed83b2e (commit)
      from  6bbff162f1d72ed52d705c4c146cd3152ef4648c (commit)


- Log -----------------------------------------------------------------
commit 92e9359b24660228fa8fbf9129837ce5ab287715
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Mar 9 18:49:06 2021 +0100

    TEST: Stop the cleanup in test/recipes/20-test_mac.t
    
    Let the files remain to make test forensics easy
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Shane Lontis <shane.lontis at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/14484)

commit c9d01f4186817612e8afa401951e0968aed83b2e
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Mar 9 18:23:39 2021 +0100

    PROV: use EVP_CIPHER_CTX_set_params() rather than EVP_CIPHER_CTX_ctrl()
    
    This is in gmac_final(), where the cipher is known to be fetched.
    It's more suitable to use OSSL_PARAMs than _ctrl functions, as the
    latter are expected to become obsolete.
    
    Fixes #14359
    
    Reviewed-by: Paul Dale <pauli at openssl.org>
    Reviewed-by: Shane Lontis <shane.lontis at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/14484)

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

Summary of changes:
 providers/implementations/macs/gmac_prov.c |  7 ++++---
 test/recipes/20-test_mac.t                 | 20 +++++++++++++-------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/providers/implementations/macs/gmac_prov.c b/providers/implementations/macs/gmac_prov.c
index 14ca948077..1f4047ccd3 100644
--- a/providers/implementations/macs/gmac_prov.c
+++ b/providers/implementations/macs/gmac_prov.c
@@ -146,6 +146,7 @@ static int gmac_update(void *vmacctx, const unsigned char *data,
 static int gmac_final(void *vmacctx, unsigned char *out, size_t *outl,
                       size_t outsize)
 {
+    OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
     struct gmac_data_st *macctx = vmacctx;
     int hlen = 0;
 
@@ -155,10 +156,10 @@ static int gmac_final(void *vmacctx, unsigned char *out, size_t *outl,
     if (!EVP_EncryptFinal_ex(macctx->ctx, out, &hlen))
         return 0;
 
-    /* TODO(3.0) Use params */
     hlen = gmac_size();
-    if (!EVP_CIPHER_CTX_ctrl(macctx->ctx, EVP_CTRL_AEAD_GET_TAG,
-                             hlen, out))
+    params[0] = OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG,
+                                                  out, (size_t)hlen);
+    if (!EVP_CIPHER_CTX_get_params(macctx->ctx, params))
         return 0;
 
     *outl = hlen;
diff --git a/test/recipes/20-test_mac.t b/test/recipes/20-test_mac.t
index fac72cfaaf..b6a8078763 100644
--- a/test/recipes/20-test_mac.t
+++ b/test/recipes/20-test_mac.t
@@ -97,21 +97,26 @@ push @mac_fail_tests, @siphash_fail_tests unless disabled("siphash");
 
 plan tests => (scalar @mac_tests * 2) + scalar @mac_fail_tests;
 
+my $test_count = 0;
+
 foreach (@mac_tests) {
+    $test_count++;
     ok(compareline($_->{cmd}, $_->{type}, $_->{input}, $_->{expected}, $_->{err}), $_->{desc});
 }
 foreach (@mac_tests) {
+    $test_count++;
     ok(comparefile($_->{cmd}, $_->{type}, $_->{input}, $_->{expected}), $_->{desc});
 }
 
 foreach (@mac_fail_tests) {
+    $test_count++;
     ok(compareline($_->{cmd}, $_->{type}, $_->{input}, $_->{expected}, $_->{err}), $_->{desc});
 }
 
 # Create a temp input file and save the input data into it, and
 # then compare the stdout output matches the expected value.
 sub compareline {
-    my $tmpfile = 'tmp.bin';
+    my $tmpfile = "input-$test_count.bin";
     my ($cmdarray_orig, $type, $input, $expect, $err) = @_;
     my $cmdarray = dclone $cmdarray_orig;
     if (defined($expect)) {
@@ -129,7 +134,7 @@ sub compareline {
     push @$cmdarray, @other;
 
     my @lines = run(app($cmdarray), capture => 1);
-    unlink $tmpfile;
+    # Not unlinking $tmpfile
 
     if (defined($expect)) {
         if ($lines[1] =~ m|^\Q${expect}\E\R$|) {
@@ -162,8 +167,8 @@ sub compareline {
 # use the '-bin -out <file>' commandline options to save results out to a file.
 # Read this file back in and check its output matches the expected value.
 sub comparefile {
-    my $tmpfile = 'tmp.bin';
-    my $outfile = 'out.bin';
+    my $tmpfile = "input-$test_count.bin";
+    my $outfile = "output-$test_count.bin";
     my ($cmdarray, $type, $input, $expect) = @_;
     $expect = uc $expect;
 
@@ -178,16 +183,17 @@ sub comparefile {
     push @$cmdarray, @other;
 
     run(app($cmdarray));
-    unlink $tmpfile;
+    # Not unlinking $tmpfile
+
     open(my $out, '<', $outfile) or die "Could not open file";
     binmode($out);
     my $buffer;
     my $BUFSIZE = 1024;
     read($out, $buffer, $BUFSIZE) or die "unable to read";
- 
+    # Not unlinking $outfile
+
     my $line = uc unpack("H*", $buffer);
     close($out);
-    unlink $outfile;
 
     if ($line eq $expect) {
         return 1;


More information about the openssl-commits mailing list