@@ -179,7 +179,7 @@ protected function injectSignature($xml) {
179
179
$ sInfo = '<ds:SignedInfo Id="Signature-SignedInfo ' . $ this ->signedInfoID . '"> ' . "\n" .
180
180
'<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"> ' .
181
181
'</ds:CanonicalizationMethod> ' . "\n" .
182
- '<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09 /xmldsig#rsa-sha1 "> ' .
182
+ '<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04 /xmldsig-more #rsa-sha512 "> ' .
183
183
'</ds:SignatureMethod> ' . "\n" .
184
184
'<ds:Reference Id="SignedPropertiesID ' . $ this ->signedPropertiesID . '" ' .
185
185
'Type="http://uri.etsi.org/01903#SignedProperties" ' .
@@ -248,11 +248,10 @@ private function injectTimestamp($signedXml) {
248
248
$ payload = '<ds:SignatureValue ' . $ payload . '</ds:SignatureValue> ' ;
249
249
$ payload = $ tools ->injectNamespaces ($ payload , $ this ->getNamespaces ());
250
250
251
- // Create TimeStampQuery in ASN1 using SHA-1
252
- $ tsq = "302c0201013021300906052b0e03021a05000414 " ;
253
- $ tsq .= hash ('sha1 ' , $ payload );
254
- $ tsq .= "0201000101ff " ;
255
- $ tsq = hex2bin ($ tsq );
251
+ // Create TimeStampQuery in ASN1 using SHA-512
252
+ $ tsq = "\x30\x59\x02\x01\x01\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40" ;
253
+ $ tsq .= hash ('sha512 ' , $ payload , true );
254
+ $ tsq .= "\x01\x01\xff" ;
256
255
257
256
// Await TimeStampRequest
258
257
$ chOpts = array (
@@ -280,7 +279,7 @@ private function injectTimestamp($signedXml) {
280
279
281
280
// Validate TimeStampRequest
282
281
$ responseCode = substr ($ tsr , 6 , 3 );
283
- if ($ responseCode !== "\02\01\00 " ) { // Bytes for INTEGER 0 in ASN1
282
+ if ($ responseCode !== "\x02\x01\x00 " ) { // Bytes for INTEGER 0 in ASN1
284
283
throw new \Exception ('Invalid TSR response code ' );
285
284
}
286
285
0 commit comments