-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
return encrypted node from XMLSecEnc::encryptNode() when replace is s…
…et to false. (Olav) add test git-svn-id: http://xmlseclibs.googlecode.com/svn/trunk@44 fc874575-5144-0410-81e8-bd400901c4fa
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--TEST-- | ||
Encryption without modifying original data | ||
--FILE-- | ||
<?php | ||
require(dirname(__FILE__) . '/../xmlseclibs.php'); | ||
|
||
$dom = new DOMDocument(); | ||
$dom->load(dirname(__FILE__) . '/basic-doc.xml'); | ||
|
||
$origData = $dom->saveXML(); | ||
|
||
$objKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC); | ||
$objKey->generateSessionKey(); | ||
|
||
$siteKey = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, array('type'=>'public')); | ||
$siteKey->loadKey(dirname(__FILE__) . '/mycert.pem', TRUE, TRUE); | ||
|
||
$enc = new XMLSecEnc(); | ||
$enc->setNode($dom->documentElement); | ||
$enc->encryptKey($siteKey, $objKey); | ||
|
||
$enc->type = XMLSecEnc::Element; | ||
$encNode = $enc->encryptNode($objKey, FALSE); | ||
|
||
$newData = $dom->saveXML(); | ||
if ($newData !== $origData) { | ||
echo "Original data was modified.\n"; | ||
} | ||
|
||
if ($encNode->namespaceURI !== XMLSecEnc::XMLENCNS || $encNode->localName !== 'EncryptedData') { | ||
echo "Encrypted node wasn't a <xenc:EncryptedData>-element.\n"; | ||
} | ||
|
||
?> | ||
--EXPECTF-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters