File: parse_client_ciphers.pl

package info (click to toggle)
testssl.sh 3.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,624 kB
  • sloc: sh: 22,574; perl: 1,139; java: 42; makefile: 19
file content (45 lines) | stat: -rwxr-xr-x 943 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl

use strict;
use Data::Dumper;

my @spec;
my %ciphers;

# Turn cipher section of page like this https://www.ssllabs.com/ssltest/viewClient.html?name=Android&version=4.0.4
# into an openssl cipher spec

foreach my $line ( split /\n/, `../bin/openssl.Linux.x86_64 ciphers -V 'ALL:COMPLEMENTOFALL:\@STRENGTH'`) {
	my @fields = split /\s+/, $line;
	my $hex = "";
	foreach my $byte ( split /,/, $fields[1] ) {
		$byte = lc $byte;
		$byte =~ s/^0x//;
		$hex .= $byte;
	}
	$hex =~ s/^0+//;
	$ciphers{"0x$hex"} = $fields[3];
}

while (<>) {
	chomp;
	if ( $_ =~ /^(TLS|SSL)/ ) {
		if ( $_ !~ /^TLS_EMPTY_RENEGOTIATION_INFO_SCSV/ ) {
			$_ =~ /(0x[0-9a-f]+)/;
			if ( $1 ) {
				push @spec, $ciphers{$1};
				unless ( $ciphers{$1} ) {
					die "Unable to find cipher for $1";
				}
			} else {
				print "** $_\n";
			}
		}
	}
}
print join ":", @spec;
print "\n";
my $count = @spec;
print "$count ciphers\n";

#  vim:ts=5:sw=5:expandtab