| 1 | package VOMS::Lite::AC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.004; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Time::Local; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use VOMS::Lite::ASN1Helper qw(ASN1Unwrap ASN1OIDtoOID Hex DecToHex ASN1BitStr ASN1Wrap ASN1Index); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use VOMS::Lite::CertKeyHelper qw(digestSign buildchain); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use VOMS::Lite::PEMHelper qw(readCert); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use VOMS::Lite::X509; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use VOMS::Lite::KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | #use Regexp::Common qw (URI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $VERSION = '0.20'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ############################################# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub Examine { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Examine: not called CC=96 SCAR=91.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my ($decoded,$dataref)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | $dataref={Start=>"",End=>"",FQANs=>"",IssuerDN=>"",HolderIssuerDN=>"",VOMSDIR=>"/etc/grid-security/vomsdir"} if( ! defined $dataref ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my %Values=%$dataref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my @ASN1Index=ASN1Index($decoded); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my @Values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | return ( {Errors=>"Unable to parse attribute certificate"} ) if (@ASN1Index==0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my ($index,$ignoreuntil)=(0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Drill down into the certificate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | shift @ASN1Index; # skip the wrapping of the attribute certificate sequence | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | shift @ASN1Index; # skip the wrapping of the bundle of atribute certificate sequence | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Get each AC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my @ACs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | foreach (@ASN1Index) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ( $HEADSTART < $ignoreuntil ) { next; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | push @ACs,[$CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $ignoreuntil=$HEADSTART+$HEADLEN+$CHUNKLEN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | foreach (@ACs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my %LocalValues; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my ($ACversion,$ACholder,$ACissuer,$ACalgorithmId,$ACSerial,$ACvalidity,$ACattribute,$ACUniqueId,$ACExtensions,$ACSignatureType,$ACSignature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN)=@$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my ($TBSAC,$SIGType,$SIG); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $ignoreuntil=$HEADSTART+$HEADLEN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $ignoreafter=$HEADSTART+$HEADLEN+$CHUNKLEN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $index=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $SIGSTART; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | foreach (@ASN1Index) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ( $HEADSTART < $ignoreuntil ) { next; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | elsif ( $HEADSTART >= $ignoreafter ) { last; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($index==0) { $TBSAC = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN)); $index++; $SIGSTART=$HEADSTART+$HEADLEN+$CHUNKLEN; next;} #this is a container | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | elsif ($index==1) { $ACversion = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | elsif ($index==2) { $ACholder = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | elsif ($index==3) { $ACissuer = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | elsif ($index==4) { $ACalgorithmId = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | elsif ($index==5) { $ACSerial = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | elsif ($index==6) { $ACvalidity = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));;} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | elsif ($index==7) { $ACattribute = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | elsif ($index==8 && $HEADSTART < $SIGSTART) { $ACExtensions = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$index == 8 and $HEADSTART < $SIGSTART
MC/DC0%0/2
$index == 8 and $HEADSTART < $SIGSTART
$index == 8
$HEADSTART < $SIGSTART
Truth table0%0/3
A and B
A= $index == 8B= $HEADSTART < $SIGSTART
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | elsif ($index==8) {$index++; next;} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | elsif ($index==9) { $ACSignatureType = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN));} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | elsif ($index==10){ $ACSignature = substr($decoded,$HEADSTART,($HEADLEN+$CHUNKLEN)); last;} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $index++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $ignoreuntil=$HEADSTART+$HEADLEN+$CHUNKLEN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # Extract the main components of the Attribute Certificate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | #Standard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if (defined $Values{TBSAC}) {$LocalValues{TBSAC}=$TBSAC;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if (defined $Values{ACversion}) {$LocalValues{ACversion}=$ACversion;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (defined $Values{ACholder}) {$LocalValues{ACholder}=$ACholder;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (defined $Values{ACissuer}) {$LocalValues{ACissuer}=$ACissuer;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if (defined $Values{ACalgorithmId}) {$LocalValues{ACalgorithmId}=$ACalgorithmId;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if (defined $Values{ACSerial}) {$LocalValues{ACSerial}=$ACSerial;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if (defined $Values{ACvalidity}) {$LocalValues{ACvalidity}=$ACvalidity;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if (defined $Values{ACattribute}) {$LocalValues{ACattribute}=$ACattribute;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if (defined $Values{ACExtensions}) {$LocalValues{ACExtensions}=$ACExtensions;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if (defined $Values{ACSignatureType}) {$LocalValues{ACSignatureType}=$ACSignatureType;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if (defined $Values{ACSignature}) {$LocalValues{ACSignature}=$ACSignature;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ($ACExtensions ne "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my @ACExtensionIndex=ASN1Index($ACExtensions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | shift @ACExtensionIndex; #Unwrap extensions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | while (@ACExtensionIndex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $Seqref=shift(@ACExtensionIndex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $OIDref=shift(@ACExtensionIndex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $OSref=shift(@ACExtensionIndex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $Critical=( $OSref =~ /\x01\x01[^\0]/ )?1:0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $OSref=shift(@ACExtensionIndex) if ($Critical); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $OID=substr($ACExtensions,(${ $OIDref }[3]+${ $OIDref }[4]),${ $OIDref }[5]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $OIDstr=ASN1OIDtoOID($OID); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if($OIDstr eq "2.5.29.56" && defined $Values{'noRevAvail'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$OIDstr eq "2.5.29.56" and defined $Values{"noRevAvail"}
MC/DC0%0/2
$OIDstr eq "2.5.29.56" and defined $Values{"noRevAvail"}
$OIDstr eq "2.5.29.56"
defined $Values{"noRevAvail"}
Truth table0%0/3
A and B
A= $OIDstr eq "2.5.29.56"B= defined $Values{"noRevAvail"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $LocalValues{noRevAvail} = "\x01"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if($OIDstr eq "2.5.29.35" && defined $Values{'authorityKeyIdentifier'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$OIDstr eq "2.5.29.35" and defined $Values{"authorityKeyIdentifier"}
MC/DC0%0/2
$OIDstr eq "2.5.29.35" and defined $Values{"authorityKeyIdentifier"}
$OIDstr eq "2.5.29.35"
defined $Values{"authorityKeyIdentifier"}
Truth table0%0/3
A and B
A= $OIDstr eq "2.5.29.35"B= defined $Values{"authorityKeyIdentifier"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $AKI=substr($ACExtensions,(${ $OSref }[3]+${ $OSref }[4]),${ $OSref }[5]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $AKI=ASN1Unwrap($AKI); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $LocalValues{authorityKeyIdentifier}=$AKI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $LocalValues{authorityKeyIdentifierSkid} = undef; #explicitly undefine these incase they were set in the call! | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $LocalValues{authorityKeyIdentifierIssuer} = undef; # | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $LocalValues{authorityKeyIdentifierSerial} = undef; # | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | until (length($AKI) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my ($headlen,$reallen,$Class,$Constructed,$Tag,$str)=ASN1Unwrap($AKI); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $AKI=substr($AKI,($headlen+$reallen)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($Tag==0) {$LocalValues{authorityKeyIdentifierSkid}=$str;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | elsif ($Tag==1) {$LocalValues{authorityKeyIdentifierIssuer}=$str;} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | elsif ($Tag==2) {$LocalValues{authorityKeyIdentifierSerial}=Hex($str);} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if($OIDstr eq "1.3.6.1.4.1.8005.100.100.11" && defined $Values{'vOMSTags'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$OIDstr eq "1.3.6.1.4.1.8005.100.100.11" and defined $Values{"vOMSTags"}
MC/DC0%0/2
$OIDstr eq "1.3.6.1.4.1.8005.100.100.11" and defined $Values{"vOMSTags"}
$OIDstr eq "1.3.6.1.4.1.8005.100.100.11"
defined $Values{"vOMSTags"}
Truth table0%0/3
A and B
A= $OIDstr eq "1.3.6.1.4.1.8005.100.100.11"B= defined $Values{"vOMSTags"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $LocalValues{vOMSTags}=substr($ACExtensions,(${ $OSref }[3]+${ $OSref }[4]),${ $OSref }[5]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if($OIDstr eq "1.3.6.1.4.1.8005.100.100.10" && ( defined $Values{'vOMSACCertList'} || defined $Values{Verify} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$OIDstr eq "1.3.6.1.4.1.8005.100.100.10" and defined $Values{"vOMSACCertList"} || defined $Values{"Verify"}
defined $Values{"vOMSACCertList"} or defined $Values{"Verify"}
MC/DC0%0/3
$OIDstr eq "1.3.6.1.4.1.8005.100.100.10" and defined $Values{"vOMSACCertList"} || defined $Values{"Verify"}
$OIDstr eq "1.3.6.1.4.1.8005.100.100.10"
defined $Values{"vOMSACCertList"}
defined $Values{"Verify"}
Truth table0%0/4
A and B or C
A= $OIDstr eq "1.3.6.1.4.1.8005.100.100.10"B= defined $Values{"vOMSACCertList"}C= defined $Values{"Verify"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $SEQ=ASN1Unwrap(substr($ACExtensions,(${ $OSref }[3]+${ $OSref }[4]),${ $OSref }[5])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my @DERs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | until (length($SEQ) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ($headlen,$reallen,$Class,$Constructed,$Tag,$cert)=ASN1Unwrap($SEQ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $SEQ=substr($SEQ,($headlen+$reallen)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | push @DERs,$cert; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $LocalValues{vOMSACCertList} = \@DERs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | #Deep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (defined $Values{Version} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $LocalValues{Version} = ASN1Unwrap($ACversion); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | #To whom does the AC belong | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( defined $Values{HolderIssuerDN} || defined $Values{HolderSerial} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Values{"HolderIssuerDN"} or defined $Values{"HolderSerial"}
MC/DC0%0/2
defined $Values{"HolderIssuerDN"} or defined $Values{"HolderSerial"}
defined $Values{"HolderIssuerDN"}
defined $Values{"HolderSerial"}
Truth table0%0/3
A or B
A= defined $Values{"HolderIssuerDN"}B= defined $Values{"HolderSerial"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $Values{HolderSerial}=""; $Values{HolderIssuerDN}=""; # one doesn't make sense without the other makesure both are set | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $a0=ASN1Unwrap($ACholder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $SEQ=ASN1Unwrap($a0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my ($headlen,$reallen,$Class,$Constructed,$Tag,$name)=ASN1Unwrap($SEQ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $int=ASN1Unwrap(substr($SEQ,($headlen+$reallen))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $SEQ=ASN1Unwrap($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my @rdns=ASN1Index($SEQ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | while (@rdns) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN)=(0,0,0,0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | until ($TAG == 6 ) { ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @{shift @rdns}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $OID=substr($SEQ,($HEADSTART+$HEADLEN),$CHUNKLEN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @{shift @rdns}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $Value=substr($SEQ,($HEADSTART+$HEADLEN),$CHUNKLEN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $LocalValues{HolderIssuerDN}.="/".VOMS::Lite::CertKeyHelper::OIDtoDNattrib(ASN1OIDtoOID($OID))."=$Value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $LocalValues{HolderSerial} = "0x".Hex($int); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # Who was the Issuer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ( defined $Values{IssuerDN} || defined $Values{Verify}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Values{"IssuerDN"} or defined $Values{"Verify"}
MC/DC0%0/2
defined $Values{"IssuerDN"} or defined $Values{"Verify"}
defined $Values{"IssuerDN"}
defined $Values{"Verify"}
Truth table0%0/3
A or B
A= defined $Values{"IssuerDN"}B= defined $Values{"Verify"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $SEQ=ASN1Unwrap($ACissuer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $name=ASN1Unwrap($SEQ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $SEQ=ASN1Unwrap($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my @rdns=ASN1Index($SEQ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | while (@rdns) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN)=(0,0,0,0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | until ($TAG == 6 ) { ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @{shift @rdns}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $OID=substr($SEQ,($HEADSTART+$HEADLEN),$CHUNKLEN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @{shift @rdns}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $Value=substr($SEQ,($HEADSTART+$HEADLEN),$CHUNKLEN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $LocalValues{IssuerDN}.="/".VOMS::Lite::CertKeyHelper::OIDtoDNattrib(ASN1OIDtoOID($OID))."=$Value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # What was/were the Attribute(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( defined $Values{PA} || defined $Values{FQANs} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Values{"PA"} or defined $Values{"FQANs"}
MC/DC0%0/2
defined $Values{"PA"} or defined $Values{"FQANs"}
defined $Values{"PA"}
defined $Values{"FQANs"}
Truth table0%0/3
A or B
A= defined $Values{"PA"}B= defined $Values{"FQANs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my @AttrIndex=ASN1Index($ACattribute); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my @Attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | my $PA; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN)=(0,0,-1,0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | until ($CLASS==2 && $TAG == 6 ) { ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @{shift @AttrIndex}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$CLASS == 2 and $TAG == 6
MC/DC0%0/2
$CLASS == 2 and $TAG == 6
$CLASS == 2
$TAG == 6
Truth table0%0/3
A and B
A= $CLASS == 2B= $TAG == 6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $PA=substr($ACattribute,($HEADSTART+$HEADLEN),$CHUNKLEN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | while (@AttrIndex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN)=(0,0,-1,0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | until ($CLASS==0 && $TAG == 4 ) { ($CLASS,$CONSTRUCTED,$TAG,$HEADSTART,$HEADLEN,$CHUNKLEN) = @{shift @AttrIndex}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$CLASS == 0 and $TAG == 4
MC/DC0%0/2
$CLASS == 0 and $TAG == 4
$CLASS == 0
$TAG == 4
Truth table0%0/3
A and B
A= $CLASS == 0B= $TAG == 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my $Value=substr($ACattribute,($HEADSTART+$HEADLEN),$CHUNKLEN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | push @Attrs,$Value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $LocalValues{PA}=$PA; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $LocalValues{FQANs}=\@Attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # Values of Start and End Time Seconds since Epoch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if (defined $Values{Start} || defined $Values{End}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Values{"Start"} or defined $Values{"End"}
MC/DC0%0/2
defined $Values{"Start"} or defined $Values{"End"}
defined $Values{"Start"}
defined $Values{"End"}
Truth table0%0/3
A or B
A= defined $Values{"Start"}B= defined $Values{"End"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my @validity=ASN1Unwrap($ACvalidity); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my @st=ASN1Unwrap($validity[5]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my @et=ASN1Unwrap(substr($validity[5],$st[0]+$st[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ( $st[4] eq "23" && $st[5]=~ /^(..)(..)(..)(..)(..)(..)Z$/ ) { $LocalValues{Start} = timegm($6,$5,$4,$3,($2-1),$1); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$st[4] eq 23 and $st[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
MC/DC0%0/2
$st[4] eq 23 and $st[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
$st[4] eq 23
$st[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
Truth table0%0/3
A and B
A= $st[4] eq 23B= $st[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | elsif ( $st[4] eq "24" && $st[5]=~ /^(....)(..)(..)(..)(..)(..)Z$/ ) { $LocalValues{Start} = timegm($6,$5,$4,$3,($2-1),$1); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$st[4] eq 24 and $st[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
MC/DC0%0/2
$st[4] eq 24 and $st[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
$st[4] eq 24
$st[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
Truth table0%0/3
A and B
A= $st[4] eq 24B= $st[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ( $et[4] eq "23" && $et[5]=~ /^(..)(..)(..)(..)(..)(..)Z$/ ) { $LocalValues{End} = timegm($6,$5,$4,$3,($2-1),$1); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$et[4] eq 23 and $et[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
MC/DC0%0/2
$et[4] eq 23 and $et[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
$et[4] eq 23
$et[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
Truth table0%0/3
A and B
A= $et[4] eq 23B= $et[5] =~ /^(..)(..)(..)(..)(..)(..)Z$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | elsif ( $et[4] eq "24" && $et[5]=~ /^(....)(..)(..)(..)(..)(..)Z$/ ) { $LocalValues{End} = timegm($6,$5,$4,$3,($2-1),$1); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$et[4] eq 24 and $et[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
MC/DC0%0/2
$et[4] eq 24 and $et[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
$et[4] eq 24
$et[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
Truth table0%0/3
A and B
A= $et[4] eq 24B= $et[5] =~ /^(....)(..)(..)(..)(..)(..)Z$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # Signature Value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if (defined $Values{SignatureValue} || defined $Values{SignatureType} || defined $Values{Verify}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $Values{"SignatureValue"} or defined $Values{"SignatureType"} or defined $Values{"Verify"}
defined $Values{"SignatureValue"} or defined $Values{"SignatureType"}
MC/DC0%0/3
defined $Values{"SignatureValue"} or defined $Values{"SignatureType"} or defined $Values{"Verify"}
defined $Values{"SignatureValue"}
defined $Values{"SignatureType"}
defined $Values{"Verify"}
Truth table0%0/4
A or B or C
A= defined $Values{"SignatureValue"}B= defined $Values{"SignatureType"}C= defined $Values{"Verify"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $LocalValues{'EncSignatureValue'}=Hex(substr(ASN1Unwrap($ACSignature),1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $HexACSignature=Hex($ACSignatureType); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ( $HexACSignature eq "300d06092a864886f70d0101040500" ) { $LocalValues{'SignatureType'}="md5WithRSA"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | elsif ( $HexACSignature eq "300d06092a864886f70d0101050500" ) { $LocalValues{'SignatureType'}="sha1WithRSA"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | elsif ( $HexACSignature eq "300d06092a864886f70d0101030500" ) { $LocalValues{'SignatureType'}="md4WithRSA"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | elsif ( $HexACSignature eq "300d06092a864886f70d0101020500" ) { $LocalValues{'SignatureType'}="md2WithRSA"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | else { $LocalValues{'SignatureType'}="unrecognised"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Verify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if (defined $Values{Verify}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my @ACIssuers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ( ! defined $Values{'VOMSDIR'} ) { $Values{'VOMSDIR'}="/etc/grid-security/vomsdir"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( -d $Values{'VOMSDIR'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | opendir(my $dh, $Values{'VOMSDIR'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | @ACIssuers = grep { /^[^.]/ && -f "$Values{VOMSDIR}/$_" } readdir($dh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
/^[^.]/ && -f "$Values{'VOMSDIR'}/$_"
MC/DC0%0/2
/^[^.]/ && -f "$Values{'VOMSDIR'}/$_"
/^[^.]/
-f "$Values{'VOMSDIR'}/$_"
Truth table0%0/3
A && B
A= /^[^.]/B= -f "$Values{'VOMSDIR'}/$_"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $LocalValues{Verify}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | for (my $II=-1;$II<@ACIssuers;$II++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $Values{'IssuerDN'}=""; # set Issuer DN to be exported | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $Values{'InternalVOMSCert'}=""; # set indicator of VOMS cert attached | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my @decodedCERTS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ( $II == -1 ) { # 1st time round try attached certs. Assuming the certlist is a chain not a list of possible issuers | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | next if ( ! defined $LocalValues{vOMSACCertList} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | @decodedCERTS=@{ $LocalValues{vOMSACCertList} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $LocalValues{'InternalVOMSCert'} = "Attached"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | @decodedCERTS=readCert($Values{'VOMSDIR'}."/$ACIssuers[$II]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $LocalValues{'InternalVOMSCert'} = "Local"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my %Chain = %{ buildchain( { trustedCAdirs => ["/etc/grid-security/certificates"], ####Can this be an option? | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | suppliedcerts => \@decodedCERTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | trustedCAs => [] } ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | next if ( @{ shift @{ $Chain{Errors} } } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | next if (! ${ $Chain{TrustedCA} }[-1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | next if ( $Chain{'EndEntityDN'} ne $LocalValues{'IssuerDN'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $X509REF=VOMS::Lite::X509::Examine($Chain{EndEntityCert},{Keymodulus=>"",KeypublicExponent=>""}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if (VOMS::Lite::CertKeyHelper::verifySignature( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | $LocalValues{'SignatureType'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | $LocalValues{'EncSignatureValue'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | $TBSAC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | Hex(${ $X509REF }{'KeypublicExponent'}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | Hex(${ $X509REF }{'Keymodulus'}))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $LocalValues{'Verify'} = 1 ; last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | push @Values,{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | foreach (keys %Values) { ${ $Values[-1] }{$_}=$LocalValues{$_}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return @Values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ############################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | ▶ | sub Create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Create: called CC=56 SCAR=53.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | my $inputref = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | my %context = %{$inputref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | my @error=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | my @warning=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | my $AC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # Check for values which need to be defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ( ! defined $context{'Cert'} ) { push @error, "VOMS::Lite::AC: Holder certificate not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( ! defined $context{'VOMSCert'} ) { push @error, "VOMS::Lite::AC: VOMS certificate not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if ( ! defined $context{'VOMSKey'} ) { push @error, "VOMS::Lite::AC: VOMS key not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ( ! defined $context{'Lifetime'} ) { push @error, "VOMS::Lite::AC: VOMS AC Lifetime not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ( ! defined $context{'Server'} ) { push @error, "VOMS::Lite::AC: VOMS Server FQDN not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if ( ! defined $context{'Port'} ) { push @error, "VOMS::Lite::AC: VOMS Server Port not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ( ! defined $context{'Serial'} ) { push @error, "VOMS::Lite::AC: VOMS AC Serial not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ( ! defined $context{'Code'} ) { push @warning, "VOMS::Lite::AC: Code not supplied, using Port Value"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ( ! defined $context{'Attribs'} ) { push @error, "VOMS::Lite::AC: VOMS Attributes not supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # Bail if there isn't enough information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ( @error > 0 ) { return { Errors => \@error} ; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # Load input data into local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ▶ | my $CertInfoRef = (($context{'Cert'} =~ /^(\060.*)$/s) ? VOMS::Lite::X509::Examine($&, {X509issuer=>"", X509serial=>"", X509subject=>""}) : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | my $VCertInfoRef = (($context{'VOMSCert'} =~ /^(\060.+)$/s) ? VOMS::Lite::X509::Examine($&, {X509issuer=>"", subjectKeyIdentifier=>"", X509subject=>""}) : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | my $VKeyInfoRef = (($context{'VOMSKey'} =~ /^(\060.+)$/s) ? VOMS::Lite::KEY::Examine($&, {Keymodulus=>"", KeyprivateExponent=>""}) : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my %CERTINFO; if ( defined $CertInfoRef ) { %CERTINFO=%$CertInfoRef; } else { push @error, "VOMS::Lite::AC: Unable to parse holder certificate."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | my %VCERTINFO; if ( defined $VCertInfoRef ) { %VCERTINFO=%$VCertInfoRef; } else { push @error, "VOMS::Lite::AC: Unable to parse VOMS certificate."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | my %VKEYINFO; if ( defined $VKeyInfoRef ) { %VKEYINFO=%$VKeyInfoRef; } else { push @error, "VOMS::Lite::AC: Unable to parse VOMS key."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if ( @error > 0 ) { return { Errors => \@error} ; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | ▶ | my $Lifetime = (($context{'Lifetime'} =~ /^([0-9]+)$/) ? $& : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | my $Server = (($context{'Server'} =~ /^([a-z0-9_.-]+)$/) ? $& : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | ▶ | my $Port = (($context{'Port'} =~ /^([0-9]{1,5})$/ && $context{'Port'} < 65536) ? $& : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$context{"Port"} =~ /^([0-9]{1,5})$/ and $context{"Port"} < 65536
MC/DC0%0/2
$context{"Port"} =~ /^([0-9]{1,5})$/ and $context{"Port"} < 65536
$context{"Port"} =~ /^([0-9]{1,5})$/
$context{"Port"} < 65536
Truth table33%1/3
A and B
A= $context{"Port"} =~ /^([0-9]{1,5})$/B= $context{"Port"} < 65536
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | ▶ | my $Serial = (($context{'Serial'} =~ /^([0-9a-f]+)$/) ? $& : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | ▶ | my $Code = (($context{'Code'} =~ /^([0-9]+)$/) ? $& : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | my $AttribRef = $context{'Attribs'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | my $Broken = $context{'Broken'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # Get the attributes from the supplied reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | my @Attribs=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | foreach ( @$AttribRef ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | my ($cap,$rl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | if ( /(\/Capability=[\w.-]+)$/ ) { $cap = $1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | ▶ | if ( /(\/Role=[\w.-]+)$cap$/ ) { $rl = $1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | ▶ | if ( /^((?:\/[\w.-]+)+$rl$cap)$/ ) { push @Attribs,$&; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # Get any targets from the supplied reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | my @Targets=(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | if (defined $context{'Targets'} && $context{'Targets'} =~ /^ARRAY/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $context{"Targets"} and $context{"Targets"} =~ /^ARRAY/
MC/DC0%0/2
defined $context{"Targets"} and $context{"Targets"} =~ /^ARRAY/
defined $context{"Targets"}
$context{"Targets"} =~ /^ARRAY/
Truth table33%1/3
A and B
A= defined $context{"Targets"}B= $context{"Targets"} =~ /^ARRAY/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | foreach ( @{ $context{'Targets'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if (/^([a-zA-Z0-9()'*~!._;\/?:\@&=+\$,#-]|%[a-fA-F0-9]{2})+$/) { push @Targets, $1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # if (/^($RE{URI})$/) { push @Targets, $1;} --- Regexp: a sledge hammer -- we shouldn't be so prescriptive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | else { push @error, "VOMS::Lite::AC: At least 1 target was an invalid URI (see eg RFC2396)";} | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # Check for errors in local variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if ( ! defined $Lifetime ) { push @error, "VOMS::Lite::AC: Invalid Lifetime"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ( ! defined $Server ) { push @error, "VOMS::Lite::AC: Invalid Server"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if ( ! defined $Port ) { push @error, "VOMS::Lite::AC: Invalid Port"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if ( ! defined $Serial ) { push @error, "VOMS::Lite::AC: Invalid Serial Number"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if ( ! defined $Code ) { $Code = $Port; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if ( ! defined $CERTINFO{X509issuer} ) { push @error, "VOMS::Lite::AC: Unable to get holder certificate's issuer"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ( ! defined $CERTINFO{X509serial} ) { push @error, "VOMS::Lite::AC: Unable to get holder certificate's serial"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ( ! defined $CERTINFO{X509subject} ) { push @error, "VOMS::Lite::AC: Unable to get holder certificate's subject"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( ! defined $VCERTINFO{X509issuer} ) { push @error, "VOMS::Lite::AC: Unable to get VOMS certificate's issuer"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if ( ! defined $VCERTINFO{subjectKeyIdentifier} ) { push @error, "VOMS::Lite::AC: Unable to get VOMS certificate's Subject Key Identifier"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | if ( ! defined $VCERTINFO{X509subject} ) { push @error, "VOMS::Lite::AC: Unable to get VOMS certificate's subject"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ( ! defined $VKEYINFO{Keymodulus} ) { push @error, "VOMS::Lite::AC: Unable to get VOMS key's Modulus"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if ( ! defined $VKEYINFO{KeyprivateExponent} ) { push @error, "VOMS::Lite::AC: Unable to get VOMS key's Exponent"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ( $#Attribs < 0 ) { push @error, "VOMS::Lite::AC: No Attributes supplied"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # Bail if any required variable failed to load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if ( @error > 0 ) { return { Targets => \@Targets, Attribs => \@Attribs, Warnings => \@warning, Errors => \@error }; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # Pad serial number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | $Serial =~ s/^.(..)*$/0$&/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # The Identity of this VOMS from first part of first Attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | ▶ | my $Group=(($Attribs[0] =~ /^\/?([^\/]+)/) ? $1 : undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if ( ! defined $Group ) { push @error, "VOMS::Lite::AC: VOMS Group not defined"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if ( @error > 0 ) { return { Targets => \@Targets, Attribs => \@Attribs, Warnings => \@warning, Errors => \@error }; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | my $VOMSURI=$Group."://".$Server.":".$Port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # Get times Now and Now + N hours | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | my $NOW=time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | my @NOW=gmtime($NOW); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | my @FUT=gmtime($NOW+$Lifetime); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 1 | my $NotBeforeDate = sprintf("%04i%02i%02i%02i%02i%02iZ",($NOW[5]+1900),($NOW[4]+1),$NOW[3],$NOW[2],$NOW[1],$NOW[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | my $NotAfterDate = sprintf("%04i%02i%02i%02i%02i%02iZ",($FUT[5]+1900),($FUT[4]+1),$FUT[3],$FUT[2],$FUT[1],$FUT[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ########################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # OK Let's create a VOMS Attribute Certificate! This consists of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # AttCertVersion Holder AttCertIssuer AlgorithmIdentifier CertificateSerialNumber | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # AttCertValidityPeriod AttributeSequence UniqueIdentifier Extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # Version (=2 (i.e. 01)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | my $AttCertVersion="020101"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # Holder of Attribute. This this is a sequence containing the holder certificate's issuer DN and serial. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | ▶ | my $HolderIssuer = Hex( ( defined $Broken && $Broken ) ? $CERTINFO{X509subject}:$CERTINFO{X509issuer} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $Broken and $Broken
MC/DC0%0/2
defined $Broken and $Broken
defined $Broken
$Broken
Truth table33%1/3
A and B
A= defined $BrokenB= $Broken
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | my $HolderSerial = Hex( $CERTINFO{X509serial} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | my $HolderInfo = ASN1Wrap( "30",ASN1Wrap( "a4",$HolderIssuer ) ).$HolderSerial; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | my $Holder = ASN1Wrap( "30",ASN1Wrap( "a0",$HolderInfo ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Issuer of Attribute Certificate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | my $AttCertIssuerInfo = Hex($VCERTINFO{X509subject}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | my $AttCertIssuer = ASN1Wrap("a0",ASN1Wrap("30",ASN1Wrap("a4",$AttCertIssuerInfo))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # Signing Algorythm used in this Attribute Certificate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | my $AlgorithmIdentifier = "300d06092a864886f70d0101040500"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # Serial Number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | my $SN = $Serial.DecToHex($Code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | ▶ | if ( length($SN) > 80 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | push @warning, "AC: The size of the serial number is too large, using truncated version."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $SN = substr($SN,-40); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | my $CertificateSerialNumber = ASN1Wrap("02",$SN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # Attribute Certificate validity period | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | my $AttCertValidityPeriod = ASN1Wrap("30",ASN1Wrap("18",Hex($NotBeforeDate)).ASN1Wrap("18",Hex($NotAfterDate))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Attributes from Attrib array supplied and VOMS URI (from group, server and port) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | my $VOMSOIDChunck = "060a2b06010401be45646404"; # OID, encoded-length=10, 1.3.6.1.4.1.8005.100.100.4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | my $VOMSURIChunck = ASN1Wrap("a0",ASN1Wrap("86",Hex("$VOMSURI"))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | my $VOMSTripleChunck = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | my $VT=""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | foreach (@Attribs) { $VT .= ASN1Wrap("04",Hex($_)); } # Concatination of wrapped Attributes | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | $VOMSTripleChunck = ASN1Wrap("30",$VT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | my $VOMSAttribChunck = ASN1Wrap("31",ASN1Wrap("30",$VOMSURIChunck.$VOMSTripleChunck)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my $AttributeSequence = ASN1Wrap("30",ASN1Wrap("30",$VOMSOIDChunck.$VOMSAttribChunck)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | #Unique Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | my $UniqueIdentifier=""; # Optional and we do not specify it here | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | #Extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | #Targets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | my $ACTargets=""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | my $targetInformation=""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | foreach my $uniformResourceIdentifier (@Targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $ACTargets.=ASN1Wrap("30",ASN1Wrap("a0",ASN1Wrap("a0",ASN1Wrap("86",$uniformResourceIdentifier)))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | if ($ACTargets ne "") { $targetInformation=ASN1Wrap("30","0603551d37". # OID 2.5.29.55 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | "0101ff". # Critical | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | ASN1Wrap("04",ASN1Wrap("30",$ACTargets)));} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | #Issuer Certs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # my $IssuerCerts=""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | my $IssuerCerts=ASN1Wrap("30","060a2b06010401be4564640a".ASN1Wrap("04",ASN1Wrap("30",ASN1Wrap("30",Hex($context{'VOMSCert'}))))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | #NoRevocation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | my $NoRevAvail = "30090603551d3804020500"; # OID 2.5.29.56 + contents=Null | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | #Issuer Unique ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | my $IssuerUniqueID=ASN1Wrap("30","0603551d23".ASN1Wrap("04",ASN1Wrap("30",ASN1Wrap("80",Hex($VCERTINFO{subjectKeyIdentifier}))))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | #Tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | my $Tag=""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | my $Extensions=ASN1Wrap("30",$targetInformation.$IssuerCerts.$NoRevAvail.$IssuerUniqueID.$Tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # Concatinate and wrap into a ToBeSignedAttributeCertificate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | my $UnsignedAC = ASN1Wrap("30",$AttCertVersion. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | $Holder. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | $AttCertIssuer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | $AlgorithmIdentifier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | $CertificateSerialNumber. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | $AttCertValidityPeriod. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | $AttributeSequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | $UniqueIdentifier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | $Extensions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ########################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # Make MD5 Checksum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | my $BinaryUnsignedAC = $UnsignedAC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | $BinaryUnsignedAC =~ s/(..)/pack('C',hex($&))/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # Make MD5 signature and rsa sign it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | my $RSAsignedDigest = digestSign("md5WithRSA",$BinaryUnsignedAC,Hex($VKEYINFO{KeyprivateExponent}),Hex($VKEYINFO{Keymodulus})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | my $ACSignature = ASN1Wrap("03",ASN1BitStr($RSAsignedDigest)); #(Always n*8 bits for MDnRSA and SHA1RSA) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # Wrap it all up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | # $AC=ASN1Wrap("30",ASN1Wrap("30",ASN1Wrap("30",$UnsignedAC.$AlgorithmIdentifier.$ACSignature))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | $AC=ASN1Wrap("30",$UnsignedAC.$AlgorithmIdentifier.$ACSignature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | $AC=~s/(..)/pack('C',hex($&))/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | return { AC => $AC, Targets => \@Targets, Attribs => \@Attribs, Warnings => \@warning }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||