Skip to content

Commit 0c9a35a

Browse files
committed
Get extra values from EncryptionMethod XML
1 parent 912180e commit 0c9a35a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/XML/Enc.pm

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ sub _getKeyEncryptionMethod {
339339
my $xpc = shift;
340340
my $context = shift;
341341

342+
my %method;
342343
if ($xpc->findvalue('dsig:KeyInfo/dsig:RetrievalMethod/@Type', $context)
343344
eq 'http://www.w3.org/2001/04/xmlenc#EncryptedKey')
344345
{
@@ -349,9 +350,15 @@ sub _getKeyEncryptionMethod {
349350
if (! $keyinfo ) {
350351
die "Unable to find EncryptedKey";
351352
}
352-
return $keyinfo->[0]->findvalue('//xenc:EncryptedKey/xenc:EncryptionMethod/@Algorithm', $context);
353+
$method{Algorithm} = $keyinfo->[0]->findvalue('//xenc:EncryptedKey/xenc:EncryptionMethod/@Algorithm', $context);
354+
$method{KeySize} = $keyinfo->[0]->findvalue('//xenc:EncryptedKey/xenc:EncryptionMethod/xenc:KeySize', $context);
355+
$method{OAEPparams} = $keyinfo->[0]->findvalue('//xenc:EncryptedKey/xenc:EncryptionMethod/xenc:OAEPparams', $context);
356+
return \%method;
353357
}
354-
return $xpc->findvalue('dsig:KeyInfo/xenc:EncryptedKey/xenc:EncryptionMethod/@Algorithm', $context)
358+
$method{Algorithm} = $xpc->findvalue('dsig:KeyInfo/xenc:EncryptedKey/xenc:EncryptionMethod/@Algorithm', $context);
359+
$method{KeySize} = $xpc->findvalue('dsig:KeyInfo/xenc:EncryptedKey/xenc:EncryptionMethod/xenc:KeySize', $context);
360+
$method{OAEPparams} = $xpc->findvalue('dsig:KeyInfo/xenc:EncryptedKey/xenc:EncryptionMethod/xenc:OAEPparams', $context);
361+
return \%method;
355362
}
356363

357364
sub _setKeyEncryptionMethod {
@@ -445,10 +452,10 @@ sub _DecryptKey {
445452
my $keymethod = shift;
446453
my $encryptedkey = shift;
447454

448-
if ($keymethod eq 'http://www.w3.org/2001/04/xmlenc#rsa-1_5') {
455+
if ($keymethod->{Algorithm} eq 'http://www.w3.org/2001/04/xmlenc#rsa-1_5') {
449456
$self->{key_obj}->use_pkcs1_padding;
450457
}
451-
elsif ($keymethod eq 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p') {
458+
elsif ($keymethod->{Algorithm} eq 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p') {
452459
$self->{key_obj}->use_pkcs1_oaep_padding;
453460
} else {
454461
die "Unsupported Key Encryption Method";

0 commit comments

Comments
 (0)