2 # Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
9 #Convert CCM CAVS test vectors to a format suitable for evp_test
34 # Pull out the cipher mode from the comment at the beginning of the file
35 if(/^#\s*"([^-]+)-\w+" information/) {
37 # Pull out the key length from the comment at the beginning of the file
38 } elsif(/^#\s*(\w+) Keylen: (\d+)/) {
41 # Some parameters common to many tests appear as a list in square brackets
44 my @pairs = split(/, /, $1);
45 foreach my $pair (@pairs) {
46 $pair =~ /(\w+)\s*=\s*(\d+)/;
51 } elsif ($1 eq "Plen") {
54 } elsif ($1 eq "Tlen") {
59 } elsif (/^\s*(\w+)\s*=\s*(\S.*)\r/) {
62 } elsif ($1 eq "Nonce") {
69 } elsif ($1 eq "Adata") {
71 } elsif ($1 eq "CT") {
72 $ct = substr($2, 0, length($2) - ($taglen * 2));
73 $tag = substr($2, $taglen * -2);
74 } elsif ($1 eq "Payload") {
76 } elsif ($1 eq "Result") {
78 $res = "CIPHERUPDATE_ERROR";
80 } elsif ($1 eq "Count") {
82 } elsif ($1 eq "Plen") {
84 } elsif ($1 eq "Tlen") {
86 } elsif ($1 eq "Alen") {
89 # Something else - probably just a blank line
91 print "Cipher = $alg-$keylen-$mode\n";
102 print "\nPlaintext =";
106 print "\nCiphertext = $ct\n";
108 print "Operation = DECRYPT\n";
109 print "Result = $res\n";