mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 #!/usr/bin/perl
markrad 0:cdf462088d13 2 #
markrad 0:cdf462088d13 3 # Based on NIST gcmDecryptxxx.rsp validation files
markrad 0:cdf462088d13 4 # Only first 3 of every set used for compile time saving
markrad 0:cdf462088d13 5
markrad 0:cdf462088d13 6 use strict;
markrad 0:cdf462088d13 7
markrad 0:cdf462088d13 8 my $file = shift;
markrad 0:cdf462088d13 9
markrad 0:cdf462088d13 10 open(TEST_DATA, "$file") or die "Opening test cases '$file': $!";
markrad 0:cdf462088d13 11
markrad 0:cdf462088d13 12 sub get_suite_val($)
markrad 0:cdf462088d13 13 {
markrad 0:cdf462088d13 14 my $name = shift;
markrad 0:cdf462088d13 15 my $val = "";
markrad 0:cdf462088d13 16
markrad 0:cdf462088d13 17 while(my $line = <TEST_DATA>)
markrad 0:cdf462088d13 18 {
markrad 0:cdf462088d13 19 next if ($line !~ /^\[/);
markrad 0:cdf462088d13 20 ($val) = ($line =~ /\[$name\s\=\s(\w+)\]/);
markrad 0:cdf462088d13 21 last;
markrad 0:cdf462088d13 22 }
markrad 0:cdf462088d13 23
markrad 0:cdf462088d13 24 return $val;
markrad 0:cdf462088d13 25 }
markrad 0:cdf462088d13 26
markrad 0:cdf462088d13 27 sub get_val($)
markrad 0:cdf462088d13 28 {
markrad 0:cdf462088d13 29 my $name = shift;
markrad 0:cdf462088d13 30 my $val = "";
markrad 0:cdf462088d13 31 my $line;
markrad 0:cdf462088d13 32
markrad 0:cdf462088d13 33 while($line = <TEST_DATA>)
markrad 0:cdf462088d13 34 {
markrad 0:cdf462088d13 35 next if($line !~ /=/);
markrad 0:cdf462088d13 36 last;
markrad 0:cdf462088d13 37 }
markrad 0:cdf462088d13 38
markrad 0:cdf462088d13 39 ($val) = ($line =~ /^$name = (\w+)/);
markrad 0:cdf462088d13 40
markrad 0:cdf462088d13 41 return $val;
markrad 0:cdf462088d13 42 }
markrad 0:cdf462088d13 43
markrad 0:cdf462088d13 44 sub get_val_or_fail($)
markrad 0:cdf462088d13 45 {
markrad 0:cdf462088d13 46 my $name = shift;
markrad 0:cdf462088d13 47 my $val = "FAIL";
markrad 0:cdf462088d13 48 my $line;
markrad 0:cdf462088d13 49
markrad 0:cdf462088d13 50 while($line = <TEST_DATA>)
markrad 0:cdf462088d13 51 {
markrad 0:cdf462088d13 52 next if($line !~ /=/ && $line !~ /FAIL/);
markrad 0:cdf462088d13 53 last;
markrad 0:cdf462088d13 54 }
markrad 0:cdf462088d13 55
markrad 0:cdf462088d13 56 ($val) = ($line =~ /^$name = (\w+)/) if ($line =~ /=/);
markrad 0:cdf462088d13 57
markrad 0:cdf462088d13 58 return $val;
markrad 0:cdf462088d13 59 }
markrad 0:cdf462088d13 60
markrad 0:cdf462088d13 61 my $cnt = 1;;
markrad 0:cdf462088d13 62 while (my $line = <TEST_DATA>)
markrad 0:cdf462088d13 63 {
markrad 0:cdf462088d13 64 my $key_len = get_suite_val("Keylen");
markrad 0:cdf462088d13 65 next if ($key_len !~ /\d+/);
markrad 0:cdf462088d13 66 my $iv_len = get_suite_val("IVlen");
markrad 0:cdf462088d13 67 my $pt_len = get_suite_val("PTlen");
markrad 0:cdf462088d13 68 my $add_len = get_suite_val("AADlen");
markrad 0:cdf462088d13 69 my $tag_len = get_suite_val("Taglen");
markrad 0:cdf462088d13 70
markrad 0:cdf462088d13 71 for ($cnt = 0; $cnt < 3; $cnt++)
markrad 0:cdf462088d13 72 {
markrad 0:cdf462088d13 73 my $Count = get_val("Count");
markrad 0:cdf462088d13 74 my $key = get_val("Key");
markrad 0:cdf462088d13 75 my $iv = get_val("IV");
markrad 0:cdf462088d13 76 my $ct = get_val("CT");
markrad 0:cdf462088d13 77 my $add = get_val("AAD");
markrad 0:cdf462088d13 78 my $tag = get_val("Tag");
markrad 0:cdf462088d13 79 my $pt = get_val_or_fail("PT");
markrad 0:cdf462088d13 80
markrad 0:cdf462088d13 81 print("GCM NIST Validation (AES-$key_len,$iv_len,$pt_len,$add_len,$tag_len) #$Count\n");
markrad 0:cdf462088d13 82 print("gcm_decrypt_and_verify");
markrad 0:cdf462088d13 83 print(":\"$key\"");
markrad 0:cdf462088d13 84 print(":\"$ct\"");
markrad 0:cdf462088d13 85 print(":\"$iv\"");
markrad 0:cdf462088d13 86 print(":\"$add\"");
markrad 0:cdf462088d13 87 print(":$tag_len");
markrad 0:cdf462088d13 88 print(":\"$tag\"");
markrad 0:cdf462088d13 89 print(":\"$pt\"");
markrad 0:cdf462088d13 90 print(":0");
markrad 0:cdf462088d13 91 print("\n\n");
markrad 0:cdf462088d13 92 }
markrad 0:cdf462088d13 93 }
markrad 0:cdf462088d13 94
markrad 0:cdf462088d13 95 print("GCM Selftest\n");
markrad 0:cdf462088d13 96 print("gcm_selftest:\n\n");
markrad 0:cdf462088d13 97
markrad 0:cdf462088d13 98 close(TEST_DATA);