@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | //get length of OID data |
| 75 | 75 | $len = self::getLength($data); |
| 76 | 76 | //get only a string with bytes belongs to OID |
| 77 | - $oidData = substr($data, 2 + $bytes, $len-($bytes)); |
|
| 77 | + $oidData = substr($data, 2 + $bytes, $len - ($bytes)); |
|
| 78 | 78 | //parse OID data many possibel formats and structures |
| 79 | 79 | $head = strlen($oidData) - strlen($xcv) - 2; |
| 80 | 80 | $ret = substr($oidData, -$head); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | if ($num == 0) { |
| 119 | 119 | $bun = 40 * $partes[$num]; |
| 120 | 120 | } elseif ($num == 1) { |
| 121 | - $bun += $partes[$num]; |
|
| 121 | + $bun += $partes[$num]; |
|
| 122 | 122 | $abBinary[] = $bun; |
| 123 | 123 | } else { |
| 124 | 124 | $abBinary = self::xBase128($abBinary, (integer) $partes[$num], true); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $abc = $abIn; |
| 144 | 144 | if ($qIn > 127) { |
| 145 | - $abc = self::xBase128($abc, floor($qIn/128), false); |
|
| 145 | + $abc = self::xBase128($abc, floor($qIn / 128), false); |
|
| 146 | 146 | } |
| 147 | 147 | $qIn2 = $qIn % 128; |
| 148 | 148 | if ($flag) { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | class Signer |
| 34 | 34 | { |
| 35 | - private static $canonical = [true,false,null,null]; |
|
| 35 | + private static $canonical = [true, false, null, null]; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Make Signature tag |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $tagname, |
| 53 | 53 | $mark = 'Id', |
| 54 | 54 | $algorithm = OPENSSL_ALGO_SHA1, |
| 55 | - $canonical = [true,false,null,null], |
|
| 55 | + $canonical = [true, false, null, null], |
|
| 56 | 56 | $rootname = '' |
| 57 | 57 | ) { |
| 58 | 58 | if (!empty($canonical)) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (empty($content)) { |
| 62 | 62 | throw SignerException::isNotXml(); |
| 63 | 63 | } |
| 64 | - if (! Validator::isXML($content)) { |
|
| 64 | + if (!Validator::isXML($content)) { |
|
| 65 | 65 | throw SignerException::isNotXml(); |
| 66 | 66 | } |
| 67 | 67 | $dom = new DOMDocument('1.0', 'UTF-8'); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | if (empty($node) || empty($root)) { |
| 77 | 77 | throw SignerException::tagNotFound($tagname); |
| 78 | 78 | } |
| 79 | - if (! self::existsSignature($content)) { |
|
| 79 | + if (!self::existsSignature($content)) { |
|
| 80 | 80 | $dom = self::createSignature( |
| 81 | 81 | $certificate, |
| 82 | 82 | $dom, |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | DOMElement $node, |
| 110 | 110 | $mark, |
| 111 | 111 | $algorithm = OPENSSL_ALGO_SHA1, |
| 112 | - $canonical = [true,false,null,null] |
|
| 112 | + $canonical = [true, false, null, null] |
|
| 113 | 113 | ) { |
| 114 | 114 | $nsDSIG = 'http://www.w3.org/2000/09/xmldsig#'; |
| 115 | 115 | $nsCannonMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
| 122 | 122 | $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256'; |
| 123 | 123 | } |
| 124 | - $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 124 | + $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 125 | 125 | $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
| 126 | 126 | $idSigned = trim($node->getAttribute($mark)); |
| 127 | 127 | $digestValue = self::makeDigest($node, $digestAlgorithm, $canonical); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public static function removeSignature($content) |
| 178 | 178 | { |
| 179 | - if (! self::existsSignature($content)) { |
|
| 179 | + if (!self::existsSignature($content)) { |
|
| 180 | 180 | return $content; |
| 181 | 181 | } |
| 182 | 182 | $dom = new \DOMDocument('1.0', 'utf-8'); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | public static function isSigned( |
| 204 | 204 | $content, |
| 205 | 205 | $tagname = '', |
| 206 | - $canonical = [true,false,null,null] |
|
| 206 | + $canonical = [true, false, null, null] |
|
| 207 | 207 | ) { |
| 208 | 208 | if (self::existsSignature($content)) { |
| 209 | 209 | if (self::digestCheck($content, $tagname, $canonical)) { |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public static function existsSignature($content) |
| 224 | 224 | { |
| 225 | - if (! Validator::isXML($content)) { |
|
| 225 | + if (!Validator::isXML($content)) { |
|
| 226 | 226 | throw SignerException::isNotXml(); |
| 227 | 227 | } |
| 228 | 228 | $dom = new \DOMDocument('1.0', 'utf-8'); |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public static function signatureCheck( |
| 246 | 246 | $xml, |
| 247 | - $canonical = [true,false,null,null] |
|
| 247 | + $canonical = [true, false, null, null] |
|
| 248 | 248 | ) { |
| 249 | 249 | $dom = new \DOMDocument('1.0', 'utf-8'); |
| 250 | 250 | $dom->formatOutput = false; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $decodedSignature = base64_decode( |
| 271 | 271 | str_replace(array("\r", "\n"), '', $signatureValue) |
| 272 | 272 | ); |
| 273 | - if (! $publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) { |
|
| 273 | + if (!$publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) { |
|
| 274 | 274 | throw SignerException::signatureComparisonFailed(); |
| 275 | 275 | } |
| 276 | 276 | return true; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | public static function digestCheck( |
| 288 | 288 | $xml, |
| 289 | 289 | $tagname = '', |
| 290 | - $canonical = [true,false,null,null] |
|
| 290 | + $canonical = [true, false, null, null] |
|
| 291 | 291 | ) { |
| 292 | 292 | $dom = new \DOMDocument('1.0', 'utf-8'); |
| 293 | 293 | $dom->formatOutput = false; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | private static function makeDigest( |
| 345 | 345 | DOMNode $node, |
| 346 | 346 | $algorithm, |
| 347 | - $canonical = [true,false,null,null] |
|
| 347 | + $canonical = [true, false, null, null] |
|
| 348 | 348 | ) { |
| 349 | 349 | //calcular o hash dos dados |
| 350 | 350 | $c14n = self::canonize($node, $canonical); |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | private static function canonize( |
| 362 | 362 | DOMNode $node, |
| 363 | - $canonical = [true,false,null,null] |
|
| 363 | + $canonical = [true, false, null, null] |
|
| 364 | 364 | ) { |
| 365 | 365 | return $node->C14N( |
| 366 | 366 | $canonical[0], |