Skip to content

Commit 4c5099e

Browse files
timleggewaterkip
authored andcommitted
Fix the namespace of MGF
1 parent 36480e5 commit 4c5099e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/XML/Enc.pm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ sub decrypt {
261261
my $xpc = XML::LibXML::XPathContext->new($doc);
262262
$xpc->registerNs('dsig', 'http://www.w3.org/2000/09/xmldsig#');
263263
$xpc->registerNs('xenc', 'http://www.w3.org/2001/04/xmlenc#');
264+
$xpc->registerNs('xenc11', 'http://www.w3.org/2009/xmlenc11#');
264265
$xpc->registerNs('saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
265266

266267
return $doc unless $xpc->exists('//xenc:EncryptedData');
@@ -425,7 +426,7 @@ sub _get_mgf {
425426
my $node = shift;
426427
my $xpc = shift;
427428

428-
my $value = $xpc->findvalue('./xenc:EncryptionMethod/xenc:MGF/@Algorithm', $node);
429+
my $value = $xpc->findvalue('./xenc:EncryptionMethod/xenc11:MGF/@Algorithm', $node);
429430
return $value if $value;
430431
return;
431432
}
@@ -481,6 +482,7 @@ sub encrypt {
481482
my $xpc = XML::LibXML::XPathContext->new($encrypted);
482483
$xpc->registerNs('dsig', 'http://www.w3.org/2000/09/xmldsig#');
483484
$xpc->registerNs('xenc', 'http://www.w3.org/2001/04/xmlenc#');
485+
$xpc->registerNs('xenc11', 'http://www.w3.org/2009/xmlenc11#');
484486
$xpc->registerNs('saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
485487

486488
# Encrypt the data an empty key is passed by reference to allow
@@ -981,6 +983,7 @@ sub _create_encrypted_data_xml {
981983

982984
my $xencns = 'http://www.w3.org/2001/04/xmlenc#';
983985
my $dsigns = 'http://www.w3.org/2000/09/xmldsig#';
986+
my $xenc11ns = 'http://www.w3.org/2009/xmlenc11#';
984987

985988
my $encdata = $self->_create_node($doc, $xencns, $doc, 'xenc:EncryptedData',
986989
{
@@ -1036,9 +1039,9 @@ sub _create_encrypted_data_xml {
10361039
if ($self->{key_transport} eq 'http://www.w3.org/2009/xmlenc11#rsa-oaep') {
10371040
my $oaepmethod = $self->_create_node(
10381041
$doc,
1039-
$xencns,
1042+
$xenc11ns,
10401043
$kencmethod,
1041-
'xenc:MGF',
1044+
'xenc11:MGF',
10421045
{
10431046
Algorithm => $self->{oaep_mgf_alg},
10441047
}

0 commit comments

Comments
 (0)