Skip to content

Commit 28a495f

Browse files
committed
#237. Set RSA_SHA256 and SHA256 as default signatureAlgorithm and digestAlgorithm values
1 parent 5af8bc9 commit 28a495f

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,14 @@ $advancedSettings = array (
496496
// 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
497497
// 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'
498498
// 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512'
499-
'signatureAlgorithm' => 'http://www.w3.org/2000/09/xmldsig#rsa-sha1',
499+
'signatureAlgorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
500500

501501
// Algorithm that the toolkit will use on digest process. Options:
502502
// 'http://www.w3.org/2000/09/xmldsig#sha1'
503503
// 'http://www.w3.org/2001/04/xmlenc#sha256'
504504
// 'http://www.w3.org/2001/04/xmldsig-more#sha384'
505505
// 'http://www.w3.org/2001/04/xmlenc#sha512'
506-
'digestAlgorithm' => 'http://www.w3.org/2000/09/xmldsig#sha1',
506+
'digestAlgorithm' => 'http://www.w3.org/2001/04/xmlenc#sha256',
507507

508508
// ADFS URL-Encodes SAML data as lowercase, and the toolkit by default uses
509509
// uppercase. Turn it True for ADFS compatibility on signature verification

advanced_settings_example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@
8787
// 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
8888
// 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'
8989
// 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512'
90-
'signatureAlgorithm' => 'http://www.w3.org/2000/09/xmldsig#rsa-sha1',
90+
'signatureAlgorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',
9191

9292
// Algorithm that the toolkit will use on digest process. Options:
9393
// 'http://www.w3.org/2000/09/xmldsig#sha1'
9494
// 'http://www.w3.org/2001/04/xmlenc#sha256'
9595
// 'http://www.w3.org/2001/04/xmldsig-more#sha384'
9696
// 'http://www.w3.org/2001/04/xmlenc#sha512'
97-
'digestAlgorithm' => 'http://www.w3.org/2000/09/xmldsig#sha1',
97+
'digestAlgorithm' => 'http://www.w3.org/2001/04/xmlenc#sha256',
9898

9999
// ADFS URL-Encodes SAML data as lowercase, and the toolkit by default uses
100100
// uppercase. Turn it True for ADFS compatibility on signature verification

lib/Saml2/Auth.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ public function getLastRequestID()
540540
* @throws Exception
541541
* @throws OneLogin_Saml2_Error
542542
*/
543-
public function buildRequestSignature($samlRequest, $relayState, $signAlgorithm = XMLSecurityKey::RSA_SHA1)
543+
public function buildRequestSignature($samlRequest, $relayState, $signAlgorithm = XMLSecurityKey::RSA_SHA256)
544544
{
545545
$key = $this->_settings->getSPkey();
546546
if (empty($key)) {
@@ -585,7 +585,7 @@ public function buildRequestSignature($samlRequest, $relayState, $signAlgorithm
585585
* @throws Exception
586586
* @throws OneLogin_Saml2_Error
587587
*/
588-
public function buildResponseSignature($samlResponse, $relayState, $signAlgorithm = XMLSecurityKey::RSA_SHA1)
588+
public function buildResponseSignature($samlResponse, $relayState, $signAlgorithm = XMLSecurityKey::RSA_SHA256)
589589
{
590590
$key = $this->_settings->getSPkey();
591591
if (empty($key)) {

lib/Saml2/Metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public static function builder($sp, $authnsign = false, $wsign = false, $validUn
183183
*
184184
* @return string Signed Metadata
185185
*/
186-
public static function signMetadata($metadata, $key, $cert, $signAlgorithm = XMLSecurityKey::RSA_SHA1, $digestAlgorithm = XMLSecurityDSig::SHA1)
186+
public static function signMetadata($metadata, $key, $cert, $signAlgorithm = XMLSecurityKey::RSA_SHA256, $digestAlgorithm = XMLSecurityDSig::SHA256)
187187
{
188188
return OneLogin_Saml2_Utils::addSign($metadata, $key, $cert, $signAlgorithm, $digestAlgorithm);
189189
}

lib/Saml2/Settings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,12 @@ private function _addDefaultValues()
382382

383383
// SignatureAlgorithm
384384
if (!isset($this->_security['signatureAlgorithm'])) {
385-
$this->_security['signatureAlgorithm'] = XMLSecurityKey::RSA_SHA1;
385+
$this->_security['signatureAlgorithm'] = XMLSecurityKey::RSA_SHA256;
386386
}
387387

388388
// DigestAlgorithm
389389
if (!isset($this->_security['digestAlgorithm'])) {
390-
$this->_security['digestAlgorithm'] = XMLSecurityDSig::SHA1;
390+
$this->_security['digestAlgorithm'] = XMLSecurityDSig::SHA256;
391391
}
392392

393393
if (!isset($this->_security['lowercaseUrlencoding'])) {

lib/Saml2/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ public static function castKey(XMLSecurityKey $key, $algorithm, $type = 'public'
12081208
*
12091209
* @throws Exception
12101210
*/
1211-
public static function addSign($xml, $key, $cert, $signAlgorithm = XMLSecurityKey::RSA_SHA1, $digestAlgorithm = XMLSecurityDSig::SHA1)
1211+
public static function addSign($xml, $key, $cert, $signAlgorithm = XMLSecurityKey::RSA_SHA256, $digestAlgorithm = XMLSecurityDSig::SHA256)
12121212
{
12131213
if ($xml instanceof DOMDocument) {
12141214
$dom = $xml;

0 commit comments

Comments
 (0)