@@ -1056,39 +1056,49 @@ public function testAddSign()
10561056 $ xmlAuthn = base64_decode (file_get_contents (TEST_ROOT . '/data/requests/authn_request.xml.base64 ' ));
10571057 $ xmlAuthnSigned = OneLogin_Saml2_Utils::addSign ($ xmlAuthn , $ key , $ cert );
10581058 $ this ->assertContains ('<ds:SignatureValue> ' , $ xmlAuthnSigned );
1059+ $ this ->assertContains ('<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> ' , $ xmlAuthnSigned );
1060+ $ this ->assertContains ('<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> ' , $ xmlAuthnSigned );
10591061 $ res = new DOMDocument ();
10601062 $ res ->loadXML ($ xmlAuthnSigned );
10611063 $ dsSignature = $ res ->firstChild ->firstChild ->nextSibling ->nextSibling ;
10621064 $ this ->assertContains ('ds:Signature ' , $ dsSignature ->tagName );
10631065
10641066 $ dom = new DOMDocument ();
10651067 $ dom ->loadXML ($ xmlAuthn );
1066- $ xmlAuthnSigned2 = OneLogin_Saml2_Utils::addSign ($ dom , $ key , $ cert );
1068+ $ xmlAuthnSigned2 = OneLogin_Saml2_Utils::addSign ($ dom , $ key , $ cert, XMLSecurityKey:: RSA_SHA256 , XMLSecurityDSig:: SHA512 );
10671069 $ this ->assertContains ('<ds:SignatureValue> ' , $ xmlAuthnSigned2 );
1070+ $ this ->assertContains ('<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> ' , $ xmlAuthnSigned2 );
1071+ $ this ->assertContains ('<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/> ' , $ xmlAuthnSigned2 );
10681072 $ res2 = new DOMDocument ();
10691073 $ res2 ->loadXML ($ xmlAuthnSigned2 );
10701074 $ dsSignature2 = $ res2 ->firstChild ->firstChild ->nextSibling ->nextSibling ;
10711075 $ this ->assertContains ('ds:Signature ' , $ dsSignature2 ->tagName );
10721076
10731077 $ xmlLogoutReq = base64_decode (file_get_contents (TEST_ROOT . '/data/logout_requests/logout_request.xml.base64 ' ));
1074- $ xmlLogoutReqSigned = OneLogin_Saml2_Utils::addSign ($ xmlLogoutReq , $ key , $ cert );
1078+ $ xmlLogoutReqSigned = OneLogin_Saml2_Utils::addSign ($ xmlLogoutReq , $ key , $ cert, XMLSecurityKey:: RSA_SHA256 , XMLSecurityDSig:: SHA512 );
10751079 $ this ->assertContains ('<ds:SignatureValue> ' , $ xmlLogoutReqSigned );
1080+ $ this ->assertContains ('<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> ' , $ xmlLogoutReqSigned );
1081+ $ this ->assertContains ('<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/> ' , $ xmlLogoutReqSigned );
10761082 $ res3 = new DOMDocument ();
10771083 $ res3 ->loadXML ($ xmlLogoutReqSigned );
10781084 $ dsSignature3 = $ res3 ->firstChild ->firstChild ->nextSibling ->nextSibling ;
10791085 $ this ->assertContains ('ds:Signature ' , $ dsSignature3 ->tagName );
10801086
10811087 $ xmlLogoutRes = base64_decode (file_get_contents (TEST_ROOT . '/data/logout_responses/logout_response.xml.base64 ' ));
1082- $ xmlLogoutResSigned = OneLogin_Saml2_Utils::addSign ($ xmlLogoutRes , $ key , $ cert );
1088+ $ xmlLogoutResSigned = OneLogin_Saml2_Utils::addSign ($ xmlLogoutRes , $ key , $ cert, XMLSecurityKey:: RSA_SHA256 , XMLSecurityDSig:: SHA512 );
10831089 $ this ->assertContains ('<ds:SignatureValue> ' , $ xmlLogoutResSigned );
1090+ $ this ->assertContains ('<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> ' , $ xmlLogoutResSigned );
1091+ $ this ->assertContains ('<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/> ' , $ xmlLogoutResSigned );
10841092 $ res4 = new DOMDocument ();
10851093 $ res4 ->loadXML ($ xmlLogoutResSigned );
10861094 $ dsSignature4 = $ res4 ->firstChild ->firstChild ->nextSibling ->nextSibling ;
10871095 $ this ->assertContains ('ds:Signature ' , $ dsSignature4 ->tagName );
10881096
10891097 $ xmlMetadata = file_get_contents (TEST_ROOT . '/data/metadata/metadata_settings1.xml ' );
1090- $ xmlMetadataSigned = OneLogin_Saml2_Utils::addSign ($ xmlMetadata , $ key , $ cert );
1098+ $ xmlMetadataSigned = OneLogin_Saml2_Utils::addSign ($ xmlMetadata , $ key , $ cert, XMLSecurityKey:: RSA_SHA256 , XMLSecurityDSig:: SHA512 );
10911099 $ this ->assertContains ('<ds:SignatureValue> ' , $ xmlMetadataSigned );
1100+ $ this ->assertContains ('<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> ' , $ xmlMetadataSigned );
1101+ $ this ->assertContains ('<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/> ' , $ xmlMetadataSigned );
10921102 $ res5 = new DOMDocument ();
10931103 $ res5 ->loadXML ($ xmlMetadataSigned );
10941104 $ dsSignature5 = $ res5 ->firstChild ->firstChild ;
0 commit comments