From 161bb7d3620e3eb397b8cfe170478d53d7a15e19 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Dec 2013 21:02:00 +0100 Subject: [PATCH 1/2] CS: Fix PEAR.ControlStructures.ControlSignature sniff. --- phpseclib/Crypt/Blowfish.php | 3 +-- phpseclib/File/ASN1.php | 6 ++---- phpseclib/File/X509.php | 9 +++------ tests/code_sniffer_ruleset.xml | 1 - 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 00e06a26..8fedee0e 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -418,8 +418,7 @@ class Crypt_Blowfish extends Crypt_Base if (!$keylength) { $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - } - elseif ($keylength > 56) { + } elseif ($keylength > 56) { $key = substr($key, 0, 56); } diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 20b33c5c..3750f9f1 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -593,8 +593,7 @@ class File_ASN1 if (isset($child['class'])) { $childClass = $child['class']; $constant = $child['cast']; - } - elseif (isset($child['constant'])) { + } elseif (isset($child['constant'])) { $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; $constant = $child['constant']; } @@ -666,8 +665,7 @@ class File_ASN1 if (isset($child['class'])) { $childClass = $child['class']; $constant = $child['cast']; - } - elseif (isset($child['constant'])) { + } elseif (isset($child['constant'])) { $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; $constant = $child['constant']; } diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index f8d86bc5..d6fe7906 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -1715,8 +1715,7 @@ class File_X509 if ($map === false) { user_error($id . ' is not a currently supported attribute', E_USER_NOTICE); unset($attributes[$i]); - } - elseif (is_array($attributes[$i]['value'])) { + } elseif (is_array($attributes[$i]['value'])) { $values = &$attributes[$i]['value']; for ($j = 0; $j < count($values); $j++) { switch ($id) { @@ -3400,8 +3399,7 @@ class File_X509 if (!empty($this->serialNumber)) { $crlNumber = $this->serialNumber; - } - else { + } else { $crlNumber = $this->getExtension('id-ce-cRLNumber'); $crlNumber = $crlNumber !== false ? $crlNumber->add(new Math_BigInteger(1)) : null; } @@ -3414,8 +3412,7 @@ class File_X509 if (!$version) { if (!empty($tbsCertList['crlExtensions'])) { $version = 1; // v2. - } - elseif (!empty($tbsCertList['revokedCertificates'])) { + } elseif (!empty($tbsCertList['revokedCertificates'])) { foreach ($tbsCertList['revokedCertificates'] as $cert) { if (!empty($cert['crlEntryExtensions'])) { $version = 1; // v2. diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 36f6545f..1838e1b5 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -29,7 +29,6 @@ 0 0 0 - 0 0 0 0 From ef2c50f9e0a0e252076eb643754347835bfb03cb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Dec 2013 21:02:30 +0100 Subject: [PATCH 2/2] Ignore coding style for "HAC 4.49" block in Math/BigInteger.php. --- phpseclib/Math/BigInteger.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 215a9a85..91a917f0 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -3299,6 +3299,7 @@ class Math_BigInteger if (!$t) { // see HAC 4.49 "Note (controlling the error probability)" + // @codingStandardsIgnoreStart if ($length >= 163) { $t = 2; } // floor(1300 / 8) else if ($length >= 106) { $t = 3; } // floor( 850 / 8) else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) @@ -3311,6 +3312,7 @@ class Math_BigInteger else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8) else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8) else { $t = 27; } + // @codingStandardsIgnoreEnd } // ie. gmp_testbit($this, 0)