From 97902d4bd37000bdd6ca7ffef366af3cc0de65d0 Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Sat, 4 Jun 2022 10:31:21 -0500 Subject: [PATCH] Upgrade to PHP 7.0 --- .github/workflows/ci.yml | 9 +- .gitignore | 1 + build/php-cs-fixer.php | 13 + build/psalm.xml | 19 +- build/psalm_baseline.xml | 18339 +++++++++++++++- composer.json | 7 +- phpseclib/Common/ConstantUtilityTrait.php | 8 +- phpseclib/Common/Functions/Strings.php | 59 +- phpseclib/Crypt/AES.php | 17 +- phpseclib/Crypt/Blowfish.php | 33 +- phpseclib/Crypt/ChaCha20.php | 53 +- phpseclib/Crypt/Common/AsymmetricKey.php | 102 +- phpseclib/Crypt/Common/BlockCipher.php | 2 + .../Crypt/Common/Formats/Keys/OpenSSH.php | 47 +- phpseclib/Crypt/Common/Formats/Keys/PKCS.php | 11 +- phpseclib/Crypt/Common/Formats/Keys/PKCS1.php | 46 +- phpseclib/Crypt/Common/Formats/Keys/PKCS8.php | 89 +- phpseclib/Crypt/Common/Formats/Keys/PuTTY.php | 55 +- .../Crypt/Common/Formats/Signature/Raw.php | 11 +- phpseclib/Crypt/Common/PrivateKey.php | 5 +- phpseclib/Crypt/Common/PublicKey.php | 4 +- phpseclib/Crypt/Common/StreamCipher.php | 6 +- phpseclib/Crypt/Common/SymmetricKey.php | 246 +- phpseclib/Crypt/Common/Traits/Fingerprint.php | 3 +- .../Crypt/Common/Traits/PasswordProtected.php | 2 + phpseclib/Crypt/DES.php | 50 +- phpseclib/Crypt/DH.php | 30 +- phpseclib/Crypt/DH/Formats/Keys/PKCS1.php | 13 +- phpseclib/Crypt/DH/Formats/Keys/PKCS8.php | 24 +- phpseclib/Crypt/DH/Parameters.php | 6 +- phpseclib/Crypt/DH/PrivateKey.php | 8 +- phpseclib/Crypt/DH/PublicKey.php | 10 +- phpseclib/Crypt/DSA.php | 32 +- phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php | 36 +- phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php | 32 +- phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php | 26 +- phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php | 30 +- phpseclib/Crypt/DSA/Formats/Keys/Raw.php | 25 +- phpseclib/Crypt/DSA/Formats/Keys/XML.php | 16 +- .../Crypt/DSA/Formats/Signature/ASN1.php | 11 +- phpseclib/Crypt/DSA/Formats/Signature/Raw.php | 2 + .../Crypt/DSA/Formats/Signature/SSH2.php | 11 +- phpseclib/Crypt/DSA/Parameters.php | 6 +- phpseclib/Crypt/DSA/PrivateKey.php | 14 +- phpseclib/Crypt/DSA/PublicKey.php | 17 +- phpseclib/Crypt/EC.php | 50 +- phpseclib/Crypt/EC/BaseCurves/Base.php | 30 +- phpseclib/Crypt/EC/BaseCurves/Binary.php | 41 +- .../Crypt/EC/BaseCurves/KoblitzPrime.php | 30 +- phpseclib/Crypt/EC/BaseCurves/Montgomery.php | 28 +- phpseclib/Crypt/EC/BaseCurves/Prime.php | 79 +- .../Crypt/EC/BaseCurves/TwistedEdwards.php | 24 +- phpseclib/Crypt/EC/Curves/Curve25519.php | 12 +- phpseclib/Crypt/EC/Curves/Curve448.php | 12 +- phpseclib/Crypt/EC/Curves/Ed25519.php | 32 +- phpseclib/Crypt/EC/Curves/Ed448.php | 31 +- phpseclib/Crypt/EC/Curves/brainpoolP160r1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP160t1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP192r1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP192t1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP224r1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP224t1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP256r1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP256t1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP320r1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP320t1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP384r1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP384t1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP512r1.php | 2 + phpseclib/Crypt/EC/Curves/brainpoolP512t1.php | 2 + phpseclib/Crypt/EC/Curves/nistb233.php | 2 + phpseclib/Crypt/EC/Curves/nistb409.php | 2 + phpseclib/Crypt/EC/Curves/nistk163.php | 2 + phpseclib/Crypt/EC/Curves/nistk233.php | 2 + phpseclib/Crypt/EC/Curves/nistk283.php | 2 + phpseclib/Crypt/EC/Curves/nistk409.php | 2 + phpseclib/Crypt/EC/Curves/nistp192.php | 2 + phpseclib/Crypt/EC/Curves/nistp224.php | 2 + phpseclib/Crypt/EC/Curves/nistp256.php | 2 + phpseclib/Crypt/EC/Curves/nistp384.php | 2 + phpseclib/Crypt/EC/Curves/nistp521.php | 2 + phpseclib/Crypt/EC/Curves/nistt571.php | 2 + phpseclib/Crypt/EC/Curves/prime192v1.php | 2 + phpseclib/Crypt/EC/Curves/prime192v2.php | 2 + phpseclib/Crypt/EC/Curves/prime192v3.php | 2 + phpseclib/Crypt/EC/Curves/prime239v1.php | 2 + phpseclib/Crypt/EC/Curves/prime239v2.php | 2 + phpseclib/Crypt/EC/Curves/prime239v3.php | 2 + phpseclib/Crypt/EC/Curves/prime256v1.php | 2 + phpseclib/Crypt/EC/Curves/secp112r1.php | 2 + phpseclib/Crypt/EC/Curves/secp112r2.php | 2 + phpseclib/Crypt/EC/Curves/secp128r1.php | 2 + phpseclib/Crypt/EC/Curves/secp128r2.php | 2 + phpseclib/Crypt/EC/Curves/secp160k1.php | 2 + phpseclib/Crypt/EC/Curves/secp160r1.php | 2 + phpseclib/Crypt/EC/Curves/secp160r2.php | 2 + phpseclib/Crypt/EC/Curves/secp192k1.php | 2 + phpseclib/Crypt/EC/Curves/secp192r1.php | 2 + phpseclib/Crypt/EC/Curves/secp224k1.php | 2 + phpseclib/Crypt/EC/Curves/secp224r1.php | 2 + phpseclib/Crypt/EC/Curves/secp256k1.php | 2 + phpseclib/Crypt/EC/Curves/secp256r1.php | 2 + phpseclib/Crypt/EC/Curves/secp384r1.php | 2 + phpseclib/Crypt/EC/Curves/secp521r1.php | 2 + phpseclib/Crypt/EC/Curves/sect113r1.php | 2 + phpseclib/Crypt/EC/Curves/sect113r2.php | 2 + phpseclib/Crypt/EC/Curves/sect131r1.php | 2 + phpseclib/Crypt/EC/Curves/sect131r2.php | 2 + phpseclib/Crypt/EC/Curves/sect163k1.php | 2 + phpseclib/Crypt/EC/Curves/sect163r1.php | 2 + phpseclib/Crypt/EC/Curves/sect163r2.php | 2 + phpseclib/Crypt/EC/Curves/sect193r1.php | 2 + phpseclib/Crypt/EC/Curves/sect193r2.php | 2 + phpseclib/Crypt/EC/Curves/sect233k1.php | 2 + phpseclib/Crypt/EC/Curves/sect233r1.php | 2 + phpseclib/Crypt/EC/Curves/sect239k1.php | 2 + phpseclib/Crypt/EC/Curves/sect283k1.php | 2 + phpseclib/Crypt/EC/Curves/sect283r1.php | 2 + phpseclib/Crypt/EC/Curves/sect409k1.php | 2 + phpseclib/Crypt/EC/Curves/sect409r1.php | 2 + phpseclib/Crypt/EC/Curves/sect571k1.php | 2 + phpseclib/Crypt/EC/Curves/sect571r1.php | 2 + phpseclib/Crypt/EC/Formats/Keys/Common.php | 34 +- .../EC/Formats/Keys/MontgomeryPrivate.php | 25 +- .../EC/Formats/Keys/MontgomeryPublic.php | 13 +- phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php | 44 +- phpseclib/Crypt/EC/Formats/Keys/PKCS1.php | 23 +- phpseclib/Crypt/EC/Formats/Keys/PKCS8.php | 29 +- phpseclib/Crypt/EC/Formats/Keys/PuTTY.php | 25 +- phpseclib/Crypt/EC/Formats/Keys/XML.php | 50 +- phpseclib/Crypt/EC/Formats/Keys/libsodium.php | 20 +- phpseclib/Crypt/EC/Formats/Signature/ASN1.php | 11 +- phpseclib/Crypt/EC/Formats/Signature/Raw.php | 2 + phpseclib/Crypt/EC/Formats/Signature/SSH2.php | 14 +- phpseclib/Crypt/EC/Parameters.php | 6 +- phpseclib/Crypt/EC/PrivateKey.php | 27 +- phpseclib/Crypt/EC/PublicKey.php | 23 +- phpseclib/Crypt/Hash.php | 113 +- phpseclib/Crypt/PublicKeyLoader.php | 14 +- phpseclib/Crypt/RC2.php | 56 +- phpseclib/Crypt/RC4.php | 49 +- phpseclib/Crypt/RSA.php | 110 +- phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php | 33 +- phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php | 37 +- phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php | 26 +- phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php | 25 +- phpseclib/Crypt/RSA/Formats/Keys/PSS.php | 28 +- phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php | 31 +- phpseclib/Crypt/RSA/Formats/Keys/Raw.php | 35 +- phpseclib/Crypt/RSA/Formats/Keys/XML.php | 23 +- phpseclib/Crypt/RSA/PrivateKey.php | 67 +- phpseclib/Crypt/RSA/PublicKey.php | 62 +- phpseclib/Crypt/Random.php | 14 +- phpseclib/Crypt/Rijndael.php | 70 +- phpseclib/Crypt/Salsa20.php | 86 +- phpseclib/Crypt/TripleDES.php | 49 +- phpseclib/Crypt/Twofish.php | 54 +- .../Exception/BadConfigurationException.php | 2 + .../Exception/BadDecryptionException.php | 2 + phpseclib/Exception/BadModeException.php | 2 + .../Exception/ConnectionClosedException.php | 2 + phpseclib/Exception/FileNotFoundException.php | 2 + .../Exception/InconsistentSetupException.php | 2 + .../Exception/InsufficientSetupException.php | 2 + phpseclib/Exception/NoKeyLoadedException.php | 2 + .../NoSupportedAlgorithmsException.php | 2 + .../Exception/UnableToConnectException.php | 2 + .../UnsupportedAlgorithmException.php | 2 + .../Exception/UnsupportedCurveException.php | 2 + .../Exception/UnsupportedFormatException.php | 2 + .../UnsupportedOperationException.php | 2 + phpseclib/File/ANSI.php | 45 +- phpseclib/File/ASN1.php | 88 +- phpseclib/File/ASN1/Element.php | 5 +- .../File/ASN1/Maps/AccessDescription.php | 2 + .../ASN1/Maps/AdministrationDomainName.php | 2 + .../File/ASN1/Maps/AlgorithmIdentifier.php | 2 + phpseclib/File/ASN1/Maps/AnotherName.php | 2 + phpseclib/File/ASN1/Maps/Attribute.php | 2 + phpseclib/File/ASN1/Maps/AttributeType.php | 2 + .../File/ASN1/Maps/AttributeTypeAndValue.php | 2 + phpseclib/File/ASN1/Maps/AttributeValue.php | 2 + phpseclib/File/ASN1/Maps/Attributes.php | 2 + .../ASN1/Maps/AuthorityInfoAccessSyntax.php | 2 + .../File/ASN1/Maps/AuthorityKeyIdentifier.php | 2 + phpseclib/File/ASN1/Maps/BaseDistance.php | 2 + phpseclib/File/ASN1/Maps/BasicConstraints.php | 2 + .../Maps/BuiltInDomainDefinedAttribute.php | 2 + .../Maps/BuiltInDomainDefinedAttributes.php | 2 + .../ASN1/Maps/BuiltInStandardAttributes.php | 2 + phpseclib/File/ASN1/Maps/CPSuri.php | 2 + .../File/ASN1/Maps/CRLDistributionPoints.php | 2 + phpseclib/File/ASN1/Maps/CRLNumber.php | 2 + phpseclib/File/ASN1/Maps/CRLReason.php | 2 + phpseclib/File/ASN1/Maps/CertPolicyId.php | 2 + phpseclib/File/ASN1/Maps/Certificate.php | 2 + .../File/ASN1/Maps/CertificateIssuer.php | 2 + phpseclib/File/ASN1/Maps/CertificateList.php | 2 + .../File/ASN1/Maps/CertificatePolicies.php | 2 + .../ASN1/Maps/CertificateSerialNumber.php | 2 + .../File/ASN1/Maps/CertificationRequest.php | 2 + .../ASN1/Maps/CertificationRequestInfo.php | 2 + .../File/ASN1/Maps/Characteristic_two.php | 2 + phpseclib/File/ASN1/Maps/CountryName.php | 2 + phpseclib/File/ASN1/Maps/Curve.php | 2 + phpseclib/File/ASN1/Maps/DHParameter.php | 2 + phpseclib/File/ASN1/Maps/DSAParams.php | 2 + phpseclib/File/ASN1/Maps/DSAPrivateKey.php | 2 + phpseclib/File/ASN1/Maps/DSAPublicKey.php | 2 + phpseclib/File/ASN1/Maps/DigestInfo.php | 2 + phpseclib/File/ASN1/Maps/DirectoryString.php | 2 + phpseclib/File/ASN1/Maps/DisplayText.php | 2 + .../File/ASN1/Maps/DistributionPoint.php | 2 + .../File/ASN1/Maps/DistributionPointName.php | 2 + phpseclib/File/ASN1/Maps/DssSigValue.php | 2 + phpseclib/File/ASN1/Maps/ECParameters.php | 2 + phpseclib/File/ASN1/Maps/ECPoint.php | 2 + phpseclib/File/ASN1/Maps/ECPrivateKey.php | 2 + phpseclib/File/ASN1/Maps/EDIPartyName.php | 2 + phpseclib/File/ASN1/Maps/EcdsaSigValue.php | 2 + phpseclib/File/ASN1/Maps/EncryptedData.php | 2 + .../ASN1/Maps/EncryptedPrivateKeyInfo.php | 2 + .../File/ASN1/Maps/ExtKeyUsageSyntax.php | 2 + phpseclib/File/ASN1/Maps/Extension.php | 2 + .../File/ASN1/Maps/ExtensionAttribute.php | 2 + .../File/ASN1/Maps/ExtensionAttributes.php | 2 + phpseclib/File/ASN1/Maps/Extensions.php | 2 + phpseclib/File/ASN1/Maps/FieldElement.php | 2 + phpseclib/File/ASN1/Maps/FieldID.php | 2 + phpseclib/File/ASN1/Maps/GeneralName.php | 2 + phpseclib/File/ASN1/Maps/GeneralNames.php | 2 + phpseclib/File/ASN1/Maps/GeneralSubtree.php | 2 + phpseclib/File/ASN1/Maps/GeneralSubtrees.php | 2 + phpseclib/File/ASN1/Maps/HashAlgorithm.php | 2 + .../File/ASN1/Maps/HoldInstructionCode.php | 2 + phpseclib/File/ASN1/Maps/InvalidityDate.php | 2 + phpseclib/File/ASN1/Maps/IssuerAltName.php | 2 + .../ASN1/Maps/IssuingDistributionPoint.php | 2 + phpseclib/File/ASN1/Maps/KeyIdentifier.php | 2 + phpseclib/File/ASN1/Maps/KeyPurposeId.php | 2 + phpseclib/File/ASN1/Maps/KeyUsage.php | 2 + phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php | 2 + phpseclib/File/ASN1/Maps/Name.php | 2 + phpseclib/File/ASN1/Maps/NameConstraints.php | 2 + phpseclib/File/ASN1/Maps/NetworkAddress.php | 2 + phpseclib/File/ASN1/Maps/NoticeReference.php | 2 + .../File/ASN1/Maps/NumericUserIdentifier.php | 2 + phpseclib/File/ASN1/Maps/ORAddress.php | 2 + phpseclib/File/ASN1/Maps/OneAsymmetricKey.php | 2 + phpseclib/File/ASN1/Maps/OrganizationName.php | 2 + .../ASN1/Maps/OrganizationalUnitNames.php | 2 + phpseclib/File/ASN1/Maps/OtherPrimeInfo.php | 2 + phpseclib/File/ASN1/Maps/OtherPrimeInfos.php | 2 + phpseclib/File/ASN1/Maps/PBEParameter.php | 2 + phpseclib/File/ASN1/Maps/PBES2params.php | 2 + phpseclib/File/ASN1/Maps/PBKDF2params.php | 2 + phpseclib/File/ASN1/Maps/PBMAC1params.php | 2 + phpseclib/File/ASN1/Maps/PKCS9String.php | 2 + phpseclib/File/ASN1/Maps/Pentanomial.php | 2 + phpseclib/File/ASN1/Maps/PersonalName.php | 2 + .../File/ASN1/Maps/PolicyInformation.php | 2 + phpseclib/File/ASN1/Maps/PolicyMappings.php | 2 + .../File/ASN1/Maps/PolicyQualifierId.php | 2 + .../File/ASN1/Maps/PolicyQualifierInfo.php | 2 + phpseclib/File/ASN1/Maps/PostalAddress.php | 2 + phpseclib/File/ASN1/Maps/Prime_p.php | 2 + .../File/ASN1/Maps/PrivateDomainName.php | 2 + phpseclib/File/ASN1/Maps/PrivateKey.php | 2 + phpseclib/File/ASN1/Maps/PrivateKeyInfo.php | 2 + .../File/ASN1/Maps/PrivateKeyUsagePeriod.php | 2 + phpseclib/File/ASN1/Maps/PublicKey.php | 2 + .../File/ASN1/Maps/PublicKeyAndChallenge.php | 2 + phpseclib/File/ASN1/Maps/PublicKeyInfo.php | 2 + phpseclib/File/ASN1/Maps/RC2CBCParameter.php | 2 + phpseclib/File/ASN1/Maps/RDNSequence.php | 2 + phpseclib/File/ASN1/Maps/RSAPrivateKey.php | 2 + phpseclib/File/ASN1/Maps/RSAPublicKey.php | 2 + .../File/ASN1/Maps/RSASSA_PSS_params.php | 2 + phpseclib/File/ASN1/Maps/ReasonFlags.php | 2 + .../ASN1/Maps/RelativeDistinguishedName.php | 2 + .../File/ASN1/Maps/RevokedCertificate.php | 2 + .../ASN1/Maps/SignedPublicKeyAndChallenge.php | 2 + .../File/ASN1/Maps/SpecifiedECDomain.php | 2 + phpseclib/File/ASN1/Maps/SubjectAltName.php | 2 + .../ASN1/Maps/SubjectDirectoryAttributes.php | 2 + .../ASN1/Maps/SubjectInfoAccessSyntax.php | 2 + .../File/ASN1/Maps/SubjectPublicKeyInfo.php | 2 + phpseclib/File/ASN1/Maps/TBSCertList.php | 2 + phpseclib/File/ASN1/Maps/TBSCertificate.php | 2 + .../File/ASN1/Maps/TerminalIdentifier.php | 2 + phpseclib/File/ASN1/Maps/Time.php | 2 + phpseclib/File/ASN1/Maps/Trinomial.php | 2 + phpseclib/File/ASN1/Maps/UniqueIdentifier.php | 2 + phpseclib/File/ASN1/Maps/UserNotice.php | 2 + phpseclib/File/ASN1/Maps/Validity.php | 2 + .../File/ASN1/Maps/netscape_ca_policy_url.php | 2 + .../File/ASN1/Maps/netscape_cert_type.php | 2 + phpseclib/File/ASN1/Maps/netscape_comment.php | 2 + phpseclib/File/X509.php | 420 +- phpseclib/Math/BigInteger.php | 219 +- phpseclib/Math/BigInteger/Engines/BCMath.php | 176 +- .../Math/BigInteger/Engines/BCMath/Base.php | 41 +- .../BigInteger/Engines/BCMath/BuiltIn.php | 9 +- .../Engines/BCMath/DefaultEngine.php | 2 + .../BigInteger/Engines/BCMath/OpenSSL.php | 2 + .../Engines/BCMath/Reductions/Barrett.php | 16 +- .../Engines/BCMath/Reductions/EvalBarrett.php | 12 +- phpseclib/Math/BigInteger/Engines/Engine.php | 168 +- phpseclib/Math/BigInteger/Engines/GMP.php | 185 +- .../BigInteger/Engines/GMP/DefaultEngine.php | 9 +- phpseclib/Math/BigInteger/Engines/OpenSSL.php | 13 +- phpseclib/Math/BigInteger/Engines/PHP.php | 189 +- .../Math/BigInteger/Engines/PHP/Base.php | 45 +- .../BigInteger/Engines/PHP/DefaultEngine.php | 2 + .../BigInteger/Engines/PHP/Montgomery.php | 13 +- .../Math/BigInteger/Engines/PHP/OpenSSL.php | 2 + .../Engines/PHP/Reductions/Barrett.php | 31 +- .../Engines/PHP/Reductions/Classic.php | 11 +- .../Engines/PHP/Reductions/EvalBarrett.php | 66 +- .../Engines/PHP/Reductions/Montgomery.php | 24 +- .../Engines/PHP/Reductions/MontgomeryMult.php | 12 +- .../Engines/PHP/Reductions/PowerOfTwo.php | 16 +- phpseclib/Math/BigInteger/Engines/PHP32.php | 104 +- phpseclib/Math/BigInteger/Engines/PHP64.php | 100 +- phpseclib/Math/BinaryField.php | 34 +- phpseclib/Math/BinaryField/Integer.php | 76 +- phpseclib/Math/Common/FiniteField/Integer.php | 6 +- phpseclib/Math/PrimeField.php | 22 +- phpseclib/Math/PrimeField/Integer.php | 71 +- phpseclib/Net/SFTP.php | 442 +- phpseclib/Net/SFTP/Attribute.php | 5 +- phpseclib/Net/SFTP/FileType.php | 2 + phpseclib/Net/SFTP/OpenFlag.php | 2 + phpseclib/Net/SFTP/OpenFlag5.php | 2 + phpseclib/Net/SFTP/PacketType.php | 2 + phpseclib/Net/SFTP/StatusCode.php | 2 + phpseclib/Net/SFTP/Stream.php | 132 +- phpseclib/Net/SSH2.php | 429 +- .../SSH2/ChannelConnectionFailureReason.php | 2 + phpseclib/Net/SSH2/DisconnectReason.php | 2 + phpseclib/Net/SSH2/MessageType.php | 2 + phpseclib/Net/SSH2/MessageTypeExtra.php | 2 + phpseclib/Net/SSH2/TerminalMode.php | 2 + phpseclib/System/SSH/Agent.php | 27 +- phpseclib/System/SSH/Agent/Identity.php | 36 +- .../System/SSH/Common/Traits/ReadBytes.php | 5 +- tests/Functional/Net/SFTPLargeFileTest.php | 6 +- tests/Functional/Net/SFTPStreamTest.php | 14 +- tests/Functional/Net/SFTPTestCase.php | 6 +- tests/Functional/Net/SFTPUserStoryTest.php | 8 +- tests/Functional/Net/SFTPWrongServerTest.php | 4 +- tests/Functional/Net/SSH2AgentTest.php | 6 +- tests/Functional/Net/SSH2Test.php | 20 +- tests/PhpseclibFunctionalTestCase.php | 13 +- tests/PhpseclibTestCase.php | 35 +- tests/Unit/Crypt/AES/EvalTest.php | 4 +- tests/Unit/Crypt/AES/McryptTest.php | 4 +- tests/Unit/Crypt/AES/OpenSSLTest.php | 4 +- tests/Unit/Crypt/AES/PurePHPTest.php | 4 +- tests/Unit/Crypt/AES/TestCase.php | 42 +- tests/Unit/Crypt/BlowfishTest.php | 8 +- tests/Unit/Crypt/ChaCha20Test.php | 14 +- tests/Unit/Crypt/DHTest.php | 32 +- tests/Unit/Crypt/DSA/CreateKeyTest.php | 4 +- tests/Unit/Crypt/DSA/LoadDSAKeyTest.php | 20 +- tests/Unit/Crypt/DSA/SignatureTest.php | 8 +- tests/Unit/Crypt/EC/CurveTest.php | 30 +- tests/Unit/Crypt/EC/Ed448PrivateKey.php | 4 +- tests/Unit/Crypt/EC/Ed448PublicKey.php | 4 +- tests/Unit/Crypt/EC/KeyTest.php | 50 +- tests/Unit/Crypt/GCMTest.php | 14 +- tests/Unit/Crypt/HashTest.php | 34 +- tests/Unit/Crypt/RC2Test.php | 8 +- tests/Unit/Crypt/RC4Test.php | 8 +- tests/Unit/Crypt/RSA/CreateKeyTest.php | 10 +- tests/Unit/Crypt/RSA/LoadKeyTest.php | 96 +- tests/Unit/Crypt/RSA/ModeTest.php | 20 +- tests/Unit/Crypt/RandomTest.php | 10 +- tests/Unit/Crypt/Salsa20Test.php | 6 +- tests/Unit/Crypt/TripleDESTest.php | 19 +- tests/Unit/Crypt/TwofishTest.php | 4 +- tests/Unit/File/ANSITest.php | 8 +- tests/Unit/File/ASN1Test.php | 36 +- tests/Unit/File/X509/CRLTest.php | 4 +- tests/Unit/File/X509/CSRTest.php | 14 +- tests/Unit/File/X509/SPKACTest.php | 8 +- tests/Unit/File/X509/X509ExtensionTest.php | 10 +- tests/Unit/File/X509/X509Test.php | 64 +- tests/Unit/Math/BigInteger/BCMathTest.php | 8 +- tests/Unit/Math/BigInteger/DefaultTest.php | 6 +- tests/Unit/Math/BigInteger/GMPTest.php | 8 +- tests/Unit/Math/BigInteger/PHP32Test.php | 10 +- .../Unit/Math/BigInteger/PHP64OpenSSLTest.php | 10 +- tests/Unit/Math/BigInteger/PHP64Test.php | 10 +- tests/Unit/Math/BigInteger/TestCase.php | 84 +- tests/Unit/Math/BigIntegerTest.php | 16 +- tests/Unit/Net/SFTPStreamUnitTest.php | 6 +- tests/Unit/Net/SSH2UnitTest.php | 25 +- ...e_compatible_with_new_phpunit_versions.php | 32 - 399 files changed, 21295 insertions(+), 4658 deletions(-) delete mode 100755 tests/make_compatible_with_new_phpunit_versions.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5bad4af9..2a34f186 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php-version: ['8.1'] quality_tools: name: Quality Tools timeout-minutes: 5 @@ -42,8 +42,6 @@ jobs: tests: name: Tests timeout-minutes: 10 - # Sometimes there is a segfault on PHP 5.6. - continue-on-error: ${{ matrix.php-version == '5.6' }} runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -54,9 +52,6 @@ jobs: php-version: ${{ matrix.php-version }} - name: Composer Install run: composer install --classmap-authoritative --no-interaction --no-cache - - name: Make Tests Compatiable With New PHPUnit Versions - if: matrix.php-version != '5.6' && matrix.php-version != '7.0' - run: php tests/make_compatible_with_new_phpunit_versions.php - name: Setup Secure Shell Functional Tests if: matrix.os == 'ubuntu-latest' run: | @@ -85,4 +80,4 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + php-version: ['8.1'] diff --git a/.gitignore b/.gitignore index 50ee3101..59556f6b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ /build/php-cs-fixer.cache /composer.lock /composer.phar +/tests/.phpunit.result.cache /vendor/ .gitignore diff --git a/build/php-cs-fixer.php b/build/php-cs-fixer.php index e66ad577..c445543a 100644 --- a/build/php-cs-fixer.php +++ b/build/php-cs-fixer.php @@ -1,5 +1,7 @@ setFinder(PhpCsFixer\Finder::create()->in(__DIR__ . '/..')) ->setCacheFile(__DIR__ . '/php-cs-fixer.cache') @@ -19,5 +21,16 @@ return (new PhpCsFixer\Config()) 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'const', 'function']], 'single_import_per_statement' => true, 'single_line_after_imports' => true, + // PHPDoc + 'no_superfluous_phpdoc_tags' => true, + 'phpdoc_trim_consecutive_blank_line_separation' => true, + 'phpdoc_trim' => true, + + // PHP 7.0 + '@PHP70Migration' => true, + '@PHP70Migration:risky' => true, + 'declare_strict_types' => false, + // PHP 7.1 + 'void_return' => true, ] ); diff --git a/build/psalm.xml b/build/psalm.xml index 90f94f67..142a414d 100644 --- a/build/psalm.xml +++ b/build/psalm.xml @@ -1,20 +1,19 @@ - - - - + @@ -23,4 +22,4 @@ - \ No newline at end of file + diff --git a/build/psalm_baseline.xml b/build/psalm_baseline.xml index 19a5bd62..979a4626 100644 --- a/build/psalm_baseline.xml +++ b/build/psalm_baseline.xml @@ -1,9 +1,11850 @@ - + + + + $trim + $var + + + $data + $data + $data + $digit + $digit + $element + $format + $length + + + $element + + + $part[0] + + + $part[0] + $result[] + $result[] + $result[] + $result[] + $result[] + $result[] + $result[] + + + $format[$i] + + + $digit + $digit + $element + $i + $part + $result[] + $result[] + $temp + $temp + + + array + + + $i + $lower + $lower < 0 ? ($lower & 0x7FFFFFFFF) + 0x80000000 : $lower + $part + $temp['num'] + $temp['num'] + $upper + + + $result + + + $parts + pack('N', $temp['num'] + 1) + pack('N', $temp['num'] + 1) + unpack('Nupper/Nlower', self::shift($data, 8)) + + + $digits + $digits + $parts + + + pack('C', $element) + pack('N', $element) + pack('NN', $element / 4294967296, $element) + pack('Na*', strlen($element), $element) + pack('Na*', strlen($element), $element) + pack('Na*', strlen($element), $element) + + + $length + $parts[$i - 1] + $parts[$i - 1] + $parts[$i - 1] + $parts[$i] + $temp + $temp['num'] + $temp['num'] + + + toBytes + + + $temp['num'] + $temp['num'] + + + string + + + $element instanceof BigInteger + $element instanceof FiniteField\Integer + + + + + AES + AES + AES + AES + AES + AES + AES + AES + AES + + + + + pack('N*', $r ^ $p[0], $l ^ $p[1]) + pack('N*', $r ^ $p[17], $l ^ $p[16]) + + + string + string + + + + $j + + + $sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff] + $sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff] + + + $p[$i + 1] + $p[$i + 1] + $p[$i - 1] + $p[$i - 1] + $p[$i] + $p[$i] + $p[$i] + $p[$i] + $p[0] + $p[0] + $p[16] + $p[16] + $p[17] + $p[17] + $p[1] + $p[1] + $sb_0[$l >> 24 & 0xff] + $sb_0[$l >> 24 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff] + $sb_1[$l >> 16 & 0xff] + $sb_1[$r >> 16 & 0xff] + $sb_1[$r >> 16 & 0xff] + $sb_2[$l >> 8 & 0xff] + $sb_2[$l >> 8 & 0xff] + $sb_2[$r >> 8 & 0xff] + $sb_2[$r >> 8 & 0xff] + $sb_3[$l & 0xff] + $sb_3[$l & 0xff] + $sb_3[$r & 0xff] + $sb_3[$r & 0xff] + $this->bctx['sb'][0] + $this->bctx['sb'][0] + $this->bctx['sb'][1] + $this->bctx['sb'][1] + $this->bctx['sb'][2] + $this->bctx['sb'][2] + $this->bctx['sb'][3] + $this->bctx['sb'][3] + + + $sb_0[$l >> 24 & 0xff] + $sb_0[$l >> 24 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff] + $sb_1[$l >> 16 & 0xff] + $sb_1[$r >> 16 & 0xff] + $sb_1[$r >> 16 & 0xff] + $sb_2[$l >> 8 & 0xff] + $sb_2[$l >> 8 & 0xff] + $sb_2[$r >> 8 & 0xff] + $sb_2[$r >> 8 & 0xff] + $sb_3[$l & 0xff] + $sb_3[$l & 0xff] + $sb_3[$r & 0xff] + $sb_3[$r & 0xff] + + + $data + $l + $l + $l + $l + $l + $l + $p + $p + $p + $r + $r + $r + $r + $r + $r + $sb_0 + $sb_0 + $sb_1 + $sb_1 + $sb_2 + $sb_2 + $sb_3 + $sb_3 + + + $data + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $p[$i + 1] + $p[$i - 1] + $p[$i] + $p[$i] + $p[0] + $p[16] + $p[17] + $p[1] + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $sb_0[$l >> 24 & 0xff] + $sb_0[$l >> 24 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_0[$r >> 24 & 0xff] + $sb_2[$l >> 8 & 0xff] + $sb_2[$l >> 8 & 0xff] + $sb_2[$r >> 8 & 0xff] + $sb_2[$r >> 8 & 0xff] + self::$parray[$i] + + + unpack('C*', $this->key) + unpack('N*', $data = $this->encryptBlock($data)) + unpack('N*', $data = $this->encryptBlock($data)) + + + $in[1] + $in[1] + $in[2] + $in[2] + + + $this->openssl_translate_mode() + + + $in[1] + $in[1] + $in[2] + $in[2] + + + $this->bctx['p'] + $this->bctx['p'] + $this->bctx['p'] + $this->bctx['sb'] + $this->bctx['sb'] + + + setupInlineCrypt + + + $bctx + $kl + Blowfish + Blowfish + Blowfish + Blowfish + Blowfish + Blowfish + Blowfish + Blowfish + Blowfish + + + + + $this->key === false + $this->nonce === false + $this->oldtag === false + + + salsa20 + + + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x0 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x12 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x1 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x13 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x2 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x14 ^ $x3 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x0 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x15 ^ $x3 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x8 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x4 ^ $x9 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x10 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x5 ^ $x9 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x10 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x6 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x11 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + $x7 ^ $x8 + + + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x12 + $x13 + $x14 + $x15 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x4 + $x5 + $x6 + $x7 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $z0 + $z1 + $z10 + $z11 + $z12 + $z13 + $z14 + $z15 + $z2 + $z3 + $z4 + $z5 + $z6 + $z7 + $z8 + $z9 + + + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x0 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x1 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x10 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x11 + $x12 + $x13 + $x14 + $x15 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x2 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x3 + $x4 + $x5 + $x6 + $x7 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x8 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $x9 + $z12 + $z13 + $z14 + $z15 + $z4 + $z5 + $z6 + $z7 + + + $ciphertext + $ciphertext + $ciphertext + $plaintext + + + false + false + false + + + $x0 + $x1 + $x10 + $x11 + $x12 + $x13 + $x14 + $x15 + $x2 + $x3 + $x4 + $x5 + $x6 + $x7 + $x8 + $x9 + + + ChaCha20 + ChaCha20 + ChaCha20 + ChaCha20 + ChaCha20 + ChaCha20 + ChaCha20 + ChaCha20 + ChaCha20 + + + $this->usePoly1305 && !isset($this->poly1305Key) + $this->usePoly1305 && !isset($this->poly1305Key) + isset($this->poly1305Key) + + + is_string($nonce) + + + + + $this->format + $type + + + string + + + string + string + string + + + validatePlugin + + + $name + $rolen + $this->q + $this->q + $this->x + $type + $vlen - $qlen + -$rolen + self::$invisiblePlugins[static::ALGORITHM] + + + $components['comment'] + self::$plugins[static::ALGORITHM]['Keys'] + self::$plugins[static::ALGORITHM]['Keys'] + + + $components['format'] + $components['format'] + self::$invisiblePlugins[static::ALGORITHM][] + self::$plugins[static::ALGORITHM][$format] + self::$plugins[static::ALGORITHM][$format] + self::$plugins[static::ALGORITHM]['Keys'] + + + self::$invisiblePlugins[static::ALGORITHM] + self::$invisiblePlugins[static::ALGORITHM] + self::$invisiblePlugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + self::$plugins[static::ALGORITHM] + + + $comment + $components + $components + $components['format'] + $components['format'] + $format + $format + $new + $new + $qlen + $qlen + $rolen + $type + + + AsymmetricKey + array + static + + + $format::load($key, $password) + $format::load($key, $password) + getLength + getLengthInBytes + getLengthInBytes + + + $qlen + static::ALGORITHM + static::ALGORITHM + + + $new + $new + $new + + + self::$plugins[static::ALGORITHM]['Keys'] + + + $key + + + $key + + + $format + $format + + + computek + getComment + getSupportedKeyFormats + loadParameters + loadParametersFormat + loadPrivateKey + loadPrivateKeyFormat + loadPublicKey + loadPublicKeyFormat + + + array + + + $format + + + isset(self::$zero) + + + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + static::ALGORITHM + + + static::onLoad($components) + static::onLoad($components) + + + $this->q + $this->q + $this->q + $this->q + $this->x + + + $name + + + $signatureFileFormats + $signatureFormats + + + + + $checkint + $checkint + $comment + $kdfoptions + $paddedKey + $publicKey + $type + $type + static::$types + static::$types + + + $comment + + + $asciiType + + + $parts[1] + + + $checkint + + + $key + + + $parts[0] + $parts[1] + + + setBinaryOutput + + + !empty($password) && is_string($password) + is_string($password) + + + $key + $key + + + static::$types + static::$types + + + + + requireAny + requireDER + requirePEM + + + + + !is_string($password) + + + self::getEncryptionMode($matches[1]) + self::getEncryptionMode($matches[1]) + self::getEncryptionMode($matches[2]) + + + $mode + + + int + + + $encryptionAlgorithm + + + $encryptionAlgorithm + + + $password + + + $key + + + $matches[1] + $matches[1] + $matches[1] + $matches[1] + $matches[2] + $matches[2] + + + $decoded !== false + + + $ciphertext === false + + + + + $hash + $salt + + + $params + $params + + + $algorithm + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decrypted['encryptionAlgorithm']['parameters'] + $decrypted['encryptionAlgorithm']['parameters'] + $decrypted['encryptionAlgorithm']['parameters'] + $encryptionAlgorithm + $encryptionScheme + $encryptionScheme['algorithm'] + $encryptionScheme['parameters'] + $iterationCount + $kdf['parameters']->element + $key + $key + $key + $key + $keyDerivationFunc['parameters'] + $prf + $prf['algorithm'] + $private['publicKey'] + $private['publicKey'][0] + $public['publicKey'] + $public['publicKey'][0] + $r['encryptionAlgorithm']['parameters']->element + $temp['length'] + $temp['length'] + $temp['start'] + $temp['start'] + $temp[0] + $temp[0] + $temp[0] + $temp[0] + $temp[0] + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_VALUE + + + $decoded[0]['content'] + $decoded[0]['content'] + $decrypted['encryptedData'] + $decrypted['encryptedData'] + $decrypted['encryptionAlgorithm']['algorithm'] + $decrypted['encryptionAlgorithm']['parameters'] + $decrypted['encryptionAlgorithm']['parameters'] + $decrypted['encryptionAlgorithm']['parameters'] + $encryptionScheme['algorithm'] + $encryptionScheme['algorithm'] + $encryptionScheme['parameters'] + $encryptionScheme['parameters'] + $kdf['algorithm'] + $kdf['parameters'] + $keyDerivationFunc['algorithm'] + $keyDerivationFunc['algorithm'] + $keyDerivationFunc['parameters'] + $prf['algorithm'] + $prf['algorithm'] + $private['privateKeyAlgorithm']['algorithm'] + $private['privateKeyAlgorithm']['algorithm'] + $private['privateKeyAlgorithm']['algorithm'] + $private['privateKeyAlgorithm']['algorithm'] + $private['publicKey'][0] + $private['publicKey'][0] + $public['publicKey'][0] + $public['publicKeyAlgorithm']['algorithm'] + $public['publicKeyAlgorithm']['algorithm'] + $public['publicKeyAlgorithm']['algorithm'] + $public['publicKeyAlgorithm']['algorithm'] + $r['encryptionAlgorithm']['algorithm'] + $r['encryptionAlgorithm']['parameters'] + $temp['length'] + $temp['length'] + $temp['start'] + $temp['start'] + + + $kdf['parameters'] + $meta['meta'] + $meta['meta'] + $meta['meta'] + $r['encryptionAlgorithm']['parameters'] + + + [static::OID_NAME => static::OID_VALUE] + + + $algorithm + $encryptionAlgorithm + $encryptionScheme + $iterationCount + $kdf + $key + $key + $key['privateKeyAlgorithm']['parameters'] + $meta['meta']['algorithm'] + $meta['meta']['cipher'] + $meta['meta']['keyDerivationFunc'] + $meta['meta']['prf'] + $prf + $temp + $temp + + + array + array + + + decrypt + decrypt + setIV + setIV + setKeyLength + setPassword + setPassword + toString + toString + toString + toString + + + $meta + $private['privateKeyAlgorithm']['algorithm'] + $private['privateKeyAlgorithm']['algorithm'] + $public['publicKeyAlgorithm']['algorithm'] + $public['publicKeyAlgorithm']['algorithm'] + static::OID_NAME + static::OID_NAME + + + $kdf['parameters']->element + $r['encryptionAlgorithm']['parameters']->element + + + $private + $meta + $r['encryptionAlgorithm'] + + + $key + $params + $temp + $temp + ASN1::asn1map($temp[0], Maps\PBEParameter::MAP) + ASN1::asn1map($temp[0], Maps\RC2CBCParameter::MAP) + + + $r['encryptionAlgorithm']['parameters']['keyDerivationFunc'] + + + $r['encryptionAlgorithm']['parameters']['keyDerivationFunc'] + + + $key + + + $kdf['parameters']->element + + + $kdf['algorithm'] + $kdf['parameters'] + $r['encryptionAlgorithm']['parameters']['keyDerivationFunc'] + + + $kdf['parameters']->element + + + $r['encryptionAlgorithm']['parameters'] + + + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $matches[1] + $matches[1] + $temp[0] + $temp[0] + $temp[0] + $temp[0] + $temp[0] + + + $decrypted['encryptionAlgorithm'] + $private['privateKeyAlgorithm'] + $private['privateKeyAlgorithm'] + $private['privateKeyAlgorithm'] + $private['privateKeyAlgorithm'] + $public['publicKey'] + $public['publicKey'] + $public['publicKey'] + $public['publicKeyAlgorithm'] + $public['publicKeyAlgorithm'] + $public['publicKeyAlgorithm'] + $public['publicKeyAlgorithm'] + $r['encryptionAlgorithm'] + $r['encryptionAlgorithm'] + $r['encryptionAlgorithm'] + $r['encryptionAlgorithm']['parameters']['keyDerivationFunc'] + + + $iv + $salt + + + setIterationCount + + + $decoded !== false + + + !empty($password) && is_string($password) + is_string($password) + + + Strings::is_stringable($key) + + + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_NAME + static::OID_VALUE + static::OID_VALUE + + + $r['encryptionAlgorithm']['parameters'] + + + static::$childOIDsLoaded + + + + + $comment + $hash->hash($source) + $hash->hash($source) + $hashkey + $hashkey + $hashkey + $key + $key[$offset + $privateLength] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $length + $offset + $password + $password + $private + $private + $private + $public + $symiv + $symkey + array_slice($key, $offset, $privateLength) + array_slice($key, 4, $publicLength) + static::$types + static::$types + + + $key[$offset + $privateLength] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + static::$types[0] + + + $components['comment'] + $components['private'] + $components['public'] + + + $key[$offset + $privateLength] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + $key[$offset++] + + + $comment + $components + $components + $components['private'] + $mac + $offset + $offset + $offset + $offset + $offset + $offset + $offset + $private + $private + $version + + + array|false + + + decrypt + disablePadding + disablePadding + encrypt + hash + hash + hash + setIV + setIV + setKey + setKey + + + $components + $hashkey + $key + $offset + $offset + $offset + $offset + $offset + $offset + $offset + $publicLength + $source + static::$types[0] + + + $components + $components + + + $key + $key + $lines + $lines + $password + $password + $temp + unpack('Nlength', Strings::shift($public, 4)) + + + $password + + + $key[0] + $key[1] + $key[2] + $key[3] + $lines[0] + $lines[count($lines) - 1] + + + preg_replace('#Argon2-Memory: (\d+)#', '$1', $key[$offset++]) + preg_replace('#Argon2-Parallelism: (\d+)#', '$1', $key[$offset++]) + preg_replace('#Argon2-Passes: (\d+)#', '$1', $key[$offset++]) + preg_replace('#Argon2-Salt: ([0-9a-f]+)#', '$1', $key[$offset++]) + preg_replace('#Comment: (.+)#', '$1', $key[2]) + preg_replace('#Encryption: (.+)#', '$1', $key[1]) + preg_replace('#Key-Derivation: (.*)#', '$1', $key[$offset++]) + preg_replace('#Private-Lines: (\d+)#', '$1', $key[$offset++]) + preg_replace('#Private-MAC: (.+)#', '$1', $key[$offset + $privateLength]) + preg_replace('#Public-Lines: (\d+)#', '$1', $key[3]) + + + $key[1] + $key[2] + $key[3] + $match[1] + $match[2] + $match[2] + + + $values['comment'] + + + $hash + $hash + $symiv + $symiv + $symkey + $symkey + + + setVersion + + + static::PUBLIC_HANDLER + + + static::$types + static::$types + + + $mac + + + + + compact('r', 's') + + + string + + + $sig['r'] + $sig['r'] + $sig['s'] + $sig['s'] + + + load + save + + + !is_array($sig) + !isset($sig['r']) || !isset($sig['s']) + + + + + $message + + + getPublicKey + sign + withPassword + + + + + $algorithm + $message + $signature + + + getFingerprint + verify + + + verify + + + + + \phpseclib3\Crypt\Common\StreamCipher + + + StreamCipher + StreamCipher + StreamCipher + StreamCipher + StreamCipher + StreamCipher + StreamCipher + StreamCipher + StreamCipher + StreamCipher + + + + + !$this->h + !$this->h + $this->iv === false + $this->key === false + $this->newtag === false + $this->nonce === false + $this->oldtag === false + + + $ciphertext + $ciphertext + $ciphertext + $result + openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING) + openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING) + + + $func_args[0] + + + $xor[0] + $xor[0] + + + string + + + $inline('decrypt', $ciphertext) + $inline('encrypt', $plaintext) + + + $length >> 3 + + + $x + + + int + + + string + + + setupKey + + + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $ciphertext + $dkLen + $dkLen + $dkLen + $dkLen + $dkLen >> 1 + $dkLen >> 1 + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $key + $key + $key + $key + $len + $len + $len + $len + $len - $len % $block_size + $len - $len % $block_size + $mcrypt_modes[$this->mode] + $mcrypt_modes[$this->mode] + $one + $orig_pos + $orig_pos + $orig_pos + $orig_pos + $orig_pos + $orig_pos + $overflow + $overflow + $plaintext + $reverseMap[$engine] + $this->openssl_options + $this->openssl_options + -$overflow + -$overflow + -$overflow + -$overflow + -$overflow + -$overflow + -$overflow - $this->block_size + MCRYPT_MODE_ECB + + + $mcrypt_modes[$this->mode] + $mcrypt_modes[$this->mode] + $reverseMap[$engine] + $this->buffer['pos'] + + + $ciphertext + $dkLen + $i + $i + $i + $i + $i + $i + $key_length + $len + $len + $len + $len + $len + $len + $len + $len + $len + $len + $len + $max + $max + $max + $max + $max + $max + $orig_pos + $orig_pos + $orig_pos + $orig_pos + $orig_pos + $orig_pos + $overflow + $overflow + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $size + $this->preferredEngine + + + int + string + string + string + + + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $dkLen + $dkLen + $key_length + $len + $len + $len + $len + $len + $len + $len + $len + $len + $max + $max + $max + $max + $max + $max + $overflow + $overflow + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $pos + $this->key_length + $xor[0] + $xor[0] + -$overflow + + + $inline('decrypt', $ciphertext) + $inline('encrypt', $plaintext) + $plaintext + $this->key_length << 3 + $this->paddable ? $this->unpad($plaintext) : $plaintext + + + $ciphertext + $ciphertext + $ciphertext + $ciphertext + $ciphertext + $encryptIV + $encrypted + $iv + $result + $this->ecb + + + openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv) + openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv) + openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV) + openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV) + openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv) + pack('N', $i++) + pack('N', 8 * strlen($str)) + + + false + false + false + false + false + false + false + false + false + mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '') + mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '') + mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '') + + + $count + $count + $count + $dkLen + $dkLen + $dkLen + $dkLen + $salt + $salt + + + $reverseMap[$engine] + + + $salt + + + $salt + $salt + $salt + + + null + null + null + null + + + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['pos'] + $buffer['pos'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $buffer['xor'] + $this->debuffer['pos'] + $this->enbuffer['enmcrypt_init'] + $this->enbuffer['enmcrypt_init'] + $this->enbuffer['pos'] + $this->enbuffer['pos'] + + + $key + $key + $key + $key + $plaintext + $plaintext + $plaintext + + + enablePadding + getMode + + + $cipher_code + + + bool + + + $cipher_name_mcrypt + $cipher_name_openssl + $cipher_name_openssl_ecb + $debuffer + $decryptIV + $demcrypt + $ecb + $enbuffer + $encryptIV + $engine + $enmcrypt + $h + $inline_crypt + $poly1305Key + $preferredEngine + + + $this->ecb + $this->ecb + $this->engine != self::ENGINE_MCRYPT && $this->enmcrypt + $this->enmcrypt + is_string($this->key) + strlen($password) + + + $this->usePoly1305 && !isset($this->poly1305Key) + $this->usePoly1305 && !isset($this->poly1305Key) + isset($this->enmcrypt) + isset($this->poly1305Key) + isset($this->poly1305Key) + isset($this->preferredEngine) + isset(self::$gcmField) + isset(self::$poly1305Field) + + + return $ciphertext; + + + MCRYPT_MODE_CBC + MCRYPT_MODE_CFB + MCRYPT_MODE_ECB + MCRYPT_MODE_ECB + MCRYPT_MODE_NOFB + MCRYPT_MODE_OFB + MCRYPT_MODE_STREAM + + + Callback + + + setupInlineCrypt + + + $this->h->key + + + $this->h->key + + + $this->key_length + + + $this->buffer + $this->key_length + $this->key_length + $this->openssl_options + $this->openssl_options + + + break; + + + new static('ctr') + new static('ctr') + new static('ecb') + + + $skip_key_adjustment + + + $ciphertext + $ciphertext + $i + $i + $size + + + + + getFingerprint + + + $type + + + $key === false + + + + + withPassword + + + + + 8 + + + $block + $key + + + $k[$c][++$ki] + $k[$c][++$ki] + $keys[++$ki] + $keys[++$ki] + $pc1map[ $l & 0xFF] + $pc1map[ $r & 0xFF] + $pc1map[($l >> 8) & 0xFF] + $pc1map[($l >> 16) & 0xFF] + $pc1map[($l >> 24) & 0xFF] + $pc1map[($r >> 8) & 0xFF] + $pc1map[($r >> 16) & 0xFF] + $pc1map[($r >> 24) & 0xFF] + $pc2mapc1[ $c >> 24 ] + $pc2mapc2[($c >> 16) & 0xFF] + $pc2mapc3[($c >> 8) & 0xFF] + $pc2mapc4[ $c & 0xFF] + $pc2mapd1[ $d >> 24 ] + $pc2mapd2[($d >> 16) & 0xFF] + $pc2mapd3[($d >> 8) & 0xFF] + $pc2mapd4[ $d & 0xFF] + $sbox1[($b1 >> 24) & 0x3F] + $sbox2[($b2 >> 24) & 0x3F] + $sbox3[($b1 >> 16) & 0x3F] + $sbox4[($b2 >> 16) & 0x3F] + $sbox5[($b1 >> 8) & 0x3F] + $sbox6[($b2 >> 8) & 0x3F] + $sbox7[ $b1 & 0x3F] + $sbox8[ $b2 & 0x3F] + $shifts[$i] + $shifts[$i] + $shuffleinvip[ $l & 0xFF] + $shuffleinvip[ $r & 0xFF] + $shuffleinvip[($l >> 8) & 0xFF] + $shuffleinvip[($l >> 16) & 0xFF] + $shuffleinvip[($l >> 24) & 0xFF] + $shuffleinvip[($r >> 8) & 0xFF] + $shuffleinvip[($r >> 16) & 0xFF] + $shuffleinvip[($r >> 24) & 0xFF] + $shuffleip[ $l & 0xFF] + $shuffleip[ $r & 0xFF] + $shuffleip[($l >> 8) & 0xFF] + $shuffleip[($l >> 16) & 0xFF] + $shuffleip[($l >> 24) & 0xFF] + $shuffleip[($r >> 8) & 0xFF] + $shuffleip[($r >> 16) & 0xFF] + $shuffleip[($r >> 24) & 0xFF] + + + $shuffleinvip[] + $shuffleip[] + + + $pc1map[ $l & 0xFF] + $pc1map[ $r & 0xFF] + $pc1map[($l >> 8) & 0xFF] + $pc1map[($l >> 16) & 0xFF] + $pc1map[($l >> 24) & 0xFF] + $pc1map[($r >> 8) & 0xFF] + $pc1map[($r >> 16) & 0xFF] + $pc1map[($r >> 24) & 0xFF] + $pc2mapc1[ $c >> 24 ] + $pc2mapc2[($c >> 16) & 0xFF] + $pc2mapc3[($c >> 8) & 0xFF] + $pc2mapc4[ $c & 0xFF] + $pc2mapd1[ $d >> 24 ] + $pc2mapd2[($d >> 16) & 0xFF] + $pc2mapd3[($d >> 8) & 0xFF] + $pc2mapd4[ $d & 0xFF] + $sbox1[($b1 >> 24) & 0x3F] + $sbox2[($b2 >> 24) & 0x3F] + $sbox3[($b1 >> 16) & 0x3F] + $sbox4[($b2 >> 16) & 0x3F] + $sbox5[($b1 >> 8) & 0x3F] + $sbox6[($b2 >> 8) & 0x3F] + $sbox7[ $b1 & 0x3F] + $sbox8[ $b2 & 0x3F] + $shuffleinvip[ $l & 0xFF] + $shuffleinvip[ $r & 0xFF] + $shuffleinvip[($l >> 8) & 0xFF] + $shuffleinvip[($l >> 16) & 0xFF] + $shuffleinvip[($l >> 24) & 0xFF] + $shuffleinvip[($r >> 8) & 0xFF] + $shuffleinvip[($r >> 16) & 0xFF] + $shuffleinvip[($r >> 24) & 0xFF] + $shuffleip[ $l & 0xFF] + $shuffleip[ $r & 0xFF] + $shuffleip[($l >> 8) & 0xFF] + $shuffleip[($l >> 16) & 0xFF] + $shuffleip[($l >> 24) & 0xFF] + $shuffleip[($r >> 8) & 0xFF] + $shuffleip[($r >> 16) & 0xFF] + $shuffleip[($r >> 24) & 0xFF] + self::$shuffle[$pc1map[ $l & 0xFF]] + self::$shuffle[$pc1map[ $r & 0xFF]] + self::$shuffle[$pc1map[($l >> 8) & 0xFF]] + self::$shuffle[$pc1map[($l >> 16) & 0xFF]] + self::$shuffle[$pc1map[($l >> 24) & 0xFF]] + self::$shuffle[$pc1map[($r >> 8) & 0xFF]] + self::$shuffle[$pc1map[($r >> 16) & 0xFF]] + self::$shuffle[$pc1map[($r >> 24) & 0xFF]] + self::$shuffle[self::$invipmap[$i]] + self::$shuffle[self::$ipmap[$i]] + + + $b1 + $b2 + $block + $c + $c + $c + $cp + $d + $d + $d + $dp + $key + $keys + $keys[$des_round][self::DECRYPT][$ki ] + $keys[$des_round][self::DECRYPT][$ki - 1] + $keys[$des_round][self::ENCRYPT][ ] + $keys[$des_round][self::ENCRYPT][ ] + $l + $l + $l + $l + $l + $r + $r + $r + $r + $r + $shuffleinvip[] + $shuffleip[] + $t + $t + $val1 + $val2 + + + string + + + $b1 + $b1 + $b1 + $b1 + $b2 + $b2 + $b2 + $b2 + $c + $c + $c + $c + $c + $c + $c + $cp + $cp + $cp + $cp + $d + $d + $d + $d + $d + $d + $d + $dp + $dp + $dp + $dp + $k[$c][++$ki] + $k[$c][++$ki] + $key['c'] + $key['c'] + $key['d'] + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $l + $pc2mapc1[ $c >> 24 ] + $pc2mapd1[ $d >> 24 ] + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] + $sbox2[($b2 >> 24) & 0x3F] + $shuffleinvip[ $l & 0xFF] + $shuffleinvip[ $r & 0xFF] + $shuffleinvip[($l >> 8) & 0xFF] + $shuffleinvip[($l >> 16) & 0xFF] + $shuffleinvip[($l >> 24) & 0xFF] + $shuffleinvip[($r >> 8) & 0xFF] + $shuffleinvip[($r >> 16) & 0xFF] + $shuffleinvip[($r >> 24) & 0xFF] + $shuffleip[ $l & 0xFF] + $shuffleip[ $r & 0xFF] + $shuffleip[($l >> 8) & 0xFF] + $shuffleip[($l >> 16) & 0xFF] + $shuffleip[($l >> 24) & 0xFF] + $shuffleip[($r >> 8) & 0xFF] + $shuffleip[($r >> 16) & 0xFF] + $shuffleip[($r >> 24) & 0xFF] + ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) + ($cp << 8) & 0xFF000000 + ($key['d'] >> 4) & 0x0FFFFFF0 + ($r >> 3) & 0x1FFFFFFF + ($r >> 31) & 0x00000001 + (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) + (($r >> 3) & 0x1FFFFFFF) ^ ($r << 29) + (($r >> 31) & 0x00000001) ^ ($r << 1) + self::$shuffle[$pc1map[ $l & 0xFF]] + self::$shuffle[$pc1map[ $r & 0xFF]] + self::$shuffle[$pc1map[($l >> 8) & 0xFF]] + self::$shuffle[$pc1map[($l >> 16) & 0xFF]] + self::$shuffle[$pc1map[($l >> 24) & 0xFF]] + self::$shuffle[$pc1map[($r >> 8) & 0xFF]] + self::$shuffle[$pc1map[($r >> 16) & 0xFF]] + self::$shuffle[$pc1map[($r >> 24) & 0xFF]] + + + + $key['c'] + $key['d'] + $t['l'] + $t['l'] + $t['l'] + $t['r'] + $t['r'] + $t['r'] + + + $this->openssl_translate_mode() + + + $crypt_block[self::DECRYPT] + $crypt_block[self::ENCRYPT] + $keys[0] + $keys[0] + $keys[1] + $keys[2] + $this->keys[self::DECRYPT] + $this->keys[self::ENCRYPT] + + + $key['c'] + $key['d'] + $t['l'] + $t['l'] + $t['l'] + $t['r'] + $t['r'] + $t['r'] + $this->kl['des_rounds'] + + + setupInlineCrypt + + + $key_length + $openssl_mode_names + + + $keys + DES + DES + DES + DES + DES + DES + DES + DES + DES + + + $this->kl + + + + + $args[0] + + + string + + + $new + + + bool + + + $args + + + computeSecret + + + $key + + + $key + $new->base + $new->prime + $new->privateKey + $new->publicKey + $type + + + $type::saveParameters($this->prime, $this->base) + powMod + toBytes + + + $args[0] + $args[0] + $args[0] + $args[1] + + + $components['base'] + $components['prime'] + + + onLoad + + + $new->privateKey + $new->publicKey + + + $public->publicKey + + + + + $decoded[0] + + + $key + + + $decoded[0] + + + PKCS1 + + + + + $privateKey + $publicKey + + + $decoded[0] + $key[$type . 'Algorithm']['parameters']->element + $key[$type] + + + $decoded[0]['content'] + $decoded[0]['content'] + $key[$type . 'Algorithm']['parameters'] + + + $components[$type] + + + $key[$type . 'Algorithm']['parameters']->element + + + $decoded[0] + $decoded[0] + $decoded[0] + + + $key[$type . 'Algorithm'] + $key[$type] + + + !is_array($decoded) + + + PKCS8 + + + + + $type + + + string + + + $type::saveParameters($this->prime, $this->base, $options) + + + $type::saveParameters($this->prime, $this->base, $options) + + + Parameters + Parameters + Parameters + + + + + DH::loadFormat('PKCS8', $key) + + + $key + + + $key + $type + $type + + + string + + + $type::savePrivateKey($this->prime, $this->base, $this->privateKey, $this->publicKey, $this->password, $options) + $type::savePublicKey($this->prime, $this->base, $this->publicKey) + + + $type::savePrivateKey($this->prime, $this->base, $this->privateKey, $this->publicKey, $this->password, $options) + + + DH\PublicKey + + + $privateKey + $publicKey + PrivateKey + PrivateKey + PrivateKey + + + isset($this->publicKey) + isset($this->publicKey) + + + + + $type + + + \phpseclib3\Math\BigInteger + string + + + $type::savePublicKey($this->prime, $this->base, $this->publicKey, $options) + + + $this->publicKey + $type::savePublicKey($this->prime, $this->base, $this->publicKey, $options) + + + PublicKey + PublicKey + PublicKey + + + $this->publicKey + $this->publicKey + + + + + count($args) == 1 && $args[0] instanceof Parameters + count($args) == 2 && is_int($args[0]) + is_int($args[0]) + is_int($args[1]) + + + $new + + + bool + + + getParameters + + + $args[0] + $args[1] + $key + + + $key + $new->g + $new->p + $new->q + $new->sigFormat + $new->x + $new->y + $this->sigFormat + $type + + + DSA\PrivateKey + + + $type::saveParameters($this->p, $this->q, $this->g) + + + + $params->g + $params->hash + $params->p + $params->q + $params->shortFormat + + + $args[0] + $args[0] + $args[1] + + + $components['g'] + $components['p'] + $components['q'] + self::$engines['OpenSSL'] + + + getEngine + getLength + getSignatureFormat + onLoad + + + $g + $p + $q + $y + DSA + + + withSignatureFormat + withSignatureFormat + + + + + $g + $g + $p + $p + $q + $q + $x + $y + $y + + + $parsed['paddedKey'] + $parsed['paddedKey'] + $parsed['publicKey'] + + + $comment + $comment + + + $comment + + + $parsed['comment'] + $parsed['publicKey'] + $parsed['type'] + $parsed[type] + + + OpenSSH + + + + + $y + + + $decoded[0] + $decoded[0] + $decoded[0] + + + $key + + + $decoded[0] + + + PKCS1 + + + + + $x + $y + + + $decoded[0] + $decoded[0] + $key[$type . 'Algorithm']['parameters']->element + $key[$type] + + + $key[$type . 'Algorithm']['parameters'] + + + $components['meta'] + + + $key[$type . 'Algorithm']['parameters']->element + + + $decoded[0] + $decoded[0] + + + $key[$type . 'Algorithm'] + $key[$type] + + + $components[$var] instanceof BigInteger + + + PKCS8 + + + + + $g + $g + $p + $p + $q + $q + $x + $y + $y + + + string + + + $components['public'] + + + $private + $public + + + PuTTY + + + + + compact('p', 'q', 'g', 'y') + compact('p', 'q', 'g', 'y', 'x') + + + string + string + + + $key['g'] + $key['p'] + $key['q'] + + + Raw + + + + + $key + + + $components + + + array + + + $components['g'] + $components['p'] + $components['q'] + $components['y'] + + + $temp->item(0)->nodeValue + + + $temp->item(0)->nodeValue + + + $components + $components + $components + $components + + + Strings::is_stringable($key) + + + XML + + + + + $components + + + array|bool + + + $decoded[0] + + + $components + + + $decoded[0] + + + is_string($sig) + + + + + Raw + + + + + false + + + string + + + load + + + $blob + $blob + + + $result === false + is_string($sig) + + + SSH2 + + + + + $type + + + string + + + $type::saveParameters($this->p, $this->q, $this->g, $options) + + + $type::saveParameters($this->p, $this->q, $this->g, $options) + + + Parameters + Parameters + Parameters + Parameters + Parameters + + + + + $format::save($r, $s) + + + getPublicKey + + + $key + + + $key + $type + $type + + + string + string + + + $format::save($r, $s) + $type::savePrivateKey($this->p, $this->q, $this->g, $this->y, $this->x, $this->password, $options) + $type::savePublicKey($this->p, $this->q, $this->g, $this->y) + + + $format::save($r, $s) + $format::save($r, $s) + $type::savePrivateKey($this->p, $this->q, $this->g, $this->y, $this->x, $this->password, $options) + + + ASN1Signature::load($signature) + + + self::$engines['OpenSSL'] + + + $r + $s + + + $x + PrivateKey + PrivateKey + PrivateKey + PrivateKey + PrivateKey + + + isset($this->y) + isset($this->y) + + + withSignatureFormat + + + + + $format::load($signature) + + + $message + $message + $params + $params + $r + $r + $s + $sig + $u2 + $w + self::$one + + + $u2 + + + $params + $sig + $type + $w + [, $u2] + + + string + + + $type::savePublicKey($this->p, $this->q, $this->g, $this->y, $options) + between + between + divide + modInverse + multiply + + + $type::savePublicKey($this->p, $this->q, $this->g, $this->y, $options) + + + PublicKey + PublicKey + PublicKey + PublicKey + PublicKey + + + + + $decoded + $new + $new + $new->withHash($components['curve']::HASH) + + + bool + + + $privatekey + $privatekey->withHash($curve::HASH) + + + getParameters + + + $components['curve']::HASH + $curve::HASH + $dA->toBytes() + $decoded[0] + $key + $params + $this->QA[0]->toBytes(true) + + + $dA + $key + $new->QA + $new->curve + $new->curve + $new->dA + $params + $privatekey->QA + $privatekey->dA + $this->curveName + $type + + + string + string|array + + + $type::saveParameters($this->curve) + createRandomMultiplier + getBasePoint + multiplyPoint + new $curve() + toBytes + toBytes + toBytes + toBytes + toString + + + $this->QA[0]->toBytes(true) + $this->QA[1]->toBytes(true) + + + $decoded['namedCurve'] + $this->curve->encodePoint($this->QA) + + + PrivateKey + + + $decoded + + + null + + + $decoded[0] + $this->QA[0] + $this->QA[0] + $this->QA[1] + + + $components['QA'] + $components['curve'] + $components['curve'] + self::$engines['OpenSSL'] + self::$engines['libsodium'] + self::$engines['libsodium'] + + + getContext + getEngine + getLength + getSignatureFormat + onLoad + + + $q + $x + + + $QA + $context + $curve + $curveName + $format + $q + $x + + + $curve + + + $this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context) + + + is_string($context) + + + $decoded + encodePoint + withSignatureFormat + + + $new->dA + $new->sigFormat + $privatekey->curveName + + + $this->sigFormat + + + $namedCurves + + + + + $this->convertToAffine($r) + + + int[] + object + + + $doubles + $doubles + $doubles + $doubles + $doubles + $factory + $order + + + $one + $one + $points[0] + $points[1] + $r + $r[0] + $scalars[0] + $scalars[1] + $zero + + + $r + $r[$d_i] + $r[1 - $d_i] + $temp[] + + + array + integer + integer + object + object + + + negate + + + $alreadyInternal ? $r[0] : $this->convertToAffine($r[0]) + $this->factory->getLength() + $this->factory->getLengthInBytes() + $this->factory->newInteger($x) + $this->factory->randomInteger() + + + $p + $p + $temp + object[] + object[] + object[] + + + $p[0] + $p[1] + $points[0] + $points[1] + $r[0] + $r[0] + $r[0] + $r[1] + $scalars[0] + $scalars[1] + + + createRandomMultiplier + randomInteger + setReduction + + + $doubles + + + isset($this->order) + + + $this->factory + $this->factory + $this->factory + $this->factory + $this->factory + \phpseclib3\Math\FiniteField\Integer + + + addPoint + addPoint + doublePoint + + + $naf + + + + + + $this->p + + + array + + + $this->a + $this->b + + + $a + $b + $factory + $modulo + $one + $order + $p + + + $m + $modulo + + + $lhs + $lhs + $rhs + $this->a + $this->b + $x2 + $x3 + $z + $z + $z2 + + + FiniteField[] + FiniteField[] + boolean + + + add + add + add + divide + equals + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + newInteger + newInteger + newInteger + newInteger + + + $lhs->equals($rhs) + + + $p + $p + $p + \phpseclib3\Math\PrimeField\Integer[] + \phpseclib3\Math\PrimeField\Integer[] + + + \phpseclib3\Math\PrimeField\Integer + \phpseclib3\Math\PrimeField\Integer + + + $factory + + + pack('H*', $a) + pack('H*', $b) + pack('H*', $x) + pack('H*', $y) + + + addPoint + derivePoint + doublePoint + verifyPoint + + + isset($this->factory) + isset($this->factory) + isset($this->factory) + + + FiniteField[] + FiniteField[] + + + + + $lambdas[0] + $this->p + + + $this->p[0] + + + + BigInteger[] + + + $p + + + $basis['a']->toHex(true) + $basis['b']->toHex(true) + $one + $p + $p['naf'] + $r->multiply($two) + $r->multiply($two) + $rhs + $two + + + $c1 + $c2 + $p['naf'] + $p['nafwidth'] + $p[0] + $p[0] + $p[1] + $p[1] + $r + $r + $v1 + $v1['a'] + $v1['b'] + $v1['b'] + $v2 + $v2['a'] + $v2['b'] + $v2['b'] + + + $a2 + $b2 + $beta['nafwidth'] + $c1 + $c1 + $c2 + $c2 + $inv + $k + $k1 + $k1 + $k2 + $k2 + $lhs + $lhs + $npoints[$pos] + $nscalars[$pos] + $nscalars[$pos] + $p + $p1 + $p2 + $q1 + $q2 + $rhs + $rhs + $rhs + $s + $temp + [$c1, $r] + [$c2, $r] + [$v1, $v2] + + + FiniteField[] + FiniteField[] + FiniteField[] + boolean + + + add + add + add + add + add + add + compare + divide + divide + divide + equals + equals + isNegative + isNegative + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + negate + negate + negate + negate + negate + negate + negate + squareRoot + subtract + subtract + subtract + toBigInteger + toHex + toHex + + + $lhs->equals($rhs) + + + multiply + + + $this->multiplyPoint($this->p, $lambdas[0])[0] + + + $a0 + $a0 + $b0 + $b0 + + + $this->factory + $this->factory + FiniteField[] + FiniteField[] + FiniteField[] + + + $basis + $basis + + + $this->basis + $this->beta + + + + + + $this->p + + + PrimeInteger[] + array + + + [clone $this->zero, clone $this->one] + + + $a + $a24 + $factory + $modulo + $one + $order + $p + $zero + + + $x + $x + + + $x + $z + + + FiniteField[][] + + + divide + + + $p + $p + $p + [$x->divide($z)] + \phpseclib3\Math\PrimeField\Integer[] + \phpseclib3\Math\PrimeField\Integer[] + + + $factory + + + $p[0] + + + setBasePoint + setCoefficients + + + $a24 + $modulo + + + isset($this->factory) + isset($this->factory) + isset($this->factory) + + + FiniteField[][] + + + $x + + + + + $jsf[0] + + + $jsf[0][$j] + $jsf[1][$j] + + + new PrimeField($modulo) + + + $jsf + $res + $this->convertToAffine($acc) + $this->p + + + array + int[] + int[] + + + $this->a + $this->b + + + $a + $a + $b + $b + $eight + $eight + $factory + $factory + $four + $four + $modulo + $modulo + $one + $one + $order + $order + $p + $p + $three + $three + $two + $two + + + $m + $point + $wnd + + + $m + $naf[$a] + $naf[$b] + $p + $point + $point + $points[$a] + $points[$a] + $points[$b] + $points[$b] + $res[$i - 1] + $scalars[$a] + $scalars[$b] + $wnd[$j][(-$z - 1) >> 1] + + + $point['naf'] + $points[$i]['nafwidth'] + $points[0]['nafwidth'] + + + $point['naf'] + + + $wnd[$j][($z - 1) >> 1] + + + $b + $bn + $jsf[0][] + $jsf[1][] + $k1 + $k1 + $k2 + $k2 + $lhs + $m14 + $m14 + $m14 + $m24 + $m24 + $m24 + $m8 + $m8 + $m8 + $m8 + $m8 + $m8 + $max + $naf[$a] + $naf[$b] + $p + $point + $rhs + $temp + $temp + $temp + $temp + $temp + $temp[$j] + $this->a + $this->b + $u1 + $u2 + $wndWidth[] + $yp + $z + $z + $z + $z2 + + + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + boolean + int[] + + + add + add + add + add + bitwise_rightShift + bitwise_rightShift + compare + compare + divide + equals + getNAF + getNAF + isOdd + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + multiply + negate + newInteger + newInteger + newInteger + newInteger + squareRoot + testBit + testBit + testBit + testBit + testBit + testBit + testBit + testBit + testBit + testBit + + + $k1->testBit(0) + $k1->testBit(0) + $k1->testBit(1) + $k1->testBit(1) + $k1->testBit(2) + $k2->testBit(0) + $k2->testBit(0) + $k2->testBit(1) + $k2->testBit(1) + $k2->testBit(2) + $m14 + $m14 + $m14 + $m24 + $m24 + $m24 + $m8 + $m8 + $m8 + $m8 + $u1 + $u2 + $wnd + $z + 1 << $wnd + + + $lhs->equals($rhs) + $point['naf'] + + + $p + $p + $p + \phpseclib3\Math\PrimeField\Integer[] + \phpseclib3\Math\PrimeField\Integer[] + + + \phpseclib3\Math\PrimeField\Integer + \phpseclib3\Math\PrimeField\Integer + + + $factory + + + $p + $wnd[$j][(-$z - 1) >> 1] + + + $dbl + + + $jsf[0] + $points[0] + + + derivePoint + doublePointHelper + jacobianAddPoint + jacobianAddPointMixedX + jacobianAddPointMixedXY + jacobianDoublePoint + jacobianDoublePointMixed + verifyPoint + + + $p + $p + $q + + + $eight + $four + + + isset($this->factory) + isset($this->factory) + isset($this->factory) + + + $this->factory + $this->factory + $this->factory + $this->factory + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + FiniteField[] + \phpseclib3\Math\PrimeFields + + + toBigInteger + toBigInteger + + + $p + + + + + new PrimeField($modulo) + + + $this->a + $this->d + + + $a + $d + $modulo + $one + $p + $two + $zero + + + $x + $y + + + $lhs + $rhs + $this->a + $this->d + $x2 + $y2 + $z + $z + + + boolean + + + add + add + divide + equals + multiply + multiply + multiply + multiply + multiply + multiply + multiply + + + + $lhs->equals($rhs) + + + $p + \phpseclib3\Math\PrimeField\Integer[] + + + \phpseclib3\Math\PrimeField\Integer + \phpseclib3\Math\PrimeField\Integer + + + getA + getD + + + isset($this->factory) + isset($this->factory) + isset($this->factory) + + + $this->factory + $this->factory + $this->factory + $this->factory + + + + + [$this->factory->newInteger(new BigInteger(9))] + + + newInteger + newInteger + + + Curve25519 + Curve25519 + Curve25519 + Curve25519 + Curve25519 + Curve25519 + Curve25519 + + + $this->factory + $this->factory + + + + + [$this->factory->newInteger(new BigInteger(5))] + + + newInteger + newInteger + + + Curve448 + Curve448 + Curve448 + Curve448 + Curve448 + Curve448 + Curve448 + + + $this->factory + $this->factory + + + + + $dA + $this->extractSecret(Random::string(32)) + clone $this->zero + + + BigInteger + \phpseclib3\Math\PrimeField\Integer + + + [clone $this->zero, clone $this->one, clone $this->one, clone $this->zero] + + + $y + + + $y[0] + + + $y[0] + $y[0] + + + $p[3] + $temp + $u + $v + $x + $x + $x + $x2 + $y + $y + $y2 + $y[0] + $y[0] + + + FiniteField[] + FiniteField[] + + + add + divide + equals + equals + equals + isOdd + isOdd + multiply + multiply + multiply + multiply + multiply + multiply + negate + pow + pow + subtract + subtract + subtract + toBytes + + + $y[0] + $y[0] + + + $p + $p + [$x, $y] + \phpseclib3\Math\PrimeField\Integer[] + object[] + + + $p[0] + $p[1] + + + addPoint + doublePoint + recoverX + + + Ed25519 + Ed25519 + Ed25519 + Ed25519 + Ed25519 + Ed25519 + Ed25519 + Ed25519 + Ed25519 + Ed25519 + + + $this->factory + FiniteField[] + FiniteField[] + + + $dA->secret + + + + + $dA + $this->extractSecret(Random::string(57)) + clone $this->zero + + + BigInteger + \phpseclib3\Math\PrimeField\Integer + + + [clone $this->zero, clone $this->one, clone $this->one] + + + $u + $v + $x + $x + $x2 + $y + $y2 + + + FiniteField[] + FiniteField[] + + + divide + equals + equals + isOdd + isOdd + multiply + multiply + multiply + negate + pow + subtract + subtract + subtract + toBytes + + + $y->toBytes() + + + $p + $p + [$x, $y] + \phpseclib3\Math\PrimeField\Integer[] + object[] + + + addPoint + doublePoint + encodePoint + recoverX + + + Ed448 + Ed448 + Ed448 + Ed448 + Ed448 + Ed448 + Ed448 + Ed448 + Ed448 + Ed448 + + + $this->factory + FiniteField[] + FiniteField[] + + + $dA->secret + + + + + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + brainpoolP160r1 + + + brainpoolP160r1 + + + + + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + brainpoolP160t1 + + + brainpoolP160t1 + + + + + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + brainpoolP192r1 + + + brainpoolP192r1 + + + + + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + brainpoolP192t1 + + + brainpoolP192t1 + + + + + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + brainpoolP224r1 + + + brainpoolP224r1 + + + + + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + brainpoolP224t1 + + + brainpoolP224t1 + + + + + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + brainpoolP256r1 + + + brainpoolP256r1 + + + + + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + brainpoolP256t1 + + + brainpoolP256t1 + + + + + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + brainpoolP320r1 + + + brainpoolP320r1 + + + + + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + brainpoolP320t1 + + + brainpoolP320t1 + + + + + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + brainpoolP384r1 + + + brainpoolP384r1 + + + + + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + brainpoolP384t1 + + + brainpoolP384t1 + + + + + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + brainpoolP512r1 + + + brainpoolP512r1 + + + + + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + brainpoolP512t1 + + + brainpoolP512t1 + + + + + nistb233 + + + nistb233 + + + + + nistb409 + + + nistb409 + + + + + nistk163 + + + nistk163 + + + + + nistk233 + + + nistk233 + + + + + nistk283 + + + nistk283 + + + + + nistk409 + + + nistk409 + + + + + nistp192 + + + nistp192 + + + + + nistp224 + + + nistp224 + + + + + nistp256 + + + nistp256 + + + + + nistp384 + + + nistp384 + + + + + nistp521 + + + nistp521 + + + + + nistt571 + + + nistt571 + + + + + prime192v1 + + + prime192v1 + + + + + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + prime192v2 + + + prime192v2 + + + + + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + prime192v3 + + + prime192v3 + + + + + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + prime239v1 + + + prime239v1 + + + + + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + prime239v2 + + + prime239v2 + + + + + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + prime239v3 + + + prime239v3 + + + + + prime256v1 + + + prime256v1 + + + + + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + secp112r1 + + + secp112r1 + + + + + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + secp112r2 + + + secp112r2 + + + + + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + secp128r1 + + + secp128r1 + + + + + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + secp128r2 + + + secp128r2 + + + + + newInteger + + + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + secp160k1 + + + $this->factory + + + $this->basis + $this->basis + $this->basis + $this->beta + + + $this->factory + + + secp160k1 + + + + + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + secp160r1 + + + secp160r1 + + + + + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + secp160r2 + + + secp160r2 + + + + + newInteger + + + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + secp192k1 + + + $this->factory + + + $this->basis + $this->basis + $this->basis + $this->beta + + + $this->factory + + + secp192k1 + + + + + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + secp192r1 + + + + + newInteger + + + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + secp224k1 + + + $this->factory + + + $this->basis + $this->basis + $this->basis + $this->beta + + + $this->factory + + + secp224k1 + + + + + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + secp224r1 + + + + + newInteger + + + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + secp256k1 + + + $this->factory + + + $this->basis + $this->basis + $this->basis + $this->beta + + + $this->factory + + + secp256k1 + + + + + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + secp256r1 + + + + + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + secp384r1 + + + + + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + secp521r1 + + + + + sect113r1 + sect113r1 + sect113r1 + sect113r1 + sect113r1 + sect113r1 + sect113r1 + sect113r1 + + + sect113r1 + + + + + sect113r2 + sect113r2 + sect113r2 + sect113r2 + sect113r2 + sect113r2 + sect113r2 + sect113r2 + + + sect113r2 + + + + + sect131r1 + sect131r1 + sect131r1 + sect131r1 + sect131r1 + sect131r1 + sect131r1 + sect131r1 + + + sect131r1 + + + + + sect131r2 + sect131r2 + sect131r2 + sect131r2 + sect131r2 + sect131r2 + sect131r2 + sect131r2 + + + sect131r2 + + + + + sect163k1 + sect163k1 + sect163k1 + sect163k1 + sect163k1 + sect163k1 + sect163k1 + sect163k1 + + + + + sect163r1 + sect163r1 + sect163r1 + sect163r1 + sect163r1 + sect163r1 + sect163r1 + sect163r1 + + + sect163r1 + + + + + sect163r2 + sect163r2 + sect163r2 + sect163r2 + sect163r2 + sect163r2 + sect163r2 + sect163r2 + + + sect163r2 + + + + + sect193r1 + sect193r1 + sect193r1 + sect193r1 + sect193r1 + sect193r1 + sect193r1 + sect193r1 + + + sect193r1 + + + + + sect193r2 + sect193r2 + sect193r2 + sect193r2 + sect193r2 + sect193r2 + sect193r2 + sect193r2 + + + sect193r2 + + + + + sect233k1 + sect233k1 + sect233k1 + sect233k1 + sect233k1 + sect233k1 + sect233k1 + sect233k1 + + + + + sect233r1 + sect233r1 + sect233r1 + sect233r1 + sect233r1 + sect233r1 + sect233r1 + sect233r1 + + + + + sect239k1 + sect239k1 + sect239k1 + sect239k1 + sect239k1 + sect239k1 + sect239k1 + sect239k1 + + + sect239k1 + + + + + sect283k1 + sect283k1 + sect283k1 + sect283k1 + sect283k1 + sect283k1 + sect283k1 + sect283k1 + + + + + sect283r1 + sect283r1 + sect283r1 + sect283r1 + sect283r1 + sect283r1 + sect283r1 + sect283r1 + + + sect283r1 + + + + + sect409k1 + sect409k1 + sect409k1 + sect409k1 + sect409k1 + sect409k1 + sect409k1 + sect409k1 + + + + + sect409r1 + sect409r1 + sect409r1 + sect409r1 + sect409r1 + sect409r1 + sect409r1 + sect409r1 + + + + + sect571k1 + sect571k1 + sect571k1 + sect571k1 + sect571k1 + sect571k1 + sect571k1 + sect571k1 + + + + + sect571r1 + sect571r1 + sect571r1 + sect571r1 + sect571r1 + sect571r1 + sect571r1 + sect571r1 + + + sect571r1 + + + + + $class + $point + $point + + + string|false + + + new $class() + + + $curve->getModulo() + $data['curve']['a'] + $data['curve']['a'] + $data['curve']['b'] + $data['curve']['b'] + $data['fieldID']['parameters'] + $data['fieldID']['parameters'] + $data['order'] + $data['order'] + $m + $modulo[0] + $modulo[0] + $modulo[1] + $modulo[2] + $params['parameters'] + $params[0] + $point + $temp[0] + + + $curveX + $curveX + $curveY + $curveY + $data['base'] + $data['base'] + $data['curve'] + $data['curve'] + $data['curve'] + $data['curve'] + $data['fieldID'] + $data['fieldID'] + $data['fieldID'] + $data['fieldID'] + $data['order'] + $data['order'] + $point[0] + $point[1] + + + $data + $m + $point + $point + $useNamedCurves + $x + $y + [$curveX, $curveY] + [$curveX, $curveY] + + + \phpseclib3\Crypt\EC\BaseCurves\Base|false + object[] + + + new $curve() + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toString + toString + toString + toString + toString + + + $data['base'] + $data['base'] + $data['fieldID']['fieldType'] + $params['namedCurve'] + $params['namedCurve'] + $x + $x + $y + $y + + + $params['basis'] + $params['m'] + $params['parameters'] + $params['parameters'] + $temp['k1'] + $temp['k2'] + $temp['k3'] + + + $params['basis'] + $params['m'] + $params['parameters'] + $params['parameters'] + $temp['k1'] + $temp['k2'] + $temp['k3'] + + + $m + $params['parameters'] + + + $params['basis'] + $params['m'] + $params['parameters'] + $params['parameters'] + $temp['k1'] + $temp['k2'] + $temp['k3'] + + + $params + $params + $params + $params + $temp + $temp + $temp + toString + toString + toString + toString + toString + + + $modulo[0] + $modulo[0] + $modulo[1] + $modulo[2] + $params[0] + $temp[0] + + + $params['basis'] + $params['m'] + $params['parameters'] + $params['parameters'] + $temp['k1'] + $temp['k2'] + $temp['k3'] + + + setImplicitCurve + + + !$order + $order + + + $params + $params + $params + $params + $temp + $temp + $temp + derivePoint + getA + getA + getB + getB + getBasePoint + getBasePoint + getBasePoint + getModulo + getModulo + recoverX + verifyPoint + + + self::$implicitCurve + + + self::$implicitCurve + + + $len + + + + + $publicKey[0]->toBytes() + + + $publicKey[0] + + + !empty($password) && is_string($password) + is_string($password) + + + toBytes + + + MontgomeryPrivate + + + + + $publicKey[0]->toBytes() + + + $publicKey[0] + + + toBytes + + + MontgomeryPublic + + + + + $curve + + + $privateKey + + + new $curveName() + + + $key + $paddedKey + $parsed['publicKey'] + $parsed['publicKey'] + $parsed['publicKey'] + $privateKey + $privateKey->secret + + + $comment + $key['comment'] + $oid + $paddedKey + + + string + + + $comment + $comment + $curveName + $publicKey + + + $alias + + + rangeCheck + + + $publicKey[0] + $publicKey[0] + $publicKey[1] + $publicKey[1] + + + $parsed['comment'] + $parsed['publicKey'] + $parsed['publicKey'] + $parsed['publicKey'] + $parsed['type'] + $parsed['type'] + $parsed[type] + + + savePrivateKey + + + $curve instanceof Ed25519 + + + toBytes + toBytes + toBytes + toBytes + + + + + $components['curve']->getBasePoint() + $components['curve']->getBasePoint() + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $ecPrivate['parameters'] + $ecPrivate['privateKey'] + $ecPrivate['publicKey'] + $ecPrivate['publicKey'] + $key['parameters'] + $key['privateKey'] + + + $components['curve'] + $components['curve'] + $ecParams + $key + self::encodeParameters($curve) + + + getBasePoint + multiplyPoint + rangeCheck + + + $decoded + $decoded + $key + + + $decoded[0] + $decoded[0] + $decoded[0] + $matches[0] + $matches[0] + $publicKey[0] + $publicKey[1] + + + $ecPrivate['privateKey'] + $key['privateKey'] + + + saveParameters + savePrivateKey + + + getBasePoint + getBasePoint + toBytes + toBytes + + + $ecPrivate + + + + + $components['dA'] + + + $components['curve']->getBasePoint() + $curve->encodePoint($publicKey) + $decoded[0] + $decoded[0] + $key[$type . 'Algorithm']['parameters']->element + $key['privateKey'] + $key['privateKey'] + $key['privateKey'] + $key['privateKey'] + $key['publicKey'] + $key['publicKey'] + + + $key[$type . 'Algorithm']['algorithm'] + $key[$type . 'Algorithm']['parameters'] + $key['privateKeyAlgorithm']['algorithm'] + $key['publicKeyAlgorithm']['algorithm'] + + + $key['publicKey'] + $privateKey->secret + + + $key[$type . 'Algorithm']['parameters']->element + + + $components['curve'] + self::encodeParameters($curve, false, $options) + self::encodeParameters($curve, false, $options) + + + rangeCheck + + + $params + + + $key['privateKey'] + + + $key['privateKey'] + + + $key['privateKey'] + + + $key['privateKey'] + + + $key + + + $components['curve'] + $components['dA'] + + + $decoded[0] + $decoded[0] + $publicKey[0] + $publicKey[0] + $publicKey[1] + $publicKey[1] + + + $key[$type . 'Algorithm'] + $key[$type . 'Algorithm'] + $key['privateKey'] + $key['privateKey'] + $key['privateKeyAlgorithm'] + $key['publicKey'] + $key['publicKeyAlgorithm'] + + + savePrivateKey + savePublicKey + + + $key + $key + $key + encodePoint + getBasePoint + toBytes + toBytes + toBytes + toBytes + + + $privateKey->secret + + + + + $publicKey + + + string + + + $components['type'] + $length + $length + $private + $private + $private + $privateKey->secret + + + $components['dA'] + $private + + + rangeCheck + + + $components['comment'] + $components['public'] + $components['type'] + + + $length + $length + + + $public[1] + $public[1] + + + $components['comment'] + $components['curve'] + $components['public'] + $components['type'] + + + $private + + + savePrivateKey + savePublicKey + + + $types + + + extractSecret + + + $privateKey->secret + + + + + $key + $point + $xml + + + $result['namedCurve'] + $result['specifiedCurve'] + $result['specifiedCurve'] + + + $result['namedCurve'] + $result['specifiedCurve'] + $result['specifiedCurve'] + + + \DOMNodeList|string + + + $publicKey[0] + $publicKey[1] + + + new $curve() + + + \phpseclib3\Crypt\EC\BaseCurves\Base|false + string|false + + + isolateNamespace + + + $key + $key + $oid + $p + $p + $temp['base'] + $temp['curve']['a'] + $temp['curve']['b'] + $temp['fieldID']['parameters']->toBytes() + $temp['order'] + $x->item(0)->getAttribute('Value') + $y->item(0)->getAttribute('Value') + + + $temp['base'] + $temp['curve'] + $temp['curve'] + $temp['fieldID'] + $temp['fieldID'] + $temp['fieldID'] + $temp['fieldID'] + $temp['fieldID'] + $temp['fieldID'] + $temp['order'] + $x + $y + + + self::$curveOIDs[$result['namedCurve']] + + + $a + $b + $key + $key + $oid + $temp + $temp + $temp + $temp + [$x, $y] + + + new $curve() + toBytes + + + $a + $b + $temp['fieldID']['fieldType'] + $temp['fieldID']['fieldType'] + $temp['fieldID']['parameters'] + $x + $y + self::$curveOIDs[$result['namedCurve']] + + + \phpseclib3\Crypt\EC\BaseCurves\Base|false + + + $decode ? self::decodeValue($result->item(0)->textContent) : $result->item(0)->textContent + + + $curve + $curve + + + self::encodeXMLParameters($curve, $pre, $options) + self::encodeXMLParameters($curve, $pre, $options) + + + $a + $a + $b + $b + $order + $order + $x + $y + + + item + item + item + item + item + item + item + + + $base + $pubkey + + + $namedCurve->length + $params->length + $params->length + $result->length + $result->length + $x->length + $y->length + self::query($xpath, 'ecdsakeyvalue')->length + + + $result->item(0)->textContent + $result->item(0)->textContent + + + $oid + + + $result->item(0)->textContent + $result->item(0)->textContent + $result->item(0)->textContent + $result->item(0)->textContent + + + getAttribute + getAttribute + getAttribute + hasAttribute + hasAttribute + lookupPrefix + + + $publicKey[0] + $publicKey[0] + $publicKey[1] + $publicKey[1] + + + disableRFC4050Syntax + load + savePublicKey + setNamespace + + + getA + getAttribute + getAttribute + getAttribute + getB + getBasePoint + hasAttribute + hasAttribute + removeAttributeNS + toBytes + toBytes + verifyPoint + + + $p + $p + + + + + $curve->multiplyPoint($curve->getBasePoint(), $components['dA']) + + + $components['dA'] + + + $private + $privateKey->secret + + + $components['dA'] + + + savePrivateKey + savePublicKey + + + $password + + + !empty($password) && is_string($password) + is_string($password) + isset($public) + + + + + false + false + + + $components + + + array + + + $decoded[0] + + + $components + + + $decoded[0] + + + is_string($sig) + + + + + Raw + + + + + false + + + $r + $s + + + string + + + load + + + $blob + + + $result[0] + $result[1] + + + $result === false + $result === false + is_string($sig) + + + SSH2 + + + + + $type + + + string + + + $type::saveParameters($this->curve, $options) + + + $type::saveParameters($this->curve, $options) + + + Parameters + Parameters + Parameters + Parameters + Parameters + Parameters + + + + + $dA + $this->dA + $this->dA + + + getPublicKey + sign + + + $curve::HASH + $curve::SIZE + $curve::SIZE + $dA->multiply($r) + $key + $point[0]->toBytes(true) + $this->curve->getBasePoint() + $this->dA->secret + $this->dA->toBytes() + $this->withPassword()->toString('libsodium') + + + $r + + + $A + $R + $format + $key + $key + $key + $type + $type + $x + [, $r] + + + string + string + + + $format::save($r, $s) + $format::save($r, $s) + $format::save($r, $s, $this->getCurve()) + $format::save($r, $s, $this->getCurve()) + $type::savePrivateKey($this->dA, $this->curve, $this->QA, $this->password, $options) + $type::savePublicKey($this->curve, $this->QA) + divide + equals + multiply + toBigInteger + toBytes + toBytes + toBytes + toBytes + toString + withContext + + + $A + $R + $R + $R + $point[0]->toBytes(true) + $point[1]->toBytes(true) + + + $this->curve->encodePoint($point) + $type::savePrivateKey($this->dA, $this->curve, $this->QA, $this->password, $options) + + + $this->getCurve() + $this->getCurve() + + + $point[0] + $point[0] + $point[1] + + + self::$engines['OpenSSL'] + self::$engines['libsodium'] + self::$engines['libsodium'] + + + $r + $r + $s + $s + + + $dA + PrivateKey + PrivateKey + PrivateKey + PrivateKey + PrivateKey + PrivateKey + + + !isset($this->context) + $this->context + $this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context) + '' + 'SigEd25519 no Ed25519 collisions' . "\0" . chr(strlen($this->context)) . $this->context + + + $curve::HASH + $curve::SIZE + $curve::SIZE + + + encodePoint + encodePoint + encodePoint + getBasePoint + withSignatureFormat + + + $this->sigFormat + + + $y + + + + + toBigInteger + + + $Ln + $curve::HASH + $curve::SIZE + $curve::SIZE + $curve::SIZE + $message + $message + $order + $params + $params + $r + $rhs + $s + $sig + $signature + $signature + $u2 + $w + + + $u2 + $x1 + + + $A + $Ln + $format + $n_1 + $params + $rhs + $sig + $type + $w + $x1 + [, $u2] + [, $x1] + + + bool + string + + + $format::load($signature) + $type::savePublicKey($this->curve, $this->QA, $options) + between + between + divide + divide + equals + equals + equals + getLength + modInverse + multiply + subtract + + + $A + $curve::SIZE + $order->getLength() + + + $type::savePublicKey($this->curve, $this->QA, $options) + $x1->equals($r) + + + $lhs[0] + $lhs[1] + $rhs[0] + $rhs[1] + + + self::$engines['libsodium'] + + + PublicKey + PublicKey + PublicKey + PublicKey + PublicKey + PublicKey + + + !isset($this->context) + $this->context + $this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context) + '' + 'SigEd25519 no Ed25519 collisions' . "\0" . chr(strlen($this->context)) . $this->context + + + $curve::HASH + $curve::SIZE + $curve::SIZE + $curve::SIZE + $curve::SIZE + + + addPoint + encodePoint + getBasePoint + + + $this->sigFormat + + + + + !is_string($this->key) + $this->key === false + hash($algo, $text, true) + is_array($algo) + is_array($this->algo) + is_string($this->key) + is_string($this->nonce) + + + + $initial[$i] + $k[$i] + + + string + + + $matches[2] + + + string + string + + + $hash = strtolower($hash) + + + $this->hashParam + + + string + + + $x + + + function ($x) { + + + $length + + + $factory128 + $factory36 + $factory64 + $marker128 + $marker64 + $maxwordrange128 + $maxwordrange64 + $offset128 + $offset64 + + + $algo($temp, ...array_values($this->parameters)) + $algo($text, ...array_values($this->parameters)) + $b + $index + $length + $m + $output + $parity[0] + $parity[1] + $parity[2] + $parity[3] + $parity[4] + $pi + $pi + $rotationOffsets[$j][$i] + $rotationOffsets[$j][$i] + $s[$j][$i] + $s[$j][$i] + $x + $y->toBytes() + self::$maxwordrange128 + self::$maxwordrange64 + self::$maxwordrange64 + unpack('C', $index)[1] * $taglen + + + $k[$i] + $rotationOffsets[$j] + $rotationOffsets[$j] + $roundConstants[$round] + $roundConstants[$round] + $roundConstants[$round] + $s[$i][$j++] + $s[$i][$j++] + $s[$i][$j] + $s[$i][$j] + $s[$i][$j] + $s[$i][$j][1] + $s[$j][$i] + $s[$j][$i] + $s[$x][$y++] + $s[$x][$y] + $s[$x][$y][1] + $s[0][$i] + $s[0][$i] + $s[0][$i] + $s[0][0] + $s[0][0] + $s[0][0][1] + $s[1][$i] + $s[1][$i] + $s[1][$i] + $s[2][$i] + $s[2][$i] + $s[2][$i] + $s[3][$i] + $s[3][$i] + $s[3][$i] + $s[4][$i] + $s[4][$i] + $s[4][$i] + $st[$i][0] + $st[$i][0] + $st[$i][0][1] + $st[$i][1] + $st[$i][1] + $st[$i][1][1] + $st[$i][2] + $st[$i][2] + $st[$i][2][1] + $st[$i][3] + $st[$i][3] + $st[$i][3][1] + $st[$i][4] + $st[$i][4] + $st[$i][4][1] + + + $s[$i][$j] + $s[$i][$j] + $s[$i][$j] + $s[$i][0] + $s[$i][1] + $s[$i][2] + $s[$i][3] + $s[$i][4] + $s[$x][$y++] + $s[$x][$y] + $s[$x][$y] + $s[0][0] + $s[0][0] + $s[0][0] + $st[(2 * $i + 3 * $j) % 5][$j] + $st[(2 * $i + 3 * $j) % 5][$j] + + + $a + $a + $b + $b + $c + $c + $ch + $d + $d + $e + $e + $f + $f + $factory + $factory + $factory + $g + $g + $h + $h + $k + $k_i + $m + $m + $m_i + $maj + $maj + $marker + $marker + $offset + $offset + $output + $parity[] + $pi + $pi + $s0 + $s0 + $s1 + $s1 + $s[$i][$j] + $s[$i][$j][0] + $s[$i][$j][1] + $s[$x][$y++] + $s[$x][$y][0] + $s[$x][$y][1] + $s[0][0] + $s[0][0][0] + $s[0][0][1] + $subpi + $t1 + $t1 + $t1 + $t1 + $t2 + $this->computedKey + $y + $y + $y + $y + $y + $y + + + clone $a + clone $b + clone $c + clone $e + clone $f + clone $g + clone $hash[0] + clone $hash[1] + clone $hash[2] + clone $hash[3] + clone $hash[4] + clone $hash[5] + clone $hash[6] + clone $hash[7] + + + $algo($output, ...array_values($this->parameters)) + $algo($temp, ...array_values($this->parameters)) + $algo($text, ...array_values($this->parameters)) + call_user_func($this->algo, $this->key) + + + int + int + string + + + add + add + add + add + add + add + add + add + add + add + add + add + add + add + add + add + add + add + add + bitwise_and + bitwise_and + bitwise_and + bitwise_and + bitwise_and + bitwise_not + bitwise_rightRotate + bitwise_rightRotate + bitwise_rightRotate + bitwise_rightRotate + bitwise_rightRotate + bitwise_rightRotate + bitwise_xor + bitwise_xor + bitwise_xor + bitwise_xor + bitwise_xor + bitwise_xor + bitwise_xor + compare + multiply + multiply + multiply + multiply + newInteger + newInteger + newInteger + newInteger + newInteger + newInteger + subtract + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + toBytes + + + $hash[0]->toBytes() + $hash[2]->toBytes() + $hash[3]->toBytes() + $hash[4]->toBytes() + $hash[5]->toBytes() + $hash[6]->toBytes() + $hash[7]->toBytes() + $hi + $hi + $lo + $lo + $parity[0] + $parity[0][0] + $parity[0][1] + $parity[1] + $parity[1][0] + $parity[1][1] + $parity[2] + $parity[2][0] + $parity[2][1] + $parity[3] + $parity[3][0] + $parity[3][1] + $parity[4] + $parity[4][0] + $parity[4][1] + $s[$i][$j] + $s[$i][$j][0] + $s[$i][$j][1] + $s[$x][$y++] + $s[$x][$y][0] + $s[$x][$y][1] + $s[0][$i] + $s[0][$i][0] + $s[0][$i][1] + $s[0][0] + $s[0][0][0] + $s[0][0][1] + $st[$i][0] + $st[$i][0][0] + $st[$i][0][1] + $st[$i][1] + $st[$i][1][0] + $st[$i][1][1] + $st[$i][2] + $st[$i][2][0] + $st[$i][2][1] + $st[$i][3] + $st[$i][3][0] + $st[$i][3][1] + $st[$i][4] + $st[$i][4][0] + $st[$i][4][1] + $this->blockSize + unpack('C', $index)[1] + ~$st[$i][0] + ~$st[$i][0][0] + ~$st[$i][0][1] + ~$st[$i][1] + ~$st[$i][1][0] + ~$st[$i][1][1] + ~$st[$i][2] + ~$st[$i][2][0] + ~$st[$i][2][1] + ~$st[$i][3] + ~$st[$i][3][0] + ~$st[$i][3][1] + ~$st[$i][4] + ~$st[$i][4][0] + ~$st[$i][4][1] + + + $this->blockSize + $this->blockSize >> 3 + $y->toBytes() + + + $m[$i] + $m[$i] + $m[$i] + $m[$i] + $m[$i] + $output + $output + pack('N4', 0, $index, 0, 1) + + + $m_i + $p + $p + $pi + + + pack('N4', 0, 0, 0, $length << 3) + pack('P', $s[$i][$j++]) + pack('V2', $s[$i][$j][1], $s[$i][$j++][0]) + + + false + false + false + false + + + $pi[$i + 1] + $pi[$i] + unpack('C', $index)[1] + + + ~$st[$i][0] + ~$st[$i][1] + ~$st[$i][2] + ~$st[$i][3] + ~$st[$i][4] + + + $hash + $matches[2] >> 3 + + + $hash[0] + $hash[0] + $hash[1] + $hash[1] + $hash[2] + $hash[2] + $hash[3] + $hash[3] + $hash[4] + $hash[4] + $hash[5] + $hash[5] + $hash[6] + $hash[6] + $hash[7] + $hash[7] + $matches[1] + $matches[2] + $parity[1] + $parity[1] + $parity[2] + $parity[2] + $parity[3] + $parity[3] + $parity[4] + $parity[4] + $rotated[0][0] + $rotated[0][1] + $rotated[1] + $rotated[1][1] + $rotated[2] + $rotated[2][1] + $rotated[3] + $rotated[3][1] + $rotated[4] + $rotated[4][1] + $s[0] + $s[0] + $s[1] + $s[1] + $s[2] + $s[2] + $s[3] + $s[3] + $s[4] + $s[4] + $st[$i][0] + $st[$i][0] + $st[$i][0][1] + $st[$i][1] + $st[$i][1] + $st[$i][1][1] + $st[$i][2] + $st[$i][2] + $st[$i][2][1] + $st[$i][3] + $st[$i][3] + $st[$i][3][1] + $st[$i][4] + $st[$i][4] + $st[$i][4][1] + unpack('C', $index)[1] + + + $index + + + $algo + $c + $hashParam + $ipad + $length + $opad + $pad + $recomputeAESKey + + + hash($this->algo, $this->key, true) + is_string($this->key) + + + $this->blockSize + $this->blockSize + $this->blockSize + $this->blockSize + $this->blockSize + $this->blockSize + $this->blockSize + $this->blockSize + $this->blockSize + + + $this->blockSize + $this->blockSize + + + $b + + + sha3_32 + sha3_64 + sha512 + + + $c + $c + + + $k + $n + $n + $num_ints + + + + + string + string + + + $key + + + AsymmetricKey + + + $key + + + $key + + + $key + + + loadParameters + loadPublicKey + + + + + pack('vvvv', $r0, $r1, $r2, $r3) + pack('vvvv', $r0, $r1, $r2, $r3) + + + string + string + + + $length >> 3 + + + $t1 + + + $l + + + $keys[$r0 & 0x3F] + $keys[$r0 & 0x3F] + $keys[$r1 & 0x3F] + $keys[$r1 & 0x3F] + $keys[$r2 & 0x3F] + $keys[$r2 & 0x3F] + $keys[$r3 & 0x3F] + $keys[$r3 & 0x3F] + $l[$i + $t8] + $l[$i + 1] + $l[$i] + $l[$i] + $l[$i] + $pitable[$l[$i + 1] ^ $l[$i + $t8]] + $pitable[$l[$i - 1] + $l[$i - $t]] + $pitable[$l[$i] & $tm] + self::$invpitable[$l[0]] + self::$pitable[$l['a']] + + + $i + $i + $l[$i] + $l[$i] + $l[$i] + $l[0] + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $t8 + $this->current_key_length + $tm + + + $i + $i + $i + $keys[$j++] + $keys[$j++] + $keys[$j++] + $keys[$j++] + $keys[--$j] + $keys[--$j] + $keys[--$j] + $keys[--$j] + $l[$i + 1] + $l[$i - 1] + $l[$i] + $l['b'] + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r0 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r1 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r2 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $r3 + $t1 + $t8 + $t8 + ($r0 + $keys[$j++] + ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF + ($r0 ^ $r1) & $r2 + ($r0 ^ $r1) & $r2 + ($r1 + $keys[$j++] + ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF + ($r1 ^ $r2) & $r3 + ($r1 ^ $r2) & $r3 + ($r2 + $keys[$j++] + ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF + ($r2 ^ $r3) & $r0 + ($r2 ^ $r3) & $r0 + ($r3 + $keys[$j++] + ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF + ($r3 ^ $r0) & $r1 + ($r3 ^ $r0) & $r1 + 8 * $t8 + self::$pitable[$l['a']] + + + $l + $this->key + unpack('C*', $key) + unpack('v*', $in) + unpack('v*', $in) + + + pack(...$l) + + + $l['a'] + $l['b'] + + + $this->openssl_translate_mode() + + + $l[0] + + + $l['a'] + $l['b'] + + + setupInlineCrypt + + + $key_length + + + $current_key_length + $key + $keys + $orig_key + RC2 + RC2 + RC2 + RC2 + RC2 + RC2 + RC2 + RC2 + RC2 + + + isset($this->key) + + + $limit === 0 + $limit === 0 + $limit === 0 + $limit === 0 + $limit === 64 + $limit === 64 + $limit === 64 + $limit === 64 + + + $skip_key_adjustment + + + + + $keyStream[($ksj + $ksi) & 255] + + + $keyStream[$i] + $keyStream[$j] + $keyStream[($ksj + $ksi) & 255] + $stream[0] + $stream[0] + $stream[1] + $stream[1] + $stream[2] + $stream[2] + + + $keyStream[$i] + $keyStream[$j] + + + $keyStream[$i] + $keyStream[$i] + $keyStream[$j] + $keyStream[$j] + $keyStream[($ksj + $ksi) & 255] + + + $i + $i + $i + $j + $j + $j + $keyStream + $keyStream + $keyStream[$i] + $keyStream[$j] + $ksi + $ksj + $stream + + + $i + $j + $ksj + + + $key_length + + + $key + $stream + RC4 + RC4 + RC4 + RC4 + RC4 + RC4 + RC4 + RC4 + RC4 + + + + + $key + + + bool + + + RSA::load($privatekeystr) + + + $bits + $components['MGFHash'] + $components['hash'] + $components['saltLength'] + $e + $lcm['bottom'] + $n + $primes[$i] + $primes[$i] + $primes[1] + $regSize + $temp + $temp + self::$one + self::$one + + + $lcm['bottom'] + $lcm['bottom'] + $lcm['top'] + $lcm['top'] + $primes[$i] + $primes[1] + $primes[2] + $temp + + + $coefficients[$i] + $coefficients[2] + $exponents[$i] + $lcm['bottom'] + $lcm['top'] + $primes[$i] + $primes[$i] + + + $coefficients[$i] + $exponents[$i] + $primes[$i] + $primes[$i] + $primes[$i] + + + $primes[$i] + + + $coefficients[2] + $i + $i + $key->coefficients + $key->exponent + $key->exponent + $key->exponents + $key->k + $key->modulus + $key->primes + $lcm['bottom'] + $lcm['top'] + $prime + $privatekey->coefficients + $privatekey->exponents + $privatekey->k + $privatekey->primes + $temp + $temp + [$temp] + + + divide + gcd + getLengthInBytes + modInverse + multiply + subtract + subtract + + + $bits + $i + $t + + + RSA + + + $primes[$i] + $primes[$i] + $primes[1] + $rsa + + + $c + + + gcd + modInverse + subtract + + + toBytes + + + $primes[1] + $primes[2] + + + $components['coefficients'] + $components['exponents'] + $components['format'] + $components['isPublicKey'] + $components['modulus'] + $components['primes'] + $components['publicExponent'] + self::$engines['OpenSSL'] + self::$engines['OpenSSL'] + + + $t + + + disableBlinding + enableBlinding + getEngine + getLabel + getMGFHash + onLoad + setExponent + setOpenSSLConfigPath + + + $exponent + $k + $modulus + RSA + + + !isset($this->modulus) + $this->modulus->getLength() + + + $key->coefficients + $key->exponents + $key->primes + $key->privateExponent + $key->publicExponent + + + $i0 + + + + + $coefficients[2]->toBytes() + $exponents[1]->toBytes() + $exponents[2]->toBytes() + $key + $key + $primes[1]->toBytes() + $primes[2]->toBytes() + + + $components['isPublicKey'] + $components['privateExponent'] + + + $components[$components['isPublicKey'] ? 'publicExponent' : 'privateExponent'] + $components['coefficients'] + $components['exponents'] + $components['exponents'] + $components['isPublicKey'] + $components['isPublicKey'] + $components['modulus'] + $components['primes'] + $components['primes'] + $components['privateExponent'] + $components['publicExponent'] + + + $components['publicExponent'] + + + array + + + toBytes + toBytes + toBytes + toBytes + toBytes + + + $components + $components + + + unpack('Vmagic/Vbitlen/a4pubexp', Strings::shift($key, 12)) + unpack('atype/aversion/vreserved/Valgo', Strings::shift($key, 8)) + + + $key + $key + pack('VVa*', self::RSA1, 8 * strlen($n), $e) + pack('VVa*', self::RSA2, 8 * strlen($n), $e) + + + $bitlen / 16 + $bitlen / 16 + $bitlen / 16 + $bitlen / 16 + $bitlen / 16 + $bitlen / 8 + $bitlen / 8 + + + $coefficients[2] + $exponents[1] + $exponents[2] + $primes[1] + $primes[2] + + + !empty($password) && is_string($password) + is_string($password) + + + is_string($key) + + + MSBLOB + + + + + $d + $e + $e + $n + $n + + + $coefficients[2] + $parsed['paddedKey'] + $parsed['paddedKey'] + $parsed['publicKey'] + $primes[1] + $primes[2] + + + $comment + $exponents[] + $temp + $temp + + + modInverse + modInverse + subtract + subtract + + + $comment + + + $coefficients[2] + $primes[1] + $primes[2] + + + $parsed['comment'] + $parsed['publicKey'] + $parsed['type'] + $parsed[type] + + + savePrivateKey + + + $types + + + + + $decoded[0] + $decoded[0] + + + $primeInfo['coefficient'] + $primeInfo['exponent'] + $primeInfo['prime'] + + + $components['coefficients'][] + $components['exponents'][] + $components['primes'][] + + + $components['coefficients'][] + $components['exponents'][] + $components['primes'][] + $primeInfo + + + $key + + + $coefficients[2] + $decoded[0] + $exponents[1] + $exponents[2] + $primes[1] + $primes[2] + + + $key['coefficient'] + $key['exponent1'] + $key['exponent2'] + $key['modulus'] + $key['otherPrimeInfos'] + $key['prime1'] + $key['prime2'] + $key['privateExponent'] + $key['publicExponent'] + $key['version'] + + + + + $key[$type . 'Key'] + + + $result['meta'] + + + savePrivateKey + + + $options + + + $childOIDsLoaded + + + + + $params['hashAlgorithm'] + $params['maskGenAlgorithm'] + + + new ASN1\Element(ASN1::encodeDER($params, Maps\RSASSA_PSS_params::MAP)) + + + string + + + $decoded[0] + $decoded[0] + $key[$type . 'Key'] + $key[$type . 'KeyAlgorithm']['parameters'] + $options['saltLength'] + $params['hashAlgorithm']['algorithm'] + $params['maskGenAlgorithm']['parameters'] + $params['maskGenAlgorithm']['parameters']['algorithm'] + + + $key[$type . 'KeyAlgorithm']['parameters'] + $params['hashAlgorithm']['algorithm'] + $params['maskGenAlgorithm']['parameters'] + + + $params['hashAlgorithm']['algorithm'] + + + $result['meta'] + + + toString + + + $options['MGFHash'] + $options['hash'] + + + $params['hashAlgorithm'] + $params['maskGenAlgorithm'] + + + $params['hashAlgorithm'] + $params['maskGenAlgorithm'] + + + $params['hashAlgorithm'] + $params['maskGenAlgorithm'] + + + toString + + + $params['hashAlgorithm']['algorithm'] + $params['maskGenAlgorithm']['parameters']['algorithm'] + + + $params['hashAlgorithm'] + $params['maskGenAlgorithm'] + + + $params['hashAlgorithm'] + + + $params + $params + $params + $params + + + $decoded[0] + $decoded[0] + + + toString + + + $key[$type . 'Key'] + $key[$type . 'KeyAlgorithm'] + $params['hashAlgorithm'] + $params['maskGenAlgorithm'] + + + savePrivateKey + savePublicKey + + + $childOIDsLoaded + + + $decoded === false + $decoded === false + + + $params + $params + $params + $params + $params + $params + $params + + + + + $d + $e + $e + $n + $n + + + $coefficients[2] + $primes[1] + $primes[2] + + + $components['public'] + + + $exponents[] + $temp + $temp + + + modInverse + modInverse + subtract + subtract + + + $private + $public + + + $coefficients[2] + $primes[1] + $primes[2] + + + savePrivateKey + savePublicKey + + + $types + + + $result === false + $result === false + + + + + function ($var) { + function ($var) { + function ($var) { + + + $components['primes'][1] + $components['primes'][1] + $components['primes'][2] + $components['primes'][2] + + + $components['coefficients'] + $components['exponents'] + $components['modulus'] + $components['primes'] + $components['privateExponent'] + $components['publicExponent'] + $exponents[] + $temp + $temp + + + clone $var + clone $var + clone $var + + + modInverse + modInverse + modInverse + subtract + subtract + + + !empty($password) && is_string($password) + is_string($password) + + + Raw + + + + + $key + + + $coefficients[2]->toBytes() + $exponents[1]->toBytes() + $exponents[2]->toBytes() + $primes[1]->toBytes() + $primes[2]->toBytes() + + + toBytes + toBytes + toBytes + toBytes + toBytes + + + $temp->item(0)->nodeValue + + + $temp->item(0)->nodeValue + + + $coefficients[2] + $exponents[1] + $exponents[2] + $primes[1] + $primes[2] + + + !empty($password) && is_string($password) + is_string($password) + + + Strings::is_stringable($key) + + + XML + + + + + $em[0] + $em[0] + $em[1] + + + !$hashesMatch + $m[$i] === "\0" + $m[$i] === "\1" + + + $this->rsassa_pkcs1_v1_5_sign($message) + $this->rsassa_pss_sign($message) + + + string + + + $em + + + $publicExponent + + + $em[0] + $em[0] + $em[1] + $key + $r + $r->multiply($h) + $smallest->subtract(self::$one) + $this->coefficients[$i] + $this->coefficients[$i] + $this->coefficients[2] + $this->coefficients[2] + $this->exponents[$i] + $this->exponents[$i] + $this->exponents[1] + $this->exponents[2] + $this->primes[$i - 1] + $this->primes[$i] + $this->primes[$i] + $this->primes[$i] + $this->primes[$i] + $this->primes[$i] + $this->primes[$i] + $this->primes[$i] + $this->primes[1] + $this->primes[1] + $this->primes[1] + $this->primes[2] + $this->primes[2] + $this->primes[2] + $this->publicExponent + + + $key + $r + $r + $r + $smallest + $smallest + $type + $type + + + string + + + $type::savePrivateKey($this->modulus, $this->publicExponent, $this->exponent, $this->primes, $this->exponents, $this->coefficients, $this->password, $options) + $type::savePublicKey($this->modulus, $this->exponent, $options) + $type::savePublicKey($this->modulus, $this->publicExponent) + compare + equals + equals + equals + multiply + multiply + subtract + + + $type::savePrivateKey($this->modulus, $this->publicExponent, $this->exponent, $this->primes, $this->exponents, $this->coefficients, $this->password, $options) + $type::savePublicKey($this->modulus, $this->exponent, $options) + + + strpos($em, chr(0), 2) + + + $em + $em + $em + $em + + + $this->coefficients[2] + $this->coefficients[2] + $this->coefficients[2] + $this->exponents[1] + $this->exponents[1] + $this->exponents[2] + $this->primes[1] + $this->primes[1] + $this->primes[1] + $this->primes[2] + $this->primes[2] + + + $coefficients + $exponents + $primes + PrivateKey + PrivateKey + PrivateKey + PrivateKey + + + $y + + + + + false + false + false + false + + + $c + $this->rsassa_pss_verify($message, $signature) + hash_equals($h, $h2) + + + bool + string + string + + + $decoded[0] + $em2 + $hash + + + $decoded['digestAlgorithm']['algorithm'] + $decoded[0]['length'] + + + $oids[$decoded['digestAlgorithm']['algorithm']] + + + $em2 + $hash + $type + + + string + + + $type::savePublicKey($this->modulus, $this->publicExponent, $options) + + + $type::savePublicKey($this->modulus, $this->publicExponent, $options) + + + $em + $em + $em + $em + + + $decoded['digest'] + $decoded['digestAlgorithm'] + + + $decoded['digest'] + $decoded['digestAlgorithm'] + + + $decoded['digest'] + $decoded['digestAlgorithm'] + + + $r1 + $r2 + + + PublicKey + PublicKey + PublicKey + PublicKey + + + !is_array($decoded) + + + $decoded + $decoded + $decoded + $decoded + + + $this->publicExponent + + + $pkcs15_compat + + + + + $length + + + 0 + 1 + + + $arr + + + $_SESSION['count'] + + + $_SESSION['count'] + $_SESSION['count'] + $_SESSION['seed'] + + + $_SESSION['count'] + $i + $r + $v + + + encrypt + encrypt + encrypt + + + $_SESSION['count'] + $i + $r + $r + + + $old_session_id + $old_use_cookies + + + isset($_COOKIE) + isset($_GET) + isset($_POST) + isset($_SERVER) + + + '' + '' + '' + '' + + + + + $this->oldtag === false + $this->oldtag === false + + + pack('N*', ...$temp) + pack('N*', ...$temp) + + + string + string + string + + + 0x000000FF + 0x000000FF + 0x000000FF + 0x000000FF + 8 + 16 + 24 + + + + $col + + + $temp + $temp + $this->w[$row][$j] + + + $dt0[$dw >> 24 & 0x000000FF] + $dt0[$state[$i] >> 24 & 0x000000FF] + $dt1[$dw >> 16 & 0x000000FF] + $dt1[$state[$j] >> 16 & 0x000000FF] + $dt2[$dw >> 8 & 0x000000FF] + $dt2[$state[$k] >> 8 & 0x000000FF] + $dt3[$dw & 0x000000FF] + $dt3[$state[$l] & 0x000000FF] + $invtables[0] + $invtables[1] + $invtables[2] + $invtables[3] + $invtables[4] + $isbox[$word & 0x000000FF] + $isbox[$word >> 8 & 0x000000FF] + $isbox[$word >> 16 & 0x000000FF] + $isbox[$word >> 24 & 0x000000FF] + $rcon[$i / $this->Nk] + $sbox[$state[$i] & 0x000000FF] + $sbox[$state[$i] >> 8 & 0x000000FF] + $sbox[$state[$i] >> 16 & 0x000000FF] + $sbox[$state[$i] >> 24 & 0x000000FF] + $sbox[$word & 0x000000FF] + $sbox[$word >> 8 & 0x000000FF] + $sbox[$word >> 16 & 0x000000FF] + $sbox[$word >> 24 & 0x000000FF] + $t0[$state[$i] >> 24 & 0x000000FF] + $t1[$state[$j] >> 16 & 0x000000FF] + $t2[$state[$k] >> 8 & 0x000000FF] + $t3[$state[$l] & 0x000000FF] + $tables[0] + $tables[1] + $tables[2] + $tables[3] + $tables[4] + + + $dt0[] + $dt1[] + $dt2[] + $t0[] + $t1[] + $t2[] + + + $dt0[$state[$i] >> 24 & 0x000000FF] + $dt1[$state[$j] >> 16 & 0x000000FF] + $dt2[$state[$k] >> 8 & 0x000000FF] + $dt3[$state[$l] & 0x000000FF] + $isbox[$word & 0x000000FF] + $isbox[$word >> 8 & 0x000000FF] + $isbox[$word >> 16 & 0x000000FF] + $isbox[$word >> 24 & 0x000000FF] + $sbox[$state[$i] & 0x000000FF] + $sbox[$state[$i] >> 8 & 0x000000FF] + $sbox[$state[$i] >> 16 & 0x000000FF] + $sbox[$state[$i] >> 24 & 0x000000FF] + $state[$j] + $state[$j] + $state[$j] + $state[$j] + $state[$k] + $state[$k] + $state[$k] + $state[$k] + $state[$l] + $state[$l] + $state[$l] + $state[$l] + $t0[$state[$i] >> 24 & 0x000000FF] + $t1[$state[$j] >> 16 & 0x000000FF] + $t2[$state[$k] >> 8 & 0x000000FF] + $t3[$state[$l] & 0x000000FF] + + + $dt0 + $dt1 + $dt2 + $dt3 + $dw[] + $isbox + $j + $j + $j + $j + $j + $j + $j + $j + $k + $k + $k + $k + $k + $k + $k + $k + $l + $l + $l + $l + $l + $l + $l + $l + $sbox + $state[$i] + $state[] + $state[] + $t0 + $t1 + $t2 + $t3 + $temp + $temp + $temp + $temp[$i] + $temp[$i] + $temp[$i] + $temp[$i] + $temp[$j] + $w[$i] + $w[] + $wc + $word + $word + $word + + + array + array + array + + + $Nb + $i - $c[1] + $Nb + $i - $c[1] + $Nb + $i - $c[2] + $Nb + $i - $c[2] + $Nb + $i - $c[3] + $Nb + $i - $c[3] + $c[1] + $c[1] + $c[1] + $c[1] + $c[1] + $c[1] + $c[2] + $c[2] + $c[2] + $c[2] + $c[2] + $c[2] + $c[3] + $c[3] + $c[3] + $c[3] + $c[3] + $c[3] + $dt0[$dw >> 24 & 0x000000FF] + $dt0[$state[$i] >> 24 & 0x000000FF] + $dw[$i] + $dw[$i] + $dw[++$wc] + $dw[++$wc] + $i + $c[1] + $i + $c[1] + $i + $c[2] + $i + $c[2] + $i + $c[3] + $i + $c[3] + $isbox[$word & 0x000000FF] + $isbox[$word >> 8 & 0x000000FF] + $isbox[$word >> 16 & 0x000000FF] + $isbox[$word >> 24 & 0x000000FF] + $j + $j + $j + $j + $k + $k + $k + $k + $l + $l + $l + $l + $rcon[$i / $this->Nk] + $sbox[$state[$i] & 0x000000FF] + $sbox[$state[$i] >> 8 & 0x000000FF] + $sbox[$state[$i] >> 16 & 0x000000FF] + $sbox[$state[$i] >> 24 & 0x000000FF] + $sbox[$word & 0x000000FF] + $sbox[$word >> 8 & 0x000000FF] + $sbox[$word >> 16 & 0x000000FF] + $sbox[$word >> 24 & 0x000000FF] + $state[$i] + $state[$i] + $state[$i] + $state[$i] + $state[$i] + $state[$i] + $state[$i] + $state[$i] + $state[$j] + $state[$j] + $state[$j] + $state[$j] + $state[$k] + $state[$k] + $state[$k] + $state[$k] + $state[$l] + $state[$l] + $state[$l] + $state[$l] + $t0[$state[$i] >> 24 & 0x000000FF] + $temp + $temp + $w[$i - $this->Nk] + $w[$i] + $w[++$wc] + $w[++$wc] + $word + $word + $word + $word + $word + $word + ($Nb + $i - $c[1]) % $Nb + ($Nb + $i - $c[1]) % $Nb + ($Nb + $i - $c[2]) % $Nb + ($Nb + $i - $c[2]) % $Nb + ($Nb + $i - $c[3]) % $Nb + ($Nb + $i - $c[3]) % $Nb + ($i + $c[1]) % $Nb + ($i + $c[1]) % $Nb + ($i + $c[2]) % $Nb + ($i + $c[2]) % $Nb + ($i + $c[3]) % $Nb + ($i + $c[3]) % $Nb + ($temp << 8) & 0xFFFFFF00 + + + $tables + $tables + + + unpack('N*words', $this->key) + + + $words + $words + + + false + false + + + $this->openssl_translate_mode() + + + $w + + + $c[1] + $c[1] + $c[1] + $c[1] + $c[1] + $c[1] + $c[1] + $c[1] + $c[2] + $c[2] + $c[2] + $c[2] + $c[2] + $c[2] + $c[2] + $c[2] + $c[3] + $c[3] + $c[3] + $c[3] + $c[3] + $c[3] + $c[3] + $c[3] + $invtables[0] + $invtables[1] + $invtables[2] + $invtables[3] + $invtables[4] + $tables[0] + $tables[1] + $tables[2] + $tables[3] + $tables[4] + $this->w[0] + + + $this->kl['block_size'] + $this->kl['key_length'] + + + $dt0 + $dt1 + $dt2 + $t0 + $t1 + $t2 + + + setBlockLength + setupInlineCrypt + + + $Nr + $c + $dw + $kl + $w + Rijndael + Rijndael + Rijndael + Rijndael + Rijndael + Rijndael + Rijndael + Rijndael + Rijndael + + + (int)0xFF000000 + (int)0xFF000000 + + + is_string($this->iv) + + + + + $this->key === false + $this->key === false + $this->nonce === false + $this->nonce === false + $this->oldtag === false + + + + string + + + salsa20 + + + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $key + $temp + $z[10] + $z[11] + $z[12] + $z[13] + $z[14] + $z[15] + $z[16] + $z[1] + $z[2] + $z[3] + $z[4] + $z[5] + $z[6] + $z[7] + $z[8] + $z[9] + + + $block + $block + $block + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $temp + $x[$i] + + + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $x[$i] + static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2) + static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2) + static::salsa20($this->p1 . pack('V', $i++) . $this->p2) + + + $encrypted + + + $this->p1 + $this->p1 + $this->p1 + $this->p1 + $this->p2 + $this->p2 + $this->p2 + $this->p2 + $this->p2 + $this->p2 + $this->p2 + pack('V', $buffer['counter']) + pack('V', $buffer['counter']) + pack('V', $buffer['counter']++) + pack('V', $buffer['counter']++) + pack('V', $buffer['counter']++) + pack('V', $i++) + pack('V', $this->counter) + pack('V', strlen($text)) + pack('V', strlen($this->aad)) + + + false + false + + + $x[$i] + $z[$i] + $z[10] + $z[11] + $z[12] + $z[13] + $z[14] + $z[15] + $z[16] + $z[1] + $z[2] + $z[3] + $z[4] + $z[5] + $z[6] + $z[7] + $z[8] + $z[9] + + + $x[$i] + + + $z[10] + $z[11] + $z[12] + $z[13] + $z[14] + $z[15] + $z[16] + $z[1] + $z[2] + $z[3] + $z[4] + $z[5] + $z[6] + $z[7] + $z[8] + $z[9] + + + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['ciphertext'] + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + $buffer['counter'] + + + $debuffer + $enbuffer + Salsa20 + Salsa20 + Salsa20 + Salsa20 + Salsa20 + Salsa20 + Salsa20 + Salsa20 + + + $this->usePoly1305 && !isset($this->poly1305Key) + isset($this->poly1305Key) + isset($this->poly1305Key) + + + $key + + + + + 24 + + + + string + + + decrypt + decrypt + decrypt + disableContinuousBuffer + disableContinuousBuffer + disableContinuousBuffer + enableContinuousBuffer + enableContinuousBuffer + enableContinuousBuffer + encrypt + encrypt + encrypt + setIV + setIV + setIV + setKey + setKey + setKey + setPreferredEngine + setPreferredEngine + setPreferredEngine + setupKey + setupKey + setupKey + + + + $mode + + + $this->des[0] + $this->des[0] + $this->des[0] + $this->des[0] + $this->des[0] + $this->des[0] + $this->des[0] + $this->des[0] + $this->des[1] + $this->des[1] + $this->des[1] + $this->des[1] + $this->des[1] + $this->des[1] + $this->des[1] + $this->des[1] + $this->des[2] + $this->des[2] + $this->des[2] + $this->des[2] + $this->des[2] + $this->des[2] + $this->des[2] + $this->des[2] + + + $des + $mode_3cbc + TripleDES + TripleDES + TripleDES + TripleDES + TripleDES + TripleDES + TripleDES + TripleDES + TripleDES + + + BadModeException + + + + + + string + string + + + + $A + $B + $A + $B + $A + $B + $A + $B + $A + $B + $A + $B + $le_longs[1] + $le_longs[1] + $le_longs[1] + $le_longs[2] + $le_longs[2] + $le_longs[2] + $le_longs[3] + $le_longs[3] + $le_longs[3] + $le_longs[4] + $le_longs[4] + $le_longs[4] + $le_longs[5] + $le_longs[5] + $le_longs[6] + $le_longs[6] + $le_longs[7] + $le_longs[8] + $t0 + $t1 + $K[++$ki] + $t0 + $t1 + $K[++$ki] + $t0 + $t1 + $K[--$ki] + $t0 + $t1 + $K[--$ki] + $t0 + ($t1 << 1) + $K[++$ki] + $t0 + ($t1 << 1) + $K[++$ki] + $t0 + ($t1 << 1) + $K[--$ki] + $t0 + ($t1 << 1) + $K[--$ki] + + + $S0[ $R0 & 0xff] + $S0[ $R2 & 0xff] + $S0[$R0 & 0xff] + $S0[$R1 >> 24 & 0xff] + $S0[$R2 & 0xff] + $S0[$R3 >> 24 & 0xff] + $S0[($R1 >> 24) & 0xff] + $S0[($R3 >> 24) & 0xff] + $S1[ $R1 & 0xff] + $S1[ $R3 & 0xff] + $S1[$R0 >> 8 & 0xff] + $S1[$R1 & 0xff] + $S1[$R2 >> 8 & 0xff] + $S1[$R3 & 0xff] + $S1[($R0 >> 8) & 0xff] + $S1[($R2 >> 8) & 0xff] + $S2[$R0 >> 16 & 0xff] + $S2[$R1 >> 8 & 0xff] + $S2[$R2 >> 16 & 0xff] + $S2[$R3 >> 8 & 0xff] + $S2[($R0 >> 16) & 0xff] + $S2[($R1 >> 8) & 0xff] + $S2[($R2 >> 16) & 0xff] + $S2[($R3 >> 8) & 0xff] + $S3[$R0 >> 24 & 0xff] + $S3[$R1 >> 16 & 0xff] + $S3[$R2 >> 24 & 0xff] + $S3[$R3 >> 16 & 0xff] + $S3[($R0 >> 24) & 0xff] + $S3[($R1 >> 16) & 0xff] + $S3[($R2 >> 24) & 0xff] + $S3[($R3 >> 16) & 0xff] + $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] + $m0[$q0[$q0[$i] ^ $s4] ^ $s0] + $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] + $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] + $m0[$q0[$q0[$q1[$i] ^ $s8] ^ $s4] ^ $s0] + $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] + $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] + $m0[$q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] ^ $s0] + $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] + $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] + $m1[$q0[$q1[$i] ^ $s5] ^ $s1] + $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] + $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] + $m1[$q0[$q1[$q1[$i] ^ $s9] ^ $s5] ^ $s1] + $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] + $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] + $m1[$q0[$q1[$q1[$q0[$i] ^ $sd] ^ $s9] ^ $s5] ^ $s1] + $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] + $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] + $m2[$q1[$q0[$i] ^ $s6] ^ $s2] + $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] + $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] + $m2[$q1[$q0[$q0[$i] ^ $sa] ^ $s6] ^ $s2] + $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] + $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] + $m2[$q1[$q0[$q0[$q0[$i] ^ $se] ^ $sa] ^ $s6] ^ $s2] + $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] + $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]] + $m3[$q1[$q1[$i] ^ $s7] ^ $s3] + $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]] + $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]] + $m3[$q1[$q1[$q0[$i] ^ $sb] ^ $s7] ^ $s3] + $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]] + $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]] + $m3[$q1[$q1[$q0[$q1[$i] ^ $sf] ^ $sb] ^ $s7] ^ $s3] + $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]] + $q0[$q0[$i] ^ $key[ 9]] + $q0[$q0[$i] ^ $key[19]] + $q0[$q0[$i] ^ $key[27]] + $q0[$q0[$i] ^ $s4] + $q0[$q0[$i] ^ $sa] + $q0[$q0[$i] ^ $se] + $q0[$q0[$j] ^ $key[13]] + $q0[$q0[$j] ^ $key[23]] + $q0[$q0[$j] ^ $key[31]] + $q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] + $q0[$q0[$q0[$i] ^ $se] ^ $sa] + $q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] + $q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] + $q0[$q0[$q1[$i] ^ $s8] ^ $s4] + $q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] + $q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] + $q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] + $q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] + $q0[$q1[$i] ^ $key[10]] + $q0[$q1[$i] ^ $key[17]] + $q0[$q1[$i] ^ $key[28]] + $q0[$q1[$i] ^ $s5] + $q0[$q1[$i] ^ $s8] + $q0[$q1[$i] ^ $sf] + $q0[$q1[$j] ^ $key[14]] + $q0[$q1[$j] ^ $key[21]] + $q0[$q1[$j] ^ $key[32]] + $q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] + $q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] + $q0[$q1[$q1[$i] ^ $s9] ^ $s5] + $q0[$q1[$q1[$i] ^ $sc] ^ $s8] + $q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] + $q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] + $q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] + $q0[$q1[$q1[$q0[$i] ^ $sd] ^ $s9] ^ $s5] + $q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] + $q1[$q0[$i] ^ $key[11]] + $q1[$q0[$i] ^ $key[20]] + $q1[$q0[$i] ^ $key[26]] + $q1[$q0[$i] ^ $s6] + $q1[$q0[$i] ^ $sb] + $q1[$q0[$i] ^ $sd] + $q1[$q0[$j] ^ $key[15]] + $q1[$q0[$j] ^ $key[24]] + $q1[$q0[$j] ^ $key[30]] + $q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] + $q1[$q0[$q0[$i] ^ $sa] ^ $s6] + $q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] + $q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] + $q1[$q0[$q0[$q0[$i] ^ $se] ^ $sa] ^ $s6] + $q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] + $q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] + $q1[$q0[$q1[$i] ^ $sf] ^ $sb] + $q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] + $q1[$q1[$i] ^ $key[12]] + $q1[$q1[$i] ^ $key[18]] + $q1[$q1[$i] ^ $key[25]] + $q1[$q1[$i] ^ $s7] + $q1[$q1[$i] ^ $s9] + $q1[$q1[$i] ^ $sc] + $q1[$q1[$j] ^ $key[16]] + $q1[$q1[$j] ^ $key[22]] + $q1[$q1[$j] ^ $key[29]] + $q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] + $q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] + $q1[$q1[$q0[$i] ^ $sb] ^ $s7] + $q1[$q1[$q0[$i] ^ $sd] ^ $s9] + $q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] + $q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] + $q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] + $q1[$q1[$q0[$q1[$i] ^ $sf] ^ $sb] ^ $s7] + $q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] + + + $A + $A + $A + $B + $B + $B + $B + $B + $B + $R0 + $R0 + $R0 + $R0 + $R0 + $R1 + $R1 + $R1 + $R1 + $R1 + $R2 + $R2 + $R2 + $R2 + $R2 + $R3 + $R3 + $R3 + $R3 + $R3 + $S0[$i] + $S0[$i] + $S0[$i] + $S1[$i] + $S1[$i] + $S1[$i] + $S2[$i] + $S2[$i] + $S2[$i] + $S3[$i] + $S3[$i] + $S3[$i] + $t0 + $t0 + $t0 + $t0 + $t1 + $t1 + $t1 + $t1 + + + $A + $A + $A + $B + $B + $B + $B + $B + $B + $B + $B + $B + $K[++$ki] + $K[++$ki] + $K[++$ki] + $K[++$ki] + $K[--$ki] + $K[--$ki] + $K[--$ki] + $K[--$ki] + $K[0] + $K[0] + $K[0] + $K[0] + $K[1] + $K[1] + $K[1] + $K[1] + $K[2] + $K[2] + $K[2] + $K[2] + $K[3] + $K[3] + $K[3] + $K[3] + $K[4] + $K[4] + $K[4] + $K[4] + $K[5] + $K[5] + $K[5] + $K[5] + $K[6] + $K[6] + $K[6] + $K[6] + $K[7] + $K[7] + $K[7] + $K[7] + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R0 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R1 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R2 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $R3 + $S0[ $R0 & 0xff] + $S0[ $R2 & 0xff] + $S0[$R0 & 0xff] + $S0[$R1 >> 24 & 0xff] + $S0[$R2 & 0xff] + $S0[$R3 >> 24 & 0xff] + $S0[($R1 >> 24) & 0xff] + $S0[($R3 >> 24) & 0xff] + $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] + $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] + $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] + $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] + $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] + $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$i] + $q0[$j] + $q0[$j] + $q0[$j] + $q0[$j] + $q0[$j] + $q0[$j] + $q0[$q0[$i] ^ $key[ 9]] + $q0[$q0[$i] ^ $key[19]] + $q0[$q0[$i] ^ $key[27]] + $q0[$q0[$i] ^ $s4] + $q0[$q0[$i] ^ $sa] + $q0[$q0[$i] ^ $se] + $q0[$q0[$j] ^ $key[13]] + $q0[$q0[$j] ^ $key[23]] + $q0[$q0[$j] ^ $key[31]] + $q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] + $q0[$q0[$q0[$i] ^ $se] ^ $sa] + $q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] + $q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] + $q0[$q0[$q1[$i] ^ $s8] ^ $s4] + $q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] + $q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] + $q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] + $q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] + $q0[$q1[$i] ^ $key[10]] + $q0[$q1[$i] ^ $key[17]] + $q0[$q1[$i] ^ $key[28]] + $q0[$q1[$i] ^ $s5] + $q0[$q1[$i] ^ $s8] + $q0[$q1[$i] ^ $sf] + $q0[$q1[$j] ^ $key[14]] + $q0[$q1[$j] ^ $key[21]] + $q0[$q1[$j] ^ $key[32]] + $q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] + $q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] + $q0[$q1[$q1[$i] ^ $s9] ^ $s5] + $q0[$q1[$q1[$i] ^ $sc] ^ $s8] + $q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] + $q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] + $q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] + $q0[$q1[$q1[$q0[$i] ^ $sd] ^ $s9] ^ $s5] + $q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$i] + $q1[$j] + $q1[$j] + $q1[$j] + $q1[$j] + $q1[$j] + $q1[$j] + $q1[$q0[$i] ^ $key[11]] + $q1[$q0[$i] ^ $key[20]] + $q1[$q0[$i] ^ $key[26]] + $q1[$q0[$i] ^ $s6] + $q1[$q0[$i] ^ $sb] + $q1[$q0[$i] ^ $sd] + $q1[$q0[$j] ^ $key[15]] + $q1[$q0[$j] ^ $key[24]] + $q1[$q0[$j] ^ $key[30]] + $q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] + $q1[$q0[$q0[$i] ^ $sa] ^ $s6] + $q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] + $q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] + $q1[$q0[$q0[$q0[$i] ^ $se] ^ $sa] ^ $s6] + $q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] + $q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] + $q1[$q0[$q1[$i] ^ $sf] ^ $sb] + $q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] + $q1[$q1[$i] ^ $key[12]] + $q1[$q1[$i] ^ $key[18]] + $q1[$q1[$i] ^ $key[25]] + $q1[$q1[$i] ^ $s7] + $q1[$q1[$i] ^ $s9] + $q1[$q1[$i] ^ $sc] + $q1[$q1[$j] ^ $key[16]] + $q1[$q1[$j] ^ $key[22]] + $q1[$q1[$j] ^ $key[29]] + $q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] + $q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] + $q1[$q1[$q0[$i] ^ $sb] ^ $s7] + $q1[$q1[$q0[$i] ^ $sd] ^ $s9] + $q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] + $q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] + $q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] + $q1[$q1[$q0[$q1[$i] ^ $sf] ^ $sb] ^ $s7] + $q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] + $t0 + $t0 + $t0 + $t0 + $t0 + $t0 + $t0 + $t0 + $t1 + $t1 + $t1 + $t1 + ($R1 >> 31) & 1 + ($R3 >> 31) & 1 + (($R1 >> 31) & 1) | ($R1 << 1) + (($R3 >> 31) & 1) | ($R3 << 1) + + + $in[1] + $in[1] + $in[2] + $in[2] + $in[3] + $in[3] + $in[4] + $in[4] + $key[ 9] + $key[ 9] + $key[ 9] + $key[10] + $key[10] + $key[10] + $key[11] + $key[11] + $key[11] + $key[12] + $key[12] + $key[12] + $key[13] + $key[13] + $key[13] + $key[14] + $key[14] + $key[14] + $key[15] + $key[15] + $key[15] + $key[16] + $key[16] + $key[16] + $key[17] + $key[17] + $key[18] + $key[18] + $key[19] + $key[19] + $key[1] + $key[1] + $key[1] + $key[20] + $key[20] + $key[21] + $key[21] + $key[22] + $key[22] + $key[23] + $key[23] + $key[24] + $key[24] + $key[25] + $key[26] + $key[27] + $key[28] + $key[29] + $key[2] + $key[2] + $key[2] + $key[30] + $key[31] + $key[32] + $key[3] + $key[3] + $key[3] + $key[4] + $key[4] + $key[4] + $key[5] + $key[5] + $key[5] + $key[6] + $key[6] + $key[6] + $key[7] + $key[7] + $key[7] + $key[8] + $key[8] + $key[8] + $le_longs[1] + $le_longs[1] + $le_longs[1] + $le_longs[2] + $le_longs[2] + $le_longs[2] + $le_longs[3] + $le_longs[3] + $le_longs[3] + $le_longs[4] + $le_longs[4] + $le_longs[4] + $le_longs[5] + $le_longs[5] + $le_longs[6] + $le_longs[6] + $le_longs[7] + $le_longs[8] + + + $A + $A + $B + $B + + + $K[0] + $K[0] + $K[0] + $K[1] + $K[1] + $K[1] + $K[2] + $K[2] + $K[2] + $K[3] + $K[3] + $K[3] + $K[4] + $K[4] + $K[4] + $K[5] + $K[5] + $K[5] + $K[6] + $K[6] + $K[6] + $K[7] + $K[7] + $K[7] + $in[1] + $in[1] + $in[2] + $in[2] + $in[3] + $in[3] + $in[4] + $in[4] + $key[ 9] + $key[ 9] + $key[ 9] + $key[10] + $key[10] + $key[10] + $key[11] + $key[11] + $key[11] + $key[12] + $key[12] + $key[12] + $key[13] + $key[13] + $key[13] + $key[14] + $key[14] + $key[14] + $key[15] + $key[15] + $key[15] + $key[16] + $key[16] + $key[16] + $key[17] + $key[17] + $key[18] + $key[18] + $key[19] + $key[19] + $key[1] + $key[1] + $key[1] + $key[20] + $key[20] + $key[21] + $key[21] + $key[22] + $key[22] + $key[23] + $key[23] + $key[24] + $key[24] + $key[25] + $key[26] + $key[27] + $key[28] + $key[29] + $key[2] + $key[2] + $key[2] + $key[30] + $key[31] + $key[32] + $key[3] + $key[3] + $key[3] + $key[4] + $key[4] + $key[4] + $key[5] + $key[5] + $key[5] + $key[6] + $key[6] + $key[6] + $key[7] + $key[7] + $key[7] + $key[8] + $key[8] + $key[8] + $le_longs[1] + $le_longs[1] + $le_longs[1] + $le_longs[2] + $le_longs[2] + $le_longs[2] + $le_longs[3] + $le_longs[3] + $le_longs[3] + $le_longs[4] + $le_longs[4] + $le_longs[4] + $le_longs[5] + $le_longs[5] + $le_longs[6] + $le_longs[6] + $le_longs[7] + $le_longs[8] + + + setupInlineCrypt + + + $key_length + + + $kl + Twofish + Twofish + Twofish + Twofish + Twofish + Twofish + Twofish + Twofish + Twofish + + + + + $this->base_attr_cell + + + $match[1] + $match[1] + $match[2] + + + $this->attrs[$this->y] + $this->x + $this->x + + + $cur_attr + $cur_attr + $last_attr + $last_attr + $last_attr + $this->attrs[$this->y] + $this->history[$i][$j] ?? '' + + + $this->attrs[$i][$j] + $this->attrs[$i][$j] + $this->history_attrs[$i][$j] + $this->history_attrs[$i][$j] + + + $this->attrs[$this->y][$this->x] + $this->attrs[$this->y][$this->x] + + + $back + $cur_attr + $cur_attr + $front + $last_attr + $last_attr + $temp + $this->base_attr_cell + + + $cur_attr->background + $cur_attr->foreground + + + $this->max_x - $this->x + $this->max_x - ($this->x - 1) + $this->x + $this->x + $this->x + $this->x + $this->x + 1 + + + $match[2] - 1 + $this->x + $this->x + $this->x + $this->x + $this->x + $this->x + $this->x += $match[1] + $this->x -= $match[1] + + + $match[1] + $match[1] + $match[1] + $match[1] + $match[1] + $match[2] + + + getHistory + loadString + + + \phpseclib3\File\ANSI + + + $ansi + $attr_row + $attrs + $history + $history_attrs + $max_history + $max_x + $max_y + $old_x + $old_y + $screen + $tokenization + $x + $y + + + $this->screen + $this->screen + $this->screen + $this->screen + $this->screen + + + $old_x + + + + + $current['content'] === false + $temp === false + $temp === false + $temp === false + + + $temp + false + false + false + false + false + false + false + false + false + false + false + false + pack('Ca*', 0x80 | strlen($temp), $temp) + + + $source + + + string + string + string + string + + + $source + $source + $source + $source + + + $child + $child + $child + $child + $child + $child + $child + $content + $content + $content + $content_pos + $content_pos + $content_pos + $content_pos + $content_pos + $content_pos + $length + $decoded + $decoded + $decoded + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'][$i] + $decoded['content'][0] + $decoded['length'] + $decoded['start'] + $decoded['type'] + $eighty + $encoded + $encoded_pos + $filters + $mapping + $forty + $intype + $key + $key + $key + $length + $start + $mapping['mapping'] + $mapping['mapping'] + $mapping['mapping'] + $mapping['mapping'] + $mapping['mapping'] + $mapping['mapping'] + $mapping['mapping'] + $mask + $offset + $oid + $option + $option + $size + $offset + 1 + $source + $source + $source + $source + $source + $source[$key] + $source[$key] + $source[$typename] + $start + $start + $start + $offset + $tag + $tag + $tag + $temp + $temp + $temp[$i]['content'] + $temp[$i]['content'] + $temp[0] + $value + $value + $value + $zero + ($mapping['class'] << 6) | ($tag & 0x20) | $mapping['cast'] + (self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant'] + (self::CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant'] + (self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant'] + (self::CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant'] + self::$encoded[$decoded['start']] + + + $loc + self::$location + + + $child['cast'] + $child['cast'] + $child['class'] + $child['class'] + $child['constant'] + $child['constant'] + $child['default'] + $child['default'] + $child['type'] + $child['type'] + $child['type'] + $child['type'] + $current['content'] + $current['content'] + $current['start'] + $current['start'] + $current['start'] + $decoded['constant'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'][$i] + $decoded['content'][$i] + $decoded['content'][0]['content'] + $decoded['length'] + $decoded['start'] + $decoded['start'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $filters[$part] + $mapping['mapping'][$i] + $mapping['mapping'][$temp] + $option['type'] + $option['type'] + $temp[$i]['content'] + $temp[$i]['content'] + $temp[$i]['type'] + $temp[$last]['content'] + $temp[$last]['type'] + $temp['constant'] + $temp['constant'] + $temp['type'] + $temp['type'] + $temp['type'] + $temp['type'] + $temp[0] + + + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $current['content'] + $decoded['content'] + $decoded['content'] + $decoded['type'] + + + $bits[$i] + $filters[$part] + $filters[$part] + $map[$key] + $map[$key] + $map[$key] + $map[$key] + $map[$key] + $map[$key] + $source[$key] + $special[$key] + $special[$key] + $special[$key] + [$key => $value] + self::$encoded[$decoded['start']] + self::$oids[$decoded['content']] + self::ANY_MAP[$intype] + + + $bits[$i] + $filters[$part] + + + $candidate + $candidate + $child + $child + $child + $child + $child + $child + $child + $child + $childClass + $childClass + $class + $constant + $constant + $constant + $constant + $content + $content + $content + $content_pos + $content_pos + $content_pos + $current + $decoded + $decoded['content'] + $decoded['type'] + $filters + $i + $i + $intype + $key + $key + $key + $key + $key + $key + $length + $length + $length + $length + $length + $map[$key] + $map[$key] + $map[$key] + $map[$key] + $offset + $offset + $offset + $oid + $option + $part + $remainingLength + $size + $source + $start + $start + $start + $tag + $tag + $tag + $tag + $temp + $temp + $temp + $tempClass + $tempClass + $value + $value + $value + $value + $value + $value + $values[] + + + $special[$idx]($source) + $special[$key]($candidate) + $special[$key]($candidate) + $special[$key]($value) + + + array|bool + array|bool|Element|string|null + int + string + + + format + toBytes + toString + + + $child['constant'] + $child['constant'] + $child['constant'] + $child['constant'] + $current + $current + $current + $current + $current['content'] + $encoded_pos + $filters + $i + $length + $length + $length + $length + $length + $length + $length + $length + $start + $mapping['class'] + $mapping['class'] + $mapping['class'] + $mapping['min'] + $offset + $offset + $offset + $remainingLength + $size + $size + $size + $offset + $start + $start + $start + $start + $tag + $tag + $temp[$last]['content'][0] + $temp['content'] + $temp['length'] + $temp['length'] + $temp['length'] + $temp['length'] + $type + $value + $value + ($mapping['class'] << 6) | ($tag & 0x20) + ($mapping['class'] << 6) | (ord($temp[0]) & 0x20) + ($mapping['class'] << 6) | 0x20 + ($size + 1) & 7 + + + $current + ['length' => $start - $current['start']] + $decoded['content'] + $decoded['content'] + $decoded['content'] ? $decoded['content']->format(self::$format) : false + $length + $temp + self::$oids[$decoded['content']] ?? $decoded['content'] + self::$reverseOIDs[$name] ?? $name + + + pack('N', $length) + unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)) + + + format + + + $source + $source + $source + $source + $temp + $value + bindec($byte) + + + $length + $temp[$i] + $temp[$i] + $temp[$i] + $temp[$last] + $temp[$last] + $temp['content'] + $temp['length'] + $temp['length'] + $temp['length'] + $temp['type'] + + + $source + $value + + + toBytes + + + $part2 + $temp + $temp + $temp + + + $source + + + subtract + toBytes + + + $decoded['content'][0] + $decoded['content'][0] + $matches[1] + $matches[2] + + + $child['default'] + $child['type'] + $child['type'] + $decoded['constant'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['content'] + $decoded['length'] + $decoded['start'] + $decoded['start'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $decoded['type'] + $mapping['children'] + $mapping['children'] + $mapping['children'] + $mapping['children'] + $mapping['children'] + $mapping['children'] + $mapping['children'] + $mapping['children'] + $mapping['children'] + $mapping['class'] + $mapping['class'] + $mapping['class'] + $mapping['type'] + $mapping['type'] + $mapping['type'] + $mapping['type'] + $mapping['type'] + $mapping['type'] + $temp['content'] + $temp['length'] + $temp['length'] + $temp['length'] + $temp['type'] + + + $candidate + $candidate + $candidate + $candidate + $temp + $temp + + + decodeLength + setTimeFormat + + + + + \phpseclib3\File\ASN1\Element + + + + + CPSuri + + + + + PBMAC1params + + + + + Prime_p + + + + + PrivateKeyInfo + + + + + SubjectInfoAccessSyntax + + + + + Trinomial + + + + + !is_array($this->currentCert) + !is_array($this->currentCert) + !is_array($this->currentCert) + !is_array($this->currentCert) + !is_array($this->currentCert) + !is_array($this->currentCert) + !is_array($this->currentCert) + !is_array($this->currentCert) + !isset($this->currentCert) + !isset($this->currentCert) + !isset($this->currentCert) + !isset($this->currentCert) + + + false + false + false + false + false + false + false + false + inet_ntop($ip) + + + new BigInteger($serial, $base) + + + $j + $value + + + string + string + string + string + string + string + string + + + $x + + + function ($x) { + + + $dn + $domains + $propValue + $value + $value + $value + $value + $value + + + getAttribute + getChain + getDNProp + getExtension + getExtensionHelper + getIssuerDN + getIssuerDNProp + getMapping + getPublicKey + getRevoked + getRevokedCertificateExtension + getSubjectDN + getSubjectDNProp + loadCRL + loadCSR + loadSPKAC + loadX509 + sign + signCRL + signCSR + signSPKAC + translateDNProp + + + $attribute['value'] + $attribute['value'] + $attribute['value'] + $attributes[$key]['value'] + $basicConstraints + $ca + $ca + $ca + $ca['tbsCertificate']['subject'] + $ca['tbsCertificate']['subject'] + $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] + $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] + $data + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0]['content'][0]['length'] + $decoded[0]['content'][0]['length'] + $decoded[0]['content'][0]['length'] + $decoded[0]['content'][0]['length'] + $decoded[0]['content'][0]['start'] + $decoded[0]['content'][0]['start'] + $decoded[0]['content'][0]['start'] + $decoded[0]['content'][0]['start'] + $dn + $dn + $dn + $dn + $dn + $dn + $dn + $dn + $dns[$i] + $dns[$i] + $id + $id + $id + $id + $ipAddress + $ip[0] + $ip[1] + $issuer->privateKey->withPassword()->toString('PSS') + $key + $key + $key + $key + $key + $key + $key + $keyUsage + $map + $map + $map + $map + $map + $map + $map + $map + $map + $notAfter + $notBefore + $prop + $propName + $rc['userCertificate'] + $rclist + $rdn + $s + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'] + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'] + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] + $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey'] + $subid + $subid + $subject->domains + $subvalue + $subvalue + $this->currentCert['certificationRequestInfo']['subject'] + $this->currentCert['certificationRequestInfo']['subject'] + $this->currentCert['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm'] + $this->currentCert['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] + $this->currentCert['publicKeyAndChallenge']['spki']['algorithm']['algorithm'] + $this->currentCert['publicKeyAndChallenge']['spki']['subjectPublicKey'] + $this->currentCert['signature'] + $this->currentCert['signature'] + $this->currentCert['signature'] + $this->currentCert['signature'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['subject'] + $this->currentCert['tbsCertificate']['subject'] + $type + $type + $url + $v + $v + $value + $value + $value + $value + $value + $value + $value[$j]['policyQualifiers'] + $value[$j]['policyQualifiers'] + $value[0] + $values + $values + $values + $values + $values[$j] + $values[$j] + $x509 + $x[0] + is_string($key) ? $key : $key->__toString() + + + $prop + + + $attr['value'] + $attr['value'] + $attribute['type'] + $attribute['type'] + $attribute['type'] + $attribute['type'] + $attribute['value'] + $attribute['value'] + $attribute['value'] + $attribute['value'] + $attribute['value'] + $attributes[$i]['type'] + $attributes[$i]['type'] + $attributes[$i]['value'] + $attributes[$i]['value'] + $attributes[$i]['value'] + $attributes[$i]['value'] + $attributes[$key]['value'] + $attributes[$key]['value'] + $ca['tbsCertificate'] + $ca['tbsCertificate'] + $ca['tbsCertificate'] + $ca['tbsCertificate'] + $ca['tbsCertificate'] + $ca['tbsCertificate']['serialNumber'] + $ca['tbsCertificate']['serialNumber'] + $cert['tbsCertificate']['subject'] + $cert['tbsCertificate']['subjectPublicKeyInfo'] + $cert['tbsCertificate']['subjectPublicKeyInfo'] + $crl['tbsCertList']['revokedCertificates'] + $csr['certificationRequestInfo']['subject'] + $csr['certificationRequestInfo']['subject'] + $csr['certificationRequestInfo']['subjectPKInfo'] + $csr['certificationRequestInfo']['subjectPKInfo'] + $csr['certificationRequestInfo']['subjectPKInfo'] + $currentCert['tbsCertificate']['issuer'] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + $dn[$i] + $dn[$i] + $dn[$i] + $dn[$i] + $dns[$i][$j] + $dns[$i][$j] + $dns[$i][$j] + $dns[$i][$j] + $extension['extnId'] + $extensions[$i]['extnId'] + $extensions[$i]['extnId'] + $extensions[$i]['extnValue'] + $extensions[$i]['extnValue'] + $field[0] + $field[0] + $key['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] + $key['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] + $keyinfo['algorithm'] + $keyinfo['subjectPublicKey'] + $notAfter['generalTime'] + $notAfter['utcTime'] + $notBefore['generalTime'] + $notBefore['utcTime'] + $opt['accessLocation'] + $opt['accessMethod'] + $rc['userCertificate'] + $rc['userCertificate'] + $rdn[$i] + $root[$i] + $signingCert['tbsCertificate'] + $signingCert['tbsCertificate'] + $signingCert['tbsCertificate'] + $signingCert['tbsCertificate'] + $spkac['publicKeyAndChallenge']['spki'] + $spkac['publicKeyAndChallenge']['spki'] + $spkac['publicKeyAndChallenge']['spki'] + $tbsCertList['nextUpdate'] + $tbsCertList['revokedCertificates'] + $tbsCertList['version'] + $this->currentCert['certificationRequestInfo']['subject'] + $this->currentCert['certificationRequestInfo']['subject'] + $this->currentCert['certificationRequestInfo']['subjectPKInfo'] + $this->currentCert['certificationRequestInfo']['subjectPKInfo'] + $this->currentCert['publicKeyAndChallenge']['spki'] + $this->currentCert['publicKeyAndChallenge']['spki'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertList']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['subject'] + $this->currentCert['tbsCertificate']['subject'] + $this->currentCert['tbsCertificate']['subject'] + $this->currentCert['tbsCertificate']['validity'] + $this->currentCert['tbsCertificate']['validity'] + $value[$j] + $value[$j] + $value[$j] + $value[$j]['policyQualifiers'][$k] + $value[$j]['policyQualifiers'][$k] + $value['authorityCertSerialNumber'] + $value['extnId'] + $value['extnId'] + $value['extnId'] + $value['extnId'] + $value['extnValue'] + $value['type'] + $value[0] + $values[$j] + $values[$j] + $x509['tbsCertificate']['subject'] + $x509['tbsCertificate']['subjectPublicKeyInfo'] + $x[0] + + + $attr['value'] + $attributes[$key]['value'] + $attributes[$key]['value'] + $attributes[$last]['value'] + $cert['tbsCertificate']['signature'] + $cert['tbsCertificate']['subjectPublicKeyInfo'] + $csr['certificationRequestInfo']['subjectPKInfo'] + $csr['certificationRequestInfo']['subjectPKInfo'] + $extensions[$key] + $extensions[] + $rclist[$i]['revocationDate'] + $root[$i] + $spkac['publicKeyAndChallenge']['spki'] + $spkac['publicKeyAndChallenge']['spki'] + $tbsCertList['issuer'] + $tbsCertList['nextUpdate'] + $tbsCertList['thisUpdate'] + $tbsCertList['version'] + $this->currentCert['certificationRequestInfo']['subject'] + $this->currentCert['certificationRequestInfo']['subjectPKInfo'] + $this->currentCert['publicKeyAndChallenge']['challenge'] + $this->currentCert['publicKeyAndChallenge']['spki'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['signatureAlgorithm']['algorithm'] + $this->currentCert['tbsCertList']['signature'] + $this->currentCert['tbsCertificate']['issuer'] + $this->currentCert['tbsCertificate']['serialNumber'] + $this->currentCert['tbsCertificate']['signature'] + $this->currentCert['tbsCertificate']['subject'] + $this->currentCert['tbsCertificate']['subjectPublicKeyInfo'] + $this->currentCert['tbsCertificate']['validity'] + $this->currentCert['tbsCertificate']['validity'] + $this->dn['rdnSequence'][] + $value['authorityCertSerialNumber'] + $values[$j] + $values[$j] + $values[$j] + $x509['tbsCertificate']['subjectPublicKeyInfo'] + + + $attributes[$last] + $extensions[$key] + $rdn[$i] + + + $attr + $attr + $attribute + $attribute + $attribute + $attribute + $attributes[$key]['value'][$disposition] + $attributes[$last]['value'][] + $attrs[] + $authorityKey + $authorityKey + $authorityKey + $authorityKey + $basicConstraints + $ca + $ca + $ca + $cert + $cert + $certificationRequestInfo + $crlNumber + $crlNumber + $csrexts + $currentKeyIdentifier + $currentKeyIdentifier + $data + $dn + $dn + $dn + $extension + $extension + $extension + $extension + $extensions[] + $field + $filters['tbsCertificate']['extensions'][] + $i + $i + $id + $id + $id + $id + $ipAddress + $issuerAltName + $key + $key + $key + $key + $key + $key + $key + $keyUsage + $map + $map + $map + $map + $map + $map + $map + $map + $map + $name + $names + $notAfter + $notAfter + $notBefore + $notBefore + $opt + $prop + $propName + $propName + $propName + $publicKeyAndChallenge + $rc + $rc + $rclist + $rdn + $result[$desc] + $result['certificationRequestInfo'] + $result['publicKeyAndChallenge'] + $result['tbsCertList'] + $result['tbsCertificate'] + $result[] + $result[] + $root + $root + $root + $s + $subid + $subid + $subjectKeyID + $subjectKeyID + $subjectKeyID + $subjectKeyID + $subvalue + $subvalue + $subvalue + $tbsCertList + $tbsCertList + $tbsCertificate + $this->currentCert + $this->currentCert + $this->dn + $this->dn + $this->dn + $this->dn + $this->publicKey + $this->publicKey + $this->publicKey + $this->publicKey + $type + $type + $type + $url + $v + $v + $v + $v + $v + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $value + $values + $values + $version + + + ?array + array|bool|string + array|false + array|false + bool + + + __toString + add + equals + equals + getPublicKey + toBytes + toString + toString + + + $issuer->privateKey->sign($this->signatureSubject) + $issuer->privateKey->sign($this->signatureSubject) + $this->privateKey->sign($this->signatureSubject) + $this->privateKey->sign($this->signatureSubject) + $value + + + $dn + $key->verify($signatureSubject, $signature) + $root + $root + self::$extensions[$id] ?? null + + + $i + int|false + + + $line + $line + $publicKey + $rclist + $rclist + $rclist + $rclist + $results + base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'])) + base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'])) + base64_decode(preg_replace('#-.+-|[\r\n]#', '', $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey'])) + pack('N', $hash) + unpack('Vhash', $hash) + + + inet_pton($ip[0]) + inet_pton($ip[1]) + + + false + false + false + false + false + false + false + false + false + false + false + + + $crl + $csr + $date + $date + $dn + $raw + + + $parts['host'] + $parts['scheme'] + $parts[path] + $results[$i + 1] + $results[$i] + + + $date + $date + $dn + $value + + + __toString + toString + toString + + + $key->getCurve() + + + $cert + $csr + + + $cert + $crl + $csr + $path + $spkac + $temp + $v + $value + $values[$j] + preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']) + preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']) + preg_replace('#-.+-|[\r\n]#', '', $spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']) + preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->toString($format)) + preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm) + preg_replace('#^ecdsa-with-#', '', strtolower($signatureAlgorithm)) + preg_replace('#^id-dsa-with-#', '', strtolower($signatureAlgorithm)) + preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element) + + + $spkac['publicKeyAndChallenge'] + $spkac['publicKeyAndChallenge'] + + + $cert['signatureAlgorithm'] + $spkac['publicKeyAndChallenge'] + + + $result + + + $desc + + + $currentCert + $currentCert + $currentCert + $currentCert + $signatureSubject + $signatureSubject + $signatureSubject + $signatureSubject + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null + is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null + null + null + null + null + null + null + + + $parts['host'] + $parts['scheme'] + $parts[path] + + + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $ip[0] + $ip[1] + $temp[1] + $this->domains[0] + + + $value + __toString + + + $ca['tbsCertificate'] + $ca['tbsCertificate'] + $crl['tbsCertList'] + $csr['certificationRequestInfo'] + $currentCert['tbsCertificate'] + $dn['rdnSequence'] + $dn['rdnSequence'] + $dn['rdnSequence'] + $spkac['publicKeyAndChallenge'] + $spkac['publicKeyAndChallenge'] + $spkac['publicKeyAndChallenge'] + $this->currentCert['signature'] + $this->currentCert['signature'] + $this->currentCert['signature'] + $this->currentCert['signature'] + $this->currentCert['signatureAlgorithm'] + $this->currentCert['signatureAlgorithm'] + $this->currentCert['signatureAlgorithm'] + $this->currentCert['signatureAlgorithm'] + $this->dn['rdnSequence'] + $x509['tbsCertificate'] + + + $signingCert + $signingCert + $subjectPublicKey + + + decodeIP + decodeNameConstraintIP + disableURLFetch + enableURLFetch + encodeIP + getAttributes + getChain + getCurrentCert + getIssuerDNProp + getRevoked + getRevokedCertificateExtensions + getSubjectDN + getSubjectDNProp + listRevoked + removeRevokedCertificateExtension + revoke + setAttribute + setIPAddress + setKeyIdentifier + setRevokedCertificateExtension + setSerialNumber + signCRL + unrevoke + + + \phpseclib3\File\X509 + bool + bool + bool + bool + bool + + + $CAs + $challenge + $currentCert + $currentKeyIdentifier + $dn + $endDate + $oids + $privateKey + $publicKey + $serialNumber + $signatureSubject + $startDate + + + !is_array($v) && isset($type) + $encoded !== false + + + $s !== false + $v !== false + $v !== false + is_array($crl->currentCert) + is_array($subject->currentCert) + is_array($subject->currentCert) + is_array($this->currentCert) + is_array($this->currentCert) + is_array($this->currentCert) + isset($crl->currentCert) + isset($crl->currentCert) && is_array($crl->currentCert) + isset($issuer->currentKeyIdentifier) + isset($issuer->currentKeyIdentifier) + isset($key->privateKey) + isset($key->publicKey) + isset($subject->currentCert) + isset($subject->currentCert) + isset($subject->currentCert) && is_array($subject->currentCert) + isset($subject->currentCert) && is_array($subject->currentCert) + isset($subject->currentKeyIdentifier) + isset($subject->publicKey) + isset($this->currentCert) && is_array($this->currentCert) + isset($this->currentCert) && is_array($this->currentCert) + isset($this->currentCert) && is_array($this->currentCert) + isset($this->currentCert) && is_array($this->currentCert) + + + strtolower + + + !isset($this->signatureSubject) + $this->currentCert + $this->currentCert + $this->currentCert + $this->currentCert + $this->signatureSubject + $this->signatureSubject + $this->signatureSubject + $this->signatureSubject + isset($this->currentCert) + isset($this->publicKey) + null + null + null + null + null + null + null + null + + + $cert + $crl + $csr + $root + $root + $root + $root + $spkac + + + !is_array($cert) + !is_array($crl) + !is_array($csr) + !is_array($spkac) + $cert === false + $crl === false + $csr === false + $spkac === false + 'md5' + 'sha1' + 'sha224' + 'sha224' + 'sha224' + 'sha256' + 'sha256' + 'sha384' + 'sha384' + is_array($cert) + is_array($crl) + is_array($csr) + is_array($root) + is_array($spkac) + is_string($extnId) + + + verify + + + new static() + + + $attr + $extension + $extension + + + $oids + + + $count + $key + $key + $subvalue + $value + + + + $modexp + + + $gcd + $max + $min + $x + $y + $this->value + + $val + + + $class::max(...$nums) + $class::min(...$nums) + $class::randomRange($min->value, $max->value) + $class::randomRangePrime($min->value, $max->value) + $func($x->value) + $q + $r + $this->value->abs() + $this->value->add($y->value) + $this->value->bitwise_and($x->value) + $this->value->bitwise_leftRotate($shift) + $this->value->bitwise_leftShift($shift) + $this->value->bitwise_not() + $this->value->bitwise_or($x->value) + $this->value->bitwise_rightRotate($shift) + $this->value->bitwise_rightShift($shift) + $this->value->bitwise_split($split) + $this->value->bitwise_xor($x->value) + $this->value->extendedGCD($n->value) + $this->value->gcd($n->value) + $this->value->modInverse($n->value) + $this->value->modPow($e->value, $n->value) + $this->value->multiply($x->value) + $this->value->negate() + $this->value->pow($n->value) + $this->value->powMod($e->value, $n->value) + $this->value->root($n) + $this->value->subtract($y->value) + $val + + + $q + $r + + + $func + [$q, $r] + + + $func($x->value) + + + bool + bool + bool + bool + bool + bool + int + int + int + int + int|bool + string + string + string + string + + + $fqmain::isValidEngine() + __debugInfo + abs + add + between + bitwise_and + bitwise_leftRotate + bitwise_leftShift + bitwise_not + bitwise_or + bitwise_rightRotate + bitwise_rightShift + bitwise_split + bitwise_xor + compare + createRecurringModuloFunction + divide + equals + extendedGCD + gcd + getLength + getLengthInBytes + getPrecision + isNegative + isOdd + isPrime + modInverse + modPow + multiply + negate + pow + powMod + root + setPrecision + subtract + testBit + toBits + toBytes + toHex + toString + + + [$main, $modexp] + + + $class::scan1divide($r->value) + $this->value->between($min->value, $max->value) + $this->value->compare($y->value) + $this->value->equals($x->value) + $this->value->getLength() + $this->value->getLengthInBytes() + $this->value->getPrecision() + $this->value->isNegative() + $this->value->isOdd() + $this->value->isPrime($t) + $this->value->testBit($x) + $this->value->toBits($twos_compliment) + $this->value->toBytes($twos_compliment) + $this->value->toHex($twos_compliment) + $this->value->toString() + + + $modexp + + + abs + between + bitwise_leftRotate + bitwise_not + bitwise_split + extendedGCD + getEngine + jsonSerialize + max + min + root + + + $bits + + + $hex + $precision + + + isset(self::$mainEngine) + $class::max(...$nums) $class::min(...$nums) @@ -11,8 +11852,51 @@ $class::randomRangePrime($min->value, $max->value) $class::scan1divide($r->value) + + new self::$mainEngine($x, $base) + new static("$x") + new static($class::max(...$nums)) + new static($class::min(...$nums)) + new static($class::random($size)) + new static($class::randomPrime($size)) + new static($class::randomRange($min->value, $max->value)) + new static($class::randomRangePrime($min->value, $max->value)) + new static($func($x->value)) + new static($gcd) + new static($max) + new static($min) + new static($q) + new static($r) + new static($this->hex, -16) + new static($this->value->abs()) + new static($this->value->add($y->value)) + new static($this->value->bitwise_and($x->value)) + new static($this->value->bitwise_leftRotate($shift)) + new static($this->value->bitwise_leftShift($shift)) + new static($this->value->bitwise_not()) + new static($this->value->bitwise_or($x->value)) + new static($this->value->bitwise_rightRotate($shift)) + new static($this->value->bitwise_rightShift($shift)) + new static($this->value->bitwise_xor($x->value)) + new static($this->value->gcd($n->value)) + new static($this->value->modInverse($n->value)) + new static($this->value->modPow($e->value, $n->value)) + new static($this->value->multiply($x->value)) + new static($this->value->negate()) + new static($this->value->pow($n->value)) + new static($this->value->powMod($e->value, $n->value)) + new static($this->value->root($n)) + new static($this->value->subtract($y->value)) + new static($val) + new static($x) + new static($y) + + + $this->powModOuter($e, $n) + $this->powModOuter($e, $n) + $current $current @@ -46,6 +11930,178 @@ $y->value $y->value[0] == '-' ? substr($y->value, 1) : $y->value + + BCMath + BCMath + + + $temp->add(static::$one[static::class]) + $this->bitwiseAndHelper($x) + $this->bitwiseXorHelper($x) + $this->bitwiseXorHelper($x) + [$this->normalize($quotient), $this->normalize($remainder)] + self::maxHelper($nums) + self::minHelper($nums) + self::randomRangeHelper($min, $max) + + + $x + + + $x + $x + $x + 1 + + + BCMath + + + $r_value[strlen($r_value) - 1] + $this->value[strlen($this->value) - 1] + $this->value[strlen($this->value) - 1] + $x + + + $class::powModHelper($this, $e, $n, static::class) + + + BCMath + BCMath + BCMath + BCMath + BCMath + BCMath + Engine + array{gcd: static, x: static, y: static} + array{static, static} + + + $current + $r_value + $temp >> 16 + $temp >> 8 + $temp->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $x + $y->value + + + $current[0] + $r_value[strlen($r_value) - 1] + $temp->value[0] + $this->value[0] + $this->value[0] + $this->value[strlen($this->value) - 1] + $this->value[strlen($this->value) - 1] + $y->value[0] + + + $current + $current + $current + $current + $n->value + $r_value + $result->bitmask->value + $result->value + $temp + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $u + $v + $v + $x + $x->value + $y->value + $y->value + $y->value + $y->value + $y->value + $y->value[0] == '-' ? substr($y->value, 1) : $y->value + + + $remainder->value + bcmod($this->value, bcpow('2', $x + 1, 0)) + + + $remainder->value[0] + + + $temp + $temp + + + bcmod($result->value, $result->bitmask->value) + bcmod($this->value, $y->value) + + + $current[0] + $temp->value[0] + $this->value[0] + $this->value[0] + $y->value[0] + + + abs + between + bitwise_and + bitwise_leftShift + bitwise_or + bitwise_rightShift + bitwise_xor + divide + equals + gcd + isNegative + make_odd + max + min + modInverse + modPow + multiply + negate + pow + powMod + powModInner + randomRange + randomRangePrime + scan1divide + subtract + testBit + testSmallPrimes + toBytes + toString + + + BCMath + BCMath + + + $this->bitmask + $class::powModHelper($this, $e, $n, static::class) $current @@ -57,8 +12113,46 @@ $this->value $y->value + + new static($a) + new static($b) + new static($u) + new static() + new static() + new static() + + + $value + + + $class + $temp + $x + $x + $x + $y + static::slidingWindow($x, $e, $n, $class) + + + new $class() + + + string + string + string + + + static::reduce($x, $n) + static::reduce(bcmul($x, $x), $n) + static::reduce(bcmul($x, $y), $n) + + + multiplyReduce + prepareReduce + squareReduce + static::reduce($x, $n) static::reduce(bcmul($x, $x), $n) @@ -71,8 +12165,173 @@ $n->value $x->value + + bcpowmod($x->value, $e->value, $n->value) + + + $e->value + $n->value + $x->value + + + BuiltIn + + + + + OpenSSL + + + + + $lhs + $lhs + $lhs + $lsd + $m + $m + $m + $msd + $n + $n + $n + $n + $n + $n + $q + $r1 + $r2 + $temp + $temp + $temp + $temp + $temp + $x + + + string + string + + + $cache[self::DATA][$key] + $cache[self::DATA][$key] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $m + $m + $m + $m1 + $m_length + 1 + $n + $u + -$cutoff + -$cutoff + -($m_length >> 1) - 1 + + + $cache[self::DATA] + $cache[self::DATA] + $cache[self::DATA] + $cache[self::DATA] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + + + $cache[self::DATA] + $cache[self::DATA] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + + + $cache[self::DATA][$key] + $cache[self::DATA][$key] + + + $cutoff + $key + $key + + + $m_length + $m_length + $m_length + -($m_length >> 1) + + + bcmod($n, $m) + bcmod($x, $n) + + + $m1 + $u + + + reduce + + + $key + + + + + $lhs + $lhs + + + $m + + + $m + $m + + + $custom_reduction + + + $inline + self::$custom_reduction + self::$custom_reduction + + + $inline($n) + + + callable|void + string + + + $func + $inline($n) + + + EvalBarrett + + + $fqengine + $leading_ones | $temp + $left & $right + $left ^ $right + $left | $right + $max + $min + $temp + $this->hex + Random::string($size) + Random::string(1) + Strings::bits2bin($x) + chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3) + chr(1) . str_repeat("\0", $size) + new static('-1') + new static('-1') + $x[0] $x[0] @@ -82,6 +12341,351 @@ static::$zero static::$zero + + $x + $x + $x + $x + + + $fqengine::generateCustomReduction($this, static::class) + + + $min->isPrime() ? $min : false + $x + + + $bits + $bits[0] + $bytes + $hex + $left + $left + $left + $mask + $max->toBytes() + $right + $right + $right + $temp + $temp[0] + $temp[0] + $this->toBytes($twos_compliment) + $this->toBytes() + $window_ranges + $x + $x[0] + + + $bits[0] + $g->divide(static::$two[static::class])[0] + $max_multiple + $max_multiple + $og->subtract($g)->divide(static::$two[static::class])[0] + $q + $random + $step->divide(static::$two[static::class])[0] + $temp[0] + $temp[0] + $window_ranges[$i] + + + $temp[0] + + + $a + $a + $b + $bits + $bytes + $c + $comp + $compare + $compare + $comparison + $d + $e + $func + $g + $g + $g + $g + $g + $g + $guess + $hex + $left + $left + $left + $left + $left + $mask + $mask + $mask + $mask + $max + $max + $max + $max_multiple + $max_multiple + $min + $min + $n + $n + $n_1 + $n_2 + $num + $og + $powers[$i2 + 1] + $powers[1] + $powers[2] + $r + $random + $random + $random + $random_max + $random_max + $result + $result + $result + $result + $result + $right + $right + $right + $right + $root + $root + $root + $s + $step + $step + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp->value + $this->value + $this->value + $this->value + $u + $v + $vals[] + $x + $x + $x + $y + $y + [$max_multiple] + [$max_multiple] + [$q] + [, $random] + + + clone $n_1 + + + Engine + Engine + Engine + Engine + Engine + Engine + Engine + Engine + Engine + Engine + Engine|string + \Closure + static|false + static|false + static|false + + + $fqengine::isValidEngine() + add + add + add + add + add + add + bitwise_and + bitwise_and + bitwise_leftShift + bitwise_leftShift + bitwise_or + bitwise_rightShift + compare + compare + compare + compare + compare + compare + compare + divide + divide + divide + divide + divide + equals + equals + equals + equals + equals + equals + equals + equals + equals + isPrime + modInverse + modPow + modPow + multiply + multiply + multiply + multiply + multiply + multiply + pow + pow + pow + powModInner + subtract + subtract + subtract + subtract + subtract + subtract + subtract + subtract + toBytes + toBytes + toBytes + + + static::ENGINE_DIR + static::ENGINE_DIR + + + $temp->value + $temp->value + $temp->value + + + $max + $min + $nums[0] + $nums[0] + $random->add($min) + $this->compare(static::$zero[static::class]) < 0 ? $this->normalize($n->subtract($x)) : $this->normalize($x) + $this->normalize($n->subtract($temp)) + $this->normalize($result) + $this->normalize($root) + $this->normalize($root) + $this->normalize($temp->powModInner($e, $n)) + $this->normalize(new static($leading_ones | $temp, 256)) + $this->normalize(new static($left & $right, -256)) + $this->normalize(new static($left ^ $right, -256)) + $this->normalize(new static($left | $right, -256)) + $this->normalize(new static($temp, 256)) + $this->normalize(static::$zero[static::class]) + $this->powModInner($e, $n) + $this->toString() + $x + static::randomRange($min, $max) + static::randomRangePrime($min, $max) + + + Engine[] + array_reverse($vals) + + + array{gcd: Engine, x: Engine, y: Engine} + + + strpos($msb, '0') + + + subtract + toBytes + + + $t + $x + $x + bindec($msb) + + + $powers[bindec(substr($e_bits, $i, $j + 1))] + + + $this->value + $x + $x + $x[0] + + + $x[0] + + + $x + preg_replace('#(?<!^)-.*|(?<=^|-)0*|[^-0-9].*#', '', (string) $x) + + + $nums[0] + $nums[0] + $nums[0] + $nums[0] + + + add + bitwise_and + bitwise_rightShift + compare + equals + equals + equals + multiply + multiply + multiply + multiply + pow + subtract + subtract + + + $comp + + + bitwise_not + bitwise_rightRotate + bitwise_split + createRecurringModuloFunction + getLength + jsonSerialize + root + + + $n + $size + $size + + + $reduce + + + $hex + $reduce + $value + + + static::$modexpEngine + static::ENGINE_DIR static::ENGINE_DIR @@ -168,18 +12772,712 @@ toBytes toString + + new $class() + new $class(1) + new static($leading_ones | $temp, 256) + new static($left & $right, -256) + new static($left ^ $right, -256) + new static($left | $right, -256) + new static($mask, 256) + new static($max, 256) + new static($min, 256) + new static($n) + new static($temp, 256) + new static($this->hex, -16) + new static('-1') + new static('-1') + new static('2') + new static() + new static() + new static() + new static() + new static(0) + new static(1) + new static(1) + new static(1) + new static(1) + new static(1) + new static(2) + new static(Random::string($size), 256) + new static(Random::string(1), 256) + new static(Strings::bits2bin($x), 128 * $base) + new static(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256) + new static(chr(1) . str_repeat("\0", $size), 256) + + + $root + + + $min + $x + + + $this->powModOuter($e, $n) + $this->powModOuter($e, $n) + self::randomRangePrime($min, $x) + + + GMP + GMP + GMP + + + $this->value * $x->value + $this->value ** $n->value + $this->value + $y->value + $this->value - $y->value + $x->value % $temp + + + GMP + + + self::maxHelper($nums) + self::minHelper($nums) + self::randomRangeHelper($min, $max) + + + $x + + + $this->value ?? '0' + $x + $x + + + GMP + + + $class::powModHelper($this, $e, $n) + + + GMP + GMP + GMP + + + $temp + $temp + + + gmp_import($this->value) + gmp_invert($this->value, $n->value) + + + $n->value + $n->value + $n->value + $r->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value ?? '0' + $x->value + $y->value + $y->value + $y->value + + + $this->value + $this->value + + + $n->value + $r->value + $s + $shift + $shift + $temp + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $x->value + $x->value + $x->value + $y->value + $y->value + 1 + + + -$result->value + -$result->value + -$this->value + + + abs + between + bitwise_and + bitwise_leftShift + bitwise_or + bitwise_rightShift + bitwise_xor + divide + equals + extendedGCD + gcd + isNegative + isOdd + make_odd + max + min + modInverse + modPow + multiply + negate + pow + powMod + powModInner + randomRange + scan1divide + subtract + testBit + toBytes + toString + + + GMP + GMP + + + $this->bitmask + + + $this->value + '0' + $class::powModHelper($this, $e, $n) + + new static() + + + + + $e->value + $n->value + $x->value + + + DefaultEngine + + + $x->toBytes() + + + openssl_error_string() + + + isValidEngine + powModHelper + toBytes + + $result + $result + $value + + + $x + + + $prime + $s + $temp + $temp + $temp->value + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $temp_value + $temp_value + $x + $x + $x + $x / static::BASE + $x->value + $x_value + $x_window[0] * static::BASE_FULL + $x_window[1] + $xx[self::SIGN] + $xx[self::VALUE] + $xy[self::SIGN] + $xy[self::VALUE] + $y->value[0] + $y_window[0] + $z1[self::SIGN] + $z1[self::SIGN] + $z1[self::VALUE] + $z1[self::VALUE] + $z1[self::VALUE] + $z1[self::VALUE] + static::MAX10LEN + static::MAX10LEN + static::MAX10LEN + strlen($x) + ((static::MAX10LEN - 1) * strlen($x)) % static::MAX10LEN + + + $digit + $this->value + $value + $value + $value + $x_value + self::baseSquare($x) + self::karatsuba($x_value, $y_value) + self::karatsubaSquare($x) + self::regularMultiply($x_value, $y_value) + + + $mod + $temp + $x_value[$i - 1] + $x_value[$i - 2] + $x_value[$i] + + + $bit + $carry + $carry + $carry + $carry + $carry + $carry + $carry_mask + $carry_shift + $diff + $digit + $digit + $digit[$j] + $digit[] + $digit[] + $lhs + $lhs + $mask + $mask + $msb + $msb + $n + $newbits + $overflow + $overflow + $overflow + $overflow + $prime + $product_value[$j] + $product_value[$k] + $quotient->value + $quotient_value[$q_index] + $quotient_value[$q_index] + $quotient_value[$q_index] + $quotient_value[$x_max - $y_max] + $remaining + $remaining + $remaining + $remaining + $remaining + $result->is_negative + $result->value + $rhs_value + $s + $shift + $shift + $shift + $square_value[$i + $max_index + 1] + $sum + $sum + $sum + $sum + $sum + $sum + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp_value + $tempmask + $tempmask + $tempoverflow + $tempsplit + $this->value + $val[$i] + $val[$i] + $vals[] + $value[$i] + $value[$i] + $value[$i] + $value[$j] + $x + $x + $x + $x + $x + $x_value + $x_value[$i] + $x_value[$i] + $x_value[$i] + $x_value[$j] + [$temp, $mod] + static::$isValidEngine[static::class] + + + PHP + PHP + array + array + + + add + add + compare + compare + compare + divide + equals + multiply + multiply + multiply + multiply + multiply + rshift + subtract + subtract + subtract + + + $bit + $digit + $digit[$j] + $digit[$j] + $mask + $msb + $msb + $overflow + $overflow + $overflow + $product_value[$k] + $quotient_value[$q_index] + $quotient_value[$q_index] + $quotient_value[$x_max - $y_max] + $remaining + $remaining + $remaining + $remaining + $remaining + $shift + $shift + $square_value[$i2] + $square_value[$k] + $sum + $sum + $sum + $sum + $sum + $sum + $sum + $sum + $sum + $sum + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $tempmask + $tempmask + $tempoverflow + $tempsplit + $tempsplit + $this->value[$digit] + $this->value[$i] + $this->value[$i] + $this->value[$i] + $this->value[0] + $this->value[0] + $val[$i] + $val[$i] + $val[$i] & $tempmask + $value[$i] + $value[$i] + $value[$i] + $value[$j] + $x + $x + $x_value[$i] + $x_value[$i] + $x_value[$i] + $x_value[$j] + $x_value[$j] + $x_value[$j] + $x_value[$j] + $x_window[0] * static::BASE_FULL + ($x_value[$j] + $y_value[$j]) * static::BASE_FULL + ($x_value[$j] - $y_value[$j]) * static::BASE_FULL + ((static::MAX10LEN - 1) * strlen($x)) % static::MAX10LEN + (static::MAX10LEN - 1) * strlen($x) + 1 << $overflow + 1 << $overflow + 1 << $shift + 1 << $tempoverflow + 2 * $value[$j] + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::BASE_FULL + static::MAX10LEN + ~$r_value[$i] + ~$this->value[0] + + + $lhs + $lhs + + + $mod->value + $rhs->value + $temp->value + $temp->value + $temp->value + $x->value + $x->value + + + static::$isValidEngine + + + $class::powModHelper($this, $e, $n, static::class) + $temp + $xx[self::VALUE] + $xy[self::VALUE] + + + array_reverse($vals) + list<int> + + + $this->value[$i] + $this->value[0] + $this->value[count($this->value)] + $val[$i] + $val[$i] + + + list<static> + static + + + pack('N', $x) + + + $r_value + $result->bitmask->value + $temp->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $this->value + $val + $val + $val + $val + $value + $value + $value + $x + $x + $x + $x + $x + $x->value + $y->value + $y->value + $y->value + $y_value + $y_value + + + $r_value[$i] + $result->bitmask->value[$i] + $this->value[$i] + $this->value[$i] + $this->value[0] + $this->value[0] + $this->value[0] + $val[$i] + $val[$i] + $value[0] + $x[0] + $y->value[0] + $y->value[count($y->value) - 1] + $y_value[$y_max - 1] + $y_value[$y_max] + + + $this->value[$i] + $this->value[$i] + $this->value[0] + $this->value[count($this->value)] + $val[$i] + $val[$i] + $val[] + + + $x + $x + + + ~$r_value[$i] + ~$this->value[0] + + + $result->bitmask->value + + + $arr[self::SIGN] + $arr[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $this->value[0] + $this->value[0] + $this->value[0] + $value[0] + $x[0] + $xx[self::SIGN] + $xx[self::VALUE] + $xx[self::VALUE] + $xy[self::SIGN] + $xy[self::VALUE] + $xy[self::VALUE] + $y->value[0] + $y_value[0] + $z1[self::SIGN] + $z1[self::SIGN] + $z1[self::VALUE] + $z1[self::VALUE] + $z1[self::VALUE] + $z1[self::VALUE] + + + compare + divide + equals + multiply + multiply + multiply + multiply + subtract + subtract + + + $j + $mask + $tempmask + + + abs + bitwise_leftShift + bitwise_rightShift + isNegative + isOdd + make_odd + negate + pad + powModInner + scan1divide + square + testBit + testSmallPrimes + toBytes + toString + + + PHP + + + PHP + PHP + + + static::$isValidEngine + + + (string) $mod->value[0] + + + $value[$i] + $value[$i] + + + '' + static::BASE static::BASE @@ -268,8 +13566,82 @@ subtract subtract + + new static($this->int2bytes((int) substr($x, 0, static::MAX10LEN)), 256) + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static() + new static(1) + new static(Hex::decode($x), 256) + + + $digit + $x_max + $x_size + + + $class + $temp + static::slidingWindow($x, $e, $n, $class) + + + $class::multiplyHelper($x, false, $y, false) + $class::square($x) + $class::square($x->value) + new $class() + new $class() + + + $temp + $temp + + + $temp + $temp + $temp[self::VALUE] + + + $temp + [, $temp] + [, $temp] + + + array + array + array + + + divide + + + static::reduce($class::square($x), $n, $class) + static::reduce($temp[self::VALUE], $n, $class) + static::reduce($x, $n, $class) + + + isValidEngine + multiplyReduce + prepareReduce + squareReduce + divide static::reduce($class::square($x), $n, $class) @@ -278,35 +13650,984 @@ + + $n->value + $n->value[$i] + + + $n->value[$i] + $result + + + $j + $result + $result + $result + $temp + $temp + $y1 + $y2 + [, $result] + + + T + + + add + divide + multiply + multiply + + + $class::BASE + $n->value[0] + + + $result + + + strrpos($temp, '1') + + + $n->value[0] + + + $n->value[0] + + + $n->value + lshift + modInverse + multiply + multiply + + + $j + $n->value modInverse rshift + + new $class() + new $class() + + + + + OpenSSL + + + $class::addHelper($result, false, $corrector_value, false) + $class::multiplyHelper($temp, false, $cache[self::DATA][$key], false) + $class::subtractHelper($result, false, $temp[self::VALUE], $temp[self::SIGN]) + $class::subtractHelper($result[self::VALUE], $result[self::SIGN], $n, false) + new $class() + new $class() + new $class() + new $class() + + + $cache[self::DATA][$key] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cutoff + $cutoff + $m + $m1 + $m_length - 1 + $n + $n + $n[self::VALUE] + $n[self::VALUE] + $result[self::SIGN] + $result[self::SIGN] + $result[self::SIGN] + $result[self::VALUE] + $result[self::VALUE] + $result[self::VALUE] + $temp[self::SIGN] + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $u + ($m_length >> 1) + 1 + + + $lsd + $product_value + + + $cache[self::DATA] + $cache[self::DATA] + $cache[self::DATA] + $cache[self::DATA] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $m1 + $result[self::SIGN] + $result[self::SIGN] + $result[self::VALUE] + $result[self::VALUE] + $result[self::VALUE] + $result[self::VALUE] + $temp + $temp + $temp + $temp[self::VALUE] + $u + + + $cache[self::DATA] + $cache[self::DATA] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + + + $cache[self::DATA][$key] + $cache[self::DATA][$key] + + + $cache[self::DATA][] + $carry + $carry + $cutoff + $key + $key + $lhs_value + $m1 + $product_value[$j] + $product_value[$k] + $result + $result + $result + $result + $temp + $temp + $temp + $u + [$temp, ] + [$u, $m1] + [, $temp] + [, $temp] + + + array + array + + + $class::addHelper($lsd, false, $temp[self::VALUE], false) + $class::multiplyHelper($msd, false, $m1, false) + $class::multiplyHelper($temp, false, $m, false) + $class::multiplyHelper($temp, false, $u, false) + $class::subtractHelper($n[self::VALUE], false, $temp[self::VALUE], false) + $class::subtractHelper($result[self::VALUE], $result[self::SIGN], $m, false) + divide + divide + + + $class::BASE_FULL + $class::BASE_FULL + $m_length + $m_length + $m_length + $product_value[$k] + $temp + $temp + $temp + $temp + $temp + $temp + $x_value[$j] + $x_value[$j] + + + $m1->value + $temp->value + $temp->value + $temp->value + $u->value + + + $result[self::VALUE] + $result[self::VALUE] + $temp->value + $temp->value + + + $n[self::VALUE] + $result[self::SIGN] + $result[self::SIGN] + $result[self::VALUE] + $result[self::VALUE] + $result[self::VALUE] + $temp[self::SIGN] + $temp[self::SIGN] + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $temp[self::VALUE] + $y_value[0] + + + $m1 + $u + divide divide + + new $class() + new $class() + new $class() + new $class() + + + Barrett + + + $key + + + + + new $class() + new $class() + + + $temp + + + [, $temp] + + + array + + + divide + + + $temp->value + + + $temp->value + + + Classic + + + new $class() + new $class() + new $class() + + + $custom_reduction + + + $class::BASE_FULL + $class::BASE_FULL + $class::MAX_DIGIT2 + $class::MAX_DIGIT2 + $class::MAX_DIGIT2 + $class::MAX_DIGIT2 + $known[$j] * $class::BASE_FULL + $known[$i] + $m + $m->value + $m1 + $u + + + $m1 + $u + $u + + + $inline + $lhs_value + $m1 + $u + $u + [$u, $m1] + [$u] + self::$custom_reduction + self::$custom_reduction + + + $inline($n) + + + array + callable + + + divide + divide + + + $arr[$i] + $arr[$j] + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::BASE_FULL + $class::MAX_DIGIT + $class::MAX_DIGIT + $class::MAX_DIGIT + $known[$i] + $known[$i] + $known[$i] + $known[$j] + + + $m1->value + $u->value + $u->value + + + $func + $func + $inline($n) + + + $m + $m + $m + $m + $m + $m + $m + $m + $m + $m + $m->value + $m->value + + + $m + $m->value + + + generateCustomReduction + reduce + $m $m->value + + + $class::addHelper($result[self::VALUE], false, $temp, false) + $class::regularMultiply([$temp], $n) + $class::subtractHelper($result[self::VALUE], false, $n, false) + new $class() + new $class() + + + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $class::BASE_FULL + $class::BASE_FULL + $result + $result * (2 - fmod($x * $result, $class::BASE_FULL)) + $result[self::VALUE] + $temp + $x * $result + + + $cache[self::DATA] + $cache[self::DATA] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $result[self::VALUE] + $result[self::VALUE] + $result[self::VALUE] + $temp + + + $cache[self::DATA] + $cache[self::VARIABLE] + $result[self::VALUE] + + + $cache[self::DATA][$key] + + + $key + $result + $result + $result + $result + $result + $result + $result + $temp + $temp + $temp + $x + [, $temp] + + + array + array + int + + + divide + + + $class::BASE_FULL + $class::MAX_DIGIT + $result + $result + $result + $result + $result + $result[self::VALUE][$i] + $temp + $temp + $temp + $x + $x + $x + $x + $x + $x + ($x & 0xFF) * $result + ($x & 0xFFFF) * $result + ($x * $result) % $class::BASE_FULL + 2 - ($x & 0xFFFF) * $result + + + $temp->value + + + $result & $class::MAX_DIGIT + $result[self::VALUE] + $temp->value + + + $result[self::VALUE] + $x[0] + + + reduce + + + + $a[self::VALUE] + $a[self::VALUE] + $a[self::VALUE] + $a[self::VALUE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $temp[self::VALUE] + + + $a[self::VALUE][0] + $cache[self::DATA] + $cache[self::DATA] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + $cache[self::VARIABLE] + + + $cache[self::DATA] + $cache[self::VARIABLE] + + + $cache[self::DATA][$key] + + + $key + $temp + $temp + $temp + $temp + + + array + + + $a[self::VALUE][0] + $class::BASE_FULL + $class::BASE_FULL + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $y[0] + + + $a[self::VALUE] + + + $class + $m + + $a[self::VALUE] + $a[self::VALUE] + $a[self::VALUE] + $a[self::VALUE] + $a[self::VALUE] + $temp[self::VALUE] + $y[0] + + + MontgomeryMult + + + + + new $class() + new $class() + new $class() + + + $result + + + array + + + bitwise_and + subtract + + + $result->value + + + $result->value + + + + + $this->powModOuter($e, $n) + $this->powModOuter($e, $n) + + + PHP32 + PHP32 + + + $this->bitwiseAndHelper($x) + $this->bitwiseOrHelper($x) + $this->bitwiseXorHelper($x) + $this->extendedGCDHelper($n) + $this->powHelper($n) + self::maxHelper($nums) + self::minHelper($nums) + self::randomRangeHelper($min, $max) + + + $digit + $digit + $vals[] + + + $digit + $digit + + + PHP32 + PHP32 + PHP32 + PHP32 + PHP32 + PHP32 + PHP32 + PHP32[] + + + $this->value + $this->value + $this->value + $this->value + $val + $val + $val + $y->value + $y->value + $y->value + $y->value + + + $digit + + + $val + $val + + + $this->extendedGCD($n)['gcd'] + + + between + bitwise_and + bitwise_or + bitwise_xor + divide + equals + gcd + max + min + modInverse + modPow + multiply + pow + powMod + randomRange + randomRangePrime + subtract + + + PHP32 + PHP32 + + + $this->powModOuter($e, $n) + + + PHP64 + + + $this->bitwiseAndHelper($x) + $this->bitwiseOrHelper($x) + $this->bitwiseXorHelper($x) + $this->extendedGCDHelper($n) + $this->powHelper($n) + self::maxHelper($nums) + self::minHelper($nums) + self::randomRangeHelper($min, $max) + + + $val[$i - 1] + + + $digit + $digit + $digit + $digit + $vals[] + + + $digit + $digit + $digit + $digit + + + PHP64 + PHP64 + PHP64 + PHP64 + PHP64 + PHP64 + PHP64 + PHP64[] + + + $this->value + $this->value + $this->value + $this->value + $val + $val + $val + $y->value + $y->value + $y->value + $y->value + + + $digit + $val[$i - 1] + + + $val + $val + + + $this->extendedGCD($n)['gcd'] + + + between + bitwise_and + bitwise_or + bitwise_xor + divide + equals + gcd + max + min + modInverse + modPow + multiply + pow + powMod + randomRange + randomRangePrime + subtract + + + PHP64 + PHP64 + $val + + + $c + + + function ($c) use ($u, $mStart, $m, $t, $finalMask, $pad, $h) { + + + $indices + + + $c + $m + $one + + + $val[$index] + + + $index + $m + + + gmp_import($x) + + + $m + + + getLength + getLengthInBytes + randomInteger + + + + + pack('J', $z) + + + string + + + string + + + $instanceID + $instanceID + $instanceID + $num + $x + $x + $x + $y + $y + $y + $z + + + $num + $r + $r + $x + $x + $y + $y + $y + $z + + + static::$modulo[$instanceID] + static::$reduce[$instanceID] + static::$reduce[$instanceID] + + + $r + $this->instanceID + $this->value + $x + $x0 + $x1 + $x2 + $x3 + $y + $y0 + $y1 + $y2 + $y3 + $z + $z0 + $z0 + $z1 + $z1 + $z2 + $z2 + $z3 + $z3 + + + $x + $x + $x + $x + $x0 + $x0 + $x0 + $x0 + $x1 + $x1 + $x1 + $x1 + $x2 + $x2 + $x2 + $x2 + $x3 + $x3 + $x3 + $x3 + $y + $y + $y + $y + $z0 + $z0 + $z1 + $z2 + $z3 + ($x0 * $y0) ^ ($x1 * $y3) + ($x0 * $y1) ^ ($x1 * $y0) + ($x0 * $y2) ^ ($x1 * $y1) + ($x0 * $y3) ^ ($x1 * $y2) + + + unpack('N', $x)[1] + unpack('N', $y)[1] + + + unpack('N', $x)[1] + unpack('N', $y)[1] + + + compare + divide + equals + negate + subtract + toBits + + + (string) $this->toBigInteger() + + + + !isset($q) + + + new static($this->instanceID) + new static($this->instanceID) + new static($this->instanceID, $x ^ $y) + new static($this->instanceID, $x ^ static::$modulo[$this->instanceID]) + new static($this->instanceID, static::polynomialMultiply($this->value, $y->value)) + + + + + jsonSerialize + + + toHex + + + + + $one + + + getLength + getLengthInBytes + randomInteger + setReduction + + + $this->modulo + $this->reduce + + + + $instanceID + + + $length + $one + $two + static::$zero[static::class] + static::$zero[static::class] + static::$zero[static::class] + + + static::$modulo[$instanceID] + static::$reduce[$instanceID] + + + $this->value + + + clone static::$zero[static::class] + + + static::$reduce + + + compare + equals + getNAF + isOdd + pow + toBits + static::$zero static::$zero @@ -315,5 +14636,4021 @@ static::$zero static::$zero + + new static($this->instanceID) + new static($this->instanceID) + new static($this->instanceID) + new static($this->instanceID, $r) + new static($this->instanceID, $this->value->multiply($denominator)) + new static($this->instanceID, $this->value->multiply($x->value)) + new static($this->instanceID, static::$modulo[$this->instanceID]->subtract($this->value)) + + + + + false + false + false + false + false + + + array + array|string + int + + + bool + + + $request_id + $value + + + chmod + fileatime + filegroup + filemtime + fileowner + fileperms + filesize + get_lstat_cache_prop + get_stat_cache_prop + get_xstat_cache_prop + parseLongname + query_stat_cache + readlink + realpath + + + $a['filename'] + $attr['mode'] + $b['filename'] + $content + $dir + $dir + $dir + $dir + $dir + $dir + $dir + $dir + $dir + $filename + $filename + $filename + $filename + $filename + $filename + $filename + $filename + $flags + $flags + $flags + $flags + $fp + $fp + $fp + $fp + $fp + $fp + $fp + $length + $length + $res_offset + $link + $link + $link + $link + $longname + $newname + $newname + $oldname + $oldname + $path + $path + $path + $remote_file + $remote_file + $remote_file + $stat['atime'] + $stat['atime'] + $stat['mtime'] + $stat['mtime'] + $status + $status + $status + $status + $status + $status + $status + $status + $status + $status + $status + $stop - $start + $temp + $temp + $this->extensions['versions'] + $this->pwd + $this->realpath($dir . '/' . $key) + $this->realpath($dir . '/' . $value) + $this->realpath($path) + $this->realpath($path) + $this->server_channels[self::CHANNEL] + $this->server_channels[self::CHANNEL] + + + $props['type'] + $props['type'] + $result->{$type}[$prop] + $temp[$dir] + $temp[$dir] + $this->requestBuffer[$request_id]['packet'] + $this->requestBuffer[$request_id]['packet_type'] + + + $attr[$key] + $temp[$dir] + $temp[$dir] + + + $attr[$key] + $contents[$shortname] + $this->extensions[$key] + $this->requestBuffer[$packet_id] + $this->requestBuffer[$request_id] + + + $a[$sort] + $attr + $attr + $attr + $attr + $attr + $attr[$key] + $attributes['type'] + $b[$sort] + $depth + $depth + $dir + $dir + $dir + $dir + $fileType + $filename + $filename + $filename + $filename + $filename + $key + $length + $link + $link + $newname + $offset + $oldname + $order + $path + $path + $path + $props + $props + $remote_file + $remote_file + $res_offset + $response + $response + $response + $result + $result + $result + $result + $result + $result + $result + $size + $size + $size + $size + $subtemp + $temp + $temp + $temp + $temp + $temp + $temp + $temp + $temp[$dir] + $temp['extensions'] + $this->packet_type + $this->pwd + $this->queueSize + $this->uploadQueueSize + $type + $value + $value + + + array + array|false + array|false + bool + int + string + string + string|bool + + + $a[$sort] + $a[$sort] + $attr + $attr + $attr + $attr + $attr + $b[$sort] + $b[$sort] + $content + $depth + $depth + $key + $key + $length + $offset + $res_offset + $shortname + $shortname + $size + $size + $start + $subtemp + $temp + $temp + $this->realpath($dir . '/..') + $value + $value + $value + $value + $value + + + $result['.']->lstat + $result['.']->stat + + + $attr + $content ?? true + $order === SORT_ASC ? $a[$sort] - $b[$sort] : $b[$sort] - $a[$sort] + $result + $result->lstat + $result->stat + $result['.']->lstat + $result['.']->stat + $temp + count($this->sftp_errors) ? $this->sftp_errors[count($this->sftp_errors) - 1] : '' + + + $attr + $attr + $attr + $attr + $attr + $fp + $fp + $packet + $packet + $packet + $this->server_identifier + pack('Na*', strlen($handle), $handle) + pack('Na*', strlen($path), $path) + unpack('Nlength', Strings::shift($this->packet_buffer, 4)) + unpack('Npacket_id', Strings::shift($this->packet_buffer, 4)) + + + $attr + $this->pwd + + + false + false + + + $data + $data + $data + $data + $data + $local_file + $local_file + + + $stat['atime'] + $stat['atime'] + $stat['atime'] + $stat['mtime'] + $stat['mtime'] + $stat['mtime'] + $stat['size'] + $this->stat($remote_file)['size'] + + + $data + $data + $data + $data + $data + + + $fp + $fp + preg_replace('#/(?=/)|/$#', '', $dir) + preg_replace('#^/|/(?=/)|/$#', '', $path) + preg_replace('#^/|/(?=/)|/$#', '', $path) + preg_replace('#^/|/(?=/)|/$#', '', $path) + + + $dirs[0] + $this->channel_status[self::CHANNEL] + $this->server_channels[self::CHANNEL] + + + $a['filename'] + $a['filename'] + $a['filename'] + $a['filename'] + $a['filename'] + $attrs['mode'] + $b['filename'] + $b['filename'] + $b['filename'] + $b['filename'] + $stat['atime'] + $stat['atime'] + $stat['atime'] + $stat['mtime'] + $stat['mtime'] + $stat['mtime'] + $stat['size'] + $stat['size'] + $stat['type'] + $this->stat($remote_file)['size'] + + + $attr + $attr + $attr + $attr + $attr + $attr + $attr + $attr + $content + $content + $fp + $fp + $longname + $result + + + chgrp + chown + clearStatCache + disableArbitraryLengthPackets + disableDatePreservation + disablePathCanonicalization + enableArbitraryLengthPackets + enableDatePreservation + enablePathCanonicalization + enableStatCache + file_exists + fileatime + filegroup + filemtime + fileowner + fileperms + filetype + get + getLastSFTPError + getNegotiatedVersion + getSFTPErrors + getSFTPLog + getSupportedVersions + is_dir + is_file + is_link + is_readable + is_writeable + rawlist + readlink + rename + rmdir + setListOrder + setPreferredVersion + symlink + touch + truncate + + + bool + + + $defaultVersion + $version + + + (int) $ver + + + $fileType !== false + $this->version < 4 && $fileType !== false + + + !is_string($path) + is_int($filename) + is_object($path) + is_string($mode) + is_string($mode) && is_int($filename) + + + break; + + + $key + + + bool + int + + + $attrib_bits + $attrib_bits_valid + $flag + $mask + $packet + $response + $response + $response + $temp + $text_hint + $type + $value + $who + + + + + $path === false + $path === false + $path === false + $path === false + $path === false + $path === false + $path === false + $path_from === false + + + false + false + false + false + false + + + bool + + + $var + + + _dir_readdir + _stream_read + + + $host + $host + $host + $orig + $orig + $pass + $pass + $port + $result + $result + $user + $user + + + $context[$scheme] + $context[$scheme] + $context[$scheme] + $context[$scheme] + $var[0] + $var[1] + self::$instances[$host][$port] + self::$instances[$host][$port] + + + $context[$scheme] + $context[$scheme] + $context[$scheme] + $context[$scheme] + $context[$scheme] + $context[$scheme] + $context[$scheme] + $context[$scheme] + $context[$scheme] + self::$instances[$host][$port] + self::$instances[$host][$port] + + + $argument + $atime + $pass + $pass + $result + $result + $results + $results + $sftp + $sftp + $this->entries + $this->notification + $this->pos + $this->sftp + $this->size + $time + $user + + + bool + bool + bool + bool + bool + resource + string + + + chgrp + chmod + chown + delete + delete + filesize + get + lstat + mkdir + nlist + put + rename + rename + rmdir + stat + stat + stat + touch + touch + truncate + truncate + + + $fragment + $path + $path + $path + $path + $query + + + $path + $path + $results + $results + $this->sftp->chgrp($path, $var) + $this->sftp->chown($path, $var) + $this->sftp->delete($path, false) + $this->sftp->fsock + $this->sftp->mkdir($path, $mode, $options & STREAM_MKDIR_RECURSIVE) + $this->sftp->rmdir($path) + $this->sftp->touch($path, $time, $atime) + + + parse_url($path) + + + $path1['path'] + $path2['path'] + $path_to['path'] + + + $host + + + $this->mode[0] + $this->mode[0] + $this->mode[0] + + + preg_replace('#[bt]$#', '', $mode) + + + $path_to['path'] + + + __call + __construct + + + $path + + + $instances + + + $context + $entries + $eof + $mode + $notification + $path + $pos + $sftp + $size + + + isset($this->notification) && is_callable($this->notification) + isset($this->notification) && is_callable($this->notification) + isset($this->notification) && is_callable($this->notification) + isset($this->notification) && is_callable($this->notification) + + + isset($this->notification) + isset($this->notification) + + + $arg1 + $arg2 + $cast_as + $operation + $option + $options + $options + + + + + $arg instanceof Agent + $arg instanceof PrivateKey || $arg instanceof Agent + $request_channel === false + $this->session_id === false + is_array($arg) + is_array($arg) + is_array($arg) + is_null($this->exit_status) + + + false + false + + + self::$crypto_engine + self::$crypto_engine + true + + + $payload[0] + + + int + string + + + bool|SSH2 + + + array{Hash, int}|null + string + + + $algorithm + $host + $password + $timeout + + + $curTimeout + $keepAlive + $quiet_mode + $realtime_log_wrap + $timeout + + + connect + get_channel_packet + + + $a['comp'] + $a['crypt'] + $a['mac'] + $aad + $auth + $auth_methods + $c2s_compression_algorithms + $c2s_compression_algorithms + $c2s_encryption_algorithms + $c2s_encryption_algorithms + $c2s_mac_algorithms + $c2s_mac_algorithms + $c2s_mac_algorithms + $channel + $current_log + $data + $decrypt + $encrypt + $error_message + $extra + $filename + $gBytes + $gBytes + $kex_algorithms + $kex_algorithms + $key + $keyBytes + $keyBytes + $keyBytes + $length + $length + $m + $m + $mac_algorithm_in + $mac_algorithm_in + $mac_algorithm_out + $mac_algorithm_out + $matches[0] + $matches[3] + $max_size + $nonce + $ourPublicBytes + $p + $p + $packet + $packet[0] + $password + $password + $payload + $payload[0] + $preferred['hostkey'] + $preferred['kex'] + $primeBytes + $primeBytes + $prompt + $raw + $reason_code + $reconstructed + $remaining_length + $responses[$i] + $s2c_compression_algorithms + $s2c_compression_algorithms + $s2c_encryption_algorithms + $s2c_encryption_algorithms + $s2c_mac_algorithms + $s2c_mac_algorithms + $s2c_mac_algorithms + $server_channel + $server_host_key_algorithms + $server_host_key_algorithms + $server_public_host_key + $signature + $signature + $skip_channel_filter + $skip_channel_filter + $stop - $start + $temp + $temp + $temp['length'] + $theirPublicBytes + $theirPublicBytes + $this->channel_buffers[$client_channel] + $this->compression_algorithms_client_to_server + $this->compression_algorithms_server_to_client + $this->curTimeout + $this->curTimeout + $this->curTimeout == 0 ? 100000 : $this->curTimeout + $this->encryption_algorithms_client_to_server + $this->encryption_algorithms_server_to_client + $this->keepAlive + $this->keepAlive + $this->kex_algorithm + $this->kex_algorithm + $this->kex_algorithm + $this->kex_algorithm + $this->kex_algorithm + $this->kex_algorithms + $this->mac_algorithms_client_to_server + $this->mac_algorithms_server_to_client + $this->message_number_log[count($this->message_number_log) - 1] + $this->preferred['hostkey'] + $this->server_channels[$client_channel] + $this->server_channels[$request_channel] + $this->server_channels[self::CHANNEL_EXEC] + $this->server_channels[self::CHANNEL_EXEC] + $this->server_channels[self::CHANNEL_SHELL] + $this->server_channels[self::CHANNEL_SHELL] + $this->server_channels[self::CHANNEL_SUBSYSTEM] + $this->server_host_key_algorithms + $this->server_public_host_key + $this->signature + $type + $type + $type + array_shift($this->channel_buffers[$client_channel]) + array_shift($this->message_log) + + + $diff + $key + + + $a['comp'] + $a['crypt'] + $a['mac'] + $keyBytes[0] + $m[$subkey] + $matches[0] + $matches[1] + $matches[3] + $matches[3] + $packet[0] + $this->channel_buffers[$client_channel][$i] + + + $a['comp'] + $a['crypt'] + $a['mac'] + $this->channel_buffers[$channel][] + $this->channel_buffers[$channel][] + $this->channel_buffers[$channel][] + + + $compression_map[$compression_algorithm_in] + $compression_map[$compression_algorithm_out] + $this->channel_buffers[$channel] + $this->channel_buffers[$channel] + $this->channel_buffers[$channel] + $this->channel_buffers[$client_channel][$i] + $this->channel_status[$channel] + $this->channel_status[$channel] + $this->channel_status[$channel] + $this->channel_status[$channel] + $this->server_channels[$channel] + $this->server_channels[$channel] + $this->server_channels[$channel] + $this->server_channels[$channel] + $this->window_size_client_to_server[$channel] + $this->window_size_client_to_server[$channel] + $this->window_size_server_to_client[$channel] + $this->window_size_server_to_client[$channel] + $this->window_size_server_to_client[$channel] + + + $a + $algo + $auth + $c2s_compression_algorithms + $c2s_encryption_algorithms + $c2s_mac_algorithms + $compression_algorithm_in + $compression_algorithm_out + $current_log + $curveName + $decrypt + $encrypt + $expected_key_format + $extra + $filename + $i + $kex_algorithms + $key + $keyBytes + $length + $m + $mac_algorithm_in + $mac_algorithm_out + $max_size + $method + $newargs[] + $ourPublicBytes + $p + $packet + $privatekey + $privatekey + $privatekey + $privatekey + $publickey + $reconstructed + $response + $response + $response + $responses[] + $result + $s2c_compression_algorithms + $s2c_encryption_algorithms + $s2c_mac_algorithms + $server_host_key_algorithm + $server_host_key_algorithms + $signature + $temp + $temp + $temp[$key] + $this->auth_methods_to_continue + $this->auth_methods_to_continue + $this->auth_methods_to_continue + $this->auth_methods_to_continue + $this->auth_methods_to_continue + $this->hmac_check_name + $this->hmac_check_name + $this->hmac_create_name + $this->hmac_create_name + $this->kex_algorithm + $this->last_interactive_response + $this->server_public_host_key + $value + $value + $value + $window_size + $window_size + + + bool + boolean + string|bool|null + + + decrypt + encrypt + getCurve + getEncodedCoordinates + setNonce + setNonce + sign + withHash + + + $curveName + $data + $data + $data + $data + $elapsed + $keyBytes + $keyBytes[0] + $message + $message_number_log[$i] + $raw + $raw + $raw + $raw + $response + $server_host_key_algorithm + $stop + $temp + $temp + $temp + $temp + $temp + $this->curTimeout + $this->curTimeout + $this->curTimeout + $this->curTimeout + $this->curTimeout + $this->curTimeout + $this->curTimeout + $this->errors[count($this->errors) - 1] + $this->window_size_client_to_server[$channel] + $this->window_size_client_to_server[$client_channel] + $this->window_size_server_to_client[$channel] + $this->window_size_server_to_client[$channel] + $window_size + $window_size + + + $result + $this->errors[$count - 1] + $this->get_channel_packet($channel) + $this->quiet_mode + + + $temp + $this->errors + array<string, SSH2> + string[] + + + self::$connections[$id] instanceof \WeakReference ? self::$connections[$id]->get() : self::$connections[$id] + + + $data + $logged + $nonce + $packet + $packet + $packet + $packet + $packet + $packet + $packet + $packet + $packet + $packet + $packet + $payload + $payload + $raw + $raw + $raw + $raw + $raw + $raw + $raw + $reconstructed + $tag + $tag + $this->server_host_key_algorithms + $this->server_identifier + pack('C', MessageType::REQUEST_FAILURE) + pack('CN', MessageType::CHANNEL_CLOSE, $this->server_channels[$channel]) + pack('CN', MessageType::CHANNEL_CLOSE, $this->server_channels[$channel]) + pack('CN', MessageType::CHANNEL_CLOSE, $this->server_channels[$client_channel]) + pack('CN', MessageType::CHANNEL_CLOSE, $this->server_channels[$client_channel]) + pack('CN', MessageType::CHANNEL_EOF, $this->server_channels[$client_channel]) + pack('CN', MessageType::CHANNEL_EOF, $this->server_channels[$client_channel]) + pack('CN', MessageType::CHANNEL_SUCCESS, $this->server_channels[$channel]) + pack('CN', MessageType::IGNORE, 0) + pack('CN', MessageType::IGNORE, 0) + pack('Na*', $this->get_seq_no, $reconstructed) + pack('Na*', $this->send_seq_no, $packet) + pack('Na*', $this->send_seq_no, $packet) + unpack('Npacket_length', $temp = Strings::shift($raw, 4)) + unpack('Npacket_length', $temp) + unpack('Npacket_length', $temp) + unpack('Npacket_length/Cpadding_length', Strings::shift($raw, 5)) + unpack('cpacket_type/Nchannel/Nlength', $payload) + + + $dh_group_sizes_packed + $kexinit_payload_client + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $keyBytes + $logged + $packet + $packet + deflate_add($this->compress_context, $data, ZLIB_PARTIAL_FLUSH) + ftell($this->realtime_log_file) + pack('N', $this->get_seq_no) + pack('N', $this->send_seq_no) + pack('N', $this->send_seq_no) + + + $fp + $this->hmac_create = false + @fsockopen($this->host, $this->port, $errno, $errstr, $this->curTimeout == 0 ? 100000 : $this->curTimeout) + false + false + false + false + false + false + false + false + false + false + false + inflate_init(ZLIB_ENCODING_RAW, ['window' => $cinfo + 8]) + + + $args + $engine + $response + $response + $response + $response + $response + $response + $response + $response + $response + $response + $response + $this->decompress_context + $this->fsock + $this->fsock + + + $temp['length'] + + + $args + + + $this->decryptInvocationCounter + $this->encryptInvocationCounter + array_shift($this->message_log) + + + $raw + $this->decryptFixedPart + $this->decryptInvocationCounter + $this->encryptFixedPart + $this->encryptInvocationCounter + + + self::encryption_algorithm_to_crypt_instance($decrypt) + self::encryption_algorithm_to_crypt_instance($decrypt) + self::encryption_algorithm_to_crypt_instance($encrypt) + self::encryption_algorithm_to_crypt_instance($encrypt) + + + decrypt + encrypt + getLengthInBytes + isValidEngine + setKey + setKey + setNonce + usesNonce + usesNonce + + + $matches[0] + $this->server_channels[self::CHANNEL_EXEC] + $this->server_channels[self::CHANNEL_EXEC] + $this->server_channels[self::CHANNEL_SHELL] + $this->server_channels[self::CHANNEL_SUBSYSTEM] + + + get + + + $temp['length'] + + + $elapsed + $matches + $matches + $matches + $matches + $orig + $result + $temp + + + disableSmartMFA + enableSmartMFA + getAlgorithmsNegotiated + getAuthMethodsToContinue + getBannerMessage + getErrors + getLastError + getLog + getServerAlgorithms + getStdError + getWindowColumns + getWindowRows + ping + reset + sendIdentificationStringFirst + sendIdentificationStringLast + sendKEXINITFirst + sendKEXINITLast + setCryptoEngine + setKeepAlive + setPreferredAlgorithms + setTerminal + setWindowColumns + setWindowRows + setWindowSize + startSubsystem + stopSubsystem + + + $preferred_signature_format + + + ($callback is callable ? bool : string|bool) + + + $agent + $decompress_context + $exit_status + $hmac_check_etm + $hmac_check_name + $hmac_create_etm + $hmac_create_name + $host + $identifier + $in_subsystem + $last_packet + $log_size + $port + $realtime_log_file + $realtime_log_size + $server_public_host_key + $stdErrorLog + + + $this->session_id !== false + Strings::is_stringable($arg) + is_bool($agent_response) + isset($this->keyboard_requests_responses) + isset($this->realtime_log_file) && is_resource($this->realtime_log_file) + + + isset($this->agent) + isset($this->agent) + isset($this->realtime_log_file) + isset($this->realtime_log_file) + + + $payload + $payload + $payload + $payload + $payload + $payload + $payload + $response + $response + $response + $response + $response + $response + + + MessageType::findConstantNameByValue($value = ord($logged[0]), false) + + + $callback === false + $hasArray + $hasString + + + withPadding + withSignatureFormat + withSignatureFormat + + + verify + + + break; + + + integer + integer + integer + + + $a + $data_type_code + $first_kex_packet_follows + $key + $response + $server_cookie + + + + + !$this->fsock + $this->fsock + + + false + pack('Na*', $agent_reply_bytes, $agent_reply_data) + + + string + + + $address + + + $agent_reply_bytes + $agent_reply_data + $key + $key_blob + $key_blob + $length + $packet + $temp + $this->readBytes(4) + $this->readBytes(4) + + + $address + $address + $agent_data_bytes + $agent_reply_bytes + $agent_reply_data + $agent_reply_data + $length + $packet + $temp + $this->expected_bytes + + + $address + $agent_data_bytes + $agent_data_bytes + $key_type + + + $packet + $packet + unpack('N', $data) + unpack('N', $this->readBytes(4)) + unpack('N', $this->readBytes(4)) + unpack('a*', $agent_reply_data) + + + fsockopen('unix://' . $address, 0, $errno, $errstr) + + + startSSHForwarding + + + \phpseclib3\System\SSH\Agent + + + $request_channel + + + $request_channel + + + bool + + + $comment + + + + + $length + $packet + $signature_blob + $this->readBytes(4) + + + $length + $packet + + + string + + + self::$curveAliases[$this->key->getCurve()] + + + $signature_blob + $signature_blob + + + unpack('N', $this->readBytes(4)) + + + self::$curveAliases[$this->key->getCurve()] + + + getCurve + withHash + withPadding + withSignatureFormat + + + $key + $key_blob + + + $type + + + + + readBytes + + + $temp + $temp + + + + + ini_get('mbstring.func_overload') + + + ini_get('mbstring.func_overload') + + + + + SFTPLargeFileTest + SFTPLargeFileTest + SFTPLargeFileTest + + + SFTPLargeFileTest + + + + + $read + + + $this->sftp->pwd() + + + $suffix + + + $suffix + + + $dirs + $fp + $fp + $fp + $this->sftp->nlist() + + + SFTPStreamTest + SFTPStreamTest + SFTPStreamTest + + + SFTPStreamTest + + + + + $scratchDir + + + $this->scratchDir + + + $this->sftp + $this->sftp + + + + + $length + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + $sftp + + + $buffer + $exampleData + $exampleDataLength + $scratchDir + + + demoCallback + testChDirOnFile + testChDirScratch + testChDirUpHome + testChModOnFile + testDeleteEmptyDir + testDeleteRecursiveScratch + testExecNlist + testFileExistsIsFileIsDirDir + testFileExistsIsFileIsDirFile + testFileExistsIsFileIsDirFileNonexistent + testLinkFile + testMkDirScratch + testPasswordLogin + testPutSizeGetFile + testPutSizeGetFileCallback + testPwdHome + testRawlistDisabledStatCache + testReadableWritable + testReadlink + testResourceXfer + testRmDirScratch + testRmDirScratchNonexistent + testSortOrder + testStatLstatCache + testStatOnCWD + testStatOnDir + testStatVsLstat + testStatcacheFix + testSymlink + testTouch + testTruncate + testTruncateLargeFile + testUploadOffsets + + + $length + $pwd + $sftp->pwd() + $sftp->pwd() + self::$buffer + self::$exampleData + self::$scratchDir + self::$scratchDir + self::$scratchDir + + + $stat2['gid'] + $stat2['uid'] + $stat['gid'] + $stat['gid'] + $stat['type'] + $stat['type'] + $stat['type'] + $stat['type'] + $stat['type'] + $stat['type'] + $stat['type'] + $stat['type'] + $stat['uid'] + $stat['uid'] + + + $cur_size + $dirname + $file + $files + $last_size + $list + $list + $list_cache_disabled + $list_cache_enabled + $lstat + $lstat + $pwd + $stat + $stat + $stat + $stat + $stat + $stat + $stat + $stat + $stat + $stat + $stat + $stat2 + self::$buffer + + + chdir + chdir + chdir + chdir + chdir + chdir + chdir + chdir + chdir + chgrp + chmod + chmod + chmod + chown + clearStatCache + clearStatCache + clearStatCache + delete + delete + delete + disableStatCache + disableStatCache + enablePTY + enableStatCache + exec + file_exists + file_exists + file_exists + file_exists + file_exists + filesize + filesize + filesize + filesize + filesize + filesize + get + get + get + get + get + get + get + is_dir + is_dir + is_dir + is_dir + is_dir + is_dir + is_file + is_file + is_file + is_file + is_file + is_file + is_file + is_link + is_readable + is_readable + is_readable + is_writable + is_writable + is_writable + is_writeable + is_writeable + is_writeable + login + lstat + lstat + lstat + lstat + lstat + lstat + mkdir + mkdir + mkdir + mkdir + mkdir + mkdir + mkdir + mkdir + mkdir + nlist + nlist + nlist + nlist + nlist + nlist + put + put + put + put + put + put + put + put + put + pwd + pwd + pwd + pwd + pwd + rawlist + rawlist + readlink + rmdir + rmdir + setListOrder + setListOrder + setListOrder + stat + stat + stat + stat + stat + stat + stat + stat + stat + stat + stat + symlink + symlink + symlink + touch + touch + touch + touch + truncate + truncate + + + self::$exampleData + self::$exampleDataLength + self::$exampleDataLength + self::$scratchDir + + + $fp + $fp + + + SFTPUserStoryTest + SFTPUserStoryTest + + + SFTPUserStoryTest + + + + + SFTPWrongServerTest + SFTPWrongServerTest + + + SFTPWrongServerTest + + + + + $args + + + testAgentForward + + + $ssh->exec("ssh " . $username . "@" . $hostname . ' \'whoami\'') + $ssh->exec('whoami') + + + $args['ssh'] + $args['ssh-agent'] + + + $agent + $ssh + + + exec + exec + startSSHForwarding + + + SSH2AgentTest + SSH2AgentTest + + + SSH2AgentTest + + + + + 'stdClass' + + + setMethods + + + [$callbackObject, 'callbackMethod'] + + + $ssh->getServerIdentification() + + + $matches[1] + $matches[1] + + + SSH2Test + SSH2Test + + + SSH2Test + + + + + $variable + $variable + + + _getEnv + + + string + + + $variable + + + $this->_getEnv($variable) + + + null + + + + + parent::assertRegExp($pattern, $string, $message) + + + $filename + + + $haystack + $haystack + + + string + + + $actual + $actual + $actual + $actual + $expected + $func + $obj + $obj + $params + $var + + + $tempFilesToUnlinkOnTearDown + + + callFunc + getVar + + + $expected + $expected + $filename + $filename + $func + $obj + $obj + $obj + $obj + $params + $value + $var + + + $this->tempFilesToUnlinkOnTearDown[$filename] + + + $this->tempFilesToUnlinkOnTearDown[] + + + $this->tempFilesToUnlinkOnTearDown[$filename] + + + $filename + $value + + + $filename + $filename + $filename + $fp + $fp + + + null + + + + + EvalTest + EvalTest + + + EvalTest + + + + + McryptTest + McryptTest + + + McryptTest + + + + + OpenSSLTest + OpenSSLTest + + + OpenSSLTest + + + + + PurePHPTest + PurePHPTest + + + PurePHPTest + + + + + 'LengthException' + + + $aes + $iv + $key + $mode + $mode + $mode + $op + $op + $plaintext + $test + $test + + + $engine + + + $c1 + $c1 + $iv + $key + $len + $len + $len + $len + $mode + $mode + $mode + $plaintext + $this->engine + $this->engine + $this->engine + $this->engine + $this->engine + $this->engine + $this->engine + $this->engine + $this->engine + $this->engine + + + $c1 + $c1 + $len + $len + $len + $len + $output + $output + + + getEngine + + + $output + $output + $this->engine + + + pack('H*', '00000000000000000000000000000000' . '00000000000000000000000000000000') + pack('H*', '00000000000000000000000000000000') + pack('H*', '00000000000000000000000000000000') + pack('H*', '00000000000000000000000000000000') + pack('H*', '00000000000000000000000000000000') + pack('H*', '000000000000000000000000000000000000000000000000') + pack('H*', '00d596e2c8189b2592fac358e7396ad2') + pack('H*', '014730f80ac625fe84f026c60bfd547d') + pack('H*', '0457bdb4a6712986688349a29eb82535') + pack('H*', '0457bdb4a6712986688349a29eb82535') + pack('H*', '0b24af36193ce4665f2825d7b4749c98') + pack('H*', '1b077a6af4b7f98229de786d7516b639') + pack('H*', '26aa49dcfe7629a8901a69a9914e6dfd') + pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160') + pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160') + pack('H*', '3243f6a8885a308d313198a2e0370734') + pack('H*', '3243f6a8885a308d313198a2e0370734') + pack('H*', '51719783d3185a535bd75adc65071ce1') + pack('H*', '58c8e00b2631686d54eab84b91f0aca1') + pack('H*', '6a118a874519e64e9963798a503f1d35') + pack('H*', '761c1fe41a18acf20d241650611d90f1') + pack('H*', '8a560769d605868ad80d819bdba03771') + pack('H*', '91fbef2d15a97816060bee1feaa49afe') + pack('H*', '941a4773058224e1ef66d10e0a6ee782') + pack('H*', '96ab5c2ff612d9dfaae8c31f30c42168') + pack('H*', '9798c4640bad75c7c3227db910174e72') + pack('H*', '9aa234ea7c750a8109a0f32d768b964e') + pack('H*', '9c2d8842e5f48f57648205d39a239af1') + pack('H*', 'b26aeb1874e47ca8358ff22378f09144') + pack('H*', 'bff52510095f518ecca60af4205444bb') + pack('H*', 'cb9fceec81286ca3e989bd979b0cb284') + pack('H*', 'f34481ec3cc627bacd5dc3fb08f273e6') + + + continuousBufferBatteryCombosWithoutSingleCombos + continuousBufferCombos + testContinuousBuffer + testContinuousBufferBattery + testECBDecrypt + testEncryptDecryptWithContinuousBuffer + testGFSBox128 + testGFSBox192 + testGFSBox256 + testGetKeyLengthDefault + testGetKeyLengthWith192BitKey + testKeyPaddingAES + testKeyPaddingRijndael + testNoKey + testNonContinuousBufferBattery + testSetKeyLengthWithLargerKey + testSetKeyLengthWithSmallerKey + + + + + $engine + $expected + $key + $plaintext + + + $engine + $key + $plaintext + + + BlowfishTest + BlowfishTest + + + BlowfishTest + + + + + $actual + $result + $result + + + $aad + $key + $nonce + $nonce + $nonce + + + ChaCha20Test + ChaCha20Test + + + ChaCha20Test + + + $result + + + + + $ourPriv + + + $theirPub + $theirPublic + + + $alicePublic + $alicePublic + $alicePublic->toString('MontgomeryPublic') + $alicePublic->toString('MontgomeryPublic') + $bobPublic + $bobPublic + $bobPublic->toString('MontgomeryPublic') + $bobPublic->toString('MontgomeryPublic') + $key + $key + $secrets[$i] + $theirPub + $theirPublic + + + $alicePublic + $alicePublic + $bobPublic + $bobPublic + $key + $key + $ourEphemeralPublic + $secrets[$i] + $secrets[$i] + $theirPub + $theirPublic + + + toString + toString + toString + toString + toString + + + $ourEphemeralPublic->toString('MontgomeryPublic') + + + pack('H*', '5dab087e624a8a4b79e17f8b83800ee66f3bb1292618b6fd1c2f8b27ff88e0eb') + pack('H*', '77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a') + + + $secrets[0] + + + DHTest + DHTest + + + getPublicKey + getPublicKey + getPublicKey + getPublicKey + + + DHTest + + + + + 160 + 512 + + + $params + + + testCreateParameters + + + $params + + + CreateKeyTest + CreateKeyTest + + + CreateKeyTest + + + + + $dsa + $sig + + + toString + toString + toString + + + preg_replace('#\s#', '', $key) + preg_replace('#\s#', '', $pkcs8) + + + LoadDSAKeyTest + LoadDSAKeyTest + + + sign + verify + + + LoadDSAKeyTest + + + + + $dsa + $dsa + $dsa + $dsa + $dsa + $dsa + $dsa + $public + $public + $signature + $signature + $signature1 + $signature2 + + + getPublicKey + sign + sign + sign + sign + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + withHash + withHash + withSignatureFormat + withSignatureFormat + + + SignatureTest + SignatureTest + + + withSignatureFormat + withSignatureFormat + withSignatureFormat + withSignatureFormat + + + SignatureTest + + + + + $class + 'phpseclib3\Crypt\EC\Formats\Keys\PKCS8' + + + new $class() + new $class() + + + $name + $name + $name + $name + $name + $name + + + $name + $name + $name + $sig = $privateKey->sign("\x03") + $sig = $privateKey->sign("\x03") + $sig = $privateKey->sign("\x72") + $sig = $privateKey->sign("\xaf\x82") + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign($message) + $sig = $privateKey->sign('') + $sig = $privateKey->sign('') + + + $QA + $curve + $dA + $oid + $privateKey + $privatekey + $public + $publicKey + $publickey + $publickey + $publickey + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $sig + $signature + $signature1 + $signature1 + $signature2 + $signature2 + + + createRandomMultiplier + getBasePoint + getBasePoint + getPublicKey + multiplyPoint + sign + sign + verify + verify + verify + verify + verify + verify + verify + verify + verify + verifyPoint + verifyPoint + + + $name + $name + + + $private + $private + $private + $private + $private + $private + $private + $public + $public + $public + $public + $public + $public + $public + $public + $public + $public + $public + $public + $public + $public + $public + + + $private + $private + $private + $private + $private + $private + $private + $private + $public + $public + $public + $public + $public + $public + $public + $public + + + CurveTest + CurveTest + + + getPublicKey + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + sign + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + verify + withContext + withContext + + + CurveTest + + + $oid + + + + + $components['dA'] + + + $key + $password + + + load + + + + + $key + $password + + + load + + + + + $key->toString('XML') + 'RangeException' + + + $actual + $expected + $message + + + $actual + $expected + $message + + + $sig + $sig + $sig2 + + + getCurve + getCurve + getCurve + sign + verify + + + $raw + + + KeyTest + KeyTest + + + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getCurve + getPublicKey + getPublicKey + getPublicKey + sign + sign + verify + verify + withSignatureFormat + withSignatureFormat + + + KeyTest + + + $private + + + + + $aad + $aad + $ciphertext + $ciphertext + $engine + $engine + $key + $key + $nonce + $nonce + $plaintext + $plaintext + $tag + $tag + + + $aad + $aad + $ciphertext + $ciphertext + $engine + $engine + $key + $key + $nonce + $nonce + $plaintext + $plaintext + $tag + $tag + + + GCMTest + GCMTest + + + GCMTest + + + + + $algo + $algorithm + $error + $expected + $expected + $hash + $hash + $hash + $hash + $hash + $hash + $key + $key + $key + $length + $message + $message + $message + $message + $message + $message + $message + $result + $result + $result + $result + $tag + + + $algo + $algorithm + $error + $expected + $expected + $hash + $hash + $hash + $hash + $key + $key + $message + $message + $message + $result + $result + + + $hash + $hash + $hash + + + HashTest + HashTest + + + HashTest + + + + + $ciphertext + $engine + $key + $keyLen + $plaintext + + + $engines + + + $engine + $keyLen + + + $engine + + + pack('H*', $ciphertext) + pack('H*', $key) + pack('H*', $plaintext) + + + RC2Test + RC2Test + + + RC2Test + + + + + $engine + $expected + $key + $offset + + + $engine + $key + $offset + 16 + + + $offset + + + RC4Test + RC4Test + + + new RC4(RC4::MODE_CTR) + new RC4(RC4::MODE_CTR) + new RC4(RC4::MODE_CTR) + + + RC4Test + + + + + $args + + + $key + $r['primes'] + $r['primes'] + $rsa->getPublicKey()->toString('PKCS1') + + + $privatekey + $publickey + + + $actual + $ciphertext + $key + $plaintext + $prime + $signature + list($publickey, $privatekey) + + + decrypt + encrypt + getLength + toString + toString + + + $r['primes'] + $r['primes'] + PKCS8::extractEncryptionAlgorithm($key)['algorithm'] + + + CreateKeyTest + CreateKeyTest + + + getPublicKey + getPublicKey + getPublicKey + sign + verify + withPassword + + + CreateKeyTest + + + $i + + + + + false + + + $key + + + $key + $pass + + + $encryptedKey + $key + $key + $pass + $pass + $pass + $pass + $r['meta']['algorithm'] + $r['meta']['cipher'] + $r['meta']['prf'] + $rsa->sign('zzzz') + + + $key['d'] + $key['e'] + $key['n'] + $key['primes'] + $key['primes'] + $r2['meta']['algorithm'] + $r2['meta']['cipher'] + $r2['meta']['prf'] + $r['meta']['algorithm'] + $r['meta']['algorithm'] + $r['meta']['cipher'] + $r['meta']['prf'] + + + $encryptedKey + $key + $key2 + $rsa + $rsa + $rsa2 + $sig + + + sign + toString + toString + toString + withPadding + + + $key + $raw + hex2bin($key) + + + $ciphertext + + + $raw['comment'] + + + $key + $key + $orig + preg_replace('#\s#', '', $key) + preg_replace('#\s#', '', $newkey) + + + $r2['MGFHash'] + $r2['hash'] + $r2['meta'] + $r2['meta'] + $r2['meta'] + $r2['saltLength'] + $r['MGFHash'] + $r['hash'] + $r['meta'] + $r['meta']['algorithm'] + $r['meta']['prf'] + $r['saltLength'] + $raw['comment'] + + + LoadKeyTest + LoadKeyTest + + + RSA::load($key, false, 'PKCS8') + + + asPrivateKey + sign + verify + withMGFHash + withPassword + withPassword + withPassword + + + LoadKeyTest + + + + + 'LengthException' + + + $rsa->decrypt($result) + + + $ciphertext + $result + $rsa + $rsa + $rsa + $rsa + $rsa + $rsa + $rsa + $rsa + $rsa + $rsa + + + decrypt + decrypt + encrypt + encrypt + getHash + getHash + getMGFHash + getMGFHash + getPublicKey + getSaltLength + getSaltLength + sign + verify + verify + verify + verify + verify + withHash + withHash + withMGFHash + withMGFHash + withMGFHash + withMGFHash + withPadding + withSaltLength + + + base64_decode('158753FF2AF4D1E5BBAB574D5AE6B54D') + base64_decode('272435F22706FA96DE26E980D22DFF67') + + + ModeTest + ModeTest + + + decrypt + encrypt + getPublicKey + withLabel + withLabel + withMGFHash + withPadding + withPadding + withPadding + withSaltLength + withSaltLength + withSaltLength + + + ModeTest + + + + + $length + $x + + + $length + + + RandomTest + RandomTest + + + RandomTest + + + + + $engine + $expected + $iv + $key + + + $engine + $key + + + pack('H*', $iv) + pack('H*', $key) + + + Salsa20Test + Salsa20Test + + + Salsa20Test + + + + + $engine + $engine + $expected + $expected + $iv + $key + $key + $plaintext + $plaintext + + + $engines + + + $engine + $engine + $engine + $iv + $key + $key + $plaintext + $plaintext + + + $engine + $engine + + + base64_decode($key) + + + TripleDESTest + TripleDESTest + + + TripleDESTest + + + + + $key + $key + $key + $plaintext + $plaintext + $plaintext + $plaintext + $plaintext + $plaintext + + + TwofishTest + TwofishTest + + + TwofishTest + + + + + $lines[22] + + + ANSITest + ANSITest + + + ANSITest + + + + + $a[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'][1]['content'][0]['content'] + + + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + $decoded[0]['content'] + + + $a + $data + $em + $em + $em + $em + $em + $em + $em + $em + $em + $orig + base64_decode($str) + base64_decode($str) + base64_decode($str) + base64_decode('MBaAFJtUo7c00HsI5EPZ4bkICfkOY2Pv') + file_get_contents(dirname(__FILE__) . '/ASN1/FE.pdf.p7m') + + + base64_decode('MD6gJQYKKwYBBAGCNxQCA6AXDBVvZmZpY2VAY2VydGRpZ2l0YWwucm+BFW9mZmljZUBjZXJ0ZGlnaXRhbC5ybw==') + + + $a[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + $decoded[0] + + + ASN1Test + ASN1Test + + + ASN1Test + + + + + $test + + + CRLTest + CRLTest + + + CRLTest + + + + + $rsa + $x509->signCSR() + $x509->signCSR() + + + $csr + $csr + $rsa + $spkac + + + getPadding + getPadding + getPadding + getPadding + withHash + + + $x509->getPublicKey()->getPadding() + $x509->getPublicKey()->getPadding() + $x509->getPublicKey()->getPadding() + $x509->getPublicKey()->getPadding() + + + $csr + + + CSRTest + CSRTest + + + withPadding + + + CSRTest + + + + + $privatekey + $privatekey + + + $spkac + $spkac + $spkac + + + $spkac['publicKeyAndChallenge'] + + + $spkac['publicKeyAndChallenge'] + + + $pubKey + $spkac + $spkac + $spkac + $spkac + $spkac + + + SPKACTest + SPKACTest + + + SPKACTest + + + + + 'phpseclib3\Math\BigInteger' + + + $privateKey + + + $authority->sign($issuer, $subject) + $publicKey + $result + $subjectKey + + + $customExtensionDecodedData['list'] + $customExtensionDecodedData['name'] + $customExtensionDecodedData['num'] + $customExtensionDecodedData['num'] + $customExtensionDecodedData['toggle'] + $decodedData['tbsCertificate'] + $extension['extnId'] + $extension['extnValue'] + $loader->loadX509($cert)['tbsCertificate'] + + + $customExtensionDecodedData + $decodedData + $extension + $publicKey + $result + $subjectKey + + + $customExtensionDecodedData['list'] + $customExtensionDecodedData['name'] + $customExtensionDecodedData['num'] + $customExtensionDecodedData['num'] + $customExtensionDecodedData['toggle'] + + + X509ExtensionTest + X509ExtensionTest + + + getPublicKey + + + X509ExtensionTest + + + + + $private + $private + $private + $private + $privatekey + + + $cakey + $cert + $cert['signatureAlgorithm'] + $cert['tbsCertificate']['signature'] + $cert['tbsCertificate']['subjectPublicKeyInfo']['algorithm'] + $crt + $decoded + $newcert->sign($ca, $oldcert) + $privKey + $private + $private->getPublicKey() + $pubKey + $public + $public + $public + $public + $publickey + $r + $r['signatureAlgorithm'] + $r['tbsCertificate']['signature'] + $r['tbsCertificate']['subjectPublicKeyInfo']['algorithm'] + $result + $result + $result + $result + $result + $result['tbsCertificate']['extensions'] + + + $cert['signatureAlgorithm'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $cert['tbsCertificate'] + $r['signatureAlgorithm'] + $r['signatureAlgorithm'] + $r['signatureAlgorithm'] + $r['signatureAlgorithm'] + $r['signatureAlgorithm'] + $r['signatureAlgorithm'] + $r['signatureAlgorithm'] + $r['signatureAlgorithm'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $r['tbsCertificate'] + $result['tbsCertificate'] + + + $cert['tbsCertificate'] + + + $authorityKeyIdentifier + $authorityKeyIdentifier + $cakey + $cert + $cert + $cert + $cert + $cert + $cert + $cert + $crt + $decoded + $privKey + $private + $pubKey + $public + $public + $public + $public + $publickey + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $r + $result + $result + $result + $result + $result + $result + + + getPublicKey + getPublicKey + withHash + withHash + withHash + + + $a + + + X509Test + X509Test + + + getPublicKey + getPublicKey + getPublicKey + getPublicKey + getPublicKey + withPadding + withPadding + withPadding + + + X509Test + + + $cert + + + + + 'DefaultEngine' + + + $base + $x + + + $base + + + BCMathTest + BCMathTest + + + 'DefaultEngine' + + + BCMathTest + + + + + $base + $x + + + $base + $x + + + DefaultTest + DefaultTest + + + DefaultTest + + + + + 'DefaultEngine' + + + $base + $x + + + $base + + + GMPTest + GMPTest + + + 'DefaultEngine' + + + GMPTest + + + + + 'DefaultEngine' + + + $base + $x + + + $base + + + PHP32Test + PHP32Test + + + 'DefaultEngine' + + + PHP32Test + + + + + 'OpenSSL' + + + $base + $x + + + $base + + + PHP64OpenSSLTest + PHP64OpenSSLTest + + + 'OpenSSL' + + + PHP64OpenSSLTest + + + + + 'DefaultEngine' + + + $base + $x + + + $base + + + PHP64Test + PHP64Test + + + 'DefaultEngine' + + + PHP64Test + + + + + $r + + + $arr['gcd'] + $arr['x'] + $arr['y'] + $q + $q + $q + $q + $r + $r + $r + $r + + + $a + $a + $a + $a + $a + $a + $a + $a + $a + $a + $a + $alicePrivate + $alicePublic + $aliceShared + $arr + $b + $b + $b + $b + $b + $b + $b + $b + $b + $b + $bigInteger + $bigInteger + $bigInteger + $bigInteger + $bigInteger + $bigInteger + $bobPrivate + $bobPublic + $bobShared + $c + $c + $c + $c + $c + $c + $class + $class + $class + $class + $d + $d + $d + $e + $generator + $max + $max + $max + $min + $min + $min + $n + $n + $num + $prime + $prime + $r + $rand1 + $temp + $temp + $temp + $three + $two + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x + $x2 + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $y + $z + $z + $z + $z + $z + $z + list($q, $r) + list($q, $r) + list($q, $r) + list($q, $r) + + + clone $a + clone $x + + + $class::max($max, $min) + $class::max($min, $max) + $class::min($max, $min) + $class::min($min, $max) + $class::randomPrime(128) + $class::randomRange($min, $max) + abs + add + add + bitwise_AND + bitwise_LeftShift + bitwise_NOT + bitwise_OR + bitwise_OR + bitwise_OR + bitwise_RightShift + bitwise_RightShift + bitwise_RightShift + bitwise_XOR + bitwise_not + bitwise_xor + bitwise_xor + compare + compare + compare + compare + compare + compare + compare + compare + compare + compare + compare + divide + divide + divide + divide + equals + equals + equals + equals + equals + equals + equals + equals + equals + equals + equals + equals + extendedGCD + gcd + getLength + getPrecision + getPrecision + getPrecision + getPrecision + modInverse + modPow + modPow + modPow + modPow + modPow + multiply + multiply + multiply + pow + pow + powMod + root + root + setPrecision + setPrecision + subtract + toBits + toBits + toBits + toBytes + toBytes + toBytes + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toHex + toString + toString + toString + toString + toString + toString + toString + toString + toString + toString + toString + toString + + + $a->toString() + $b->toString() + + + test48ToHex + testAbs + testAdd + testBitwiseAND + testBitwiseLeftShift + testBitwiseNOT + testBitwiseOR + testBitwiseRightShift + testBitwiseXOR + testClone + testCompare + testConstructorBase10 + testConstructorBase16 + testConstructorBase2 + testConstructorBase256 + testDebugInfo + testDiffieHellmanKeyAgreement + testDivide + testEquals + testExtendedGCD + testGCD + testMax + testMin + testModInverse + testModPow + testMultiply + testNegativePrecision + testPow + testPrecision + testRandomPrime + testRandomTwoArgument + testRoot + testSerializable + testSlidingWindow + testSubtract + testToBits + testToBytes + testToBytesTwosCompliment + testToHex + testZeroBase10 + testZeros + + + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + getInstance + static::getStaticClass() + static::getStaticClass() + static::getStaticClass() + static::getStaticClass() + + + $q + + + + + $engine[0] + $engine[1] + + + $engine[0] + + + $engine[0] + $engine[1] + + + BigIntegerTest + BigIntegerTest + + + BigIntegerTest + + + + + SFTPStreamUnitTest + SFTPStreamUnitTest + + + SFTPStreamUnitTest + + + + + 'phpseclib3\Net\SSH2' + + + setMethods + + + + \phpseclib3\Net\SSH2 + + + $expected + + + $identifier + + + $identifier + $result + + + SSH2UnitTest + SSH2UnitTest + + + SSH2UnitTest + diff --git a/composer.json b/composer.json index 0f40d7c0..96c10082 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "asn1", "asn.1", "BigInteger" - ], + ], "homepage": "http://phpseclib.sourceforge.net", "license": "MIT", "authors": [ @@ -51,9 +51,8 @@ } ], "require": { - "php": ">=5.6.1", - "paragonie/constant_time_encoding": "^1|^2", - "paragonie/random_compat": "^1.4|^2.0|^9.99.99" + "php": ">=7.1", + "paragonie/constant_time_encoding": "^2" }, "require-dev": { "phpunit/phpunit": "*" diff --git a/phpseclib/Common/ConstantUtilityTrait.php b/phpseclib/Common/ConstantUtilityTrait.php index 3d54d169..b1b33536 100644 --- a/phpseclib/Common/ConstantUtilityTrait.php +++ b/phpseclib/Common/ConstantUtilityTrait.php @@ -1,5 +1,7 @@ = 0; $i--) { @@ -361,11 +337,8 @@ abstract class Strings /** * Increment the current string - * - * @param string $var - * @return string */ - public static function increment_str(&$var) + public static function increment_str(string &$var): string { if (function_exists('sodium_increment')) { $var = strrev($var); @@ -406,11 +379,9 @@ abstract class Strings /** * Find whether the type of a variable is string (or could be converted to one) * - * @param mixed $var - * @return bool * @psalm-assert-if-true string|\Stringable $var */ - public static function is_stringable($var) + public static function is_stringable($var): bool { return is_string($var) || (is_object($var) && method_exists($var, '__toString')); } diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 40387162..17ab2490 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -45,6 +45,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; /** @@ -59,11 +61,10 @@ class AES extends Rijndael * * Since \phpseclib3\Crypt\AES extends \phpseclib3\Crypt\Rijndael, this function is, technically, available, but it doesn't do anything. * - * @see \phpseclib3\Crypt\Rijndael::setBlockLength() - * @param int $length * @throws \BadMethodCallException anytime it's called + *@see \phpseclib3\Crypt\Rijndael::setBlockLength() */ - public function setBlockLength($length) + public function setBlockLength(int $length): void { throw new \BadMethodCallException('The block length cannot be set for AES.'); } @@ -73,11 +74,10 @@ class AES extends Rijndael * * Valid key lengths are 128, 192, and 256. Set the link to bool(false) to disable a fixed key length * - * @see \phpseclib3\Crypt\Rijndael:setKeyLength() - * @param int $length * @throws \LengthException if the key length isn't supported + *@see \phpseclib3\Crypt\Rijndael:setKeyLength() */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { switch ($length) { case 128: @@ -95,12 +95,11 @@ class AES extends Rijndael * * Rijndael supports five different key lengths, AES only supports three. * + * @throws \LengthException if the key length isn't supported * @see \phpseclib3\Crypt\Rijndael:setKey() * @see setKeyLength() - * @param string $key - * @throws \LengthException if the key length isn't supported */ - public function setKey($key) + public function setKey(string $key): void { switch (strlen($key)) { case 16: diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 530ca231..62abe52d 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -33,6 +33,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\BlockCipher; @@ -273,10 +275,9 @@ class Blowfish extends BlockCipher /** * Default Constructor. * - * @param string $mode * @throws \InvalidArgumentException if an invalid / unsupported mode is provided */ - public function __construct($mode) + public function __construct(string $mode) { parent::__construct($mode); @@ -289,10 +290,8 @@ class Blowfish extends BlockCipher * Sets the key length. * * Key lengths can be between 32 and 448 bits. - * - * @param int $length */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { if ($length < 32 || $length > 448) { throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys of sizes between 32 and 448 bits are supported'); @@ -308,11 +307,9 @@ class Blowfish extends BlockCipher * * This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() * - * @see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() - * @param int $engine - * @return bool + *@see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { if ($engine == self::ENGINE_OPENSSL) { if (version_compare(PHP_VERSION, '5.3.7') < 0 && $this->key_length != 16) { @@ -333,7 +330,7 @@ class Blowfish extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupKey() */ - protected function setupKey() + protected function setupKey(): void { if (isset($this->kl['key']) && $this->key === $this->kl['key']) { // already expanded @@ -370,13 +367,13 @@ class Blowfish extends BlockCipher // encrypt P3 and P4 with the new P1 and P2, do it with all P-array and subkeys $data = "\0\0\0\0\0\0\0\0"; for ($i = 0; $i < 18; $i += 2) { - list($l, $r) = array_values(unpack('N*', $data = $this->encryptBlock($data))); + [$l, $r] = array_values(unpack('N*', $data = $this->encryptBlock($data))); $this->bctx['p'][$i ] = $l; $this->bctx['p'][$i + 1] = $r; } for ($i = 0; $i < 4; ++$i) { for ($j = 0; $j < 256; $j += 2) { - list($l, $r) = array_values(unpack('N*', $data = $this->encryptBlock($data))); + [$l, $r] = array_values(unpack('N*', $data = $this->encryptBlock($data))); $this->bctx['sb'][$i][$j ] = $l; $this->bctx['sb'][$i][$j + 1] = $r; } @@ -385,11 +382,8 @@ class Blowfish extends BlockCipher /** * Encrypts a block - * - * @param string $in - * @return string */ - protected function encryptBlock($in) + protected function encryptBlock(string $in): string { $p = $this->bctx['p']; // extract($this->bctx['sb'], EXTR_PREFIX_ALL, 'sb'); // slower @@ -418,11 +412,8 @@ class Blowfish extends BlockCipher /** * Decrypts a block - * - * @param string $in - * @return string */ - protected function decryptBlock($in) + protected function decryptBlock(string $in): string { $p = $this->bctx['p']; $sb_0 = $this->bctx['sb'][0]; @@ -453,7 +444,7 @@ class Blowfish extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupInlineCrypt() */ - protected function setupInlineCrypt() + protected function setupInlineCrypt(): void { $p = $this->bctx['p']; $init_crypt = ' diff --git a/phpseclib/Crypt/ChaCha20.php b/phpseclib/Crypt/ChaCha20.php index e080d8fc..151fe9eb 100644 --- a/phpseclib/Crypt/ChaCha20.php +++ b/phpseclib/Crypt/ChaCha20.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Exception\BadDecryptionException; @@ -35,11 +37,9 @@ class ChaCha20 extends Salsa20 * * This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() * - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @param int $engine - * @return bool + *@see \phpseclib3\Crypt\Common\SymmetricKey::__construct() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { switch ($engine) { case self::ENGINE_LIBSODIUM: @@ -73,12 +73,11 @@ class ChaCha20 extends Salsa20 /** * Encrypts a message. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() - * @see self::crypt() - * @param string $plaintext * @return string $ciphertext + *@see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() + * @see self::crypt() */ - public function encrypt($plaintext) + public function encrypt(string $plaintext): string { $this->setup(); @@ -95,12 +94,11 @@ class ChaCha20 extends Salsa20 * $this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)). * At least if the continuous buffer is disabled. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() - * @see self::crypt() - * @param string $ciphertext * @return string $plaintext + *@see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() + * @see self::crypt() */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext): string { $this->setup(); @@ -114,11 +112,10 @@ class ChaCha20 extends Salsa20 /** * Encrypts a message with libsodium * - * @see self::encrypt() - * @param string $plaintext * @return string $text + *@see self::encrypt() */ - private function encrypt_with_libsodium($plaintext) + private function encrypt_with_libsodium(string $plaintext): string { $params = [$plaintext, $this->aad, $this->nonce, $this->key]; $ciphertext = strlen($this->nonce) == 8 ? @@ -140,11 +137,10 @@ class ChaCha20 extends Salsa20 /** * Decrypts a message with libsodium * - * @see self::decrypt() - * @param string $ciphertext * @return string $text + *@see self::decrypt() */ - private function decrypt_with_libsodium($ciphertext) + private function decrypt_with_libsodium(string $ciphertext): string { $params = [$ciphertext, $this->aad, $this->nonce, $this->key]; @@ -177,10 +173,8 @@ class ChaCha20 extends Salsa20 /** * Sets the nonce. - * - * @param string $nonce */ - public function setNonce($nonce) + public function setNonce(string $nonce): void { if (!is_string($nonce)) { throw new \UnexpectedValueException('The nonce should be a string'); @@ -224,7 +218,7 @@ class ChaCha20 extends Salsa20 * @see self::setNonce() * @see self::disableContinuousBuffer() */ - protected function setup() + protected function setup(): void { if (!$this->changed) { return; @@ -267,13 +261,8 @@ class ChaCha20 extends Salsa20 /** * The quarterround function - * - * @param int $a - * @param int $b - * @param int $c - * @param int $d */ - protected static function quarterRound(&$a, &$b, &$c, &$d) + protected static function quarterRound(int &$a, int &$b, int &$c, int &$d): void { // in https://datatracker.ietf.org/doc/html/rfc7539#section-2.1 the addition, // xor'ing and rotation are all on the same line so i'm keeping it on the same @@ -306,7 +295,7 @@ class ChaCha20 extends Salsa20 * @param int $x14 (by reference) * @param int $x15 (by reference) */ - protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15) + protected static function doubleRound(int &$x0, int &$x1, int &$x2, int &$x3, int &$x4, int &$x5, int &$x6, int &$x7, int &$x8, int &$x9, int &$x10, int &$x11, int &$x12, int &$x13, int &$x14, int &$x15): void { // columnRound static::quarterRound($x0, $x4, $x8, $x12); @@ -332,12 +321,10 @@ class ChaCha20 extends Salsa20 * For comparison purposes, RC4 takes 0.16s and AES in CTR mode with the Eval engine takes 0.48s. * AES in CTR mode with the PHP engine takes 1.19s. Salsa20 / ChaCha20 do not benefit as much from the Eval * approach due to the fact that there are a lot less variables to de-reference, fewer loops to unroll, etc - * - * @param string $x */ - protected static function salsa20($x) + protected static function salsa20(string $x) { - list(, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15) = unpack('V*', $x); + [, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15] = unpack('V*', $x); $z0 = $x0; $z1 = $x1; $z2 = $x2; diff --git a/phpseclib/Crypt/Common/AsymmetricKey.php b/phpseclib/Crypt/Common/AsymmetricKey.php index f0e7e79a..17016ea5 100644 --- a/phpseclib/Crypt/Common/AsymmetricKey.php +++ b/phpseclib/Crypt/Common/AsymmetricKey.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common; use phpseclib3\Crypt\DSA; @@ -109,10 +111,8 @@ abstract class AsymmetricKey private $comment; /** - * @param string $type - * @return string */ - abstract public function toString($type, array $options = []); + abstract public function toString(string $type, array $options = []): string; /** * The constructor @@ -128,7 +128,7 @@ abstract class AsymmetricKey /** * Initialize static variables */ - protected static function initialize_static_variables() + protected static function initialize_static_variables(): void { if (!isset(self::$zero)) { self::$zero = new BigInteger(0); @@ -144,11 +144,10 @@ abstract class AsymmetricKey /** * Load the key * - * @param string $key + * @param string|array $key * @param string $password optional - * @return AsymmetricKey */ - public static function load($key, $password = false) + public static function load($key, $password = false): AsymmetricKey { self::initialize_static_variables(); @@ -172,7 +171,7 @@ abstract class AsymmetricKey } $components['format'] = $format; - $comment = isset($components['comment']) ? $components['comment'] : null; + $comment = $components['comment'] ?? null; $new = static::onLoad($components); $new->format = $format; $new->comment = $comment; @@ -184,11 +183,10 @@ abstract class AsymmetricKey /** * Loads a private key * - * @return PrivateKey * @param string|array $key * @param string $password optional */ - public static function loadPrivateKey($key, $password = '') + public static function loadPrivateKey($key, string $password = ''): PrivateKey { $key = self::load($key, $password); if (!$key instanceof PrivateKey) { @@ -200,10 +198,9 @@ abstract class AsymmetricKey /** * Loads a public key * - * @return PublicKey * @param string|array $key */ - public static function loadPublicKey($key) + public static function loadPublicKey($key): PublicKey { $key = self::load($key); if (!$key instanceof PublicKey) { @@ -215,10 +212,9 @@ abstract class AsymmetricKey /** * Loads parameters * - * @return AsymmetricKey * @param string|array $key */ - public static function loadParameters($key) + public static function loadParameters($key): AsymmetricKey { $key = self::load($key); if (!$key instanceof PrivateKey && !$key instanceof PublicKey) { @@ -230,12 +226,10 @@ abstract class AsymmetricKey /** * Load the key, assuming a specific format * - * @param string $type - * @param string $key * @param string $password optional * @return static */ - public static function loadFormat($type, $key, $password = false) + public static function loadFormat(string $type, string $key, $password = false): AsymmetricKey { self::initialize_static_variables(); @@ -262,12 +256,9 @@ abstract class AsymmetricKey /** * Loads a private key * - * @return PrivateKey - * @param string $type - * @param string $key * @param string $password optional */ - public static function loadPrivateKeyFormat($type, $key, $password = false) + public static function loadPrivateKeyFormat(string $type, string $key, $password = false): PrivateKey { $key = self::loadFormat($type, $key, $password); if (!$key instanceof PrivateKey) { @@ -278,12 +269,8 @@ abstract class AsymmetricKey /** * Loads a public key - * - * @return PublicKey - * @param string $type - * @param string $key */ - public static function loadPublicKeyFormat($type, $key) + public static function loadPublicKeyFormat(string $type, string $key): PublicKey { $key = self::loadFormat($type, $key); if (!$key instanceof PublicKey) { @@ -295,11 +282,9 @@ abstract class AsymmetricKey /** * Loads parameters * - * @return AsymmetricKey - * @param string $type * @param string|array $key */ - public static function loadParametersFormat($type, $key) + public static function loadParametersFormat(string $type, $key): AsymmetricKey { $key = self::loadFormat($type, $key); if (!$key instanceof PrivateKey && !$key instanceof PublicKey) { @@ -311,12 +296,9 @@ abstract class AsymmetricKey /** * Validate Plugin * - * @param string $format - * @param string $type - * @param string $method optional - * @return mixed + * @param string|null $method optional */ - protected static function validatePlugin($format, $type, $method = null) + protected static function validatePlugin(string $format, string $type, string $method = null) { $type = strtolower($type); if (!isset(self::$plugins[static::ALGORITHM][$format][$type])) { @@ -332,10 +314,8 @@ abstract class AsymmetricKey /** * Load Plugins - * - * @param string $format */ - private static function loadPlugins($format) + private static function loadPlugins(string $format): void { if (!isset(self::$plugins[static::ALGORITHM][$format])) { self::$plugins[static::ALGORITHM][$format] = []; @@ -362,10 +342,8 @@ abstract class AsymmetricKey /** * Returns a list of supported formats. - * - * @return array */ - public static function getSupportedKeyFormats() + public static function getSupportedKeyFormats(): array { self::initialize_static_variables(); @@ -378,11 +356,9 @@ abstract class AsymmetricKey * The plugin needs to either already be loaded or be auto-loadable. * Loading a plugin whose shortname overwrite an existing shortname will overwrite the old plugin. * - * @see self::load() - * @param string $fullname - * @return bool + *@see self::load() */ - public static function addFileFormat($fullname) + public static function addFileFormat(string $fullname): void { self::initialize_static_variables(); @@ -403,9 +379,8 @@ abstract class AsymmetricKey * with RSA::createKey() then this will throw an exception. * * @see self::load() - * @return mixed */ - public function getLoadedFormat() + public function getLoadedFormat(): string { if (empty($this->format)) { throw new NoKeyLoadedException('This key was created with createKey - it was not loaded with load. Therefore there is no "loaded format"'); @@ -419,19 +394,16 @@ abstract class AsymmetricKey * Returns the key's comment * * Not all key formats support comments. If you want to set a comment use toString() - * - * @return null|string */ - public function getComment() + public function getComment(): ?string { return $this->comment; } /** * Tests engine validity - * */ - public static function useBestEngine() + public static function useBestEngine(): array { static::$engines = [ 'PHP' => true, @@ -447,9 +419,8 @@ abstract class AsymmetricKey /** * Flag to use internal engine only (useful for unit testing) - * */ - public static function useInternalEngine() + public static function useInternalEngine(): void { static::$engines = [ 'PHP' => true, @@ -470,10 +441,8 @@ abstract class AsymmetricKey /** * Determines which hashing function should be used - * - * @param string $hash */ - public function withHash($hash) + public function withHash(string $hash): AsymmetricKey { $new = clone $this; @@ -485,9 +454,8 @@ abstract class AsymmetricKey /** * Returns the hash algorithm currently being used - * */ - public function getHash() + public function getHash(): Hash { return clone $this->hash; } @@ -496,10 +464,9 @@ abstract class AsymmetricKey * Compute the pseudorandom k for signature generation, * using the process specified for deterministic DSA. * - * @param string $h1 * @return string */ - protected function computek($h1) + protected function computek(string $h1) { $v = str_repeat("\1", strlen($h1)); @@ -539,11 +506,8 @@ abstract class AsymmetricKey /** * Integer to Octet String - * - * @param \phpseclib3\Math\BigInteger $v - * @return string */ - private function int2octets($v) + private function int2octets(BigInteger $v): string { $out = $v->toBytes(); $rolen = $this->q->getLengthInBytes(); @@ -558,11 +522,8 @@ abstract class AsymmetricKey /** * Bit String to Integer - * - * @param string $in - * @return \phpseclib3\Math\BigInteger */ - protected function bits2int($in) + protected function bits2int(string $in): BigInteger { $v = new BigInteger($in, 256); $vlen = strlen($in) << 3; @@ -575,11 +536,8 @@ abstract class AsymmetricKey /** * Bit String to Octet String - * - * @param string $in - * @return string */ - private function bits2octets($in) + private function bits2octets(string $in): string { $z1 = $this->bits2int($in); $z2 = $z1->subtract($this->q); diff --git a/phpseclib/Crypt/Common/BlockCipher.php b/phpseclib/Crypt/Common/BlockCipher.php index b2642be1..2c685861 100644 --- a/phpseclib/Crypt/Common/BlockCipher.php +++ b/phpseclib/Crypt/Common/BlockCipher.php @@ -12,6 +12,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common; /** diff --git a/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php index 87a0b6fe..7711cf39 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -43,10 +45,8 @@ abstract class OpenSSH /** * Sets the default comment - * - * @param string $comment */ - public static function setComment($comment) + public static function setComment(string $comment): void { self::$comment = str_replace(["\r", "\n"], '', $comment); } @@ -56,11 +56,10 @@ abstract class OpenSSH * * $type can be either ssh-dss or ssh-rsa * - * @param string $key - * @param string $password - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -76,7 +75,7 @@ abstract class OpenSSH if ($magic != "openssh-key-v1\0") { throw new \RuntimeException('Expected openssh-key-v1'); } - list($ciphername, $kdfname, $kdfoptions, $numKeys) = Strings::unpackSSH2('sssN', $key); + [$ciphername, $kdfname, $kdfoptions, $numKeys] = Strings::unpackSSH2('sssN', $key); if ($numKeys != 1) { // if we wanted to support multiple keys we could update PublicKeyLoader to preview what the # of keys // would be; it'd then call Common\Keys\OpenSSH.php::load() and get the paddedKey. it'd then pass @@ -114,9 +113,9 @@ abstract class OpenSSH //list($salt, $rounds) = Strings::unpackSSH2('sN', $kdfoptions); } - list($publicKey, $paddedKey) = Strings::unpackSSH2('ss', $key); - list($type) = Strings::unpackSSH2('s', $publicKey); - list($checkint1, $checkint2) = Strings::unpackSSH2('NN', $paddedKey); + [$publicKey, $paddedKey] = Strings::unpackSSH2('ss', $key); + [$type] = Strings::unpackSSH2('s', $publicKey); + [$checkint1, $checkint2] = Strings::unpackSSH2('NN', $paddedKey); // any leftover bytes in $paddedKey are for padding? but they should be sequential bytes. eg. 1, 2, 3, etc. if ($checkint1 != $checkint2) { throw new \RuntimeException('The two checkints do not match'); @@ -130,18 +129,18 @@ abstract class OpenSSH if (!isset($parts[1])) { $key = base64_decode($parts[0]); - $comment = isset($parts[1]) ? $parts[1] : false; + $comment = $parts[1] ?? false; } else { $asciiType = $parts[0]; self::checkType($parts[0]); $key = base64_decode($parts[1]); - $comment = isset($parts[2]) ? $parts[2] : false; + $comment = $parts[2] ?? false; } if ($key === false) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); } - list($type) = Strings::unpackSSH2('s', $key); + [$type] = Strings::unpackSSH2('s', $key); self::checkType($type); if (isset($asciiType) && $asciiType != $type) { throw new \RuntimeException('Two different types of keys are claimed: ' . $asciiType . ' and ' . $type); @@ -160,20 +159,16 @@ abstract class OpenSSH * * Printable keys are what are generated by default. These are the ones that go in * $HOME/.ssh/authorized_key. - * - * @param bool $enabled */ - public static function setBinaryOutput($enabled) + public static function setBinaryOutput(bool $enabled): void { self::$binary = $enabled; } /** * Checks to see if the type is valid - * - * @param string $candidate */ - private static function checkType($candidate) + private static function checkType(string $candidate): void { if (!in_array($candidate, static::$types)) { throw new \RuntimeException("The key type ($candidate) is not equal to: " . implode(',', static::$types)); @@ -183,21 +178,17 @@ abstract class OpenSSH /** * Wrap a private key appropriately * - * @param string $publicKey - * @param string $privateKey - * @param string $password - * @param array $options - * @return string + * @param string|false $password */ - protected static function wrapPrivateKey($publicKey, $privateKey, $password, $options) + protected static function wrapPrivateKey(string $publicKey, string $privateKey, $password, array $options): string { if (!empty($password) && is_string($password)) { throw new UnsupportedFormatException('Encrypted OpenSSH private keys are not supported'); } - list(, $checkint) = unpack('N', Random::string(4)); + [, $checkint] = unpack('N', Random::string(4)); - $comment = isset($options['comment']) ? $options['comment'] : self::$comment; + $comment = $options['comment'] ?? self::$comment; $paddedKey = Strings::packSSH2('NN', $checkint, $checkint) . $privateKey . Strings::packSSH2('s', $comment); diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS.php index 0219400b..5ebb2034 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Formats\Keys; /** @@ -43,18 +45,16 @@ abstract class PKCS /** * Require base64-encoded PEM's be supplied - * */ - public static function requirePEM() + public static function requirePEM(): void { self::$format = self::MODE_PEM; } /** * Require raw DER's be supplied - * */ - public static function requireDER() + public static function requireDER(): void { self::$format = self::MODE_DER; } @@ -63,9 +63,8 @@ abstract class PKCS * Accept any format and auto detect the format * * This is the default setting - * */ - public static function requireAny() + public static function requireAny(): void { self::$format = self::MODE_ANY; } diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php index c7094f63..c6d56f7c 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -39,10 +41,8 @@ abstract class PKCS1 extends PKCS /** * Sets the default encryption algorithm - * - * @param string $algo */ - public static function setEncryptionAlgorithm($algo) + public static function setEncryptionAlgorithm(string $algo): void { self::$defaultEncryptionAlgorithm = $algo; } @@ -50,11 +50,10 @@ abstract class PKCS1 extends PKCS /** * Returns the mode constant corresponding to the mode string * - * @param string $mode * @return int * @throws \UnexpectedValueException if the block cipher mode is unsupported */ - private static function getEncryptionMode($mode) + private static function getEncryptionMode(string $mode) { switch ($mode) { case 'CBC': @@ -70,17 +69,16 @@ abstract class PKCS1 extends PKCS /** * Returns a cipher object corresponding to a string * - * @param string $algo - * @return string + * @return AES|DES|TripleDES * @throws \UnexpectedValueException if the encryption algorithm is unsupported */ - private static function getEncryptionObject($algo) + private static function getEncryptionObject(string $algo) { $modes = '(CBC|ECB|CFB|OFB|CTR)'; switch (true) { case preg_match("#^AES-(128|192|256)-$modes$#", $algo, $matches): $cipher = new AES(self::getEncryptionMode($matches[2])); - $cipher->setKeyLength($matches[1]); + $cipher->setKeyLength((int) $matches[1]); return $cipher; case preg_match("#^DES-EDE3-$modes$#", $algo, $matches): return new TripleDES(self::getEncryptionMode($matches[1])); @@ -93,13 +91,8 @@ abstract class PKCS1 extends PKCS /** * Generate a symmetric key for PKCS#1 keys - * - * @param string $password - * @param string $iv - * @param int $length - * @return string */ - private static function generateSymmetricKey($password, $iv, $length) + private static function generateSymmetricKey(string $password, string $iv, int $length): string { $symkey = ''; $iv = substr($iv, 0, 8); @@ -112,11 +105,11 @@ abstract class PKCS1 extends PKCS /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password + * @return array|string */ - protected static function load($key, $password) + protected static function load($key, $password = '') { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -166,13 +159,10 @@ abstract class PKCS1 extends PKCS /** * Wrap a private key appropriately * - * @param string $key - * @param string $type - * @param string $password + * @param string|false $password * @param array $options optional - * @return string */ - protected static function wrapPrivateKey($key, $type, $password, array $options = []) + protected static function wrapPrivateKey(string $key, string $type, $password, array $options = []): string { if (empty($password) || !is_string($password)) { return "-----BEGIN $type PRIVATE KEY-----\r\n" . @@ -180,7 +170,7 @@ abstract class PKCS1 extends PKCS "-----END $type PRIVATE KEY-----"; } - $encryptionAlgorithm = isset($options['encryptionAlgorithm']) ? $options['encryptionAlgorithm'] : self::$defaultEncryptionAlgorithm; + $encryptionAlgorithm = $options['encryptionAlgorithm'] ?? self::$defaultEncryptionAlgorithm; $cipher = self::getEncryptionObject($encryptionAlgorithm); $iv = Random::string($cipher->getBlockLength() >> 3); @@ -197,12 +187,8 @@ abstract class PKCS1 extends PKCS /** * Wrap a public key appropriately - * - * @param string $key - * @param string $type - * @return string */ - protected static function wrapPublicKey($key, $type) + protected static function wrapPublicKey(string $key, string $type): string { return "-----BEGIN $type PUBLIC KEY-----\r\n" . chunk_split(Base64::encode($key), 64) . diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php index e0b35820..b288ec51 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php @@ -23,11 +23,14 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Formats\Keys; use ParagonIE\ConstantTime\Base64; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\AES; +use phpseclib3\Crypt\Common\SymmetricKey; use phpseclib3\Crypt\DES; use phpseclib3\Crypt\Random; use phpseclib3\Crypt\RC2; @@ -86,40 +89,32 @@ abstract class PKCS8 extends PKCS /** * Sets the default encryption algorithm - * - * @param string $algo */ - public static function setEncryptionAlgorithm($algo) + public static function setEncryptionAlgorithm(string $algo): void { self::$defaultEncryptionAlgorithm = $algo; } /** * Sets the default encryption algorithm for PBES2 - * - * @param string $algo */ - public static function setEncryptionScheme($algo) + public static function setEncryptionScheme(string $algo): void { self::$defaultEncryptionScheme = $algo; } /** * Sets the iteration count - * - * @param int $count */ - public static function setIterationCount($count) + public static function setIterationCount(int $count): void { self::$defaultIterationCount = $count; } /** * Sets the PRF for PBES2 - * - * @param string $algo */ - public static function setPRF($algo) + public static function setPRF(string $algo): void { self::$defaultPRF = $algo; } @@ -127,10 +122,9 @@ abstract class PKCS8 extends PKCS /** * Returns a SymmetricKey object based on a PBES1 $algo * - * @return \phpseclib3\Crypt\Common\SymmetricKey - * @param string $algo + *@return \phpseclib3\Crypt\Common\SymmetricKey */ - private static function getPBES1EncryptionObject($algo) + private static function getPBES1EncryptionObject(string $algo) { $algo = preg_match('#^pbeWith(?:MD2|MD5|SHA1|SHA)And(.*?)-CBC$#', $algo, $matches) ? $matches[1] : @@ -175,11 +169,8 @@ abstract class PKCS8 extends PKCS /** * Returns a hash based on a PBES1 $algo - * - * @return string - * @param string $algo */ - private static function getPBES1Hash($algo) + private static function getPBES1Hash(string $algo): string { if (preg_match('#^pbeWith(MD2|MD5|SHA1|SHA)And.*?-CBC$#', $algo, $matches)) { return $matches[1] == 'SHA' ? 'sha1' : $matches[1]; @@ -190,11 +181,8 @@ abstract class PKCS8 extends PKCS /** * Returns a KDF baesd on a PBES1 $algo - * - * @return string - * @param string $algo */ - private static function getPBES1KDF($algo) + private static function getPBES1KDF(string $algo): string { switch ($algo) { case 'pbeWithMD2AndDES-CBC': @@ -211,11 +199,8 @@ abstract class PKCS8 extends PKCS /** * Returns a SymmetricKey object baesd on a PBES2 $algo - * - * @return SymmetricKey - * @param string $algo */ - private static function getPBES2EncryptionObject($algo) + private static function getPBES2EncryptionObject(string $algo): SymmetricKey { switch ($algo) { case 'desCBC': @@ -235,7 +220,7 @@ abstract class PKCS8 extends PKCS case 'aes192-CBC-PAD': case 'aes256-CBC-PAD': $cipher = new AES('cbc'); - $cipher->setKeyLength(substr($algo, 3, 3)); + $cipher->setKeyLength((int) substr($algo, 3, 3)); break; default: throw new UnsupportedAlgorithmException("$algo is not supported"); @@ -246,9 +231,8 @@ abstract class PKCS8 extends PKCS /** * Initialize static variables - * */ - private static function initialize_static_variables() + private static function initialize_static_variables(): void { if (!isset(static::$childOIDsLoaded)) { throw new InsufficientSetupException('This class should not be called directly'); @@ -310,18 +294,17 @@ abstract class PKCS8 extends PKCS /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - protected static function load($key, $password = '') + protected static function load($key, $password = ''): array { $decoded = self::preParse($key); $meta = []; $decrypted = ASN1::asn1map($decoded[0], Maps\EncryptedPrivateKeyInfo::MAP); - if (strlen($password) && is_array($decrypted)) { + if ($password !== false && strlen($password) && is_array($decrypted)) { $algorithm = $decrypted['encryptionAlgorithm']['algorithm']; switch ($algorithm) { // PBES1 @@ -486,16 +469,13 @@ abstract class PKCS8 extends PKCS /** * Wrap a private key appropriately * - * @param string $key - * @param string $attr - * @param mixed $params - * @param string $password - * @param string $oid optional + * @param array|string $attr + * @param string|false $password + * @param string|null $oid optional * @param string $publicKey optional * @param array $options optional - * @return string */ - protected static function wrapPrivateKey($key, $attr, $params, $password, $oid = null, $publicKey = '', array $options = []) + protected static function wrapPrivateKey(string $key, $attr, $params, $password, string $oid = null, string $publicKey = '', array $options = []): string { self::initialize_static_variables(); @@ -520,10 +500,10 @@ abstract class PKCS8 extends PKCS if (!empty($password) && is_string($password)) { $salt = Random::string(8); - $iterationCount = isset($options['iterationCount']) ? $options['iterationCount'] : self::$defaultIterationCount; - $encryptionAlgorithm = isset($options['encryptionAlgorithm']) ? $options['encryptionAlgorithm'] : self::$defaultEncryptionAlgorithm; - $encryptionScheme = isset($options['encryptionScheme']) ? $options['encryptionScheme'] : self::$defaultEncryptionScheme; - $prf = isset($options['PRF']) ? $options['PRF'] : self::$defaultPRF; + $iterationCount = $options['iterationCount'] ?? self::$defaultIterationCount; + $encryptionAlgorithm = $options['encryptionAlgorithm'] ?? self::$defaultEncryptionAlgorithm; + $encryptionScheme = $options['encryptionScheme'] ?? self::$defaultEncryptionScheme; + $prf = $options['PRF'] ?? self::$defaultPRF; if ($encryptionAlgorithm == 'id-PBES2') { $crypto = self::getPBES2EncryptionObject($encryptionScheme); @@ -598,13 +578,8 @@ abstract class PKCS8 extends PKCS /** * Wrap a public key appropriately - * - * @param string $key - * @param mixed $params - * @param string $oid - * @return string */ - protected static function wrapPublicKey($key, $params, $oid = null) + protected static function wrapPublicKey(string $key, $params, string $oid = null): string { self::initialize_static_variables(); @@ -625,11 +600,8 @@ abstract class PKCS8 extends PKCS /** * Perform some preliminary parsing of the key - * - * @param string $key - * @return array */ - private static function preParse(&$key) + private static function preParse(string &$key): array { self::initialize_static_variables(); @@ -656,11 +628,8 @@ abstract class PKCS8 extends PKCS /** * Returns the encryption parameters used by the key - * - * @param string $key - * @return array */ - public static function extractEncryptionAlgorithm($key) + public static function extractEncryptionAlgorithm(string $key): array { $decoded = self::preParse($key); diff --git a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php index 027774cc..8d86e9d9 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -46,20 +48,16 @@ abstract class PuTTY /** * Sets the default comment - * - * @param string $comment */ - public static function setComment($comment) + public static function setComment(string $comment): void { self::$comment = str_replace(["\r", "\n"], '', $comment); } /** * Sets the default version - * - * @param int $version */ - public static function setVersion($version) + public static function setVersion(int $version): void { if ($version != 2 && $version != 3) { throw new \RuntimeException('Only supported versions are 2 and 3'); @@ -69,12 +67,8 @@ abstract class PuTTY /** * Generate a symmetric key for PuTTY v2 keys - * - * @param string $password - * @param int $length - * @return string */ - private static function generateV2Key($password, $length) + private static function generateV2Key(string $password, int $length): string { $symkey = ''; $sequence = 0; @@ -87,15 +81,8 @@ abstract class PuTTY /** * Generate a symmetric key for PuTTY v3 keys - * - * @param string $password - * @param string $flavour - * @param int $memory - * @param int $passes - * @param string $salt - * @return array */ - private static function generateV3Key($password, $flavour, $memory, $passes, $salt) + private static function generateV3Key(string $password, string $flavour, int $memory, int $passes, string $salt): array { if (!function_exists('sodium_crypto_pwhash')) { throw new \RuntimeException('sodium_crypto_pwhash needs to exist for Argon2 password hasing'); @@ -125,9 +112,9 @@ abstract class PuTTY /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password - * @return array + * @param array|string $key + * @param string|false $password + * @return array|false */ public static function load($key, $password) { @@ -196,7 +183,7 @@ abstract class PuTTY $encryption = trim(preg_replace('#Encryption: (.+)#', '$1', $key[1])); $components['comment'] = trim(preg_replace('#Comment: (.+)#', '$1', $key[2])); - $publicLength = trim(preg_replace('#Public-Lines: (\d+)#', '$1', $key[3])); + $publicLength = (int) trim(preg_replace('#Public-Lines: (\d+)#', '$1', $key[3])); $public = Base64::decode(implode('', array_map('trim', array_slice($key, 4, $publicLength)))); $source = Strings::packSSH2('ssss', $type, $encryption, $components['comment'], $public); @@ -229,7 +216,7 @@ abstract class PuTTY $parallelism = trim(preg_replace('#Argon2-Parallelism: (\d+)#', '$1', $key[$offset++])); $salt = Hex::decode(trim(preg_replace('#Argon2-Salt: ([0-9a-f]+)#', '$1', $key[$offset++]))); - extract(self::generateV3Key($password, $flavour, $memory, $passes, $salt)); + extract(self::generateV3Key($password, $flavour, (int)$memory, (int)$passes, $salt)); break; case 2: @@ -249,7 +236,7 @@ abstract class PuTTY $hash->setKey(sha1($hashkey, true)); } - $privateLength = trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$offset++])); + $privateLength = (int) trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$offset++])); $private = Base64::decode(implode('', array_map('trim', array_slice($key, $offset, $privateLength)))); if ($encryption != 'none') { @@ -276,18 +263,14 @@ abstract class PuTTY /** * Wrap a private key appropriately * - * @param string $public - * @param string $private - * @param string $type - * @param string $password + * @param string|false $password * @param array $options optional - * @return string */ - protected static function wrapPrivateKey($public, $private, $type, $password, array $options = []) + protected static function wrapPrivateKey(string $public, string $private, string $type, $password, array $options = []): string { $encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none'; - $comment = isset($options['comment']) ? $options['comment'] : self::$comment; - $version = isset($options['version']) ? $options['version'] : self::$version; + $comment = $options['comment'] ?? self::$comment; + $version = $options['version'] ?? self::$version; $key = "PuTTY-User-Key-File-$version: $type\r\n"; $key .= "Encryption: $encryption\r\n"; @@ -359,12 +342,8 @@ abstract class PuTTY * Wrap a public key appropriately * * This is basically the format described in RFC 4716 (https://tools.ietf.org/html/rfc4716) - * - * @param string $key - * @param string $type - * @return string */ - protected static function wrapPublicKey($key, $type) + protected static function wrapPublicKey(string $key, string $type): string { $key = pack('Na*a*', strlen($type), $type, $key); $key = "---- BEGIN SSH2 PUBLIC KEY ----\r\n" . diff --git a/phpseclib/Crypt/Common/Formats/Signature/Raw.php b/phpseclib/Crypt/Common/Formats/Signature/Raw.php index ab8e7e46..6d6d3fdf 100644 --- a/phpseclib/Crypt/Common/Formats/Signature/Raw.php +++ b/phpseclib/Crypt/Common/Formats/Signature/Raw.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Formats\Signature; use phpseclib3\Math\BigInteger; @@ -27,10 +29,9 @@ abstract class Raw /** * Loads a signature * - * @param array $sig * @return array|bool */ - public static function load($sig) + public static function load(array $sig) { switch (true) { case !is_array($sig): @@ -48,12 +49,8 @@ abstract class Raw /** * Returns a signature in the appropriate format - * - * @param \phpseclib3\Math\BigInteger $r - * @param \phpseclib3\Math\BigInteger $s - * @return string */ - public static function save(BigInteger $r, BigInteger $s) + public static function save(BigInteger $r, BigInteger $s): string { return compact('r', 's'); } diff --git a/phpseclib/Crypt/Common/PrivateKey.php b/phpseclib/Crypt/Common/PrivateKey.php index a6e1eb0b..fd0b9d69 100644 --- a/phpseclib/Crypt/Common/PrivateKey.php +++ b/phpseclib/Crypt/Common/PrivateKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common; /** @@ -21,11 +23,10 @@ interface PrivateKey public function sign($message); //public function decrypt($ciphertext); public function getPublicKey(); - public function toString($type, array $options = []); + public function toString(string $type, array $options = []): string; /** * @param string|false $password - * @return mixed */ public function withPassword($password = false); } diff --git a/phpseclib/Crypt/Common/PublicKey.php b/phpseclib/Crypt/Common/PublicKey.php index 48a5875b..88ff2a10 100644 --- a/phpseclib/Crypt/Common/PublicKey.php +++ b/phpseclib/Crypt/Common/PublicKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common; /** @@ -20,6 +22,6 @@ interface PublicKey { public function verify($message, $signature); //public function encrypt($plaintext); - public function toString($type, array $options = []); + public function toString(string $type, array $options = []): string; public function getFingerprint($algorithm); } diff --git a/phpseclib/Crypt/Common/StreamCipher.php b/phpseclib/Crypt/Common/StreamCipher.php index 0e2d6f0c..72c353ab 100644 --- a/phpseclib/Crypt/Common/StreamCipher.php +++ b/phpseclib/Crypt/Common/StreamCipher.php @@ -12,6 +12,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common; /** @@ -44,10 +46,8 @@ abstract class StreamCipher extends SymmetricKey /** * Stream ciphers not use an IV - * - * @return bool */ - public function usesIV() + public function usesIV(): bool { return false; } diff --git a/phpseclib/Crypt/Common/SymmetricKey.php b/phpseclib/Crypt/Common/SymmetricKey.php index f7640d1f..c0803dd4 100644 --- a/phpseclib/Crypt/Common/SymmetricKey.php +++ b/phpseclib/Crypt/Common/SymmetricKey.php @@ -32,6 +32,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common; use phpseclib3\Common\Functions\Strings; @@ -596,10 +598,9 @@ abstract class SymmetricKey * * - gcm * - * @param string $mode * @throws BadModeException if an invalid / unsupported mode is provided */ - public function __construct($mode) + public function __construct(string $mode) { $mode = strtolower($mode); // necessary because of 5.6 compatibility; we can't do isset(self::MODE_MAP[$mode]) in 5.6 @@ -647,11 +648,10 @@ abstract class SymmetricKey * * {@internal Can be overwritten by a sub class, but does not have to be} * - * @param string $iv * @throws \LengthException if the IV length isn't equal to the block size * @throws \BadMethodCallException if an IV is provided when one shouldn't be */ - public function setIV($iv) + public function setIV(string $iv): void { if ($this->mode == self::MODE_ECB) { throw new \BadMethodCallException('This mode does not require an IV.'); @@ -680,7 +680,7 @@ abstract class SymmetricKey * * @throws \BadMethodCallException if Poly1305 is enabled whilst in GCM mode */ - public function enablePoly1305() + public function enablePoly1305(): void { if ($this->mode == self::MODE_GCM) { throw new \BadMethodCallException('Poly1305 cannot be used in GCM mode'); @@ -695,11 +695,11 @@ abstract class SymmetricKey * Once enabled Poly1305 cannot be disabled. If $key is not passed then an attempt to call createPoly1305Key * will be made. * - * @param string $key optional + * @param string|null $key optional * @throws \LengthException if the key isn't long enough * @throws \BadMethodCallException if Poly1305 is enabled whilst in GCM mode */ - public function setPoly1305Key($key = null) + public function setPoly1305Key(string $key = null): void { if ($this->mode == self::MODE_GCM) { throw new \BadMethodCallException('Poly1305 cannot be used in GCM mode'); @@ -723,10 +723,9 @@ abstract class SymmetricKey * * setNonce() is only required when gcm is used * - * @param string $nonce * @throws \BadMethodCallException if an nonce is provided when one shouldn't be */ - public function setNonce($nonce) + public function setNonce(string $nonce): void { if ($this->mode != self::MODE_GCM) { throw new \BadMethodCallException('Nonces are only used in GCM mode.'); @@ -741,10 +740,9 @@ abstract class SymmetricKey * * setAAD() is only used by gcm or in poly1305 mode * - * @param string $aad * @throws \BadMethodCallException if mode isn't GCM or if poly1305 isn't being utilized */ - public function setAAD($aad) + public function setAAD(string $aad): void { if ($this->mode != self::MODE_GCM && !$this->usePoly1305) { throw new \BadMethodCallException('Additional authenticated data is only utilized in GCM mode or with Poly1305'); @@ -755,50 +753,40 @@ abstract class SymmetricKey /** * Returns whether or not the algorithm uses an IV - * - * @return bool */ - public function usesIV() + public function usesIV(): bool { return $this->mode != self::MODE_GCM && $this->mode != self::MODE_ECB; } /** * Returns whether or not the algorithm uses a nonce - * - * @return bool */ - public function usesNonce() + public function usesNonce(): bool { return $this->mode == self::MODE_GCM; } /** * Returns the current key length in bits - * - * @return int */ - public function getKeyLength() + public function getKeyLength(): int { return $this->key_length << 3; } /** * Returns the current block length in bits - * - * @return int */ - public function getBlockLength() + public function getBlockLength(): int { return $this->block_size << 3; } /** * Returns the current block length in bytes - * - * @return int */ - public function getBlockLengthInBytes() + public function getBlockLengthInBytes(): int { return $this->block_size; } @@ -807,10 +795,8 @@ abstract class SymmetricKey * Sets the key length. * * Keys with explicitly set lengths need to be treated accordingly - * - * @param int $length */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { $this->explicit_key_length = $length >> 3; @@ -831,10 +817,8 @@ abstract class SymmetricKey * If the key is not explicitly set, it'll be assumed to be all null bytes. * * {@internal Could, but not must, extend by the child Crypt_* class} - * - * @param string $key */ - public function setKey($key) + public function setKey(string $key): void { if ($this->explicit_key_length !== false && strlen($key) != $this->explicit_key_length) { throw new InconsistentSetupException('Key length has already been set to ' . $this->explicit_key_length . ' bytes and this key is ' . strlen($key) . ' bytes'); @@ -856,14 +840,11 @@ abstract class SymmetricKey * * {@internal Could, but not must, extend by the child Crypt_* class} * - * @see Crypt/Hash.php - * @param string $password - * @param string $method * @param string[] ...$func_args - * @throws \LengthException if pbkdf1 is being used and the derived key length exceeds the hash length - * @return bool + *@throws \LengthException if pbkdf1 is being used and the derived key length exceeds the hash length + * @see Crypt/Hash.php */ - public function setPassword($password, $method = 'pbkdf2', ...$func_args) + public function setPassword(string $password, string $method = 'pbkdf2', ...$func_args): bool { $key = ''; @@ -878,11 +859,11 @@ abstract class SymmetricKey $hashObj->setHash($hash); // WPA and WPA2 use the SSID as the salt - $salt = isset($func_args[1]) ? $func_args[1] : $this->password_default_salt; + $salt = $func_args[1] ?? $this->password_default_salt; // RFC2898#section-4.2 uses 1,000 iterations by default // WPA and WPA2 use 4,096. - $count = isset($func_args[2]) ? $func_args[2] : 1000; + $count = $func_args[2] ?? 1000; // Keylength if (isset($func_args[3])) { @@ -1000,15 +981,10 @@ abstract class SymmetricKey * * {@link https://tools.ietf.org/html/rfc7292#appendix-B} * - * @see self::setPassword() - * @param int $n - * @param \phpseclib3\Crypt\Hash $hashObj - * @param string $i - * @param string $d - * @param int $count * @return string $a + *@see self::setPassword() */ - private static function pkcs12helper($n, $hashObj, $i, $d, $count) + private static function pkcs12helper(int $n, Hash $hashObj, string $i, string $d, int $count): string { static $one; if (!isset($one)) { @@ -1062,11 +1038,10 @@ abstract class SymmetricKey * * {@internal Could, but not must, extend by the child Crypt_* class} * - * @see self::decrypt() - * @param string $plaintext * @return string $ciphertext + *@see self::decrypt() */ - public function encrypt($plaintext) + public function encrypt(string $plaintext): string { if ($this->paddable) { $plaintext = $this->pad($plaintext); @@ -1195,7 +1170,7 @@ abstract class SymmetricKey } if ($this->engine === self::ENGINE_MCRYPT) { - set_error_handler(function () { + set_error_handler(function (): void { }); if ($this->enchanged) { mcrypt_generic_init($this->enmcrypt, $this->key, $this->getIV($this->encryptIV)); @@ -1441,12 +1416,11 @@ abstract class SymmetricKey * * {@internal Could, but not must, extend by the child Crypt_* class} * - * @see self::encrypt() - * @param string $ciphertext * @return string $plaintext * @throws \LengthException if we're inside a block cipher and the ciphertext length is not a multiple of the block size + *@see self::encrypt() */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext): string { if ($this->paddable && strlen($ciphertext) % $this->block_size) { throw new \LengthException('The ciphertext length (' . strlen($ciphertext) . ') needs to be a multiple of the block size (' . $this->block_size . ')'); @@ -1585,7 +1559,7 @@ abstract class SymmetricKey } if ($this->engine === self::ENGINE_MCRYPT) { - set_error_handler(function () { + set_error_handler(function (): void { }); $block_size = $this->block_size; if ($this->dechanged) { @@ -1809,13 +1783,13 @@ abstract class SymmetricKey * * Only used in GCM or Poly1305 mode * - * @see self::encrypt() * @param int $length optional * @return string * @throws \LengthException if $length isn't of a sufficient length * @throws \RuntimeException if GCM mode isn't being used + *@see self::encrypt() */ - public function getTag($length = 16) + public function getTag(int $length = 16) { if ($this->mode != self::MODE_GCM && !$this->usePoly1305) { throw new \BadMethodCallException('Authentication tags are only utilized in GCM mode or with Poly1305'); @@ -1844,12 +1818,11 @@ abstract class SymmetricKey * * Only used in GCM mode * - * @see self::decrypt() - * @param string $tag * @throws \LengthException if $length isn't of a sufficient length * @throws \RuntimeException if GCM mode isn't being used + *@see self::decrypt() */ - public function setTag($tag) + public function setTag(string $tag): void { if ($this->usePoly1305 && !isset($this->poly1305Key) && method_exists($this, 'createPoly1305Key')) { $this->createPoly1305Key(); @@ -1871,12 +1844,10 @@ abstract class SymmetricKey * * mcrypt requires an IV even if ECB is used * - * @see self::encrypt() - * @see self::decrypt() - * @param string $iv - * @return string + *@see self::encrypt() + * @see self::decrypt() */ - protected function getIV($iv) + protected function getIV(string $iv): string { return $this->mode == self::MODE_ECB ? str_repeat("\0", $this->block_size) : $iv; } @@ -1889,14 +1860,10 @@ abstract class SymmetricKey * and SymmetricKey::decrypt(). Also, OpenSSL doesn't implement CTR for all of it's symmetric ciphers so this * function will emulate CTR with ECB when necessary. * - * @see self::encrypt() + *@see self::encrypt() * @see self::decrypt() - * @param string $plaintext - * @param string $encryptIV - * @param array $buffer - * @return string */ - private function openssl_ctr_process($plaintext, &$encryptIV, &$buffer) + private function openssl_ctr_process(string $plaintext, string &$encryptIV, array &$buffer): string { $ciphertext = ''; @@ -1976,14 +1943,10 @@ abstract class SymmetricKey * for OFB is the same for both encrypting and decrypting this function is re-used by both SymmetricKey::encrypt() * and SymmetricKey::decrypt(). * - * @see self::encrypt() + *@see self::encrypt() * @see self::decrypt() - * @param string $plaintext - * @param string $encryptIV - * @param array $buffer - * @return string */ - private function openssl_ofb_process($plaintext, &$encryptIV, &$buffer) + private function openssl_ofb_process(string $plaintext, string &$encryptIV, array &$buffer): string { if (strlen($buffer['xor'])) { $ciphertext = $plaintext ^ $buffer['xor']; @@ -2025,10 +1988,8 @@ abstract class SymmetricKey * phpseclib <-> OpenSSL Mode Mapper * * May need to be overwritten by classes extending this one in some cases - * - * @return string */ - protected function openssl_translate_mode() + protected function openssl_translate_mode(): ?string { switch ($this->mode) { case self::MODE_ECB: @@ -2045,6 +2006,7 @@ abstract class SymmetricKey case self::MODE_OFB: return 'ofb'; } + return null; } /** @@ -2061,7 +2023,7 @@ abstract class SymmetricKey * * @see self::disablePadding() */ - public function enablePadding() + public function enablePadding(): void { $this->padding = true; } @@ -2071,7 +2033,7 @@ abstract class SymmetricKey * * @see self::enablePadding() */ - public function disablePadding() + public function disablePadding(): void { $this->padding = false; } @@ -2114,7 +2076,7 @@ abstract class SymmetricKey * * @see self::disableContinuousBuffer() */ - public function enableContinuousBuffer() + public function enableContinuousBuffer(): void { if ($this->mode == self::MODE_ECB) { return; @@ -2138,7 +2100,7 @@ abstract class SymmetricKey * * @see self::enableContinuousBuffer() */ - public function disableContinuousBuffer() + public function disableContinuousBuffer(): void { if ($this->mode == self::MODE_ECB) { return; @@ -2155,11 +2117,9 @@ abstract class SymmetricKey /** * Test for engine validity * - * @see self::__construct() - * @param int $engine - * @return bool + *@see self::__construct() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { switch ($engine) { case self::ENGINE_OPENSSL: @@ -2185,7 +2145,7 @@ abstract class SymmetricKey } return false; case self::ENGINE_MCRYPT: - set_error_handler(function () { + set_error_handler(function (): void { }); $result = $this->cipher_name_mcrypt && extension_loaded('mcrypt') && @@ -2204,11 +2164,9 @@ abstract class SymmetricKey /** * Test for engine validity * - * @see self::__construct() - * @param string $engine - * @return bool + *@see self::__construct() */ - public function isValidEngine($engine) + public function isValidEngine(string $engine): bool { static $reverseMap; if (!isset($reverseMap)) { @@ -2240,10 +2198,9 @@ abstract class SymmetricKey * * If the preferred crypt engine is not available the fastest available one will be used * - * @see self::__construct() - * @param string $engine + *@see self::__construct() */ - public function setPreferredEngine($engine) + public function setPreferredEngine(string $engine): void { static $reverseMap; if (!isset($reverseMap)) { @@ -2251,7 +2208,7 @@ abstract class SymmetricKey $reverseMap = array_flip($reverseMap); } $engine = strtolower($engine); - $this->preferredEngine = isset($reverseMap[$engine]) ? $reverseMap[$engine] : self::ENGINE_LIBSODIUM; + $this->preferredEngine = $reverseMap[$engine] ?? self::ENGINE_LIBSODIUM; $this->setEngine(); } @@ -2261,7 +2218,7 @@ abstract class SymmetricKey * * @see self::setEngine() */ - public function getEngine() + public function getEngine(): string { return self::ENGINE_MAP[$this->engine]; } @@ -2271,7 +2228,7 @@ abstract class SymmetricKey * * @see self::__construct() */ - protected function setEngine() + protected function setEngine(): void { $this->engine = null; @@ -2300,7 +2257,7 @@ abstract class SymmetricKey } if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) { - set_error_handler(function () { + set_error_handler(function (): void { }); // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed, // (re)open them with the module named in $this->cipher_name_mcrypt @@ -2323,21 +2280,15 @@ abstract class SymmetricKey * Encrypts a block * * Note: Must be extended by the child \phpseclib3\Crypt\* class - * - * @param string $in - * @return string */ - abstract protected function encryptBlock($in); + abstract protected function encryptBlock(string $in): string; /** * Decrypts a block * * Note: Must be extended by the child \phpseclib3\Crypt\* class - * - * @param string $in - * @return string */ - abstract protected function decryptBlock($in); + abstract protected function decryptBlock(string $in): string; /** * Setup the key (expansion) @@ -2375,7 +2326,7 @@ abstract class SymmetricKey * @see self::setIV() * @see self::disableContinuousBuffer() */ - protected function setup() + protected function setup(): void { if (!$this->changed) { return; @@ -2417,7 +2368,7 @@ abstract class SymmetricKey case self::ENGINE_MCRYPT: $this->enchanged = $this->dechanged = true; - set_error_handler(function () { + set_error_handler(function (): void { }); if (!isset($this->enmcrypt)) { @@ -2473,12 +2424,10 @@ abstract class SymmetricKey * If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless * and padding will, hence forth, be enabled. * + *@throws \LengthException if padding is disabled and the plaintext's length is not a multiple of the block size * @see self::unpad() - * @param string $text - * @throws \LengthException if padding is disabled and the plaintext's length is not a multiple of the block size - * @return string */ - protected function pad($text) + protected function pad(string $text): string { $length = strlen($text); @@ -2501,12 +2450,10 @@ abstract class SymmetricKey * If padding is enabled and the reported padding length is invalid the encryption key will be assumed to be wrong * and false will be returned. * + *@throws \LengthException if the ciphertext's length is not a multiple of the block size * @see self::pad() - * @param string $text - * @throws \LengthException if the ciphertext's length is not a multiple of the block size - * @return string */ - protected function unpad($text) + protected function unpad(string $text): string { if (!$this->padding) { return $text; @@ -2684,20 +2631,19 @@ abstract class SymmetricKey * ]; * * + * @return string (the name of the created callback function) + *@see self::decrypt() * @see self::setupInlineCrypt() * @see self::encrypt() - * @see self::decrypt() - * @param array $cipher_code - * @return string (the name of the created callback function) */ - protected function createInlineCryptFunction($cipher_code) + protected function createInlineCryptFunction(array $cipher_code): \Closure { $block_size = $this->block_size; // optional - $init_crypt = isset($cipher_code['init_crypt']) ? $cipher_code['init_crypt'] : ''; - $init_encrypt = isset($cipher_code['init_encrypt']) ? $cipher_code['init_encrypt'] : ''; - $init_decrypt = isset($cipher_code['init_decrypt']) ? $cipher_code['init_decrypt'] : ''; + $init_crypt = $cipher_code['init_crypt'] ?? ''; + $init_encrypt = $cipher_code['init_encrypt'] ?? ''; + $init_decrypt = $cipher_code['init_decrypt'] ?? ''; // required $encrypt_block = $cipher_code['encrypt_block']; $decrypt_block = $cipher_code['decrypt_block']; @@ -3135,10 +3081,9 @@ abstract class SymmetricKey * * On ARM CPUs converting floats to ints doesn't always work * - * @param string $x - * @return int + * @param float|int $x */ - protected static function safe_intval($x) + protected static function safe_intval($x): int { switch (true) { case is_int($x): @@ -3152,10 +3097,8 @@ abstract class SymmetricKey /** * eval()'able string for in-line float to int - * - * @return string */ - protected static function safe_intval_inline() + protected static function safe_intval_inline(): string { switch (true) { case defined('PHP_INT_SIZE') && PHP_INT_SIZE == 8: @@ -3173,9 +3116,8 @@ abstract class SymmetricKey * * See steps 1-2 of https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf#page=23 * for more info - * */ - private function setupGCM() + private function setupGCM(): void { // don't keep on re-calculating $this->h if (!$this->h || $this->h->key != $this->key) { @@ -3204,12 +3146,10 @@ abstract class SymmetricKey * See https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf#page=20 * for more info * - * @see self::decrypt() - * @see self::encrypt() - * @param string $x - * @return string + *@see self::decrypt() + * @see self::encrypt() */ - private function ghash($x) + private function ghash(string $x): string { $h = $this->h; $y = ["\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"]; @@ -3237,13 +3177,11 @@ abstract class SymmetricKey /** * Returns the bit length of a string in a packed format * + *@see self::setupGCM() * @see self::decrypt() - * @see self::encrypt() - * @see self::setupGCM() - * @param string $str - * @return string + * @see self::encrypt() */ - private static function len64($str) + private static function len64(string $str): string { return "\0\0\0\0" . pack('N', 8 * strlen($str)); } @@ -3251,16 +3189,14 @@ abstract class SymmetricKey /** * NULL pads a string to be a multiple of 128 * + *@see self::setupGCM() * @see self::decrypt() - * @see self::encrypt() - * @see self::setupGCM() - * @param string $str - * @return string + * @see self::encrypt() */ - protected static function nullPad128($str) + protected static function nullPad128(string $str): string { $len = strlen($str); - return $str . str_repeat("\0", 16 * ceil($len / 16) - $len); + return $str . str_repeat("\0", 16 * ((int) ceil($len / 16)) - $len); } /** @@ -3269,12 +3205,10 @@ abstract class SymmetricKey * On my system ChaCha20, with libsodium, takes 0.5s. With this custom Poly1305 implementation * it takes 1.2s. * - * @see self::decrypt() - * @see self::encrypt() - * @param string $text - * @return string + *@see self::decrypt() + * @see self::encrypt() */ - protected function poly1305($text) + protected function poly1305(string $text): string { $s = $this->poly1305Key; // strlen($this->poly1305Key) == 32 $r = Strings::shift($s, 16); @@ -3302,10 +3236,8 @@ abstract class SymmetricKey * Return the mode * * You can do $obj instanceof AES or whatever to get the cipher but you can't do that to get the mode - * - * @return string */ - public function getMode() + public function getMode(): string { return array_flip(self::MODE_MAP)[$this->mode]; } diff --git a/phpseclib/Crypt/Common/Traits/Fingerprint.php b/phpseclib/Crypt/Common/Traits/Fingerprint.php index 9ca8926d..dfce8411 100644 --- a/phpseclib/Crypt/Common/Traits/Fingerprint.php +++ b/phpseclib/Crypt/Common/Traits/Fingerprint.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Traits; use phpseclib3\Crypt\Hash; @@ -31,7 +33,6 @@ trait Fingerprint * * @param string $algorithm The hashing algorithm to be used. Valid options are 'md5' and 'sha256'. False is returned * for invalid values. - * @return mixed */ public function getFingerprint($algorithm = 'md5') { diff --git a/phpseclib/Crypt/Common/Traits/PasswordProtected.php b/phpseclib/Crypt/Common/Traits/PasswordProtected.php index 0ac274e8..f238d005 100644 --- a/phpseclib/Crypt/Common/Traits/PasswordProtected.php +++ b/phpseclib/Crypt/Common/Traits/PasswordProtected.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\Common\Traits; /** diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index fc45a692..3f391813 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -38,6 +38,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\BlockCipher; @@ -561,10 +563,9 @@ class DES extends BlockCipher /** * Default Constructor. * - * @param string $mode * @throws BadModeException if an invalid / unsupported mode is provided */ - public function __construct($mode) + public function __construct(string $mode) { parent::__construct($mode); @@ -578,11 +579,9 @@ class DES extends BlockCipher * * This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() * - * @see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() - * @param int $engine - * @return bool + *@see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { if ($this->key_length_max == 8) { if ($engine == self::ENGINE_OPENSSL) { @@ -601,10 +600,9 @@ class DES extends BlockCipher * * DES also requires that every eighth bit be a parity bit, however, we'll ignore that. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::setKey() - * @param string $key + *@see \phpseclib3\Crypt\Common\SymmetricKey::setKey() */ - public function setKey($key) + public function setKey(string $key): void { if (!($this instanceof TripleDES) && strlen($key) != 8) { throw new \LengthException('Key of size ' . strlen($key) . ' not supported by this algorithm. Only keys of size 8 are supported'); @@ -617,13 +615,11 @@ class DES extends BlockCipher /** * Encrypts a block * + *@see self::encrypt() * @see \phpseclib3\Crypt\Common\SymmetricKey::encryptBlock() * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() - * @see self::encrypt() - * @param string $in - * @return string */ - protected function encryptBlock($in) + protected function encryptBlock(string $in): string { return $this->processBlock($in, self::ENCRYPT); } @@ -631,13 +627,11 @@ class DES extends BlockCipher /** * Decrypts a block * + *@see self::decrypt() * @see \phpseclib3\Crypt\Common\SymmetricKey::decryptBlock() * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() - * @see self::decrypt() - * @param string $in - * @return string */ - protected function decryptBlock($in) + protected function decryptBlock(string $in): string { return $this->processBlock($in, self::DECRYPT); } @@ -649,13 +643,11 @@ class DES extends BlockCipher * {@link http://en.wikipedia.org/wiki/Image:Feistel.png Feistel.png} to get a general * idea of what this function does. * - * @see self::encryptBlock() - * @see self::decryptBlock() - * @param string $block - * @param int $mode * @return string + *@see self::decryptBlock() + * @see self::encryptBlock() */ - private function processBlock($block, $mode) + private function processBlock(string $block, int $mode) { static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip; if (!$sbox1) { @@ -679,7 +671,7 @@ class DES extends BlockCipher // Do the initial IP permutation. $t = unpack('Nl/Nr', $block); - list($l, $r) = [$t['l'], $t['r']]; + [$l, $r] = [$t['l'], $t['r']]; $block = ($shuffleip[ $r & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") | ($shuffleip[($r >> 8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") | ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") | @@ -691,7 +683,7 @@ class DES extends BlockCipher // Extract L0 and R0. $t = unpack('Nl/Nr', $block); - list($l, $r) = [$t['l'], $t['r']]; + [$l, $r] = [$t['l'], $t['r']]; for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) { // Perform the 16 steps. @@ -735,7 +727,7 @@ class DES extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey() */ - protected function setupKey() + protected function setupKey(): void { if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->des_rounds === $this->kl['des_rounds']) { // already expanded @@ -1199,7 +1191,7 @@ class DES extends BlockCipher // Perform the PC/1 transformation and compute C and D. $t = unpack('Nl/Nr', $key); - list($l, $r) = [$t['l'], $t['r']]; + [$l, $r] = [$t['l'], $t['r']]; $key = (self::$shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") | (self::$shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") | (self::$shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") | @@ -1269,7 +1261,7 @@ class DES extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::setupInlineCrypt() */ - protected function setupInlineCrypt() + protected function setupInlineCrypt(): void { // Engine configuration for: // - DES ($des_rounds == 1) or @@ -1346,9 +1338,9 @@ class DES extends BlockCipher // end of "the Feistel (F) function" // swap L & R - list($l, $r) = [$r, $l]; + [$l, $r] = [$r, $l]; } - list($l, $r) = [$r, $l]; + [$l, $r] = [$r, $l]; } // Perform the inverse IP permutation. diff --git a/phpseclib/Crypt/DH.php b/phpseclib/Crypt/DH.php index 5186f032..4120219d 100644 --- a/phpseclib/Crypt/DH.php +++ b/phpseclib/Crypt/DH.php @@ -22,6 +22,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; @@ -69,10 +71,8 @@ abstract class DH extends AsymmetricKey * - two BigInteger's (prime and base) * - an integer representing the size of the prime in bits (the base is assumed to be 2) * - a string (eg. diffie-hellman-group14-sha1) - * - * @return Parameters */ - public static function createParameters(...$args) + public static function createParameters(...$args): Parameters { $params = new Parameters(); if (count($args) == 2 && $args[0] instanceof BigInteger && $args[1] instanceof BigInteger) { @@ -229,11 +229,10 @@ abstract class DH extends AsymmetricKey * * $length is in bits * - * @param Parameters $params * @param int $length optional * @return DH\PrivateKey */ - public static function createKey(Parameters $params, $length = 0) + public static function createKey(Parameters $params, int $length = 0): PrivateKey { $one = new BigInteger(1); if ($length) { @@ -256,7 +255,6 @@ abstract class DH extends AsymmetricKey * * @param PrivateKey|EC $private * @param PublicKey|BigInteger|string $public - * @return mixed */ public static function computeSecret($private, $public) { @@ -308,11 +306,10 @@ abstract class DH extends AsymmetricKey /** * Load the key * - * @param string $key + * @param string|array $key * @param string $password optional - * @return AsymmetricKey */ - public static function load($key, $password = false) + public static function load($key, $password = false): AsymmetricKey { try { return EC::load($key, $password); @@ -325,10 +322,9 @@ abstract class DH extends AsymmetricKey /** * OnLoad Handler * - * @return bool - * @param array $components + *@return bool */ - protected static function onLoad($components) + protected static function onLoad(array $components) { if (!isset($components['privateKey']) && !isset($components['publicKey'])) { $new = new Parameters(); @@ -353,19 +349,16 @@ abstract class DH extends AsymmetricKey /** * Determines which hashing function should be used - * - * @param string $hash */ - public function withHash($hash) + public function withHash(string $hash): AsymmetricKey { throw new UnsupportedOperationException('DH does not use a hash algorithm'); } /** * Returns the hash algorithm currently being used - * */ - public function getHash() + public function getHash(): Hash { throw new UnsupportedOperationException('DH does not use a hash algorithm'); } @@ -377,9 +370,8 @@ abstract class DH extends AsymmetricKey * value. * * @see self::getPublicKey() - * @return mixed */ - public function getParameters() + public function getParameters(): AsymmetricKey { $type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters'); diff --git a/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php b/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php index ccf5b3c0..41c62aac 100644 --- a/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php @@ -19,6 +19,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DH\Formats\Keys; use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor; @@ -36,11 +38,10 @@ abstract class PKCS1 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { $key = parent::load($key, $password); @@ -59,10 +60,8 @@ abstract class PKCS1 extends Progenitor /** * Convert EC parameters to the appropriate format - * - * @return string */ - public static function saveParameters(BigInteger $prime, BigInteger $base, array $options = []) + public static function saveParameters(BigInteger $prime, BigInteger $base, array $options = []): string { $params = [ 'prime' => $prime, diff --git a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php index 2e4c26a2..c8e7f5d5 100644 --- a/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php @@ -17,6 +17,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DH\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -56,11 +58,10 @@ abstract class PKCS8 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -104,15 +105,10 @@ abstract class PKCS8 extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $prime - * @param \phpseclib3\Math\BigInteger $base - * @param \phpseclib3\Math\BigInteger $privateKey - * @param \phpseclib3\Math\BigInteger $publicKey - * @param string $password optional + * @param string|false $password optional * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $prime, BigInteger $base, BigInteger $privateKey, BigInteger $publicKey, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $prime, BigInteger $base, BigInteger $privateKey, BigInteger $publicKey, $password = '', array $options = []): string { $params = [ 'prime' => $prime, @@ -127,13 +123,9 @@ abstract class PKCS8 extends Progenitor /** * Convert a public key to the appropriate format * - * @param \phpseclib3\Math\BigInteger $prime - * @param \phpseclib3\Math\BigInteger $base - * @param \phpseclib3\Math\BigInteger $publicKey * @param array $options optional - * @return string */ - public static function savePublicKey(BigInteger $prime, BigInteger $base, BigInteger $publicKey, array $options = []) + public static function savePublicKey(BigInteger $prime, BigInteger $base, BigInteger $publicKey, array $options = []): string { $params = [ 'prime' => $prime, diff --git a/phpseclib/Crypt/DH/Parameters.php b/phpseclib/Crypt/DH/Parameters.php index e4c15576..958bb8f3 100644 --- a/phpseclib/Crypt/DH/Parameters.php +++ b/phpseclib/Crypt/DH/Parameters.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DH; use phpseclib3\Crypt\DH; @@ -23,11 +25,9 @@ class Parameters extends DH /** * Returns the parameters * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type = 'PKCS1', array $options = []) + public function toString(string $type = 'PKCS1', array $options = []): string { $type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters'); diff --git a/phpseclib/Crypt/DH/PrivateKey.php b/phpseclib/Crypt/DH/PrivateKey.php index fe03452c..fc070db8 100644 --- a/phpseclib/Crypt/DH/PrivateKey.php +++ b/phpseclib/Crypt/DH/PrivateKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DH; use phpseclib3\Crypt\Common; @@ -42,7 +44,7 @@ class PrivateKey extends DH * * @return DH\PublicKey */ - public function getPublicKey() + public function getPublicKey(): PublicKey { $type = self::validatePlugin('Keys', 'PKCS8', 'savePublicKey'); @@ -58,11 +60,9 @@ class PrivateKey extends DH /** * Returns the private key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin('Keys', $type, 'savePrivateKey'); diff --git a/phpseclib/Crypt/DH/PublicKey.php b/phpseclib/Crypt/DH/PublicKey.php index 3536360c..b52b3d78 100644 --- a/phpseclib/Crypt/DH/PublicKey.php +++ b/phpseclib/Crypt/DH/PublicKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DH; use phpseclib3\Crypt\Common; @@ -26,11 +28,9 @@ class PublicKey extends DH /** * Returns the public key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin('Keys', $type, 'savePublicKey'); @@ -39,10 +39,8 @@ class PublicKey extends DH /** * Returns the public key as a BigInteger - * - * @return \phpseclib3\Math\BigInteger */ - public function toBigInteger() + public function toBigInteger(): \phpseclib3\Math\BigInteger { return $this->publicKey; } diff --git a/phpseclib/Crypt/DSA.php b/phpseclib/Crypt/DSA.php index 964a34cd..1e0f72c7 100644 --- a/phpseclib/Crypt/DSA.php +++ b/phpseclib/Crypt/DSA.php @@ -27,6 +27,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; @@ -97,11 +99,9 @@ abstract class DSA extends AsymmetricKey /** * Create DSA parameters * - * @param int $L - * @param int $N * @return \phpseclib3\Crypt\DSA|bool */ - public static function createParameters($L = 2048, $N = 224) + public static function createParameters(int $L = 2048, int $N = 224) { self::initialize_static_variables(); @@ -137,12 +137,12 @@ abstract class DSA extends AsymmetricKey do { $x = BigInteger::random($L); - list(, $c) = $x->divide($divisor); + [, $c] = $x->divide($divisor); $p = $x->subtract($c->subtract(self::$one)); } while ($p->getLength() != $L || !$p->isPrime()); $p_1 = $p->subtract(self::$one); - list($e) = $p_1->divide($q); + [$e] = $p_1->divide($q); // quoting http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf#page=50 , // "h could be obtained from a random number generator or from a counter that @@ -176,7 +176,7 @@ abstract class DSA extends AsymmetricKey * @param int[] ...$args * @return DSA\PrivateKey */ - public static function createKey(...$args) + public static function createKey(...$args): PrivateKey { self::initialize_static_variables(); @@ -213,10 +213,9 @@ abstract class DSA extends AsymmetricKey /** * OnLoad Handler * - * @return bool - * @param array $components + *@return bool */ - protected static function onLoad($components) + protected static function onLoad(array $components) { if (!isset(self::$engines['PHP'])) { self::useBestEngine(); @@ -259,10 +258,8 @@ abstract class DSA extends AsymmetricKey * Returns the key size * * More specifically, this L (the length of DSA Prime P) and N (the length of DSA Group Order q) - * - * @return array */ - public function getLength() + public function getLength(): array { return ['L' => $this->p->getLength(), 'N' => $this->q->getLength()]; } @@ -272,9 +269,8 @@ abstract class DSA extends AsymmetricKey * * @see self::useInternalEngine() * @see self::useBestEngine() - * @return string */ - public function getEngine() + public function getEngine(): string { if (!isset(self::$engines['PHP'])) { self::useBestEngine(); @@ -290,7 +286,6 @@ abstract class DSA extends AsymmetricKey * value. * * @see self::getPublicKey() - * @return mixed */ public function getParameters() { @@ -306,10 +301,8 @@ abstract class DSA extends AsymmetricKey * Determines the signature padding mode * * Valid values are: ASN1, SSH2, Raw - * - * @param string $format */ - public function withSignatureFormat($format) + public function withSignatureFormat(string $format): DSA { $new = clone $this; $new->shortFormat = $format; @@ -319,9 +312,8 @@ abstract class DSA extends AsymmetricKey /** * Returns the signature format currently being used - * */ - public function getSignatureFormat() + public function getSignatureFormat(): string { return $this->shortFormat; } diff --git a/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php index cc204fa9..42181959 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -36,26 +38,25 @@ abstract class OpenSSH extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { $parsed = parent::load($key, $password); if (isset($parsed['paddedKey'])) { - list($type) = Strings::unpackSSH2('s', $parsed['paddedKey']); + [$type] = Strings::unpackSSH2('s', $parsed['paddedKey']); if ($type != $parsed['type']) { throw new \RuntimeException("The public and private keys are not of the same type ($type vs $parsed[type])"); } - list($p, $q, $g, $y, $x, $comment) = Strings::unpackSSH2('i5s', $parsed['paddedKey']); + [$p, $q, $g, $y, $x, $comment] = Strings::unpackSSH2('i5s', $parsed['paddedKey']); return compact('p', 'q', 'g', 'y', 'x', 'comment'); } - list($p, $q, $g, $y) = Strings::unpackSSH2('iiii', $parsed['publicKey']); + [$p, $q, $g, $y] = Strings::unpackSSH2('iiii', $parsed['publicKey']); $comment = $parsed['comment']; @@ -65,14 +66,9 @@ abstract class OpenSSH extends Progenitor /** * Convert a public key to the appropriate format * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y * @param array $options optional - * @return string */ - public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, array $options = []) + public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, array $options = []): string { if ($q->getLength() != 160) { throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160'); @@ -86,11 +82,11 @@ abstract class OpenSSH extends Progenitor // mpint y $DSAPublicKey = Strings::packSSH2('siiii', 'ssh-dss', $p, $q, $g, $y); - if (isset($options['binary']) ? $options['binary'] : self::$binary) { + if ($options['binary'] ?? self::$binary) { return $DSAPublicKey; } - $comment = isset($options['comment']) ? $options['comment'] : self::$comment; + $comment = $options['comment'] ?? self::$comment; $DSAPublicKey = 'ssh-dss ' . base64_encode($DSAPublicKey) . ' ' . $comment; return $DSAPublicKey; @@ -99,16 +95,10 @@ abstract class OpenSSH extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @param \phpseclib3\Math\BigInteger $x - * @param string $password optional + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = []): string { $publicKey = self::savePublicKey($p, $q, $g, $y, ['binary' => true]); $privateKey = Strings::packSSH2('si5', 'ssh-dss', $p, $q, $g, $y, $x); diff --git a/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php b/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php index a7208a04..0f10ca2d 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php @@ -25,6 +25,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -43,11 +45,10 @@ abstract class PKCS1 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { $key = parent::load($key, $password); @@ -76,13 +77,8 @@ abstract class PKCS1 extends Progenitor /** * Convert DSA parameters to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @return string */ - public static function saveParameters(BigInteger $p, BigInteger $q, BigInteger $g) + public static function saveParameters(BigInteger $p, BigInteger $q, BigInteger $g): string { $key = [ 'p' => $p, @@ -100,16 +96,10 @@ abstract class PKCS1 extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @param \phpseclib3\Math\BigInteger $x * @param string $password optional * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, string $password = '', array $options = []): string { $key = [ 'version' => 0, @@ -127,14 +117,8 @@ abstract class PKCS1 extends Progenitor /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @return string */ - public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y) + public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y): string { $key = ASN1::encodeDER($y, Maps\DSAPublicKey::MAP); diff --git a/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php b/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php index aa0efa68..15b23939 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php @@ -21,6 +21,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -60,11 +62,10 @@ abstract class PKCS8 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -113,16 +114,10 @@ abstract class PKCS8 extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @param \phpseclib3\Math\BigInteger $x - * @param string $password optional + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = []): string { $params = [ 'p' => $p, @@ -138,14 +133,9 @@ abstract class PKCS8 extends Progenitor /** * Convert a public key to the appropriate format * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y * @param array $options optional - * @return string */ - public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, array $options = []) + public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, array $options = []): string { $params = [ 'p' => $p, diff --git a/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php b/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php index ff7f4c95..33a646a2 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php @@ -16,6 +16,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -46,11 +48,11 @@ abstract class PuTTY extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param array|string $key + * @param string|false $password + * @return array|false */ - public static function load($key, $password = '') + public static function load($key, $password) { $components = parent::load($key, $password); if (!isset($components['private'])) { @@ -59,8 +61,8 @@ abstract class PuTTY extends Progenitor extract($components); unset($components['public'], $components['private']); - list($p, $q, $g, $y) = Strings::unpackSSH2('iiii', $public); - list($x) = Strings::unpackSSH2('i', $private); + [$p, $q, $g, $y] = Strings::unpackSSH2('iiii', $public); + [$x] = Strings::unpackSSH2('i', $private); return compact('p', 'q', 'g', 'y', 'x', 'comment'); } @@ -68,16 +70,10 @@ abstract class PuTTY extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @param \phpseclib3\Math\BigInteger $x * @param string $password optional * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = false, array $options = []) + public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = false, array $options = []): string { if ($q->getLength() != 160) { throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160'); @@ -91,14 +87,8 @@ abstract class PuTTY extends Progenitor /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @return string */ - public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y) + public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y): string { if ($q->getLength() != 160) { throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160'); diff --git a/phpseclib/Crypt/DSA/Formats/Keys/Raw.php b/phpseclib/Crypt/DSA/Formats/Keys/Raw.php index 201aa6f9..4358b3bc 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/Raw.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/Raw.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Keys; use phpseclib3\Math\BigInteger; @@ -27,11 +29,10 @@ abstract class Raw /** * Break a public or private key down into its constituent components * - * @param array $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!is_array($key)) { throw new \UnexpectedValueException('Key should be a array - not a ' . gettype($key)); @@ -56,29 +57,17 @@ abstract class Raw /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @param \phpseclib3\Math\BigInteger $x * @param string $password optional - * @return string */ - public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '') + public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, string $password = ''): string { return compact('p', 'q', 'g', 'y', 'x'); } /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @return string */ - public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y) + public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y): string { return compact('p', 'q', 'g', 'y'); } diff --git a/phpseclib/Crypt/DSA/Formats/Keys/XML.php b/phpseclib/Crypt/DSA/Formats/Keys/XML.php index 17ee70d1..e3a27335 100644 --- a/phpseclib/Crypt/DSA/Formats/Keys/XML.php +++ b/phpseclib/Crypt/DSA/Formats/Keys/XML.php @@ -17,6 +17,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -34,11 +36,9 @@ abstract class XML /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|false $password */ - public static function load($key, $password = '') + public static function load(string $key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -114,14 +114,8 @@ abstract class XML * Convert a public key to the appropriate format * * See https://www.w3.org/TR/xmldsig-core/#sec-DSAKeyValue - * - * @param \phpseclib3\Math\BigInteger $p - * @param \phpseclib3\Math\BigInteger $q - * @param \phpseclib3\Math\BigInteger $g - * @param \phpseclib3\Math\BigInteger $y - * @return string */ - public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y) + public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y): string { return "\r\n" . '

' . Base64::encode($p->toBytes()) . "

\r\n" . diff --git a/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php b/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php index df52beed..99a50c0f 100644 --- a/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php +++ b/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php @@ -14,6 +14,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Signature; use phpseclib3\File\ASN1 as Encoder; @@ -30,10 +32,9 @@ abstract class ASN1 /** * Loads a signature * - * @param string $sig * @return array|bool */ - public static function load($sig) + public static function load(string $sig) { if (!is_string($sig)) { return false; @@ -50,12 +51,8 @@ abstract class ASN1 /** * Returns a signature in the appropriate format - * - * @param \phpseclib3\Math\BigInteger $r - * @param \phpseclib3\Math\BigInteger $s - * @return string */ - public static function save(BigInteger $r, BigInteger $s) + public static function save(BigInteger $r, BigInteger $s): string { return Encoder::encodeDER(compact('r', 's'), Maps\DssSigValue::MAP); } diff --git a/phpseclib/Crypt/DSA/Formats/Signature/Raw.php b/phpseclib/Crypt/DSA/Formats/Signature/Raw.php index 2657a2a8..205ba710 100644 --- a/phpseclib/Crypt/DSA/Formats/Signature/Raw.php +++ b/phpseclib/Crypt/DSA/Formats/Signature/Raw.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Signature; use phpseclib3\Crypt\Common\Formats\Signature\Raw as Progenitor; diff --git a/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php b/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php index dbfceabb..6dba270a 100644 --- a/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php +++ b/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA\Formats\Signature; use phpseclib3\Common\Functions\Strings; @@ -27,11 +29,8 @@ abstract class SSH2 { /** * Loads a signature - * - * @param string $sig - * @return mixed */ - public static function load($sig) + public static function load(string $sig) { if (!is_string($sig)) { return false; @@ -41,7 +40,7 @@ abstract class SSH2 if ($result === false) { return false; } - list($type, $blob) = $result; + [$type, $blob] = $result; if ($type != 'ssh-dss' || strlen($blob) != 40) { return false; } @@ -55,8 +54,6 @@ abstract class SSH2 /** * Returns a signature in the appropriate format * - * @param \phpseclib3\Math\BigInteger $r - * @param \phpseclib3\Math\BigInteger $s * @return string */ public static function save(BigInteger $r, BigInteger $s) diff --git a/phpseclib/Crypt/DSA/Parameters.php b/phpseclib/Crypt/DSA/Parameters.php index 6bcb152d..5dc8a718 100644 --- a/phpseclib/Crypt/DSA/Parameters.php +++ b/phpseclib/Crypt/DSA/Parameters.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA; use phpseclib3\Crypt\DSA; @@ -23,11 +25,9 @@ class Parameters extends DSA /** * Returns the parameters * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type = 'PKCS1', array $options = []) + public function toString(string $type = 'PKCS1', array $options = []): string { $type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters'); diff --git a/phpseclib/Crypt/DSA/PrivateKey.php b/phpseclib/Crypt/DSA/PrivateKey.php index 7039941b..82fd3846 100644 --- a/phpseclib/Crypt/DSA/PrivateKey.php +++ b/phpseclib/Crypt/DSA/PrivateKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA; use phpseclib3\Crypt\Common; @@ -51,7 +53,6 @@ class PrivateKey extends DSA implements Common\PrivateKey * without the parameters and the PKCS1 DSA public key format does not include the parameters. * * @see self::getPrivateKey() - * @return mixed */ public function getPublicKey() { @@ -73,9 +74,8 @@ class PrivateKey extends DSA implements Common\PrivateKey * * @see self::verify() * @param string $message - * @return mixed */ - public function sign($message) + public function sign($message): string { $format = $this->sigFormat; @@ -100,14 +100,14 @@ class PrivateKey extends DSA implements Common\PrivateKey while (true) { $k = BigInteger::randomRange(self::$one, $this->q->subtract(self::$one)); $r = $this->g->powMod($k, $this->p); - list(, $r) = $r->divide($this->q); + [, $r] = $r->divide($this->q); if ($r->equals(self::$zero)) { continue; } $kinv = $k->modInverse($this->q); $temp = $h->add($this->x->multiply($r)); $temp = $kinv->multiply($temp); - list(, $s) = $temp->divide($this->q); + [, $s] = $temp->divide($this->q); if (!$s->equals(self::$zero)) { break; } @@ -135,11 +135,9 @@ class PrivateKey extends DSA implements Common\PrivateKey /** * Returns the private key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin('Keys', $type, 'savePrivateKey'); diff --git a/phpseclib/Crypt/DSA/PublicKey.php b/phpseclib/Crypt/DSA/PublicKey.php index 7e00e24a..5a0af509 100644 --- a/phpseclib/Crypt/DSA/PublicKey.php +++ b/phpseclib/Crypt/DSA/PublicKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\DSA; use phpseclib3\Crypt\Common; @@ -30,9 +32,8 @@ class PublicKey extends DSA implements Common\PublicKey * @see self::verify() * @param string $message * @param string $signature - * @return mixed */ - public function verify($message, $signature) + public function verify($message, $signature): bool { $format = $this->sigFormat; @@ -60,12 +61,12 @@ class PublicKey extends DSA implements Common\PublicKey $w = $s->modInverse($this->q); $h = $this->hash->hash($message); $h = $this->bits2int($h); - list(, $u1) = $h->multiply($w)->divide($this->q); - list(, $u2) = $r->multiply($w)->divide($this->q); + [, $u1] = $h->multiply($w)->divide($this->q); + [, $u2] = $r->multiply($w)->divide($this->q); $v1 = $this->g->powMod($u1, $this->p); $v2 = $this->y->powMod($u2, $this->p); - list(, $v) = $v1->multiply($v2)->divide($this->p); - list(, $v) = $v->divide($this->q); + [, $v] = $v1->multiply($v2)->divide($this->p); + [, $v] = $v->divide($this->q); return $v->equals($r); } @@ -73,11 +74,9 @@ class PublicKey extends DSA implements Common\PublicKey /** * Returns the public key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin('Keys', $type, 'savePublicKey'); diff --git a/phpseclib/Crypt/EC.php b/phpseclib/Crypt/EC.php index 703a7bc0..f80b2e82 100644 --- a/phpseclib/Crypt/EC.php +++ b/phpseclib/Crypt/EC.php @@ -27,6 +27,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; @@ -125,11 +127,8 @@ abstract class EC extends AsymmetricKey /** * Create public / private key pair. - * - * @param string $curve - * @return \phpseclib3\Crypt\EC\PrivateKey */ - public static function createKey($curve) + public static function createKey(string $curve): PrivateKey { self::initialize_static_variables(); @@ -198,10 +197,9 @@ abstract class EC extends AsymmetricKey /** * OnLoad Handler * - * @return bool - * @param array $components + *@return bool */ - protected static function onLoad($components) + protected static function onLoad(array $components) { if (!isset(self::$engines['PHP'])) { self::useBestEngine(); @@ -294,10 +292,8 @@ abstract class EC extends AsymmetricKey * representation of the field, commonly denoted by m. A set of * elliptic curve domain parameters defines a group of order n generated * by a base point P" - * - * @return int */ - public function getLength() + public function getLength(): int { return $this->curve->getLength(); } @@ -307,9 +303,8 @@ abstract class EC extends AsymmetricKey * * @see self::useInternalEngine() * @see self::useBestEngine() - * @return string */ - public function getEngine() + public function getEngine(): string { if (!isset(self::$engines['PHP'])) { self::useBestEngine(); @@ -327,10 +322,8 @@ abstract class EC extends AsymmetricKey * Returns the public key coordinates as a string * * Used by ECDH - * - * @return string */ - public function getEncodedCoordinates() + public function getEncodedCoordinates(): string { if ($this->curve instanceof MontgomeryCurve) { return strrev($this->QA[0]->toBytes(true)); @@ -344,11 +337,10 @@ abstract class EC extends AsymmetricKey /** * Returns the parameters * - * @see self::getPublicKey() * @param string $type optional - * @return mixed + *@see self::getPublicKey() */ - public function getParameters($type = 'PKCS1') + public function getParameters(string $type = 'PKCS1') { $type = self::validatePlugin('Keys', $type, 'saveParameters'); @@ -363,10 +355,8 @@ abstract class EC extends AsymmetricKey * Determines the signature padding mode * * Valid values are: ASN1, SSH2, Raw - * - * @param string $format */ - public function withSignatureFormat($format) + public function withSignatureFormat(string $format): EC { if ($this->curve instanceof MontgomeryCurve) { throw new UnsupportedOperationException('Montgomery Curves cannot be used to create signatures'); @@ -380,9 +370,8 @@ abstract class EC extends AsymmetricKey /** * Returns the signature format currently being used - * */ - public function getSignatureFormat() + public function getSignatureFormat(): string { return $this->shortFormat; } @@ -392,11 +381,11 @@ abstract class EC extends AsymmetricKey * * Used by Ed25519 / Ed448. * - * @see self::sign() - * @see self::verify() - * @param string $context optional + * @param string|null $context optional + *@see self::verify() + * @see self::sign() */ - public function withContext($context = null) + public function withContext(string $context = null): EC { if (!$this->curve instanceof TwistedEdwardsCurve) { throw new UnsupportedCurveException('Only Ed25519 and Ed448 support contexts'); @@ -419,19 +408,16 @@ abstract class EC extends AsymmetricKey /** * Returns the signature format currently being used - * */ - public function getContext() + public function getContext(): string { return $this->context; } /** * Determines which hashing function should be used - * - * @param string $hash */ - public function withHash($hash) + public function withHash(string $hash): AsymmetricKey { if ($this->curve instanceof MontgomeryCurve) { throw new UnsupportedOperationException('Montgomery Curves cannot be used to create signatures'); diff --git a/phpseclib/Crypt/EC/BaseCurves/Base.php b/phpseclib/Crypt/EC/BaseCurves/Base.php index 60729d74..8aebf78b 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Base.php +++ b/phpseclib/Crypt/EC/BaseCurves/Base.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\BaseCurves; use phpseclib3\Math\BigInteger; @@ -75,7 +77,7 @@ abstract class Base * * @return integer */ - public function getLengthInBytes() + public function getLengthInBytes(): int { return $this->factory->getLengthInBytes(); } @@ -85,7 +87,7 @@ abstract class Base * * @return integer */ - public function getLength() + public function getLength(): int { return $this->factory->getLength(); } @@ -97,10 +99,8 @@ abstract class Base * * https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication#Montgomery_ladder * https://github.com/phpecc/phpecc/issues/16#issuecomment-59176772 - * - * @return array */ - public function multiplyPoint(array $p, BigInteger $d) + public function multiplyPoint(array $p, BigInteger $d): array { $alreadyInternal = isset($p[2]); $r = $alreadyInternal ? @@ -119,10 +119,8 @@ abstract class Base /** * Creates a random scalar multiplier - * - * @return BigInteger */ - public function createRandomMultiplier() + public function createRandomMultiplier(): BigInteger { static $one; if (!isset($one)) { @@ -135,7 +133,7 @@ abstract class Base /** * Performs range check */ - public function rangeCheck(BigInteger $x) + public function rangeCheck(BigInteger $x): void { static $zero; if (!isset($zero)) { @@ -153,17 +151,15 @@ abstract class Base /** * Sets the Order */ - public function setOrder(BigInteger $order) + public function setOrder(BigInteger $order): void { $this->order = $order; } /** * Returns the Order - * - * @return \phpseclib3\Math\BigInteger */ - public function getOrder() + public function getOrder(): BigInteger { return $this->order; } @@ -183,7 +179,7 @@ abstract class Base * * @return object[] */ - public function convertToAffine(array $p) + public function convertToAffine(array $p): array { return $p; } @@ -193,7 +189,7 @@ abstract class Base * * @return object[] */ - public function convertToInternal(array $p) + public function convertToInternal(array $p): array { return $p; } @@ -203,7 +199,7 @@ abstract class Base * * @return object[] */ - public function negatePoint(array $p) + public function negatePoint(array $p): array { $temp = [ $p[0], @@ -220,7 +216,7 @@ abstract class Base * * @return int[] */ - public function multiplyAddPoints(array $points, array $scalars) + public function multiplyAddPoints(array $points, array $scalars): array { $p1 = $this->convertToInternal($points[0]); $p2 = $this->convertToInternal($points[1]); diff --git a/phpseclib/Crypt/EC/BaseCurves/Binary.php b/phpseclib/Crypt/EC/BaseCurves/Binary.php index 4fc6c70c..960f99af 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Binary.php +++ b/phpseclib/Crypt/EC/BaseCurves/Binary.php @@ -19,6 +19,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\BaseCurves; use phpseclib3\Math\BigInteger; @@ -70,7 +72,7 @@ class Binary extends Base /** * The modulo * - * @var BigInteger + * @var array */ protected $modulo; @@ -84,7 +86,7 @@ class Binary extends Base /** * Sets the modulo */ - public function setModulo(...$modulo) + public function setModulo(...$modulo): void { $this->modulo = $modulo; $this->factory = new BinaryField(...$modulo); @@ -94,11 +96,8 @@ class Binary extends Base /** * Set coefficients a and b - * - * @param string $a - * @param string $b */ - public function setCoefficients($a, $b) + public function setCoefficients(string $a, string $b): void { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -113,7 +112,7 @@ class Binary extends Base * @param string|BinaryInteger $x * @param string|BinaryInteger $y */ - public function setBasePoint($x, $y) + public function setBasePoint($x, $y): void { switch (true) { case !is_string($x) && !$x instanceof BinaryInteger: @@ -153,7 +152,7 @@ class Binary extends Base * * @return FiniteField[] */ - public function addPoint(array $p, array $q) + public function addPoint(array $p, array $q): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -179,8 +178,8 @@ class Binary extends Base // formulas from http://hyperelliptic.org/EFD/g12o/auto-shortw-jacobian.html - list($x1, $y1, $z1) = $p; - list($x2, $y2, $z2) = $q; + [$x1, $y1, $z1] = $p; + [$x2, $y2, $z2] = $q; $o1 = $z1->multiply($z1); $b = $x2->multiply($o1); @@ -226,7 +225,7 @@ class Binary extends Base * * @return FiniteField[] */ - public function doublePoint(array $p) + public function doublePoint(array $p): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -242,7 +241,7 @@ class Binary extends Base // formulas from http://hyperelliptic.org/EFD/g12o/auto-shortw-jacobian.html - list($x1, $y1, $z1) = $p; + [$x1, $y1, $z1] = $p; $a = $x1->multiply($x1); $b = $a->multiply($a); @@ -277,10 +276,8 @@ class Binary extends Base * "Due to patent issues the compressed option is disabled by default for binary curves * and can be enabled by defining the preprocessor macro OPENSSL_EC_BIN_PT_COMP at * compile time." - * - * @return array */ - public function derivePoint($m) + public function derivePoint($m): array { throw new \RuntimeException('Point compression on binary finite field elliptic curves is not supported'); } @@ -290,9 +287,9 @@ class Binary extends Base * * @return boolean */ - public function verifyPoint(array $p) + public function verifyPoint(array $p): bool { - list($x, $y) = $p; + [$x, $y] = $p; $lhs = $y->multiply($y); $lhs = $lhs->add($x->multiply($y)); $x2 = $x->multiply($x); @@ -304,10 +301,8 @@ class Binary extends Base /** * Returns the modulo - * - * @return \phpseclib3\Math\BigInteger */ - public function getModulo() + public function getModulo(): array { return $this->modulo; } @@ -341,12 +336,12 @@ class Binary extends Base * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToAffine(array $p) + public function convertToAffine(array $p): array { if (!isset($p[2])) { return $p; } - list($x, $y, $z) = $p; + [$x, $y, $z] = $p; $z = $this->one->divide($z); $z2 = $z->multiply($z); return [ @@ -360,7 +355,7 @@ class Binary extends Base * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToInternal(array $p) + public function convertToInternal(array $p): array { if (isset($p[2])) { return $p; diff --git a/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php b/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php index dba83be4..9d0a6d71 100644 --- a/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php +++ b/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php @@ -26,6 +26,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\BaseCurves; use phpseclib3\Math\BigInteger; @@ -52,7 +54,7 @@ class KoblitzPrime extends Prime * * @return int[] */ - public function multiplyAddPoints(array $points, array $scalars) + public function multiplyAddPoints(array $points, array $scalars): array { static $zero, $one, $two; if (!isset($two)) { @@ -106,16 +108,16 @@ class KoblitzPrime extends Prime $k = $scalars[$i]->toBigInteger(); // begin split - list($v1, $v2) = $this->basis; + [$v1, $v2] = $this->basis; $c1 = $v2['b']->multiply($k); - list($c1, $r) = $c1->divide($this->order); + [$c1, $r] = $c1->divide($this->order); if ($this->order->compare($r->multiply($two)) <= 0) { $c1 = $c1->add($one); } $c2 = $v1['b']->negate()->multiply($k); - list($c2, $r) = $c2->divide($this->order); + [$c2, $r] = $c2->divide($this->order); if ($this->order->compare($r->multiply($two)) <= 0) { $c2 = $c2->add($one); } @@ -173,7 +175,7 @@ class KoblitzPrime extends Prime * * @return FiniteField[] */ - protected function doublePointHelper(array $p) + protected function doublePointHelper(array $p): array { $numerator = $this->three->multiply($p[0])->multiply($p[0]); $denominator = $this->two->multiply($p[1]); @@ -187,9 +189,9 @@ class KoblitzPrime extends Prime * * @return FiniteField[] */ - protected function jacobianDoublePoint(array $p) + protected function jacobianDoublePoint(array $p): array { - list($x1, $y1, $z1) = $p; + [$x1, $y1, $z1] = $p; $a = $x1->multiply($x1); $b = $y1->multiply($y1); $c = $b->multiply($b); @@ -212,9 +214,9 @@ class KoblitzPrime extends Prime * * @return FiniteField[] */ - protected function jacobianDoublePointMixed(array $p) + protected function jacobianDoublePointMixed(array $p): array { - list($x1, $y1) = $p; + [$x1, $y1] = $p; $xx = $x1->multiply($x1); $yy = $y1->multiply($y1); $yyyy = $yy->multiply($yy); @@ -234,9 +236,9 @@ class KoblitzPrime extends Prime * * @return boolean */ - public function verifyPoint(array $p) + public function verifyPoint(array $p): bool { - list($x, $y) = $p; + [$x, $y] = $p; $lhs = $y->multiply($y); $temp = $x->multiply($x)->multiply($x); $rhs = $temp->add($this->b); @@ -248,11 +250,9 @@ class KoblitzPrime extends Prime * Calculates the parameters needed from the Euclidean algorithm as discussed at * http://diamond.boisestate.edu/~liljanab/MATH308/GuideToECC.pdf#page=148 * - * @param BigInteger $u - * @param BigInteger $v * @return BigInteger[] */ - protected static function extendedGCD(BigInteger $u, BigInteger $v) + protected static function extendedGCD(BigInteger $u, BigInteger $v): array { $one = new BigInteger(1); $zero = new BigInteger(); @@ -272,7 +272,7 @@ class KoblitzPrime extends Prime $postGreatestIndex = 0; while (!$v->equals($zero)) { - list($q) = $u->divide($v); + [$q] = $u->divide($v); $temp = $u; $u = $v; diff --git a/phpseclib/Crypt/EC/BaseCurves/Montgomery.php b/phpseclib/Crypt/EC/BaseCurves/Montgomery.php index e3fa50b3..66c98817 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Montgomery.php +++ b/phpseclib/Crypt/EC/BaseCurves/Montgomery.php @@ -22,6 +22,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\BaseCurves; use phpseclib3\Crypt\EC\Curves\Curve25519; @@ -95,7 +97,7 @@ class Montgomery extends Base /** * Sets the modulo */ - public function setModulo(BigInteger $modulo) + public function setModulo(BigInteger $modulo): void { $this->modulo = $modulo; $this->factory = new PrimeField($modulo); @@ -106,7 +108,7 @@ class Montgomery extends Base /** * Set coefficients a */ - public function setCoefficients(BigInteger $a) + public function setCoefficients(BigInteger $a): void { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -124,7 +126,7 @@ class Montgomery extends Base * @param BigInteger|PrimeInteger $y * @return PrimeInteger[] */ - public function setBasePoint($x, $y) + public function setBasePoint($x, $y): array { switch (true) { case !$x instanceof BigInteger && !$x instanceof PrimeInteger: @@ -166,7 +168,7 @@ class Montgomery extends Base * * @return FiniteField[][] */ - private function doubleAndAddPoint(array $p, array $q, PrimeInteger $x1) + private function doubleAndAddPoint(array $p, array $q, PrimeInteger $x1): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -180,8 +182,8 @@ class Montgomery extends Base throw new \RuntimeException('Affine coordinates need to be manually converted to XZ coordinates'); } - list($x2, $z2) = $p; - list($x3, $z3) = $q; + [$x2, $z2] = $p; + [$x3, $z3] = $q; $a = $x2->add($z2); $aa = $a->multiply($a); @@ -213,10 +215,8 @@ class Montgomery extends Base * * https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication#Montgomery_ladder * https://github.com/phpecc/phpecc/issues/16#issuecomment-59176772 - * - * @return array */ - public function multiplyPoint(array $p, BigInteger $d) + public function multiplyPoint(array $p, BigInteger $d): array { $p1 = [$this->one, $this->zero]; $alreadyInternal = isset($x[1]); @@ -228,9 +228,9 @@ class Montgomery extends Base for ($i = 0; $i < strlen($b); $i++) { $b_i = (int) $b[$i]; if ($b_i) { - list($p2, $p1) = $this->doubleAndAddPoint($p2, $p1, $x); + [$p2, $p1] = $this->doubleAndAddPoint($p2, $p1, $x); } else { - list($p1, $p2) = $this->doubleAndAddPoint($p1, $p2, $x); + [$p1, $p2] = $this->doubleAndAddPoint($p1, $p2, $x); } } @@ -248,7 +248,7 @@ class Montgomery extends Base * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToInternal(array $p) + public function convertToInternal(array $p): array { if (empty($p)) { return [clone $this->zero, clone $this->one]; @@ -268,12 +268,12 @@ class Montgomery extends Base * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToAffine(array $p) + public function convertToAffine(array $p): array { if (!isset($p[1])) { return $p; } - list($x, $z) = $p; + [$x, $z] = $p; return [$x->divide($z)]; } } diff --git a/phpseclib/Crypt/EC/BaseCurves/Prime.php b/phpseclib/Crypt/EC/BaseCurves/Prime.php index d6fb2bb5..55b2d79d 100644 --- a/phpseclib/Crypt/EC/BaseCurves/Prime.php +++ b/phpseclib/Crypt/EC/BaseCurves/Prime.php @@ -19,6 +19,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\BaseCurves; use phpseclib3\Common\Functions\Strings; @@ -114,7 +116,7 @@ class Prime extends Base /** * Sets the modulo */ - public function setModulo(BigInteger $modulo) + public function setModulo(BigInteger $modulo): void { $this->modulo = $modulo; $this->factory = new PrimeField($modulo); @@ -129,7 +131,7 @@ class Prime extends Base /** * Set coefficients a and b */ - public function setCoefficients(BigInteger $a, BigInteger $b) + public function setCoefficients(BigInteger $a, BigInteger $b): void { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -143,9 +145,8 @@ class Prime extends Base * * @param BigInteger|PrimeInteger $x * @param BigInteger|PrimeInteger $y - * @return PrimeInteger[] */ - public function setBasePoint($x, $y) + public function setBasePoint($x, $y): void { switch (true) { case !$x instanceof BigInteger && !$x instanceof PrimeInteger: @@ -185,10 +186,10 @@ class Prime extends Base * * @return FiniteField[] */ - protected function jacobianAddPointMixedXY(array $p, array $q) + protected function jacobianAddPointMixedXY(array $p, array $q): array { - list($u1, $s1) = $p; - list($u2, $s2) = $q; + [$u1, $s1] = $p; + [$u2, $s2] = $q; if ($u1->equals($u2)) { if (!$s1->equals($s2)) { return []; @@ -217,10 +218,10 @@ class Prime extends Base * * @return FiniteField[] */ - protected function jacobianAddPointMixedX(array $p, array $q) + protected function jacobianAddPointMixedX(array $p, array $q): array { - list($u1, $s1, $z1) = $p; - list($x2, $y2) = $q; + [$u1, $s1, $z1] = $p; + [$x2, $y2] = $q; $z12 = $z1->multiply($z1); @@ -253,10 +254,10 @@ class Prime extends Base * * @return FiniteField[] */ - protected function jacobianAddPoint(array $p, array $q) + protected function jacobianAddPoint(array $p, array $q): array { - list($x1, $y1, $z1) = $p; - list($x2, $y2, $z2) = $q; + [$x1, $y1, $z1] = $p; + [$x2, $y2, $z2] = $q; $z12 = $z1->multiply($z1); $z22 = $z2->multiply($z2); @@ -292,7 +293,7 @@ class Prime extends Base * * @return FiniteField[] */ - public function addPoint(array $p, array $q) + public function addPoint(array $p, array $q): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -330,7 +331,7 @@ class Prime extends Base if (!$p[1]->equals($q[1])) { return []; } else { // eg. doublePoint - list($numerator, $denominator) = $this->doublePointHelper($p); + [$numerator, $denominator] = $this->doublePointHelper($p); } } else { $numerator = $q[1]->subtract($p[1]); @@ -348,7 +349,7 @@ class Prime extends Base * * @return FiniteField[] */ - protected function doublePointHelper(array $p) + protected function doublePointHelper(array $p): array { $numerator = $this->three->multiply($p[0])->multiply($p[0])->add($this->a); $denominator = $this->two->multiply($p[1]); @@ -360,9 +361,9 @@ class Prime extends Base * * @return FiniteField[] */ - protected function jacobianDoublePoint(array $p) + protected function jacobianDoublePoint(array $p): array { - list($x, $y, $z) = $p; + [$x, $y, $z] = $p; $x2 = $x->multiply($x); $y2 = $y->multiply($y); $z2 = $z->multiply($z); @@ -383,9 +384,9 @@ class Prime extends Base * * @return FiniteField[] */ - protected function jacobianDoublePointMixed(array $p) + protected function jacobianDoublePointMixed(array $p): array { - list($x, $y) = $p; + [$x, $y] = $p; $x2 = $x->multiply($x); $y2 = $y->multiply($y); $s = $this->four->multiply($x)->multiply($y2); @@ -404,7 +405,7 @@ class Prime extends Base * * @return FiniteField[] */ - public function doublePoint(array $p) + public function doublePoint(array $p): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -422,7 +423,7 @@ class Prime extends Base return $this->jacobianDoublePoint($p); } - list($numerator, $denominator) = $this->doublePointHelper($p); + [$numerator, $denominator] = $this->doublePointHelper($p); $slope = $numerator->divide($denominator); @@ -434,10 +435,8 @@ class Prime extends Base /** * Returns the X coordinate and the derived Y coordinate - * - * @return array */ - public function derivePoint($m) + public function derivePoint($m): array { $y = ord(Strings::shift($m)); $x = new BigInteger($m, 256); @@ -469,9 +468,9 @@ class Prime extends Base * * @return boolean */ - public function verifyPoint(array $p) + public function verifyPoint(array $p): bool { - list($x, $y) = $p; + [$x, $y] = $p; $lhs = $y->multiply($y); $temp = $x->multiply($this->a); $temp = $x->multiply($x)->multiply($x)->add($temp); @@ -482,10 +481,8 @@ class Prime extends Base /** * Returns the modulo - * - * @return \phpseclib3\Math\BigInteger */ - public function getModulo() + public function getModulo(): BigInteger { return $this->modulo; } @@ -518,7 +515,7 @@ class Prime extends Base * * @return int[] */ - public function multiplyAddPoints(array $points, array $scalars) + public function multiplyAddPoints(array $points, array $scalars): array { $length = count($points); @@ -527,10 +524,10 @@ class Prime extends Base } $wnd = [$this->getNAFPoints($points[0], 7)]; - $wndWidth = [isset($points[0]['nafwidth']) ? $points[0]['nafwidth'] : 7]; + $wndWidth = [$points[0]['nafwidth'] ?? 7]; for ($i = 1; $i < $length; $i++) { $wnd[] = $this->getNAFPoints($points[$i], 1); - $wndWidth[] = isset($points[$i]['nafwidth']) ? $points[$i]['nafwidth'] : 1; + $wndWidth[] = $points[$i]['nafwidth'] ?? 1; } $naf = []; @@ -582,8 +579,8 @@ class Prime extends Base } for ($j = 0; $j < $max; $j++) { - $ja = isset($jsf[0][$j]) ? $jsf[0][$j] : 0; - $jb = isset($jsf[1][$j]) ? $jsf[1][$j] : 0; + $ja = $jsf[0][$j] ?? 0; + $jb = $jsf[1][$j] ?? 0; $naf[$a][$j] = $index[3 * ($ja + 1) + $jb + 1]; $naf[$b][$j] = 0; @@ -598,7 +595,7 @@ class Prime extends Base while ($i >= 0) { $zero = true; for ($j = 0; $j < $length; $j++) { - $temp[$j] = isset($naf[$j][$i]) ? $naf[$j][$i] : 0; + $temp[$j] = $naf[$j][$i] ?? 0; if ($temp[$j] != 0) { $zero = false; } @@ -645,7 +642,7 @@ class Prime extends Base * * @return int[] */ - private function getNAFPoints($point, $wnd) + private function getNAFPoints($point, $wnd): array { if (isset($point['naf'])) { return $point['naf']; @@ -682,7 +679,7 @@ class Prime extends Base * * @return int[] */ - private static function getJSFPoints(Integer $k1, Integer $k2) + private static function getJSFPoints(Integer $k1, Integer $k2): array { static $three; if (!isset($three)) { @@ -753,12 +750,12 @@ class Prime extends Base * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToAffine(array $p) + public function convertToAffine(array $p): array { if (!isset($p[2])) { return $p; } - list($x, $y, $z) = $p; + [$x, $y, $z] = $p; $z = $this->one->divide($z); $z2 = $z->multiply($z); return [ @@ -772,7 +769,7 @@ class Prime extends Base * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToInternal(array $p) + public function convertToInternal(array $p): array { if (isset($p[2])) { return $p; diff --git a/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php b/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php index 2521a4c0..efd3833f 100644 --- a/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php +++ b/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php @@ -24,6 +24,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\BaseCurves; use phpseclib3\Math\BigInteger; @@ -89,7 +91,7 @@ class TwistedEdwards extends Base /** * Sets the modulo */ - public function setModulo(BigInteger $modulo) + public function setModulo(BigInteger $modulo): void { $this->modulo = $modulo; $this->factory = new PrimeField($modulo); @@ -101,7 +103,7 @@ class TwistedEdwards extends Base /** * Set coefficients a and b */ - public function setCoefficients(BigInteger $a, BigInteger $d) + public function setCoefficients(BigInteger $a, BigInteger $d): void { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -113,7 +115,7 @@ class TwistedEdwards extends Base /** * Set x and y coordinates for the base point */ - public function setBasePoint($x, $y) + public function setBasePoint($x, $y): void { switch (true) { case !$x instanceof BigInteger && !$x instanceof PrimeInteger: @@ -152,10 +154,8 @@ class TwistedEdwards extends Base /** * Retrieve the base point as an array - * - * @return array */ - public function getBasePoint() + public function getBasePoint(): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -173,12 +173,12 @@ class TwistedEdwards extends Base * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToAffine(array $p) + public function convertToAffine(array $p): array { if (!isset($p[2])) { return $p; } - list($x, $y, $z) = $p; + [$x, $y, $z] = $p; $z = $this->one->divide($z); return [ $x->multiply($z), @@ -188,10 +188,8 @@ class TwistedEdwards extends Base /** * Returns the modulo - * - * @return \phpseclib3\Math\BigInteger */ - public function getModulo() + public function getModulo(): BigInteger { return $this->modulo; } @@ -201,9 +199,9 @@ class TwistedEdwards extends Base * * @return boolean */ - public function verifyPoint(array $p) + public function verifyPoint(array $p): bool { - list($x, $y) = $p; + [$x, $y] = $p; $x2 = $x->multiply($x); $y2 = $y->multiply($y); diff --git a/phpseclib/Crypt/EC/Curves/Curve25519.php b/phpseclib/Crypt/EC/Curves/Curve25519.php index 0f3f4d82..2e93626d 100644 --- a/phpseclib/Crypt/EC/Curves/Curve25519.php +++ b/phpseclib/Crypt/EC/Curves/Curve25519.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Montgomery; @@ -42,10 +44,8 @@ class Curve25519 extends Montgomery * Multiply a point on the curve by a scalar * * Modifies the scalar as described at https://tools.ietf.org/html/rfc7748#page-8 - * - * @return array */ - public function multiplyPoint(array $p, BigInteger $d) + public function multiplyPoint(array $p, BigInteger $d): array { //$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes()))); //return [$this->factory->newInteger(new BigInteger($r, 256))]; @@ -61,10 +61,8 @@ class Curve25519 extends Montgomery /** * Creates a random scalar multiplier - * - * @return BigInteger */ - public function createRandomMultiplier() + public function createRandomMultiplier(): BigInteger { return BigInteger::random(256); } @@ -72,7 +70,7 @@ class Curve25519 extends Montgomery /** * Performs range check */ - public function rangeCheck(BigInteger $x) + public function rangeCheck(BigInteger $x): void { if ($x->getLength() > 256 || $x->isNegative()) { throw new \RangeException('x must be a positive integer less than 256 bytes in length'); diff --git a/phpseclib/Crypt/EC/Curves/Curve448.php b/phpseclib/Crypt/EC/Curves/Curve448.php index f4a44231..0a347732 100644 --- a/phpseclib/Crypt/EC/Curves/Curve448.php +++ b/phpseclib/Crypt/EC/Curves/Curve448.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Montgomery; @@ -53,10 +55,8 @@ class Curve448 extends Montgomery * Multiply a point on the curve by a scalar * * Modifies the scalar as described at https://tools.ietf.org/html/rfc7748#page-8 - * - * @return array */ - public function multiplyPoint(array $p, BigInteger $d) + public function multiplyPoint(array $p, BigInteger $d): array { //$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes()))); //return [$this->factory->newInteger(new BigInteger($r, 256))]; @@ -72,10 +72,8 @@ class Curve448 extends Montgomery /** * Creates a random scalar multiplier - * - * @return BigInteger */ - public function createRandomMultiplier() + public function createRandomMultiplier(): BigInteger { return BigInteger::random(446); } @@ -83,7 +81,7 @@ class Curve448 extends Montgomery /** * Performs range check */ - public function rangeCheck(BigInteger $x) + public function rangeCheck(BigInteger $x): void { if ($x->getLength() > 448 || $x->isNegative()) { throw new \RangeException('x must be a positive integer less than 446 bytes in length'); diff --git a/phpseclib/Crypt/EC/Curves/Ed25519.php b/phpseclib/Crypt/EC/Curves/Ed25519.php index 0b776a51..53dd1c8d 100644 --- a/phpseclib/Crypt/EC/Curves/Ed25519.php +++ b/phpseclib/Crypt/EC/Curves/Ed25519.php @@ -10,12 +10,15 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards; use phpseclib3\Crypt\Hash; use phpseclib3\Crypt\Random; use phpseclib3\Math\BigInteger; +use phpseclib3\Math\PrimeField\Integer; class Ed25519 extends TwistedEdwards { @@ -100,11 +103,10 @@ class Ed25519 extends TwistedEdwards * * Used by EC\Keys\Common.php * - * @param BigInteger $y * @param boolean $sign * @return object[] */ - public function recoverX(BigInteger $y, $sign) + public function recoverX(BigInteger $y, bool $sign): array { $y = $this->factory->newInteger($y); @@ -155,10 +157,9 @@ class Ed25519 extends TwistedEdwards * * Used by the various key handlers * - * @param string $str * @return \phpseclib3\Math\PrimeField\Integer */ - public function extractSecret($str) + public function extractSecret(string $str) { if (strlen($str) != 32) { throw new \LengthException('Private Key should be 32-bytes long'); @@ -185,13 +186,10 @@ class Ed25519 extends TwistedEdwards /** * Encode a point as a string - * - * @param array $point - * @return string */ - public function encodePoint($point) + public function encodePoint(array $point): string { - list($x, $y) = $point; + [$x, $y] = $point; $y = $y->toBytes(); $y[0] = $y[0] & chr(0x7F); if ($x->isOdd()) { @@ -204,10 +202,8 @@ class Ed25519 extends TwistedEdwards /** * Creates a random scalar multiplier - * - * @return \phpseclib3\Math\PrimeField\Integer */ - public function createRandomMultiplier() + public function createRandomMultiplier(): BigInteger { return $this->extractSecret(Random::string(32)); } @@ -222,7 +218,7 @@ class Ed25519 extends TwistedEdwards * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToInternal(array $p) + public function convertToInternal(array $p): array { if (empty($p)) { return [clone $this->zero, clone $this->one, clone $this->one, clone $this->zero]; @@ -243,7 +239,7 @@ class Ed25519 extends TwistedEdwards * * @return FiniteField[] */ - public function doublePoint(array $p) + public function doublePoint(array $p): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -259,7 +255,7 @@ class Ed25519 extends TwistedEdwards // from https://tools.ietf.org/html/rfc8032#page-12 - list($x1, $y1, $z1, $t1) = $p; + [$x1, $y1, $z1, $t1] = $p; $a = $x1->multiply($x1); $b = $y1->multiply($y1); @@ -283,7 +279,7 @@ class Ed25519 extends TwistedEdwards * * @return FiniteField[] */ - public function addPoint(array $p, array $q) + public function addPoint(array $p, array $q): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -309,8 +305,8 @@ class Ed25519 extends TwistedEdwards // from https://tools.ietf.org/html/rfc8032#page-12 - list($x1, $y1, $z1, $t1) = $p; - list($x2, $y2, $z2, $t2) = $q; + [$x1, $y1, $z1, $t1] = $p; + [$x2, $y2, $z2, $t2] = $q; $a = $y1->subtract($x1)->multiply($y2->subtract($x2)); $b = $y1->add($x1)->multiply($y2->add($x2)); diff --git a/phpseclib/Crypt/EC/Curves/Ed448.php b/phpseclib/Crypt/EC/Curves/Ed448.php index c4b14428..3eb2c031 100644 --- a/phpseclib/Crypt/EC/Curves/Ed448.php +++ b/phpseclib/Crypt/EC/Curves/Ed448.php @@ -10,6 +10,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards; @@ -56,11 +58,10 @@ class Ed448 extends TwistedEdwards * * Used by EC\Keys\Common.php * - * @param BigInteger $y * @param boolean $sign * @return object[] */ - public function recoverX(BigInteger $y, $sign) + public function recoverX(BigInteger $y, bool $sign): array { $y = $this->factory->newInteger($y); @@ -96,10 +97,9 @@ class Ed448 extends TwistedEdwards * * Used by the various key handlers * - * @param string $str * @return \phpseclib3\Math\PrimeField\Integer */ - public function extractSecret($str) + public function extractSecret(string $str) { if (strlen($str) != 57) { throw new \LengthException('Private Key should be 57-bytes long'); @@ -127,13 +127,10 @@ class Ed448 extends TwistedEdwards /** * Encode a point as a string - * - * @param array $point - * @return string */ - public function encodePoint($point) + public function encodePoint(array $point): string { - list($x, $y) = $point; + [$x, $y] = $point; $y = "\0" . $y->toBytes(); if ($x->isOdd()) { $y[0] = $y[0] | chr(0x80); @@ -145,10 +142,8 @@ class Ed448 extends TwistedEdwards /** * Creates a random scalar multiplier - * - * @return \phpseclib3\Math\PrimeField\Integer */ - public function createRandomMultiplier() + public function createRandomMultiplier(): BigInteger { return $this->extractSecret(Random::string(57)); } @@ -163,7 +158,7 @@ class Ed448 extends TwistedEdwards * * @return \phpseclib3\Math\PrimeField\Integer[] */ - public function convertToInternal(array $p) + public function convertToInternal(array $p): array { if (empty($p)) { return [clone $this->zero, clone $this->one, clone $this->one]; @@ -183,7 +178,7 @@ class Ed448 extends TwistedEdwards * * @return FiniteField[] */ - public function doublePoint(array $p) + public function doublePoint(array $p): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -199,7 +194,7 @@ class Ed448 extends TwistedEdwards // from https://tools.ietf.org/html/rfc8032#page-18 - list($x1, $y1, $z1) = $p; + [$x1, $y1, $z1] = $p; $b = $x1->add($y1); $b = $b->multiply($b); @@ -221,7 +216,7 @@ class Ed448 extends TwistedEdwards * * @return FiniteField[] */ - public function addPoint(array $p, array $q) + public function addPoint(array $p, array $q): array { if (!isset($this->factory)) { throw new \RuntimeException('setModulo needs to be called before this method'); @@ -247,8 +242,8 @@ class Ed448 extends TwistedEdwards // from https://tools.ietf.org/html/rfc8032#page-17 - list($x1, $y1, $z1) = $p; - list($x2, $y2, $z2) = $q; + [$x1, $y1, $z1] = $p; + [$x2, $y2, $z2] = $q; $a = $z1->multiply($z2); $b = $a->multiply($a); diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php index 7bc2272a..f4d7e6fe 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php index ebfb29ae..a87807bc 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php @@ -24,6 +24,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php index 6ec848bc..be90648e 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php index e6a86bbd..da2fb13a 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php index 3d7d8726..fc146e5e 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php index 3d4f9289..8460f8a4 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php index 5780da76..7137ae92 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP256t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP256t1.php index 724d8b8f..dd671167 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP256t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP256t1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php index 182e6227..7d24665c 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php index d5a620d8..33a8939f 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php index a20b4b44..98eb32a2 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php index 366660e6..c9acbca6 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php b/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php index 5efe5e1a..475ddfd4 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php b/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php index 745863a6..e9db26bd 100644 --- a/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php +++ b/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/nistb233.php b/phpseclib/Crypt/EC/Curves/nistb233.php index bae12b06..7182336a 100644 --- a/phpseclib/Crypt/EC/Curves/nistb233.php +++ b/phpseclib/Crypt/EC/Curves/nistb233.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistb233 extends sect233r1 diff --git a/phpseclib/Crypt/EC/Curves/nistb409.php b/phpseclib/Crypt/EC/Curves/nistb409.php index a46153d3..e6eadbc3 100644 --- a/phpseclib/Crypt/EC/Curves/nistb409.php +++ b/phpseclib/Crypt/EC/Curves/nistb409.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistb409 extends sect409r1 diff --git a/phpseclib/Crypt/EC/Curves/nistk163.php b/phpseclib/Crypt/EC/Curves/nistk163.php index 8b263761..ae06c5f5 100644 --- a/phpseclib/Crypt/EC/Curves/nistk163.php +++ b/phpseclib/Crypt/EC/Curves/nistk163.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistk163 extends sect163k1 diff --git a/phpseclib/Crypt/EC/Curves/nistk233.php b/phpseclib/Crypt/EC/Curves/nistk233.php index 69e14138..22f4de02 100644 --- a/phpseclib/Crypt/EC/Curves/nistk233.php +++ b/phpseclib/Crypt/EC/Curves/nistk233.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistk233 extends sect233k1 diff --git a/phpseclib/Crypt/EC/Curves/nistk283.php b/phpseclib/Crypt/EC/Curves/nistk283.php index 9e95f10e..3515fe61 100644 --- a/phpseclib/Crypt/EC/Curves/nistk283.php +++ b/phpseclib/Crypt/EC/Curves/nistk283.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistk283 extends sect283k1 diff --git a/phpseclib/Crypt/EC/Curves/nistk409.php b/phpseclib/Crypt/EC/Curves/nistk409.php index 06bd9af7..c33e11c6 100644 --- a/phpseclib/Crypt/EC/Curves/nistk409.php +++ b/phpseclib/Crypt/EC/Curves/nistk409.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistk409 extends sect409k1 diff --git a/phpseclib/Crypt/EC/Curves/nistp192.php b/phpseclib/Crypt/EC/Curves/nistp192.php index ddead3cf..0999dd8a 100644 --- a/phpseclib/Crypt/EC/Curves/nistp192.php +++ b/phpseclib/Crypt/EC/Curves/nistp192.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistp192 extends secp192r1 diff --git a/phpseclib/Crypt/EC/Curves/nistp224.php b/phpseclib/Crypt/EC/Curves/nistp224.php index 746571b4..732ed6c3 100644 --- a/phpseclib/Crypt/EC/Curves/nistp224.php +++ b/phpseclib/Crypt/EC/Curves/nistp224.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistp224 extends secp224r1 diff --git a/phpseclib/Crypt/EC/Curves/nistp256.php b/phpseclib/Crypt/EC/Curves/nistp256.php index a26c0f99..b63cebf0 100644 --- a/phpseclib/Crypt/EC/Curves/nistp256.php +++ b/phpseclib/Crypt/EC/Curves/nistp256.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistp256 extends secp256r1 diff --git a/phpseclib/Crypt/EC/Curves/nistp384.php b/phpseclib/Crypt/EC/Curves/nistp384.php index 1f20c02d..0c48d9f9 100644 --- a/phpseclib/Crypt/EC/Curves/nistp384.php +++ b/phpseclib/Crypt/EC/Curves/nistp384.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistp384 extends secp384r1 diff --git a/phpseclib/Crypt/EC/Curves/nistp521.php b/phpseclib/Crypt/EC/Curves/nistp521.php index 86fa0508..f6b7fc8e 100644 --- a/phpseclib/Crypt/EC/Curves/nistp521.php +++ b/phpseclib/Crypt/EC/Curves/nistp521.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistp521 extends secp521r1 diff --git a/phpseclib/Crypt/EC/Curves/nistt571.php b/phpseclib/Crypt/EC/Curves/nistt571.php index 7908b38b..eec6570f 100644 --- a/phpseclib/Crypt/EC/Curves/nistt571.php +++ b/phpseclib/Crypt/EC/Curves/nistt571.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class nistt571 extends sect571k1 diff --git a/phpseclib/Crypt/EC/Curves/prime192v1.php b/phpseclib/Crypt/EC/Curves/prime192v1.php index e9c13cd8..c60477cf 100644 --- a/phpseclib/Crypt/EC/Curves/prime192v1.php +++ b/phpseclib/Crypt/EC/Curves/prime192v1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class prime192v1 extends secp192r1 diff --git a/phpseclib/Crypt/EC/Curves/prime192v2.php b/phpseclib/Crypt/EC/Curves/prime192v2.php index e3e341f2..1f94ace0 100644 --- a/phpseclib/Crypt/EC/Curves/prime192v2.php +++ b/phpseclib/Crypt/EC/Curves/prime192v2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/prime192v3.php b/phpseclib/Crypt/EC/Curves/prime192v3.php index 1e97992d..b5ba4575 100644 --- a/phpseclib/Crypt/EC/Curves/prime192v3.php +++ b/phpseclib/Crypt/EC/Curves/prime192v3.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/prime239v1.php b/phpseclib/Crypt/EC/Curves/prime239v1.php index 084be9d7..73b8acbc 100644 --- a/phpseclib/Crypt/EC/Curves/prime239v1.php +++ b/phpseclib/Crypt/EC/Curves/prime239v1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/prime239v2.php b/phpseclib/Crypt/EC/Curves/prime239v2.php index 21941b83..cf5ab8df 100644 --- a/phpseclib/Crypt/EC/Curves/prime239v2.php +++ b/phpseclib/Crypt/EC/Curves/prime239v2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/prime239v3.php b/phpseclib/Crypt/EC/Curves/prime239v3.php index 78c50f06..8ce2095e 100644 --- a/phpseclib/Crypt/EC/Curves/prime239v3.php +++ b/phpseclib/Crypt/EC/Curves/prime239v3.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/prime256v1.php b/phpseclib/Crypt/EC/Curves/prime256v1.php index c72b22e8..905c18eb 100644 --- a/phpseclib/Crypt/EC/Curves/prime256v1.php +++ b/phpseclib/Crypt/EC/Curves/prime256v1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; final class prime256v1 extends secp256r1 diff --git a/phpseclib/Crypt/EC/Curves/secp112r1.php b/phpseclib/Crypt/EC/Curves/secp112r1.php index d1d3194b..686c2dca 100644 --- a/phpseclib/Crypt/EC/Curves/secp112r1.php +++ b/phpseclib/Crypt/EC/Curves/secp112r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp112r2.php b/phpseclib/Crypt/EC/Curves/secp112r2.php index da44e7fd..104dbcff 100644 --- a/phpseclib/Crypt/EC/Curves/secp112r2.php +++ b/phpseclib/Crypt/EC/Curves/secp112r2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp128r1.php b/phpseclib/Crypt/EC/Curves/secp128r1.php index 34456bc0..7866ad47 100644 --- a/phpseclib/Crypt/EC/Curves/secp128r1.php +++ b/phpseclib/Crypt/EC/Curves/secp128r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp128r2.php b/phpseclib/Crypt/EC/Curves/secp128r2.php index e102c340..cf88530c 100644 --- a/phpseclib/Crypt/EC/Curves/secp128r2.php +++ b/phpseclib/Crypt/EC/Curves/secp128r2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp160k1.php b/phpseclib/Crypt/EC/Curves/secp160k1.php index c6a33344..6a4d273c 100644 --- a/phpseclib/Crypt/EC/Curves/secp160k1.php +++ b/phpseclib/Crypt/EC/Curves/secp160k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\KoblitzPrime; diff --git a/phpseclib/Crypt/EC/Curves/secp160r1.php b/phpseclib/Crypt/EC/Curves/secp160r1.php index af468774..7b84e0d0 100644 --- a/phpseclib/Crypt/EC/Curves/secp160r1.php +++ b/phpseclib/Crypt/EC/Curves/secp160r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp160r2.php b/phpseclib/Crypt/EC/Curves/secp160r2.php index 9bd23d23..6cab3cd9 100644 --- a/phpseclib/Crypt/EC/Curves/secp160r2.php +++ b/phpseclib/Crypt/EC/Curves/secp160r2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp192k1.php b/phpseclib/Crypt/EC/Curves/secp192k1.php index 79ff2e09..952c56e0 100644 --- a/phpseclib/Crypt/EC/Curves/secp192k1.php +++ b/phpseclib/Crypt/EC/Curves/secp192k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\KoblitzPrime; diff --git a/phpseclib/Crypt/EC/Curves/secp192r1.php b/phpseclib/Crypt/EC/Curves/secp192r1.php index 83ab1c70..5dc8edb7 100644 --- a/phpseclib/Crypt/EC/Curves/secp192r1.php +++ b/phpseclib/Crypt/EC/Curves/secp192r1.php @@ -13,6 +13,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp224k1.php b/phpseclib/Crypt/EC/Curves/secp224k1.php index 79a5c541..bf45dc82 100644 --- a/phpseclib/Crypt/EC/Curves/secp224k1.php +++ b/phpseclib/Crypt/EC/Curves/secp224k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\KoblitzPrime; diff --git a/phpseclib/Crypt/EC/Curves/secp224r1.php b/phpseclib/Crypt/EC/Curves/secp224r1.php index a9e474a3..278ced44 100644 --- a/phpseclib/Crypt/EC/Curves/secp224r1.php +++ b/phpseclib/Crypt/EC/Curves/secp224r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp256k1.php b/phpseclib/Crypt/EC/Curves/secp256k1.php index 462e7a1c..e886e592 100644 --- a/phpseclib/Crypt/EC/Curves/secp256k1.php +++ b/phpseclib/Crypt/EC/Curves/secp256k1.php @@ -13,6 +13,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; //use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp256r1.php b/phpseclib/Crypt/EC/Curves/secp256r1.php index 9003373c..ddd6b071 100644 --- a/phpseclib/Crypt/EC/Curves/secp256r1.php +++ b/phpseclib/Crypt/EC/Curves/secp256r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp384r1.php b/phpseclib/Crypt/EC/Curves/secp384r1.php index 98764a34..abf748aa 100644 --- a/phpseclib/Crypt/EC/Curves/secp384r1.php +++ b/phpseclib/Crypt/EC/Curves/secp384r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/secp521r1.php b/phpseclib/Crypt/EC/Curves/secp521r1.php index b89a4ea7..9de3a837 100644 --- a/phpseclib/Crypt/EC/Curves/secp521r1.php +++ b/phpseclib/Crypt/EC/Curves/secp521r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Prime; diff --git a/phpseclib/Crypt/EC/Curves/sect113r1.php b/phpseclib/Crypt/EC/Curves/sect113r1.php index 77ec7603..b2f5f277 100644 --- a/phpseclib/Crypt/EC/Curves/sect113r1.php +++ b/phpseclib/Crypt/EC/Curves/sect113r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect113r2.php b/phpseclib/Crypt/EC/Curves/sect113r2.php index 2185d60e..531ccd69 100644 --- a/phpseclib/Crypt/EC/Curves/sect113r2.php +++ b/phpseclib/Crypt/EC/Curves/sect113r2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect131r1.php b/phpseclib/Crypt/EC/Curves/sect131r1.php index 1365cb60..e6d2f4f8 100644 --- a/phpseclib/Crypt/EC/Curves/sect131r1.php +++ b/phpseclib/Crypt/EC/Curves/sect131r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect131r2.php b/phpseclib/Crypt/EC/Curves/sect131r2.php index 93c11b2a..6c8da6aa 100644 --- a/phpseclib/Crypt/EC/Curves/sect131r2.php +++ b/phpseclib/Crypt/EC/Curves/sect131r2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect163k1.php b/phpseclib/Crypt/EC/Curves/sect163k1.php index 3c8574bb..95b5ad37 100644 --- a/phpseclib/Crypt/EC/Curves/sect163k1.php +++ b/phpseclib/Crypt/EC/Curves/sect163k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect163r1.php b/phpseclib/Crypt/EC/Curves/sect163r1.php index 26afd87e..a73e2b39 100644 --- a/phpseclib/Crypt/EC/Curves/sect163r1.php +++ b/phpseclib/Crypt/EC/Curves/sect163r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect163r2.php b/phpseclib/Crypt/EC/Curves/sect163r2.php index 38f94661..3c09aae8 100644 --- a/phpseclib/Crypt/EC/Curves/sect163r2.php +++ b/phpseclib/Crypt/EC/Curves/sect163r2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect193r1.php b/phpseclib/Crypt/EC/Curves/sect193r1.php index 951f261e..3ae056ae 100644 --- a/phpseclib/Crypt/EC/Curves/sect193r1.php +++ b/phpseclib/Crypt/EC/Curves/sect193r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect193r2.php b/phpseclib/Crypt/EC/Curves/sect193r2.php index e3ff47ac..6625f169 100644 --- a/phpseclib/Crypt/EC/Curves/sect193r2.php +++ b/phpseclib/Crypt/EC/Curves/sect193r2.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect233k1.php b/phpseclib/Crypt/EC/Curves/sect233k1.php index eea3f7ad..f2f5035d 100644 --- a/phpseclib/Crypt/EC/Curves/sect233k1.php +++ b/phpseclib/Crypt/EC/Curves/sect233k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect233r1.php b/phpseclib/Crypt/EC/Curves/sect233r1.php index 68219f0e..459a4778 100644 --- a/phpseclib/Crypt/EC/Curves/sect233r1.php +++ b/phpseclib/Crypt/EC/Curves/sect233r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect239k1.php b/phpseclib/Crypt/EC/Curves/sect239k1.php index 0e6994ba..f7c1ce67 100644 --- a/phpseclib/Crypt/EC/Curves/sect239k1.php +++ b/phpseclib/Crypt/EC/Curves/sect239k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect283k1.php b/phpseclib/Crypt/EC/Curves/sect283k1.php index 279c24aa..f9dac72f 100644 --- a/phpseclib/Crypt/EC/Curves/sect283k1.php +++ b/phpseclib/Crypt/EC/Curves/sect283k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect283r1.php b/phpseclib/Crypt/EC/Curves/sect283r1.php index e44a6076..a22d4602 100644 --- a/phpseclib/Crypt/EC/Curves/sect283r1.php +++ b/phpseclib/Crypt/EC/Curves/sect283r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect409k1.php b/phpseclib/Crypt/EC/Curves/sect409k1.php index 1fe329d8..abb3bb25 100644 --- a/phpseclib/Crypt/EC/Curves/sect409k1.php +++ b/phpseclib/Crypt/EC/Curves/sect409k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect409r1.php b/phpseclib/Crypt/EC/Curves/sect409r1.php index 3e209ef8..03a92db1 100644 --- a/phpseclib/Crypt/EC/Curves/sect409r1.php +++ b/phpseclib/Crypt/EC/Curves/sect409r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect571k1.php b/phpseclib/Crypt/EC/Curves/sect571k1.php index 3c54eabd..06901bbb 100644 --- a/phpseclib/Crypt/EC/Curves/sect571k1.php +++ b/phpseclib/Crypt/EC/Curves/sect571k1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Curves/sect571r1.php b/phpseclib/Crypt/EC/Curves/sect571r1.php index 172c1af9..3d79f9e2 100644 --- a/phpseclib/Crypt/EC/Curves/sect571r1.php +++ b/phpseclib/Crypt/EC/Curves/sect571r1.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Curves; use phpseclib3\Crypt\EC\BaseCurves\Binary; diff --git a/phpseclib/Crypt/EC/Formats/Keys/Common.php b/phpseclib/Crypt/EC/Formats/Keys/Common.php index 88f3af4c..09456a20 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/Common.php +++ b/phpseclib/Crypt/EC/Formats/Keys/Common.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use ParagonIE\ConstantTime\Hex; @@ -55,7 +57,7 @@ trait Common /** * Initialize static variables */ - private static function initialize_static_variables() + private static function initialize_static_variables(): void { if (empty(self::$curveOIDs)) { // the sec* curves are from the standards for efficient cryptography group @@ -183,10 +185,8 @@ trait Common * * If the key contains an implicit curve phpseclib needs the curve * to be explicitly provided - * - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve */ - public static function setImplicitCurve(BaseCurve $curve) + public static function setImplicitCurve(BaseCurve $curve): void { self::$implicitCurve = $curve; } @@ -195,7 +195,6 @@ trait Common * Returns an instance of \phpseclib3\Crypt\EC\BaseCurves\Base based * on the curve parameters * - * @param array $params * @return \phpseclib3\Crypt\EC\BaseCurves\Base|false */ protected static function loadCurveByParam(array $params) @@ -269,11 +268,9 @@ trait Common * * Supports both compressed and uncompressed points * - * @param string $str - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve * @return object[] */ - public static function extractPoint($str, BaseCurve $curve) + public static function extractPoint(string $str, BaseCurve $curve): array { if ($curve instanceof TwistedEdwardsCurve) { // first step of point deciding as discussed at the following URL's: @@ -313,7 +310,7 @@ trait Common // point compression is not being used if ($keylen == 2 * $order + 1) { preg_match("#(.)(.{{$order}})(.{{$order}})#s", $str, $matches); - list(, $w, $x, $y) = $matches; + [, $w, $x, $y] = $matches; if ($w != "\4") { throw new \UnexpectedValueException('The first byte of an uncompressed point should be 04 - not ' . Hex::encode($val)); } @@ -335,15 +332,14 @@ trait Common /** * Encode Parameters * - * @todo Maybe at some point this could be moved to __toString() for each of the curves? - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve * @param bool $returnArray optional * @param array $options optional * @return string|false + *@todo Maybe at some point this could be moved to __toString() for each of the curves? */ - private static function encodeParameters(BaseCurve $curve, $returnArray = false, array $options = []) + private static function encodeParameters(BaseCurve $curve, bool $returnArray = false, array $options = []) { - $useNamedCurves = isset($options['namedCurve']) ? $options['namedCurve'] : self::$useNamedCurves; + $useNamedCurves = $options['namedCurve'] ?? self::$useNamedCurves; $reflect = new \ReflectionClass($curve); $name = $reflect->getShortName(); @@ -383,8 +379,8 @@ trait Common break; } - list($candidateX, $candidateY) = $candidate->getBasePoint(); - list($curveX, $curveY) = $curve->getBasePoint(); + [$candidateX, $candidateY] = $candidate->getBasePoint(); + [$curveX, $curveY] = $curve->getBasePoint(); if ($candidateX->toBytes() != $curveX->toBytes()) { break; } @@ -409,8 +405,8 @@ trait Common break; } - list($candidateX, $candidateY) = $candidate->getBasePoint(); - list($curveX, $curveY) = $curve->getBasePoint(); + [$candidateX, $candidateY] = $candidate->getBasePoint(); + [$curveX, $curveY] = $curve->getBasePoint(); if ($candidateX->toBytes() != $curveX->toBytes()) { break; } @@ -531,7 +527,7 @@ trait Common * A specified curve has all the coefficients, the base points, etc, explicitely included. * A specified curve is a more verbose way of representing a curve */ - public static function useSpecifiedCurve() + public static function useSpecifiedCurve(): void { self::$useNamedCurves = false; } @@ -543,7 +539,7 @@ trait Common * know what the coefficients, the base points, etc, are from the name of the curve. * A named curve is a more concise way of representing a curve */ - public static function useNamedCurve() + public static function useNamedCurve(): void { self::$useNamedCurves = true; } diff --git a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php index 3f1d40fc..7e7e23c4 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php +++ b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php @@ -18,6 +18,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; @@ -25,6 +27,7 @@ use phpseclib3\Crypt\EC\Curves\Curve25519; use phpseclib3\Crypt\EC\Curves\Curve448; use phpseclib3\Exception\UnsupportedFormatException; use phpseclib3\Math\BigInteger; +use phpseclib3\Math\Common\FiniteField\Integer; /** * Montgomery Curve Private Key Handler @@ -35,18 +38,15 @@ abstract class MontgomeryPrivate { /** * Is invisible flag - * */ const IS_INVISIBLE = true; /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|false $password */ - public static function load($key, $password = '') + public static function load(string $key, $password = ''): array { switch (strlen($key)) { case 32: @@ -71,11 +71,9 @@ abstract class MontgomeryPrivate /** * Convert an EC public key to the appropriate format * - * @param \phpseclib3\Crypt\EC\BaseCurves\Montgomery $curve - * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @return string + * @param Integer[] $publicKey */ - public static function savePublicKey(MontgomeryCurve $curve, array $publicKey) + public static function savePublicKey(MontgomeryCurve $curve, array $publicKey): string { return strrev($publicKey[0]->toBytes()); } @@ -83,13 +81,10 @@ abstract class MontgomeryPrivate /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $privateKey - * @param \phpseclib3\Crypt\EC\BaseCurves\Montgomery $curve - * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @param string $password optional - * @return string + * @param Integer[] $publicKey + * @param string|false $password */ - public static function savePrivateKey(BigInteger $privateKey, MontgomeryCurve $curve, array $publicKey, $password = '') + public static function savePrivateKey(BigInteger $privateKey, MontgomeryCurve $curve, array $publicKey, $password = ''): string { if (!empty($password) && is_string($password)) { throw new UnsupportedFormatException('MontgomeryPrivate private keys do not support encryption'); diff --git a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php index d1ad48a5..dbc56ab7 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php +++ b/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve; @@ -27,18 +29,15 @@ abstract class MontgomeryPublic { /** * Is invisible flag - * */ const IS_INVISIBLE = true; /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|false $password */ - public static function load($key, $password = '') + public static function load(string $key, $password = ''): array { switch (strlen($key)) { case 32: @@ -60,11 +59,9 @@ abstract class MontgomeryPublic /** * Convert an EC public key to the appropriate format * - * @param \phpseclib3\Crypt\EC\BaseCurves\Montgomery $curve * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @return string */ - public static function savePublicKey(MontgomeryCurve $curve, array $publicKey) + public static function savePublicKey(MontgomeryCurve $curve, array $publicKey): string { return strrev($publicKey[0]->toBytes()); } diff --git a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php index a3aa482f..8212f43f 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -46,27 +48,26 @@ abstract class OpenSSH extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { $parsed = parent::load($key, $password); if (isset($parsed['paddedKey'])) { $paddedKey = $parsed['paddedKey']; - list($type) = Strings::unpackSSH2('s', $paddedKey); + [$type] = Strings::unpackSSH2('s', $paddedKey); if ($type != $parsed['type']) { throw new \RuntimeException("The public and private keys are not of the same type ($type vs $parsed[type])"); } if ($type == 'ssh-ed25519') { - list(, $key, $comment) = Strings::unpackSSH2('sss', $paddedKey); + [, $key, $comment] = Strings::unpackSSH2('sss', $paddedKey); $key = libsodium::load($key); $key['comment'] = $comment; return $key; } - list($curveName, $publicKey, $privateKey, $comment) = Strings::unpackSSH2('ssis', $paddedKey); + [$curveName, $publicKey, $privateKey, $comment] = Strings::unpackSSH2('ssis', $paddedKey); $curve = self::loadCurveByParam(['namedCurve' => $curveName]); $curve->rangeCheck($privateKey); return [ @@ -85,7 +86,7 @@ abstract class OpenSSH extends Progenitor $curve = new Ed25519(); $qa = self::extractPoint($parsed['publicKey'], $curve); } else { - list($curveName, $publicKey) = Strings::unpackSSH2('ss', $parsed['publicKey']); + [$curveName, $publicKey] = Strings::unpackSSH2('ss', $parsed['publicKey']); $curveName = '\phpseclib3\Crypt\EC\Curves\\' . $curveName; $curve = new $curveName(); @@ -101,10 +102,8 @@ abstract class OpenSSH extends Progenitor /** * Returns the alias that corresponds to a curve - * - * @return string */ - private static function getAlias(BaseCurve $curve) + private static function getAlias(BaseCurve $curve): string { self::initialize_static_variables(); @@ -134,19 +133,17 @@ abstract class OpenSSH extends Progenitor /** * Convert an EC public key to the appropriate format * - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey * @param array $options optional - * @return string */ - public static function savePublicKey(BaseCurve $curve, array $publicKey, array $options = []) + public static function savePublicKey(BaseCurve $curve, array $publicKey, array $options = []): string { - $comment = isset($options['comment']) ? $options['comment'] : self::$comment; + $comment = $options['comment'] ?? self::$comment; if ($curve instanceof Ed25519) { $key = Strings::packSSH2('ss', 'ssh-ed25519', $curve->encodePoint($publicKey)); - if (isset($options['binary']) ? $options['binary'] : self::$binary) { + if ($options['binary'] ?? self::$binary) { return $key; } @@ -159,7 +156,7 @@ abstract class OpenSSH extends Progenitor $points = "\4" . $publicKey[0]->toBytes() . $publicKey[1]->toBytes(); $key = Strings::packSSH2('sss', 'ecdsa-sha2-' . $alias, $alias, $points); - if (isset($options['binary']) ? $options['binary'] : self::$binary) { + if ($options['binary'] ?? self::$binary) { return $key; } @@ -171,15 +168,18 @@ abstract class OpenSSH extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $privateKey * @param \phpseclib3\Crypt\EC\Curves\Ed25519 $curve * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @param string $password optional + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = []) - { + public static function savePrivateKey( + BigInteger $privateKey, + BaseCurve $curve, + array $publicKey, + $password = '', + array $options = [] + ): string { if ($curve instanceof Ed25519) { if (!isset($privateKey->secret)) { throw new \RuntimeException('Private Key does not have a secret set'); diff --git a/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php b/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php index 51a6d4ea..d3167edd 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php @@ -23,6 +23,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -35,6 +37,7 @@ use phpseclib3\Exception\UnsupportedCurveException; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; use phpseclib3\Math\BigInteger; +use phpseclib3\Math\Common\FiniteField\Integer; /** * "PKCS1" (RFC5915) Formatted EC Key Handler @@ -48,11 +51,10 @@ abstract class PKCS1 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { self::initialize_static_variables(); @@ -142,10 +144,8 @@ abstract class PKCS1 extends Progenitor /** * Convert EC parameters to the appropriate format - * - * @return string */ - public static function saveParameters(BaseCurve $curve, array $options = []) + public static function saveParameters(BaseCurve $curve, array $options = []): string { self::initialize_static_variables(); @@ -163,14 +163,11 @@ abstract class PKCS1 extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $privateKey - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve - * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @param string $password optional + * @param Integer[] $publicKey + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = []): string { self::initialize_static_variables(); diff --git a/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php b/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php index 54a3e96f..f56faf16 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php @@ -21,6 +21,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -34,6 +36,7 @@ use phpseclib3\Exception\UnsupportedCurveException; use phpseclib3\File\ASN1; use phpseclib3\File\ASN1\Maps; use phpseclib3\Math\BigInteger; +use phpseclib3\Math\Common\FiniteField\Integer; /** * PKCS#8 Formatted EC Key Handler @@ -61,11 +64,10 @@ abstract class PKCS8 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { // initialize_static_variables() is defined in both the trait and the parent class // when it's defined in two places it's the traits one that's called @@ -129,10 +131,8 @@ abstract class PKCS8 extends Progenitor /** * Break a public or private EdDSA key down into its constituent components - * - * @return array */ - private static function loadEdDSA(array $key) + private static function loadEdDSA(array $key): array { $components = []; @@ -165,12 +165,10 @@ abstract class PKCS8 extends Progenitor /** * Convert an EC public key to the appropriate format * - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve - * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey + * @param Integer[] $publicKey * @param array $options optional - * @return string */ - public static function savePublicKey(BaseCurve $curve, array $publicKey, array $options = []) + public static function savePublicKey(BaseCurve $curve, array $publicKey, array $options = []): string { self::initialize_static_variables(); @@ -196,14 +194,11 @@ abstract class PKCS8 extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $privateKey - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve - * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @param string $password optional + * @param Integer[] $publicKey + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = []): string { self::initialize_static_variables(); diff --git a/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php b/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php index 0a579217..42a03a5d 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -51,11 +53,11 @@ abstract class PuTTY extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password + * @return array|false */ - public static function load($key, $password = '') + public static function load($key, $password) { $components = parent::load($key, $password); if (!isset($components['private'])) { @@ -73,7 +75,7 @@ abstract class PuTTY extends Progenitor } $components['dA'] = $components['curve']->extractSecret($private); } else { - list($components['dA']) = Strings::unpackSSH2('i', $private); + [$components['dA']] = Strings::unpackSSH2('i', $private); $components['curve']->rangeCheck($components['dA']); } @@ -83,21 +85,18 @@ abstract class PuTTY extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $privateKey - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey * @param string $password optional * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = false, array $options = []) + public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = false, array $options = []): string { self::initialize_static_variables(); $public = explode(' ', OpenSSH::savePublicKey($curve, $publicKey)); $name = $public[0]; $public = Base64::decode($public[1]); - list(, $length) = unpack('N', Strings::shift($public, 4)); + [, $length] = unpack('N', Strings::shift($public, 4)); Strings::shift($public, $length); // PuTTY pads private keys with a null byte per the following: @@ -119,16 +118,14 @@ abstract class PuTTY extends Progenitor /** * Convert an EC public key to the appropriate format * - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve * @param \phpseclib3\Math\Common\FiniteField[] $publicKey - * @return string */ - public static function savePublicKey(BaseCurve $curve, array $publicKey) + public static function savePublicKey(BaseCurve $curve, array $publicKey): string { $public = explode(' ', OpenSSH::savePublicKey($curve, $publicKey)); $type = $public[0]; $public = Base64::decode($public[1]); - list(, $length) = unpack('N', Strings::shift($public, 4)); + [, $length] = unpack('N', Strings::shift($public, 4)); Strings::shift($public, $length); return self::wrapPublicKey($public, $type); diff --git a/phpseclib/Crypt/EC/Formats/Keys/XML.php b/phpseclib/Crypt/EC/Formats/Keys/XML.php index d548bc27..d452e275 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/XML.php +++ b/phpseclib/Crypt/EC/Formats/Keys/XML.php @@ -16,6 +16,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -54,11 +56,10 @@ abstract class XML /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { self::initialize_static_variables(); @@ -109,13 +110,11 @@ abstract class XML /** * Case-insensitive xpath query * - * @param \DOMXPath $xpath - * @param string $name - * @param string $error optional + * @param string|null $error optional * @param bool $decode optional - * @return \DOMNodeList + * @return \DOMNodeList|string */ - private static function query($xpath, $name, $error = null, $decode = true) + private static function query(\DOMXPath $xpath, string $name, string $error = null, bool $decode = true) { $query = '/'; $names = explode('/', $name); @@ -135,11 +134,8 @@ abstract class XML /** * Finds the first element in the relevant namespace, strips the namespacing and returns the XML for that element. - * - * @param string $xml - * @param string $ns */ - private static function isolateNamespace($xml, $ns) + private static function isolateNamespace(string $xml, string $ns) { $dom = new \DOMDocument(); if (!$dom->loadXML($xml)) { @@ -160,10 +156,8 @@ abstract class XML /** * Decodes the value - * - * @param string $value */ - private static function decodeValue($value) + private static function decodeValue(string $value): string { return Base64::decode(str_replace(["\r", "\n", ' ', "\t"], '', $value)); } @@ -171,11 +165,9 @@ abstract class XML /** * Extract points from an XML document * - * @param \DOMXPath $xpath - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve * @return object[] */ - private static function extractPointRFC4050(\DOMXPath $xpath, BaseCurve $curve) + private static function extractPointRFC4050(\DOMXPath $xpath, BaseCurve $curve): array { $x = self::query($xpath, 'publickey/x'); $y = self::query($xpath, 'publickey/y'); @@ -199,7 +191,6 @@ abstract class XML * Returns an instance of \phpseclib3\Crypt\EC\BaseCurves\Base based * on the curve parameters * - * @param \DomXPath $xpath * @return \phpseclib3\Crypt\EC\BaseCurves\Base|false */ private static function loadCurveByParam(\DOMXPath $xpath) @@ -279,7 +270,6 @@ abstract class XML * Returns an instance of \phpseclib3\Crypt\EC\BaseCurves\Base based * on the curve parameters * - * @param \DomXPath $xpath * @return \phpseclib3\Crypt\EC\BaseCurves\Base|false */ private static function loadCurveByParamRFC4050(\DOMXPath $xpath) @@ -340,10 +330,8 @@ abstract class XML * Sets the namespace. dsig11 is the most common one. * * Set to null to unset. Used only for creating public keys. - * - * @param string $namespace */ - public static function setNamespace($namespace) + public static function setNamespace(string $namespace): void { self::$namespace = $namespace; } @@ -351,7 +339,7 @@ abstract class XML /** * Uses the XML syntax specified in https://tools.ietf.org/html/rfc4050 */ - public static function enableRFC4050Syntax() + public static function enableRFC4050Syntax(): void { self::$rfc4050 = true; } @@ -359,7 +347,7 @@ abstract class XML /** * Uses the XML syntax specified in https://www.w3.org/TR/xmldsig-core/#sec-ECParameters */ - public static function disableRFC4050Syntax() + public static function disableRFC4050Syntax(): void { self::$rfc4050 = false; } @@ -367,12 +355,10 @@ abstract class XML /** * Convert a public key to the appropriate format * - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey * @param array $options optional - * @return string */ - public static function savePublicKey(BaseCurve $curve, array $publicKey, array $options = []) + public static function savePublicKey(BaseCurve $curve, array $publicKey, array $options = []): string { self::initialize_static_variables(); @@ -408,12 +394,10 @@ abstract class XML /** * Encode Parameters * - * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve - * @param string $pre * @param array $options optional * @return string|false */ - private static function encodeXMLParameters(BaseCurve $curve, $pre, array $options = []) + private static function encodeXMLParameters(BaseCurve $curve, string $pre, array $options = []) { $result = self::encodeParameters($curve, true, $options); @@ -435,7 +419,7 @@ abstract class XML '' . "\r\n"; $a = $curve->getA(); $b = $curve->getB(); - list($x, $y) = $curve->getBasePoint(); + [$x, $y] = $curve->getBasePoint(); break; default: throw new UnsupportedCurveException('Field Type of ' . $temp['fieldID']['fieldType'] . ' is not supported'); diff --git a/phpseclib/Crypt/EC/Formats/Keys/libsodium.php b/phpseclib/Crypt/EC/Formats/Keys/libsodium.php index c9259a07..7fa32507 100644 --- a/phpseclib/Crypt/EC/Formats/Keys/libsodium.php +++ b/phpseclib/Crypt/EC/Formats/Keys/libsodium.php @@ -15,6 +15,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Keys; use phpseclib3\Crypt\EC\Curves\Ed25519; @@ -32,18 +34,15 @@ abstract class libsodium /** * Is invisible flag - * */ const IS_INVISIBLE = true; /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|false $password optional */ - public static function load($key, $password = '') + public static function load(string $key, $password = ''): array { switch (strlen($key)) { case 32: @@ -79,11 +78,9 @@ abstract class libsodium /** * Convert an EC public key to the appropriate format * - * @param \phpseclib3\Crypt\EC\Curves\Ed25519 $curve * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @return string */ - public static function savePublicKey(Ed25519 $curve, array $publicKey) + public static function savePublicKey(Ed25519 $curve, array $publicKey): string { return $curve->encodePoint($publicKey); } @@ -91,13 +88,10 @@ abstract class libsodium /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $privateKey - * @param \phpseclib3\Crypt\EC\Curves\Ed25519 $curve * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey - * @param string $password optional - * @return string + * @param string|false $password */ - public static function savePrivateKey(BigInteger $privateKey, Ed25519 $curve, array $publicKey, $password = '') + public static function savePrivateKey(BigInteger $privateKey, Ed25519 $curve, array $publicKey, $password = ''): string { if (!isset($privateKey->secret)) { throw new \RuntimeException('Private Key does not have a secret set'); diff --git a/phpseclib/Crypt/EC/Formats/Signature/ASN1.php b/phpseclib/Crypt/EC/Formats/Signature/ASN1.php index d2a80a14..288d0045 100644 --- a/phpseclib/Crypt/EC/Formats/Signature/ASN1.php +++ b/phpseclib/Crypt/EC/Formats/Signature/ASN1.php @@ -14,6 +14,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Signature; use phpseclib3\File\ASN1 as Encoder; @@ -30,10 +32,9 @@ abstract class ASN1 /** * Loads a signature * - * @param string $sig * @return array */ - public static function load($sig) + public static function load(string $sig) { if (!is_string($sig)) { return false; @@ -50,12 +51,8 @@ abstract class ASN1 /** * Returns a signature in the appropriate format - * - * @param \phpseclib3\Math\BigInteger $r - * @param \phpseclib3\Math\BigInteger $s - * @return string */ - public static function save(BigInteger $r, BigInteger $s) + public static function save(BigInteger $r, BigInteger $s): string { return Encoder::encodeDER(compact('r', 's'), EcdsaSigValue::MAP); } diff --git a/phpseclib/Crypt/EC/Formats/Signature/Raw.php b/phpseclib/Crypt/EC/Formats/Signature/Raw.php index 7e4b47fe..43b2aadb 100644 --- a/phpseclib/Crypt/EC/Formats/Signature/Raw.php +++ b/phpseclib/Crypt/EC/Formats/Signature/Raw.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Signature; use phpseclib3\Crypt\Common\Formats\Signature\Raw as Progenitor; diff --git a/phpseclib/Crypt/EC/Formats/Signature/SSH2.php b/phpseclib/Crypt/EC/Formats/Signature/SSH2.php index e0644421..dd1f1122 100644 --- a/phpseclib/Crypt/EC/Formats/Signature/SSH2.php +++ b/phpseclib/Crypt/EC/Formats/Signature/SSH2.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC\Formats\Signature; use phpseclib3\Common\Functions\Strings; @@ -27,11 +29,8 @@ abstract class SSH2 { /** * Loads a signature - * - * @param string $sig - * @return mixed */ - public static function load($sig) + public static function load(string $sig) { if (!is_string($sig)) { return false; @@ -41,7 +40,7 @@ abstract class SSH2 if ($result === false) { return false; } - list($type, $blob) = $result; + [$type, $blob] = $result; switch ($type) { // see https://tools.ietf.org/html/rfc5656#section-3.1.2 case 'ecdsa-sha2-nistp256': @@ -66,12 +65,9 @@ abstract class SSH2 /** * Returns a signature in the appropriate format * - * @param \phpseclib3\Math\BigInteger $r - * @param \phpseclib3\Math\BigInteger $s - * @param string $curve * @return string */ - public static function save(BigInteger $r, BigInteger $s, $curve) + public static function save(BigInteger $r, BigInteger $s, string $curve) { switch ($curve) { case 'secp256r1': diff --git a/phpseclib/Crypt/EC/Parameters.php b/phpseclib/Crypt/EC/Parameters.php index c9bf1bea..96782865 100644 --- a/phpseclib/Crypt/EC/Parameters.php +++ b/phpseclib/Crypt/EC/Parameters.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC; use phpseclib3\Crypt\EC; @@ -23,11 +25,9 @@ class Parameters extends EC /** * Returns the parameters * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type = 'PKCS1', array $options = []) + public function toString(string $type = 'PKCS1', array $options = []): string { $type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters'); diff --git a/phpseclib/Crypt/EC/PrivateKey.php b/phpseclib/Crypt/EC/PrivateKey.php index 3632b778..f9991bf8 100644 --- a/phpseclib/Crypt/EC/PrivateKey.php +++ b/phpseclib/Crypt/EC/PrivateKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC; use phpseclib3\Common\Functions\Strings; @@ -48,11 +50,8 @@ class PrivateKey extends EC implements Common\PrivateKey * Multiplies an encoded point by the private key * * Used by ECDH - * - * @param string $coordinates - * @return string */ - public function multiply($coordinates) + public function multiply(string $coordinates): string { if ($this->curve instanceof MontgomeryCurve) { if ($this->curve instanceof Curve25519 && self::$engines['libsodium']) { @@ -82,7 +81,6 @@ class PrivateKey extends EC implements Common\PrivateKey * * @see self::verify() * @param string $message - * @return mixed */ public function sign($message) { @@ -118,22 +116,22 @@ class PrivateKey extends EC implements Common\PrivateKey $dom = !isset($this->context) ? '' : 'SigEd25519 no Ed25519 collisions' . "\0" . chr(strlen($this->context)) . $this->context; } else { - $context = isset($this->context) ? $this->context : ''; + $context = $this->context ?? ''; $dom = 'SigEd448' . "\0" . chr(strlen($context)) . $context; } // SHA-512(dom2(F, C) || prefix || PH(M)) $r = $hash->hash($dom . $secret . $message); $r = strrev($r); $r = new BigInteger($r, 256); - list(, $r) = $r->divide($order); + [, $r] = $r->divide($order); $R = $curve->multiplyPoint($curve->getBasePoint(), $r); $R = $curve->encodePoint($R); $k = $hash->hash($dom . $R . $A . $message); $k = strrev($k); $k = new BigInteger($k, 256); - list(, $k) = $k->divide($order); + [, $k] = $k->divide($order); $S = $k->multiply($dA)->add($r); - list(, $S) = $S->divide($order); + [, $S] = $S->divide($order); $S = str_pad(strrev($S->toBytes()), $curve::SIZE, "\0"); return $shortFormat == 'SSH2' ? Strings::packSSH2('ss', 'ssh-' . strtolower($this->getCurve()), $R . $S) : $R . $S; } @@ -166,16 +164,16 @@ class PrivateKey extends EC implements Common\PrivateKey while (true) { $k = BigInteger::randomRange(self::$one, $order->subtract(self::$one)); - list($x, $y) = $this->curve->multiplyPoint($this->curve->getBasePoint(), $k); + [$x, $y] = $this->curve->multiplyPoint($this->curve->getBasePoint(), $k); $x = $x->toBigInteger(); - list(, $r) = $x->divide($order); + [, $r] = $x->divide($order); if ($r->equals(self::$zero)) { continue; } $kinv = $k->modInverse($order); $temp = $z->add($dA->multiply($r)); $temp = $kinv->multiply($temp); - list(, $s) = $temp->divide($order); + [, $s] = $temp->divide($order); if (!$s->equals(self::$zero)) { break; } @@ -209,11 +207,9 @@ class PrivateKey extends EC implements Common\PrivateKey /** * Returns the private key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin('Keys', $type, 'savePrivateKey'); @@ -224,7 +220,6 @@ class PrivateKey extends EC implements Common\PrivateKey * Returns the public key * * @see self::getPrivateKey() - * @return mixed */ public function getPublicKey() { diff --git a/phpseclib/Crypt/EC/PublicKey.php b/phpseclib/Crypt/EC/PublicKey.php index 609d5960..ef394360 100644 --- a/phpseclib/Crypt/EC/PublicKey.php +++ b/phpseclib/Crypt/EC/PublicKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\EC; use phpseclib3\Common\Functions\Strings; @@ -38,9 +40,8 @@ class PublicKey extends EC implements Common\PublicKey * @see self::verify() * @param string $message * @param string $signature - * @return mixed */ - public function verify($message, $signature) + public function verify($message, $signature): bool { if ($this->curve instanceof MontgomeryCurve) { throw new UnsupportedOperationException('Montgomery Curves cannot be used to create signatures'); @@ -56,7 +57,7 @@ class PublicKey extends EC implements Common\PublicKey if ($this->curve instanceof TwistedEdwardsCurve) { if ($shortFormat == 'SSH2') { - list(, $signature) = Strings::unpackSSH2('ss', $signature); + [, $signature] = Strings::unpackSSH2('ss', $signature); } if ($this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context)) { @@ -91,7 +92,7 @@ class PublicKey extends EC implements Common\PublicKey $dom2 = !isset($this->context) ? '' : 'SigEd25519 no Ed25519 collisions' . "\0" . chr(strlen($this->context)) . $this->context; } else { - $context = isset($this->context) ? $this->context : ''; + $context = $this->context ?? ''; $dom2 = 'SigEd448' . "\0" . chr(strlen($context)) . $context; } @@ -99,7 +100,7 @@ class PublicKey extends EC implements Common\PublicKey $k = $hash->hash($dom2 . substr($signature, 0, $curve::SIZE) . $A . $message); $k = strrev($k); $k = new BigInteger($k, 256); - list(, $k) = $k->divide($order); + [, $k] = $k->divide($order); $qa = $curve->convertToInternal($this->QA); @@ -139,19 +140,19 @@ class PublicKey extends EC implements Common\PublicKey $z = $Ln > 0 ? $e->bitwise_rightShift($Ln) : $e; $w = $s->modInverse($order); - list(, $u1) = $z->multiply($w)->divide($order); - list(, $u2) = $r->multiply($w)->divide($order); + [, $u1] = $z->multiply($w)->divide($order); + [, $u2] = $r->multiply($w)->divide($order); $u1 = $this->curve->convertInteger($u1); $u2 = $this->curve->convertInteger($u2); - list($x1, $y1) = $this->curve->multiplyAddPoints( + [$x1, $y1] = $this->curve->multiplyAddPoints( [$this->curve->getBasePoint(), $this->QA], [$u1, $u2] ); $x1 = $x1->toBigInteger(); - list(, $x1) = $x1->divide($order); + [, $x1] = $x1->divide($order); return $x1->equals($r); } @@ -159,11 +160,9 @@ class PublicKey extends EC implements Common\PublicKey /** * Returns the public key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin('Keys', $type, 'savePublicKey'); diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 5964c57d..6ac2dcd9 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -29,6 +29,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Common\Functions\Strings; @@ -45,19 +47,16 @@ class Hash { /** * Padding Types - * */ const PADDING_KECCAK = 1; /** * Padding Types - * */ const PADDING_SHA3 = 2; /** * Padding Types - * */ const PADDING_SHAKE = 3; @@ -189,10 +188,8 @@ class Hash /** * Default Constructor. - * - * @param string $hash */ - public function __construct($hash = 'sha256') + public function __construct(string $hash = 'sha256') { $this->setHash($hash); } @@ -204,7 +201,7 @@ class Hash * * @param string $key */ - public function setKey($key = false) + public function setKey($key = false): void { $this->key = $key; $this->computeKey(); @@ -218,7 +215,7 @@ class Hash * * @param string $nonce */ - public function setNonce($nonce = false) + public function setNonce($nonce = false): void { switch (true) { case !is_string($nonce): @@ -240,9 +237,8 @@ class Hash * As documented in https://www.reddit.com/r/PHP/comments/9nct2l/symfonypolyfill_hash_pbkdf2_correct_fix_for/ * when doing an HMAC multiple times it's faster to compute the hash once instead of computing it during * every call - * */ - private function computeKey() + private function computeKey(): void { if ($this->key === false) { $this->computedKey = false; @@ -273,10 +269,8 @@ class Hash /** * Sets the hash function. - * - * @param string $hash */ - public function setHash($hash) + public function setHash(string $hash): void { $this->hashParam = $hash = strtolower($hash); switch ($hash) { @@ -285,7 +279,7 @@ class Hash case 'umac-96': case 'umac-128': $this->blockSize = 128; - $this->length = abs(substr($hash, -3)) >> 3; + $this->length = abs((int) substr($hash, -3)) >> 3; $this->algo = 'umac'; return; case 'md2-96': @@ -441,7 +435,7 @@ class Hash * @param int $numbytes a non-negative integer less than 2^64 * @return string string of length numbytes bytes */ - private function kdf($index, $numbytes) + private function kdf(int $index, int $numbytes): string { $this->c->setIV(pack('N4', 0, $index, 0, 1)); @@ -453,7 +447,7 @@ class Hash * * @return string string of length taglen bytes. */ - private function pdf() + private function pdf(): string { $k = $this->key; $nonce = $this->nonce; @@ -498,7 +492,7 @@ class Hash * @param int $taglen the integer 4, 8, 12 or 16. * @return string string of length taglen bytes. */ - private function uhash($m, $taglen) + private function uhash(string $m, int $taglen): string { // // One internal iteration per 4 bytes of output @@ -546,7 +540,7 @@ class Hash * @param string $m string of length less than 2^67 bits. * @return string string of length (8 * ceil(bitlength(M)/8192)) bytes. */ - private static function L1Hash($k, $m) + private static function L1Hash(string $k, string $m): string { // // Break M into 1024 byte chunks (final chunk may be shorter) @@ -586,7 +580,7 @@ class Hash * @param string $m string with length divisible by 32 bytes. * @return string string of length 8 bytes. */ - private static function nh($k, $m, $length) + private static function nh(string $k, string $m, $length): string { $toUInt32 = function ($x) { $x = new BigInteger($x, 256); @@ -655,7 +649,7 @@ class Hash * @param string $m string of length less than 2^64 bytes. * @return string string of length 16 bytes. */ - private static function L2Hash($k, $m) + private static function L2Hash(string $k, string $m): string { // // Extract keys and restrict to special key-sets @@ -691,12 +685,12 @@ class Hash * POLY Algorithm * * @param int $wordbits the integer 64 or 128. - * @param BigInteger $maxwordrange positive integer less than 2^wordbits. + * @param PrimeField\Integer $maxwordrange positive integer less than 2^wordbits. * @param BigInteger $k integer in the range 0 ... prime(wordbits) - 1. * @param string $m string with length divisible by (wordbits / 8) bytes. - * @return integer in the range 0 ... prime(wordbits) - 1. + * @return string in the range 0 ... prime(wordbits) - 1. */ - private static function poly($wordbits, $maxwordrange, $k, $m) + private static function poly(int $wordbits, PrimeField\Integer $maxwordrange, BigInteger $k, string $m): string { // // Define constants used for fixing out-of-range words @@ -748,7 +742,7 @@ class Hash * @param string $m string of length 16 bytes. * @return string string of length 4 bytes. */ - private static function L3Hash($k1, $k2, $m) + private static function L3Hash(string $k1, string $k2, string $m): string { $factory = self::$factory36; @@ -766,11 +760,8 @@ class Hash /** * Compute the Hash / HMAC / UMAC. - * - * @param string $text - * @return string */ - public function hash($text) + public function hash(string $text): string { $algo = $this->algo; if ($algo == 'umac') { @@ -854,52 +845,40 @@ class Hash /** * Returns the hash length (in bits) - * - * @return int */ - public function getLength() + public function getLength(): int { return $this->length << 3; } /** * Returns the hash length (in bytes) - * - * @return int */ - public function getLengthInBytes() + public function getLengthInBytes(): int { return $this->length; } /** * Returns the block length (in bits) - * - * @return int */ - public function getBlockLength() + public function getBlockLength(): int { return $this->blockSize; } /** * Returns the block length (in bytes) - * - * @return int */ - public function getBlockLengthInBytes() + public function getBlockLengthInBytes(): int { return $this->blockSize >> 3; } /** * Pads SHA3 based on the mode - * - * @param int $padLength - * @param int $padType - * @return string */ - private static function sha3_pad($padLength, $padType) + private static function sha3_pad(int $padLength, int $padType): string { switch ($padType) { case self::PADDING_KECCAK: @@ -936,14 +915,8 @@ class Hash * defined as "the KECCAK instance with KECCAK-f[1600] as the underlying permutation and * capacity c". This is relevant because, altho the KECCAK standard defines a mode * (KECCAK-f[800]) designed for 32-bit machines that mode is incompatible with SHA3 - * - * @param string $p - * @param int $c - * @param int $r - * @param int $d - * @param int $padType */ - private static function sha3_32($p, $c, $r, $d, $padType) + private static function sha3_32(string $p, int $c, int $r, int $d, int $padType): string { $block_size = $r >> 3; $padLength = $block_size - (strlen($p) % $block_size); @@ -996,10 +969,8 @@ class Hash /** * 32-bit block processing method for SHA3 - * - * @param array $s */ - private static function processSHA3Block32(&$s) + private static function processSHA3Block32(array &$s): void { static $rotationOffsets = [ [ 0, 1, 62, 28, 27], @@ -1105,17 +1076,14 @@ class Hash /** * Rotate 32-bit int - * - * @param array $x - * @param int $shift */ - private static function rotateLeft32($x, $shift) + private static function rotateLeft32(array $x, int $shift): array { if ($shift < 32) { - list($hi, $lo) = $x; + [$hi, $lo] = $x; } else { $shift -= 32; - list($lo, $hi) = $x; + [$lo, $hi] = $x; } return [ @@ -1126,14 +1094,8 @@ class Hash /** * Pure-PHP 64-bit implementation of SHA3 - * - * @param string $p - * @param int $c - * @param int $r - * @param int $d - * @param int $padType */ - private static function sha3_64($p, $c, $r, $d, $padType) + private static function sha3_64(string $p, int $c, int $r, int $d, int $padType): string { $block_size = $r >> 3; $padLength = $block_size - (strlen($p) % $block_size); @@ -1185,10 +1147,8 @@ class Hash /** * 64-bit block processing method for SHA3 - * - * @param array $s */ - private static function processSHA3Block64(&$s) + private static function processSHA3Block64(array &$s): void { static $rotationOffsets = [ [ 0, 1, 62, 28, 27], @@ -1271,23 +1231,16 @@ class Hash /** * Rotate 64-bit int - * - * @param int $x - * @param int $shift */ - private static function rotateLeft64($x, $shift) + private static function rotateLeft64(int $x, int $shift): int { return ($x << $shift) | (($x >> (64 - $shift)) & ((1 << $shift) - 1)); } /** * Pure-PHP implementation of SHA512 - * - * @param string $m - * @param array $hash - * @return string */ - private static function sha512($m, $hash) + private static function sha512(string $m, array $hash): string { static $k; diff --git a/phpseclib/Crypt/PublicKeyLoader.php b/phpseclib/Crypt/PublicKeyLoader.php index 61afbaeb..a103dd59 100644 --- a/phpseclib/Crypt/PublicKeyLoader.php +++ b/phpseclib/Crypt/PublicKeyLoader.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; @@ -29,11 +31,10 @@ abstract class PublicKeyLoader /** * Loads a public or private key * - * @return AsymmetricKey * @param string|array $key * @param string $password optional */ - public static function load($key, $password = false) + public static function load($key, $password = false): AsymmetricKey { try { return EC::load($key, $password); @@ -66,11 +67,10 @@ abstract class PublicKeyLoader /** * Loads a private key * - * @return PrivateKey * @param string|array $key * @param string $password optional */ - public static function loadPrivateKey($key, $password = false) + public static function loadPrivateKey($key, $password = false): PrivateKey { $key = self::load($key, $password); if (!$key instanceof PrivateKey) { @@ -82,10 +82,9 @@ abstract class PublicKeyLoader /** * Loads a public key * - * @return PublicKey * @param string|array $key */ - public static function loadPublicKey($key) + public static function loadPublicKey($key): PublicKey { $key = self::load($key); if (!$key instanceof PublicKey) { @@ -97,10 +96,9 @@ abstract class PublicKeyLoader /** * Loads parameters * - * @return AsymmetricKey * @param string|array $key */ - public static function loadParameters($key) + public static function loadParameters($key): AsymmetricKey { $key = self::load($key); if (!$key instanceof PrivateKey && !$key instanceof PublicKey) { diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 779a0e25..49d66198 100644 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -31,6 +31,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\BlockCipher; @@ -38,7 +40,6 @@ use phpseclib3\Exception\BadModeException; /** * Pure-PHP implementation of RC2. - * */ class RC2 extends BlockCipher { @@ -252,10 +253,9 @@ class RC2 extends BlockCipher /** * Default Constructor. * - * @param string $mode * @throws \InvalidArgumentException if an invalid / unsupported mode is provided */ - public function __construct($mode) + public function __construct(string $mode) { parent::__construct($mode); @@ -269,11 +269,9 @@ class RC2 extends BlockCipher * * This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() * - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @param int $engine - * @return bool + *@see \phpseclib3\Crypt\Common\SymmetricKey::__construct() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { switch ($engine) { case self::ENGINE_OPENSSL: @@ -297,7 +295,7 @@ class RC2 extends BlockCipher * @param int $length in bits * @throws \LengthException if the key length isn't supported */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { if ($length < 8 || $length > 1024) { throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported'); @@ -309,10 +307,8 @@ class RC2 extends BlockCipher /** * Returns the current key length - * - * @return int */ - public function getKeyLength() + public function getKeyLength(): int { return $this->current_key_length; } @@ -325,12 +321,10 @@ class RC2 extends BlockCipher * has more then 128 bytes in it, and set $key to a single null byte if * it is empty. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::setKey() - * @param string $key - * @param int|boolean $t1 optional Effective key length in bits. * @throws \LengthException if the key length isn't supported + *@see \phpseclib3\Crypt\Common\SymmetricKey::setKey() */ - public function setKey($key, $t1 = false) + public function setKey(string $key, $t1 = false): void { $this->orig_key = $key; @@ -339,7 +333,7 @@ class RC2 extends BlockCipher } if ($t1 < 1 || $t1 > 1024) { - throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported'); + //throw new \LengthException('Key size of ' . $t1 . ' bits is not supported by this algorithm. Only keys between 1 and 1024 bits, inclusive, are supported'); } $this->current_key_length = $t1; @@ -386,11 +380,10 @@ class RC2 extends BlockCipher * * Mostly a wrapper for \phpseclib3\Crypt\Common\SymmetricKey::encrypt, with some additional OpenSSL handling code * - * @see self::decrypt() - * @param string $plaintext * @return string $ciphertext + *@see self::decrypt() */ - public function encrypt($plaintext) + public function encrypt(string $plaintext): string { if ($this->engine == self::ENGINE_OPENSSL) { $temp = $this->key; @@ -408,11 +401,10 @@ class RC2 extends BlockCipher * * Mostly a wrapper for \phpseclib3\Crypt\Common\SymmetricKey::decrypt, with some additional OpenSSL handling code * - * @see self::encrypt() - * @param string $ciphertext * @return string $plaintext + *@see self::encrypt() */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext): string { if ($this->engine == self::ENGINE_OPENSSL) { $temp = $this->key; @@ -428,14 +420,12 @@ class RC2 extends BlockCipher /** * Encrypts a block * - * @see \phpseclib3\Crypt\Common\SymmetricKey::encryptBlock() + *@see \phpseclib3\Crypt\Common\SymmetricKey::encryptBlock() * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() - * @param string $in - * @return string */ - protected function encryptBlock($in) + protected function encryptBlock(string $in): string { - list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in)); + [$r0, $r1, $r2, $r3] = array_values(unpack('v*', $in)); $keys = $this->keys; $limit = 20; $actions = [$limit => 44, 44 => 64]; @@ -472,14 +462,12 @@ class RC2 extends BlockCipher /** * Decrypts a block * - * @see \phpseclib3\Crypt\Common\SymmetricKey::decryptBlock() + *@see \phpseclib3\Crypt\Common\SymmetricKey::decryptBlock() * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() - * @param string $in - * @return string */ - protected function decryptBlock($in) + protected function decryptBlock(string $in): string { - list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in)); + [$r0, $r1, $r2, $r3] = array_values(unpack('v*', $in)); $keys = $this->keys; $limit = 44; $actions = [$limit => 20, 20 => 0]; @@ -518,7 +506,7 @@ class RC2 extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey() */ - protected function setupKey() + protected function setupKey(): void { if (!isset($this->key)) { $this->setKey(''); @@ -538,7 +526,7 @@ class RC2 extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::setupInlineCrypt() */ - protected function setupInlineCrypt() + protected function setupInlineCrypt(): void { // Init code for both, encrypt and decrypt. $init_crypt = '$keys = $this->keys;'; diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index f7ee7349..e57c4c3f 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -40,6 +40,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\StreamCipher; @@ -98,11 +100,9 @@ class RC4 extends StreamCipher * * This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() * - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @param int $engine - * @return bool + *@see \phpseclib3\Crypt\Common\SymmetricKey::__construct() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { if ($engine == self::ENGINE_OPENSSL) { if ($this->continuousBuffer) { @@ -135,10 +135,9 @@ class RC4 extends StreamCipher * * Keys can be between 1 and 256 bytes long. * - * @param int $length * @throws \LengthException if the key length is invalid */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { if ($length < 8 || $length > 2048) { throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys between 1 and 256 bytes are supported'); @@ -153,10 +152,8 @@ class RC4 extends StreamCipher * Sets the key length * * Keys can be between 1 and 256 bytes long. - * - * @param string $key */ - public function setKey($key) + public function setKey(string $key): void { $length = strlen($key); if ($length < 1 || $length > 256) { @@ -169,12 +166,11 @@ class RC4 extends StreamCipher /** * Encrypts a message. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() - * @see self::crypt() - * @param string $plaintext * @return string $ciphertext + *@see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() + * @see self::crypt() */ - public function encrypt($plaintext) + public function encrypt(string $plaintext): string { if ($this->engine != self::ENGINE_INTERNAL) { return parent::encrypt($plaintext); @@ -188,12 +184,11 @@ class RC4 extends StreamCipher * $this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)). * At least if the continuous buffer is disabled. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() - * @see self::crypt() - * @param string $ciphertext * @return string $plaintext + *@see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() + * @see self::crypt() */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext): string { if ($this->engine != self::ENGINE_INTERNAL) { return parent::decrypt($ciphertext); @@ -203,22 +198,20 @@ class RC4 extends StreamCipher /** * Encrypts a block - * - * @param string $in */ - protected function encryptBlock($in) + protected function encryptBlock(string $in): string { // RC4 does not utilize this method + return ''; } /** * Decrypts a block - * - * @param string $in */ - protected function decryptBlock($in) + protected function decryptBlock(string $in): string { // RC4 does not utilize this method + return ''; } /** @@ -226,7 +219,7 @@ class RC4 extends StreamCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupKey() */ - protected function setupKey() + protected function setupKey(): void { $key = $this->key; $keyLength = strlen($key); @@ -250,13 +243,11 @@ class RC4 extends StreamCipher /** * Encrypts or decrypts a message. * - * @see self::encrypt() - * @see self::decrypt() - * @param string $text - * @param int $mode * @return string $text + *@see self::decrypt() + * @see self::encrypt() */ - private function crypt($text, $mode) + private function crypt(string $text, int $mode): string { if ($this->changed) { $this->setup(); diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index e96ba359..7be7ecae 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -51,6 +51,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\AsymmetricKey; @@ -166,9 +168,9 @@ abstract class RSA extends AsymmetricKey /** * Length of salt * - * @var int + * @var int|null */ - protected $sLen; + protected $sLen = null; /** * Label @@ -201,7 +203,7 @@ abstract class RSA extends AsymmetricKey /** * Modulus length * - * @var \phpseclib3\Math\BigInteger + * @var int */ protected $k; @@ -253,10 +255,8 @@ abstract class RSA extends AsymmetricKey * Sets the public exponent for key generation * * This will be 65537 unless changed. - * - * @param int $val */ - public static function setExponent($val) + public static function setExponent(int $val): void { self::$defaultExponent = $val; } @@ -265,10 +265,8 @@ abstract class RSA extends AsymmetricKey * Sets the smallest prime number in bits. Used for key generation * * This will be 4096 unless changed. - * - * @param int $val */ - public static function setSmallestPrime($val) + public static function setSmallestPrime(int $val): void { self::$smallestPrime = $val; } @@ -277,10 +275,8 @@ abstract class RSA extends AsymmetricKey * Sets the OpenSSL config file path * * Set to the empty string to use the default config file - * - * @param string $val */ - public static function setOpenSSLConfigPath($val) + public static function setOpenSSLConfigPath(string $val): void { self::$configFile = $val; } @@ -290,10 +286,9 @@ abstract class RSA extends AsymmetricKey * * The public key can be extracted from the private key * - * @return RSA - * @param int $bits + *@return RSA */ - public static function createKey($bits = 2048) + public static function createKey(int $bits = 2048) { self::initialize_static_variables(); @@ -348,9 +343,9 @@ abstract class RSA extends AsymmetricKey /** @var BigInteger $min * @var BigInteger $max */ - list($min) = $min->divide($n); + [$min] = $min->divide($n); $min = $min->add(self::$one); - list($max) = $max->divide($n); + [$max] = $max->divide($n); $primes[$i] = BigInteger::randomRangePrime($min, $max); } @@ -370,7 +365,7 @@ abstract class RSA extends AsymmetricKey $lcm['bottom'] = $lcm['bottom'] === false ? $temp : $lcm['bottom']->gcd($temp); } - list($temp) = $lcm['top']->divide($lcm['bottom']); + [$temp] = $lcm['top']->divide($lcm['bottom']); $gcd = $temp->gcd($e); $i0 = 1; } while (!$gcd->equals(self::$one)); @@ -421,10 +416,9 @@ abstract class RSA extends AsymmetricKey /** * OnLoad Handler * - * @return bool - * @param array $components + *@return bool */ - protected static function onLoad($components) + protected static function onLoad(array $components) { $key = $components['isPublicKey'] ? new PublicKey() : @@ -470,7 +464,7 @@ abstract class RSA extends AsymmetricKey /** * Initialize static variables */ - protected static function initialize_static_variables() + protected static function initialize_static_variables(): void { if (!isset(self::$configFile)) { self::$configFile = dirname(__FILE__) . '/../openssl.cnf'; @@ -499,10 +493,9 @@ abstract class RSA extends AsymmetricKey * See {@link http://tools.ietf.org/html/rfc3447#section-4.1 RFC3447#section-4.1}. * * @param bool|\phpseclib3\Math\BigInteger $x - * @param int $xLen * @return bool|string */ - protected function i2osp($x, $xLen) + protected function i2osp($x, int $xLen) { if ($x === false) { return false; @@ -518,11 +511,8 @@ abstract class RSA extends AsymmetricKey * Octet-String-to-Integer primitive * * See {@link http://tools.ietf.org/html/rfc3447#section-4.2 RFC3447#section-4.2}. - * - * @param string $x - * @return \phpseclib3\Math\BigInteger */ - protected function os2ip($x) + protected function os2ip(string $x): BigInteger { return new BigInteger($x, 256); } @@ -532,12 +522,9 @@ abstract class RSA extends AsymmetricKey * * See {@link http://tools.ietf.org/html/rfc3447#section-9.2 RFC3447#section-9.2}. * - * @param string $m - * @param int $emLen - * @throws \LengthException if the intended encoded message length is too short - * @return string + *@throws \LengthException if the intended encoded message length is too short */ - protected function emsa_pkcs1_v1_5_encode($m, $emLen) + protected function emsa_pkcs1_v1_5_encode(string $m, int $emLen): string { $h = $this->hash->hash($m); @@ -594,12 +581,8 @@ abstract class RSA extends AsymmetricKey * id-sha384, id-sha512, id-sha512/224, and id-sha512/256 should * generally be omitted, but if present, it shall have a value of type * NULL" - * - * @param string $m - * @param int $emLen - * @return string */ - protected function emsa_pkcs1_v1_5_encode_without_null($m, $emLen) + protected function emsa_pkcs1_v1_5_encode_without_null(string $m, int $emLen): string { $h = $this->hash->hash($m); @@ -648,12 +631,8 @@ abstract class RSA extends AsymmetricKey * MGF1 * * See {@link http://tools.ietf.org/html/rfc3447#appendix-B.2.1 RFC3447#appendix-B.2.1}. - * - * @param string $mgfSeed - * @param int $maskLen - * @return string */ - protected function mgf1($mgfSeed, $maskLen) + protected function mgf1(string $mgfSeed, int $maskLen): string { // if $maskLen would yield strings larger than 4GB, PKCS#1 suggests a "Mask too long" error be output. @@ -671,10 +650,8 @@ abstract class RSA extends AsymmetricKey * Returns the key size * * More specifically, this returns the size of the modulo in bits. - * - * @return int */ - public function getLength() + public function getLength(): int { return !isset($this->modulus) ? 0 : $this->modulus->getLength(); } @@ -684,10 +661,8 @@ abstract class RSA extends AsymmetricKey * * Used with signature production / verification and (if the encryption mode is self::PADDING_OAEP) encryption and * decryption. - * - * @param string $hash */ - public function withHash($hash) + public function withHash(string $hash): RSA { $new = clone $this; @@ -719,10 +694,8 @@ abstract class RSA extends AsymmetricKey * * The mask generation function is used by self::PADDING_OAEP and self::PADDING_PSS and although it's * best if Hash and MGFHash are set to the same thing this is not a requirement. - * - * @param string $hash */ - public function withMGFHash($hash) + public function withMGFHash(string $hash): RSA { $new = clone $this; @@ -751,9 +724,8 @@ abstract class RSA extends AsymmetricKey /** * Returns the MGF hash algorithm currently being used - * */ - public function getMGFHash() + public function getMGFHash(): Hash { return clone $this->mgfHash; } @@ -767,10 +739,8 @@ abstract class RSA extends AsymmetricKey * * Typical salt lengths in octets are hLen (the length of the output * of the hash function Hash) and 0. - * - * @param int $sLen */ - public function withSaltLength($sLen) + public function withSaltLength(?int $sLen): RSA { $new = clone $this; $new->sLen = $sLen; @@ -779,9 +749,8 @@ abstract class RSA extends AsymmetricKey /** * Returns the salt length currently being used - * */ - public function getSaltLength() + public function getSaltLength(): int { return $this->sLen !== null ? $this->sLen : $this->hLen; } @@ -797,10 +766,8 @@ abstract class RSA extends AsymmetricKey * the value of a label L as input. In this version of PKCS #1, L is * the empty string; other uses of the label are outside the scope of * this document. - * - * @param string $label */ - public function withLabel($label) + public function withLabel(string $label): RSA { $new = clone $this; $new->label = $label; @@ -809,9 +776,8 @@ abstract class RSA extends AsymmetricKey /** * Returns the label currently being used - * */ - public function getLabel() + public function getLabel(): string { return $this->label; } @@ -820,10 +786,8 @@ abstract class RSA extends AsymmetricKey * Determines the padding modes * * Example: $key->withPadding(RSA::ENCRYPTION_PKCS1 | RSA::SIGNATURE_PKCS1); - * - * @param int $padding */ - public function withPadding($padding) + public function withPadding(int $padding): RSA { $masks = [ self::ENCRYPTION_OAEP, @@ -869,9 +833,8 @@ abstract class RSA extends AsymmetricKey /** * Returns the padding currently being used - * */ - public function getPadding() + public function getPadding(): int { return $this->signaturePadding | $this->encryptionPadding; } @@ -886,9 +849,8 @@ abstract class RSA extends AsymmetricKey * * @see self::useInternalEngine() * @see self::useBestEngine() - * @return string */ - public function getEngine() + public function getEngine(): string { if (!isset(self::$engines['PHP'])) { self::useBestEngine(); @@ -900,18 +862,16 @@ abstract class RSA extends AsymmetricKey /** * Enable RSA Blinding - * */ - public static function enableBlinding() + public static function enableBlinding(): void { static::$enableBlinding = true; } /** * Disable RSA Blinding - * */ - public static function disableBlinding() + public static function disableBlinding(): void { static::$enableBlinding = false; } diff --git a/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php b/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php index cbd810bb..853a5f16 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php @@ -15,6 +15,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -31,48 +33,40 @@ abstract class MSBLOB { /** * Public/Private Key Pair - * */ const PRIVATEKEYBLOB = 0x7; /** * Public Key - * */ const PUBLICKEYBLOB = 0x6; /** * Public Key - * */ const PUBLICKEYBLOBEX = 0xA; /** * RSA public key exchange algorithm - * */ const CALG_RSA_KEYX = 0x0000A400; /** * RSA public key exchange algorithm - * */ const CALG_RSA_SIGN = 0x00002400; /** * Public Key - * */ const RSA1 = 0x31415352; /** * Private Key - * */ const RSA2 = 0x32415352; /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -175,16 +169,9 @@ abstract class MSBLOB /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients - * @param string $password optional - * @return string + * @param string|false $password */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '') + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = ''): string { if (count($primes) != 2) { throw new \InvalidArgumentException('MSBLOB does not support multi-prime RSA keys'); @@ -211,12 +198,8 @@ abstract class MSBLOB /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @return string */ - public static function savePublicKey(BigInteger $n, BigInteger $e) + public static function savePublicKey(BigInteger $n, BigInteger $e): string { $n = strrev($n->toBytes()); $e = str_pad(strrev($e->toBytes()), 4, "\0"); diff --git a/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php b/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php index 2367810a..f9b4dbf2 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -36,11 +38,10 @@ abstract class OpenSSH extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { static $one; if (!isset($one)) { @@ -50,14 +51,14 @@ abstract class OpenSSH extends Progenitor $parsed = parent::load($key, $password); if (isset($parsed['paddedKey'])) { - list($type) = Strings::unpackSSH2('s', $parsed['paddedKey']); + [$type] = Strings::unpackSSH2('s', $parsed['paddedKey']); if ($type != $parsed['type']) { throw new \RuntimeException("The public and private keys are not of the same type ($type vs $parsed[type])"); } $primes = $coefficients = []; - list( + [ $modulus, $publicExponent, $privateExponent, @@ -65,7 +66,7 @@ abstract class OpenSSH extends Progenitor $primes[1], $primes[2], $comment, - ) = Strings::unpackSSH2('i6s', $parsed['paddedKey']); + ] = Strings::unpackSSH2('i6s', $parsed['paddedKey']); $temp = $primes[1]->subtract($one); $exponents = [1 => $publicExponent->modInverse($temp)]; @@ -77,7 +78,7 @@ abstract class OpenSSH extends Progenitor return compact('publicExponent', 'modulus', 'privateExponent', 'primes', 'coefficients', 'exponents', 'comment', 'isPublicKey'); } - list($publicExponent, $modulus) = Strings::unpackSSH2('ii', $parsed['publicKey']); + [$publicExponent, $modulus] = Strings::unpackSSH2('ii', $parsed['publicKey']); return [ 'isPublicKey' => true, @@ -90,20 +91,17 @@ abstract class OpenSSH extends Progenitor /** * Convert a public key to the appropriate format * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e * @param array $options optional - * @return string */ - public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = []) + public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = []): string { $RSAPublicKey = Strings::packSSH2('sii', 'ssh-rsa', $e, $n); - if (isset($options['binary']) ? $options['binary'] : self::$binary) { + if ($options['binary'] ?? self::$binary) { return $RSAPublicKey; } - $comment = isset($options['comment']) ? $options['comment'] : self::$comment; + $comment = $options['comment'] ?? self::$comment; $RSAPublicKey = 'ssh-rsa ' . base64_encode($RSAPublicKey) . ' ' . $comment; return $RSAPublicKey; @@ -112,17 +110,10 @@ abstract class OpenSSH extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients - * @param string $password optional + * @param string|false $password optional * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string { $publicKey = self::savePublicKey($n, $e, ['binary' => true]); $privateKey = Strings::packSSH2('si6', 'ssh-rsa', $n, $e, $d, $coefficients[2], $primes[1], $primes[2]); diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php index b35c7adb..0b8e767d 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php @@ -20,6 +20,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -38,11 +40,10 @@ abstract class PKCS1 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -102,17 +103,10 @@ abstract class PKCS1 extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients - * @param string $password optional + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string { $num_primes = count($primes); $key = [ @@ -141,12 +135,8 @@ abstract class PKCS1 extends Progenitor /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @return string */ - public static function savePublicKey(BigInteger $n, BigInteger $e) + public static function savePublicKey(BigInteger $n, BigInteger $e): string { $key = [ 'modulus' => $n, diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php b/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php index 7ff9a199..569ce086 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php @@ -23,6 +23,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -61,11 +63,10 @@ abstract class PKCS8 extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -105,17 +106,10 @@ abstract class PKCS8 extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients - * @param string $password optional + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string { $key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients); $key = ASN1::extractBER($key); @@ -125,12 +119,9 @@ abstract class PKCS8 extends Progenitor /** * Convert a public key to the appropriate format * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e * @param array $options optional - * @return string */ - public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = []) + public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = []): string { $key = PKCS1::savePublicKey($n, $e); $key = ASN1::extractBER($key); diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PSS.php b/phpseclib/Crypt/RSA/Formats/Keys/PSS.php index ed75b9b7..5465cfc1 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PSS.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PSS.php @@ -21,6 +21,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -67,7 +69,7 @@ abstract class PSS extends Progenitor /** * Initialize static variables */ - private static function initialize_static_variables() + private static function initialize_static_variables(): void { if (!self::$oidsLoaded) { ASN1::loadOIDs([ @@ -91,11 +93,10 @@ abstract class PSS extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { self::initialize_static_variables(); @@ -154,17 +155,10 @@ abstract class PSS extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients - * @param string $password optional + * @param string|false $password * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string { self::initialize_static_variables(); @@ -177,12 +171,9 @@ abstract class PSS extends Progenitor /** * Convert a public key to the appropriate format * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e * @param array $options optional - * @return string */ - public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = []) + public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = []): string { self::initialize_static_variables(); @@ -195,7 +186,6 @@ abstract class PSS extends Progenitor /** * Encodes PSS parameters * - * @param array $options * @return string */ public static function savePSSParams(array $options) diff --git a/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php b/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php index fe35717b..9504184c 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; use phpseclib3\Common\Functions\Strings; @@ -41,11 +43,11 @@ abstract class PuTTY extends Progenitor /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param array|string $key + * @param string|false $password + * @return array|false */ - public static function load($key, $password = '') + public static function load($key, $password) { static $one; if (!isset($one)) { @@ -65,14 +67,14 @@ abstract class PuTTY extends Progenitor if ($result === false) { throw new \UnexpectedValueException('Key appears to be malformed'); } - list($publicExponent, $modulus) = $result; + [$publicExponent, $modulus] = $result; $result = Strings::unpackSSH2('iiii', $private); if ($result === false) { throw new \UnexpectedValueException('Key appears to be malformed'); } $primes = $coefficients = []; - list($privateExponent, $primes[1], $primes[2], $coefficients[2]) = $result; + [$privateExponent, $primes[1], $primes[2], $coefficients[2]] = $result; $temp = $primes[1]->subtract($one); $exponents = [1 => $publicExponent->modInverse($temp)]; @@ -85,17 +87,10 @@ abstract class PuTTY extends Progenitor /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients - * @param string $password optional + * @param string|false $password optional * @param array $options optional - * @return string */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string { if (count($primes) != 2) { throw new \InvalidArgumentException('PuTTY does not support multi-prime RSA keys'); @@ -109,12 +104,8 @@ abstract class PuTTY extends Progenitor /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @return string */ - public static function savePublicKey(BigInteger $n, BigInteger $e) + public static function savePublicKey(BigInteger $n, BigInteger $e): string { return self::wrapPublicKey(Strings::packSSH2('ii', $e, $n), 'ssh-rsa'); } diff --git a/phpseclib/Crypt/RSA/Formats/Keys/Raw.php b/phpseclib/Crypt/RSA/Formats/Keys/Raw.php index db728784..7721d768 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/Raw.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/Raw.php @@ -21,8 +21,11 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; +use phpseclib3\Exception\UnsupportedFormatException; use phpseclib3\Math\BigInteger; /** @@ -35,11 +38,10 @@ abstract class Raw /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|array $key + * @param string|false $password */ - public static function load($key, $password = '') + public static function load($key, $password = ''): array { if (!is_array($key)) { throw new \UnexpectedValueException('Key should be a array - not a ' . gettype($key)); @@ -75,7 +77,7 @@ abstract class Raw ['prime1', 'prime2'] ]; foreach ($indices as $index) { - list($i0, $i1) = $index; + [$i0, $i1] = $index; if (isset($key[$i0]) && isset($key[$i1])) { $components['primes'] = [1 => $key[$i0], $key[$i1]]; } @@ -90,7 +92,7 @@ abstract class Raw ['exponent1', 'exponent2'] ]; foreach ($indices as $index) { - list($i0, $i1) = $index; + [$i0, $i1] = $index; if (isset($key[$i0]) && isset($key[$i1])) { $components['exponents'] = [1 => $key[$i0], $key[$i1]]; } @@ -138,23 +140,16 @@ abstract class Raw /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients - * @param string $password optional + * @param string|false $password optional * @param array $options optional - * @return array */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []) + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = []): string { if (!empty($password) && is_string($password)) { throw new UnsupportedFormatException('Raw private keys do not support encryption'); } - return [ + return serialize([ 'e' => clone $e, 'n' => clone $n, 'd' => clone $d, @@ -167,17 +162,13 @@ abstract class Raw 'coefficients' => array_map(function ($var) { return clone $var; }, $coefficients) - ]; + ]); } /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @return array */ - public static function savePublicKey(BigInteger $n, BigInteger $e) + public static function savePublicKey(BigInteger $n, BigInteger $e): array { return ['e' => clone $e, 'n' => clone $n]; } diff --git a/phpseclib/Crypt/RSA/Formats/Keys/XML.php b/phpseclib/Crypt/RSA/Formats/Keys/XML.php index d9b7530e..227d6cac 100644 --- a/phpseclib/Crypt/RSA/Formats/Keys/XML.php +++ b/phpseclib/Crypt/RSA/Formats/Keys/XML.php @@ -18,6 +18,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA\Formats\Keys; use ParagonIE\ConstantTime\Base64; @@ -36,11 +38,9 @@ abstract class XML /** * Break a public or private key down into its constituent components * - * @param string $key - * @param string $password optional - * @return array + * @param string|false $password */ - public static function load($key, $password = '') + public static function load(string $key, $password = ''): array { if (!Strings::is_stringable($key)) { throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key)); @@ -124,16 +124,9 @@ abstract class XML /** * Convert a private key to the appropriate format. * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @param \phpseclib3\Math\BigInteger $d - * @param array $primes - * @param array $exponents - * @param array $coefficients * @param string $password optional - * @return string */ - public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '') + public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, string $password = ''): string { if (count($primes) != 2) { throw new \InvalidArgumentException('XML does not support multi-prime RSA keys'); @@ -157,12 +150,8 @@ abstract class XML /** * Convert a public key to the appropriate format - * - * @param \phpseclib3\Math\BigInteger $n - * @param \phpseclib3\Math\BigInteger $e - * @return string */ - public static function savePublicKey(BigInteger $n, BigInteger $e) + public static function savePublicKey(BigInteger $n, BigInteger $e): string { return "\r\n" . ' ' . Base64::encode($n->toBytes()) . "\r\n" . diff --git a/phpseclib/Crypt/RSA/PrivateKey.php b/phpseclib/Crypt/RSA/PrivateKey.php index b5e197af..3d4faee1 100644 --- a/phpseclib/Crypt/RSA/PrivateKey.php +++ b/phpseclib/Crypt/RSA/PrivateKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA; use phpseclib3\Crypt\Common; @@ -50,8 +52,6 @@ class PrivateKey extends RSA implements Common\PrivateKey /** * Public Exponent - * - * @var mixed */ protected $publicExponent = false; @@ -60,10 +60,9 @@ class PrivateKey extends RSA implements Common\PrivateKey * * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.2 RFC3447#section-5.1.2}. * - * @param \phpseclib3\Math\BigInteger $c * @return bool|\phpseclib3\Math\BigInteger */ - private function rsadp($c) + private function rsadp(BigInteger $c) { if ($c->compare(self::$zero) < 0 || $c->compare($this->modulus) > 0) { throw new \OutOfRangeException('Ciphertext representative out of range'); @@ -76,10 +75,9 @@ class PrivateKey extends RSA implements Common\PrivateKey * * See {@link http://tools.ietf.org/html/rfc3447#section-5.2.1 RFC3447#section-5.2.1}. * - * @param \phpseclib3\Math\BigInteger $m * @return bool|\phpseclib3\Math\BigInteger */ - private function rsasp1($m) + private function rsasp1(BigInteger $m) { if ($m->compare(self::$zero) < 0 || $m->compare($this->modulus) > 0) { throw new \OutOfRangeException('Signature representative out of range'); @@ -89,11 +87,8 @@ class PrivateKey extends RSA implements Common\PrivateKey /** * Exponentiate - * - * @param \phpseclib3\Math\BigInteger $x - * @return \phpseclib3\Math\BigInteger */ - protected function exponentiate(BigInteger $x) + protected function exponentiate(BigInteger $x): BigInteger { switch (true) { case empty($this->primes): @@ -114,7 +109,7 @@ class PrivateKey extends RSA implements Common\PrivateKey ]; $h = $m_i[1]->subtract($m_i[2]); $h = $h->multiply($this->coefficients[2]); - list(, $h) = $h->divide($this->primes[1]); + [, $h] = $h->divide($this->primes[1]); $m = $m_i[2]->add($h->multiply($this->primes[2])); $r = $this->primes[1]; @@ -125,7 +120,7 @@ class PrivateKey extends RSA implements Common\PrivateKey $h = $m_i->subtract($m); $h = $h->multiply($this->coefficients[$i]); - list(, $h) = $h->divide($this->primes[$i]); + [, $h] = $h->divide($this->primes[$i]); $m = $m->add($r->multiply($h)); } @@ -145,7 +140,7 @@ class PrivateKey extends RSA implements Common\PrivateKey ]; $h = $m_i[1]->subtract($m_i[2]); $h = $h->multiply($this->coefficients[2]); - list(, $h) = $h->divide($this->primes[1]); + [, $h] = $h->divide($this->primes[1]); $m = $m_i[2]->add($h->multiply($this->primes[2])); $r = $this->primes[1]; @@ -156,7 +151,7 @@ class PrivateKey extends RSA implements Common\PrivateKey $h = $m_i->subtract($m); $h = $h->multiply($this->coefficients[$i]); - list(, $h) = $h->divide($this->primes[$i]); + [, $h] = $h->divide($this->primes[$i]); $m = $m->add($r->multiply($h)); } @@ -170,20 +165,15 @@ class PrivateKey extends RSA implements Common\PrivateKey * * Protects against timing attacks by employing RSA Blinding. * Returns $x->modPow($this->exponents[$i], $this->primes[$i]) - * - * @param \phpseclib3\Math\BigInteger $x - * @param \phpseclib3\Math\BigInteger $r - * @param int $i - * @return \phpseclib3\Math\BigInteger */ - private function blind($x, $r, $i) + private function blind(BigInteger $x, BigInteger $r, int $i): BigInteger { $x = $x->multiply($r->modPow($this->publicExponent, $this->primes[$i])); $x = $x->modPow($this->exponents[$i], $this->primes[$i]); $r = $r->modInverse($this->primes[$i]); $x = $x->multiply($r); - list(, $x) = $x->divide($this->primes[$i]); + [, $x] = $x->divide($this->primes[$i]); return $x; } @@ -193,12 +183,9 @@ class PrivateKey extends RSA implements Common\PrivateKey * * See {@link http://tools.ietf.org/html/rfc3447#section-9.1.1 RFC3447#section-9.1.1}. * - * @return string - * @param string $m * @throws \RuntimeException on encoding error - * @param int $emBits */ - private function emsa_pss_encode($m, $emBits) + private function emsa_pss_encode(string $m, int $emBits): string { // if $m is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error // be output. @@ -229,10 +216,9 @@ class PrivateKey extends RSA implements Common\PrivateKey * * See {@link http://tools.ietf.org/html/rfc3447#section-8.1.1 RFC3447#section-8.1.1}. * - * @param string $m * @return bool|string */ - private function rsassa_pss_sign($m) + private function rsassa_pss_sign(string $m) { // EMSA-PSS encoding @@ -254,11 +240,10 @@ class PrivateKey extends RSA implements Common\PrivateKey * * See {@link http://tools.ietf.org/html/rfc3447#section-8.2.1 RFC3447#section-8.2.1}. * - * @param string $m - * @throws \LengthException if the RSA modulus is too short * @return bool|string + *@throws \LengthException if the RSA modulus is too short */ - private function rsassa_pkcs1_v1_5_sign($m) + private function rsassa_pkcs1_v1_5_sign(string $m) { // EMSA-PKCS1-v1_5 encoding @@ -305,10 +290,9 @@ class PrivateKey extends RSA implements Common\PrivateKey * * See {@link http://tools.ietf.org/html/rfc3447#section-7.2.2 RFC3447#section-7.2.2}. * - * @param string $c * @return bool|string */ - private function rsaes_pkcs1_v1_5_decrypt($c) + private function rsaes_pkcs1_v1_5_decrypt(string $c) { // Length checking @@ -354,10 +338,9 @@ class PrivateKey extends RSA implements Common\PrivateKey * ciphertext C, leading to a chosen-ciphertext attack such as the one * observed by Manger [36]. * - * @param string $c * @return bool|string */ - private function rsaes_oaep_decrypt($c) + private function rsaes_oaep_decrypt(string $c) { // Length checking @@ -412,11 +395,10 @@ class PrivateKey extends RSA implements Common\PrivateKey * * Doesn't use padding and is not recommended. * - * @param string $m * @return bool|string * @throws \LengthException if strlen($m) > $this->k */ - private function raw_encrypt($m) + private function raw_encrypt(string $m) { if (strlen($m) > $this->k) { throw new \LengthException('Ciphertext representative too long'); @@ -430,11 +412,10 @@ class PrivateKey extends RSA implements Common\PrivateKey /** * Decryption * - * @see self::encrypt() - * @param string $ciphertext * @return bool|string + *@see self::encrypt() */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext) { switch ($this->encryptionPadding) { case self::ENCRYPTION_NONE: @@ -449,10 +430,8 @@ class PrivateKey extends RSA implements Common\PrivateKey /** * Returns the public key - * - * @return mixed */ - public function getPublicKey() + public function getPublicKey(): RSA { $type = self::validatePlugin('Keys', 'PKCS8', 'savePublicKey'); if (empty($this->modulus) || empty($this->publicExponent)) { @@ -471,11 +450,9 @@ class PrivateKey extends RSA implements Common\PrivateKey /** * Returns the private key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin( 'Keys', diff --git a/phpseclib/Crypt/RSA/PublicKey.php b/phpseclib/Crypt/RSA/PublicKey.php index 89408792..ebbf15ce 100644 --- a/phpseclib/Crypt/RSA/PublicKey.php +++ b/phpseclib/Crypt/RSA/PublicKey.php @@ -9,6 +9,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt\RSA; use phpseclib3\Common\Functions\Strings; @@ -34,11 +36,8 @@ class PublicKey extends RSA implements Common\PublicKey /** * Exponentiate - * - * @param \phpseclib3\Math\BigInteger $x - * @return \phpseclib3\Math\BigInteger */ - private function exponentiate(BigInteger $x) + private function exponentiate(BigInteger $x): BigInteger { return $x->modPow($this->exponent, $this->modulus); } @@ -48,10 +47,9 @@ class PublicKey extends RSA implements Common\PublicKey * * See {@link http://tools.ietf.org/html/rfc3447#section-5.2.2 RFC3447#section-5.2.2}. * - * @param \phpseclib3\Math\BigInteger $s * @return bool|\phpseclib3\Math\BigInteger */ - private function rsavp1($s) + private function rsavp1(BigInteger $s) { if ($s->compare(self::$zero) < 0 || $s->compare($this->modulus) > 0) { return false; @@ -64,12 +62,9 @@ class PublicKey extends RSA implements Common\PublicKey * * See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}. * - * @param string $m - * @param string $s - * @throws \LengthException if the RSA modulus is too short - * @return bool + *@throws \LengthException if the RSA modulus is too short */ - private function rsassa_pkcs1_v1_5_verify($m, $s) + private function rsassa_pkcs1_v1_5_verify(string $m, string $s): bool { // Length checking @@ -131,12 +126,8 @@ class PublicKey extends RSA implements Common\PublicKey * is valid with respect to the specification given in [PKCS1 v2.0+]". so if you do * $rsa->getLastPadding() and get RSA::PADDING_RELAXED_PKCS1 back instead of * RSA::PADDING_PKCS1... that means BER encoding was used. - * - * @param string $m - * @param string $s - * @return bool */ - private function rsassa_pkcs1_v1_5_relaxed_verify($m, $s) + private function rsassa_pkcs1_v1_5_relaxed_verify(string $m, string $s): bool { // Length checking @@ -217,12 +208,9 @@ class PublicKey extends RSA implements Common\PublicKey * * See {@link http://tools.ietf.org/html/rfc3447#section-9.1.2 RFC3447#section-9.1.2}. * - * @param string $m - * @param string $em - * @param int $emBits * @return string */ - private function emsa_pss_verify($m, $em, $emBits) + private function emsa_pss_verify(string $m, string $em, int $emBits) { // if $m is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error // be output. @@ -263,11 +251,9 @@ class PublicKey extends RSA implements Common\PublicKey * * See {@link http://tools.ietf.org/html/rfc3447#section-8.1.2 RFC3447#section-8.1.2}. * - * @param string $m - * @param string $s * @return bool|string */ - private function rsassa_pss_verify($m, $s) + private function rsassa_pss_verify(string $m, string $s) { // Length checking @@ -317,12 +303,11 @@ class PublicKey extends RSA implements Common\PublicKey * * See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}. * - * @param string $m * @param bool $pkcs15_compat optional - * @throws \LengthException if strlen($m) > $this->k - 11 * @return bool|string + *@throws \LengthException if strlen($m) > $this->k - 11 */ - private function rsaes_pkcs1_v1_5_encrypt($m, $pkcs15_compat = false) + private function rsaes_pkcs1_v1_5_encrypt(string $m, bool $pkcs15_compat = false) { $mLen = strlen($m); @@ -360,11 +345,9 @@ class PublicKey extends RSA implements Common\PublicKey * See {@link http://tools.ietf.org/html/rfc3447#section-7.1.1 RFC3447#section-7.1.1} and * {http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding OAES}. * - * @param string $m - * @throws \LengthException if strlen($m) > $this->k - 2 * $this->hLen - 2 - * @return string + *@throws \LengthException if strlen($m) > $this->k - 2 * $this->hLen - 2 */ - private function rsaes_oaep_encrypt($m) + private function rsaes_oaep_encrypt(string $m): string { $mLen = strlen($m); @@ -405,10 +388,9 @@ class PublicKey extends RSA implements Common\PublicKey * * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.1}. * - * @param \phpseclib3\Math\BigInteger $m * @return bool|\phpseclib3\Math\BigInteger */ - private function rsaep($m) + private function rsaep(BigInteger $m) { if ($m->compare(self::$zero) < 0 || $m->compare($this->modulus) > 0) { throw new \OutOfRangeException('Message representative out of range'); @@ -421,11 +403,10 @@ class PublicKey extends RSA implements Common\PublicKey * * Doesn't use padding and is not recommended. * - * @param string $m * @return bool|string * @throws \LengthException if strlen($m) > $this->k */ - private function raw_encrypt($m) + private function raw_encrypt(string $m) { if (strlen($m) > $this->k) { throw new \LengthException('Message too long'); @@ -443,12 +424,11 @@ class PublicKey extends RSA implements Common\PublicKey * If $plaintext exceeds those limits it will be broken up so that it does and the resultant ciphertext's will * be concatenated together. * - * @see self::decrypt() - * @param string $plaintext * @return bool|string * @throws \LengthException if the RSA modulus is too short + *@see self::decrypt() */ - public function encrypt($plaintext) + public function encrypt(string $plaintext) { switch ($this->encryptionPadding) { case self::ENCRYPTION_NONE: @@ -468,11 +448,9 @@ class PublicKey extends RSA implements Common\PublicKey * or if the public key was set via setPublicKey(). If the currently loaded key is supposed to be the public key this * function won't return it since this library, for the most part, doesn't distinguish between public and private keys. * - * @param string $type * @param array $options optional - * @return mixed */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { $type = self::validatePlugin('Keys', $type, 'savePublicKey'); @@ -493,10 +471,8 @@ class PublicKey extends RSA implements Common\PublicKey /** * Converts a public key to a private key - * - * @return RSA */ - public function asPrivateKey() + public function asPrivateKey(): RSA { $new = new PrivateKey(); $new->exponent = $this->exponent; diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index e2c3cb59..2b0e5f93 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -20,6 +20,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; /** @@ -36,11 +38,9 @@ abstract class Random * microoptimizations because this function has the potential of being called a huge number of times. * eg. for RSA key generation. * - * @param int $length - * @throws \RuntimeException if a symmetric cipher is needed but not loaded - * @return string + *@throws \RuntimeException if a symmetric cipher is needed but not loaded */ - public static function string($length) + public static function string(int $length): string { if (!$length) { return ''; @@ -83,7 +83,7 @@ abstract class Random $old_session_id = session_id(); $old_use_cookies = ini_get('session.use_cookies'); $old_session_cache_limiter = session_cache_limiter(); - $_OLD_SESSION = isset($_SESSION) ? $_SESSION : false; + $_OLD_SESSION = $_SESSION ?? false; if ($old_session_id != '') { session_write_close(); } @@ -190,10 +190,8 @@ abstract class Random * Safely serialize variables * * If a class has a private __sleep() it'll emit a warning - * @return mixed - * @param mixed $arr */ - private static function safe_serialize(&$arr) + private static function safe_serialize(&$arr): string { if (is_object($arr)) { return ''; diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 2c069866..9d758561 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -50,6 +50,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Common\Functions\Strings; @@ -158,10 +160,9 @@ class Rijndael extends BlockCipher /** * Default Constructor. * - * @param string $mode * @throws \InvalidArgumentException if an invalid / unsupported mode is provided */ - public function __construct($mode) + public function __construct(string $mode) { parent::__construct($mode); @@ -186,10 +187,9 @@ class Rijndael extends BlockCipher * the mcrypt php extension, even if available. * This results then in slower encryption. * - * @throws \LengthException if the key length is invalid - * @param int $length + *@throws \LengthException if the key length is invalid */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { switch ($length) { case 128: @@ -211,11 +211,10 @@ class Rijndael extends BlockCipher * * Rijndael supports five different key lengths * - * @see setKeyLength() - * @param string $key * @throws \LengthException if the key length isn't supported + *@see setKeyLength() */ - public function setKey($key) + public function setKey(string $key): void { switch (strlen($key)) { case 16: @@ -235,10 +234,8 @@ class Rijndael extends BlockCipher * Sets the block length * * Valid block lengths are 128, 160, 192, 224, and 256. - * - * @param int $length */ - public function setBlockLength($length) + public function setBlockLength(int $length): void { switch ($length) { case 128: @@ -262,11 +259,9 @@ class Rijndael extends BlockCipher * * This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() * - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @param int $engine - * @return bool + *@see \phpseclib3\Crypt\Common\SymmetricKey::__construct() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { switch ($engine) { case self::ENGINE_LIBSODIUM: @@ -305,11 +300,8 @@ class Rijndael extends BlockCipher /** * Encrypts a block - * - * @param string $in - * @return string */ - protected function encryptBlock($in) + protected function encryptBlock(string $in): string { static $tables; if (empty($tables)) { @@ -394,11 +386,8 @@ class Rijndael extends BlockCipher /** * Decrypts a block - * - * @param string $in - * @return string */ - protected function decryptBlock($in) + protected function decryptBlock(string $in): string { static $invtables; if (empty($invtables)) { @@ -495,7 +484,7 @@ class Rijndael extends BlockCipher * @see self::setIV() * @see self::disableContinuousBuffer() */ - protected function setup() + protected function setup(): void { if (!$this->changed) { return; @@ -513,7 +502,7 @@ class Rijndael extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey() */ - protected function setupKey() + protected function setupKey(): void { // Each number in $rcon is equal to the previous number multiplied by two in Rijndael's finite field. // See http://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplicative_inverse @@ -578,7 +567,7 @@ class Rijndael extends BlockCipher // 1. Apply the Key Expansion. // 2. Apply InvMixColumn to all Round Keys except the first and the last one." // also, see fips-197.pdf#page=27, "5.3.5 Equivalent Inverse Cipher" - list($dt0, $dt1, $dt2, $dt3) = $this->getInvTables(); + [$dt0, $dt1, $dt2, $dt3] = $this->getInvTables(); $temp = $this->w = $this->dw = []; for ($i = $row = $col = 0; $i < $length; $i++, $col++) { if ($col == $this->Nb) { @@ -623,14 +612,13 @@ class Rijndael extends BlockCipher /** * Performs S-Box substitutions * - * @return array - * @param int $word + *@return array */ - private function subWord($word) + private function subWord(int $word) { static $sbox; if (empty($sbox)) { - list(, , , , $sbox) = self::getTables(); + [, , , , $sbox] = self::getTables(); } return $sbox[$word & 0x000000FF] | @@ -647,7 +635,7 @@ class Rijndael extends BlockCipher * @see self::subWord() * @return array &$tables */ - protected function &getTables() + protected function &getTables(): array { static $tables; if (empty($tables)) { @@ -735,7 +723,7 @@ class Rijndael extends BlockCipher * @see self::setupKey() * @return array &$tables */ - protected function &getInvTables() + protected function &getInvTables(): array { static $tables; if (empty($tables)) { @@ -815,7 +803,7 @@ class Rijndael extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::setupInlineCrypt() */ - protected function setupInlineCrypt() + protected function setupInlineCrypt(): void { $w = $this->w; $dw = $this->dw; @@ -851,7 +839,7 @@ class Rijndael extends BlockCipher // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey for ($round = 1; $round < $Nr; ++$round) { - list($s, $e) = [$e, $s]; + [$s, $e] = [$e, $s]; for ($i = 0; $i < $Nb; ++$i) { $encrypt_block .= '$' . $e . $i . ' = @@ -908,7 +896,7 @@ class Rijndael extends BlockCipher // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey for ($round = 1; $round < $Nr; ++$round) { - list($s, $e) = [$e, $s]; + [$s, $e] = [$e, $s]; for ($i = 0; $i < $Nb; ++$i) { $decrypt_block .= '$' . $e . $i . ' = @@ -954,12 +942,10 @@ class Rijndael extends BlockCipher /** * Encrypts a message. * - * @see self::decrypt() + *@see self::decrypt() * @see parent::encrypt() - * @param string $plaintext - * @return string */ - public function encrypt($plaintext) + public function encrypt(string $plaintext): string { $this->setup(); @@ -985,12 +971,10 @@ class Rijndael extends BlockCipher /** * Decrypts a message. * - * @see self::encrypt() + *@see self::encrypt() * @see parent::decrypt() - * @param string $ciphertext - * @return string */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext): string { $this->setup(); diff --git a/phpseclib/Crypt/Salsa20.php b/phpseclib/Crypt/Salsa20.php index d3e7a193..0b8db7c8 100644 --- a/phpseclib/Crypt/Salsa20.php +++ b/phpseclib/Crypt/Salsa20.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Common\Functions\Strings; @@ -86,10 +88,8 @@ class Salsa20 extends StreamCipher /** * Salsa20 uses a nonce - * - * @return bool */ - public function usesNonce() + public function usesNonce(): bool { return true; } @@ -97,10 +97,9 @@ class Salsa20 extends StreamCipher /** * Sets the key. * - * @param string $key * @throws \LengthException if the key length isn't supported */ - public function setKey($key) + public function setKey(string $key): void { switch (strlen($key)) { case 16: @@ -115,10 +114,8 @@ class Salsa20 extends StreamCipher /** * Sets the nonce. - * - * @param string $nonce */ - public function setNonce($nonce) + public function setNonce(string $nonce): void { if (strlen($nonce) != 8) { throw new \LengthException('Nonce of size ' . strlen($key) . ' not supported by this algorithm. Only an 64-bit nonce is supported'); @@ -131,10 +128,8 @@ class Salsa20 extends StreamCipher /** * Sets the counter. - * - * @param int $counter */ - public function setCounter($counter) + public function setCounter(int $counter): void { $this->counter = $counter; $this->setEngine(); @@ -145,7 +140,7 @@ class Salsa20 extends StreamCipher * * See https://tools.ietf.org/html/rfc8439#section-2.6.1 */ - protected function createPoly1305Key() + protected function createPoly1305Key(): void { if ($this->nonce === false) { throw new InsufficientSetupException('No nonce has been defined'); @@ -184,7 +179,7 @@ class Salsa20 extends StreamCipher * @see self::setNonce() * @see self::disableContinuousBuffer() */ - protected function setup() + protected function setup(): void { if (!$this->changed) { return; @@ -228,7 +223,7 @@ class Salsa20 extends StreamCipher /** * Setup the key (expansion) */ - protected function setupKey() + protected function setupKey(): void { // Salsa20 does not utilize this method } @@ -236,12 +231,11 @@ class Salsa20 extends StreamCipher /** * Encrypts a message. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() - * @see self::crypt() - * @param string $plaintext * @return string $ciphertext + *@see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() + * @see self::crypt() */ - public function encrypt($plaintext) + public function encrypt(string $plaintext): string { $ciphertext = $this->crypt($plaintext, self::ENCRYPT); if (isset($this->poly1305Key)) { @@ -256,12 +250,11 @@ class Salsa20 extends StreamCipher * $this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)). * At least if the continuous buffer is disabled. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() - * @see self::crypt() - * @param string $ciphertext * @return string $plaintext + *@see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() + * @see self::crypt() */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext): string { if (isset($this->poly1305Key)) { if ($this->oldtag === false) { @@ -280,34 +273,30 @@ class Salsa20 extends StreamCipher /** * Encrypts a block - * - * @param string $in */ - protected function encryptBlock($in) + protected function encryptBlock(string $in): string { // Salsa20 does not utilize this method + return ''; } /** * Decrypts a block - * - * @param string $in */ - protected function decryptBlock($in) + protected function decryptBlock(string $in): string { // Salsa20 does not utilize this method + return ''; } /** * Encrypts or decrypts a message. * - * @see self::encrypt() - * @see self::decrypt() - * @param string $text - * @param int $mode * @return string $text + *@see self::decrypt() + * @see self::encrypt() */ - private function crypt($text, $mode) + private function crypt(string $text, int $mode): string { $this->setup(); if (!$this->continuousBuffer) { @@ -397,12 +386,8 @@ class Salsa20 extends StreamCipher /** * Left Rotate - * - * @param int $x - * @param int $n - * @return int */ - protected static function leftRotate($x, $n) + protected static function leftRotate(int $x, int $n): int { $r1 = $x << $n; if (PHP_INT_SIZE == 8) { @@ -417,13 +402,8 @@ class Salsa20 extends StreamCipher /** * The quarterround function - * - * @param int $a - * @param int $b - * @param int $c - * @param int $d */ - protected static function quarterRound(&$a, &$b, &$c, &$d) + protected static function quarterRound(int &$a, int &$b, int &$c, int &$d): void { $b ^= self::leftRotate($a + $d, 7); $c ^= self::leftRotate($b + $a, 9); @@ -451,7 +431,7 @@ class Salsa20 extends StreamCipher * @param int $x14 (by reference) * @param int $x15 (by reference) */ - protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15) + protected static function doubleRound(int &$x0, int &$x1, int &$x2, int &$x3, int &$x4, int &$x5, int &$x6, int &$x7, int &$x8, int &$x9, int &$x10, int &$x11, int &$x12, int &$x13, int &$x14, int &$x15): void { // columnRound static::quarterRound($x0, $x4, $x8, $x12); @@ -467,10 +447,8 @@ class Salsa20 extends StreamCipher /** * The Salsa20 hash function function - * - * @param string $x */ - protected static function salsa20($x) + protected static function salsa20(string $x) { $z = $x = unpack('V*', $x); for ($i = 0; $i < 10; $i++) { @@ -487,15 +465,13 @@ class Salsa20 extends StreamCipher /** * Calculates Poly1305 MAC * - * @see self::decrypt() + *@see self::decrypt() * @see self::encrypt() - * @param string $ciphertext - * @return string */ - protected function poly1305($ciphertext) + protected function poly1305(string $text): string { if (!$this->usingGeneratedPoly1305Key) { - return parent::poly1305($this->aad . $ciphertext); + return parent::poly1305($this->aad . $text); } else { /* sodium_crypto_aead_chacha20poly1305_encrypt does not calculate the poly1305 tag @@ -515,9 +491,9 @@ class Salsa20 extends StreamCipher */ return parent::poly1305( self::nullPad128($this->aad) . - self::nullPad128($ciphertext) . + self::nullPad128($text) . pack('V', strlen($this->aad)) . "\0\0\0\0" . - pack('V', strlen($ciphertext)) . "\0\0\0\0" + pack('V', strlen($text)) . "\0\0\0\0" ); } } diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 1ff5ed02..058bdc2b 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -32,6 +32,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; /** @@ -126,11 +128,10 @@ class TripleDES extends DES * * - cbc3 (same as cbc) * + *@see \phpseclib3\Crypt\Common\SymmetricKey::__construct() * @see \phpseclib3\Crypt\DES::__construct() - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @param string $mode */ - public function __construct($mode) + public function __construct(string $mode) { switch (strtolower($mode)) { // In case of self::MODE_3CBC, we init as CRYPT_DES_MODE_CBC @@ -169,11 +170,9 @@ class TripleDES extends DES * * This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine() * - * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @param int $engine - * @return bool + *@see \phpseclib3\Crypt\Common\SymmetricKey::__construct() */ - protected function isValidEngineHelper($engine) + protected function isValidEngineHelper(int $engine): bool { if ($engine == self::ENGINE_OPENSSL) { $this->cipher_name_openssl_ecb = 'des-ede3'; @@ -189,10 +188,9 @@ class TripleDES extends DES * * SetIV is not required when \phpseclib3\Crypt\Common\SymmetricKey::MODE_ECB is being used. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::setIV() - * @param string $iv + *@see \phpseclib3\Crypt\Common\SymmetricKey::setIV() */ - public function setIV($iv) + public function setIV(string $iv): void { parent::setIV($iv); if ($this->mode_3cbc) { @@ -209,11 +207,10 @@ class TripleDES extends DES * * If you want to use a 64-bit key use DES.php * + *@throws \LengthException if the key length is invalid * @see \phpseclib3\Crypt\Common\SymmetricKey:setKeyLength() - * @throws \LengthException if the key length is invalid - * @param int $length */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { switch ($length) { case 128: @@ -233,12 +230,11 @@ class TripleDES extends DES * * DES also requires that every eighth bit be a parity bit, however, we'll ignore that. * + *@throws \LengthException if the key length is invalid * @see \phpseclib3\Crypt\DES::setKey() * @see \phpseclib3\Crypt\Common\SymmetricKey::setKey() - * @throws \LengthException if the key length is invalid - * @param string $key */ - public function setKey($key) + public function setKey(string $key): void { if ($this->explicit_key_length !== false && strlen($key) != $this->explicit_key_length) { throw new \LengthException('Key length has already been set to ' . $this->explicit_key_length . ' bytes and this key is ' . strlen($key) . ' bytes'); @@ -270,11 +266,10 @@ class TripleDES extends DES /** * Encrypts a message. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() - * @param string $plaintext * @return string $cipertext + *@see \phpseclib3\Crypt\Common\SymmetricKey::encrypt() */ - public function encrypt($plaintext) + public function encrypt(string $plaintext): string { // parent::en/decrypt() is able to do all the work for all modes and keylengths, // except for: self::MODE_3CBC (inner chaining CBC) with a key > 64bits @@ -296,11 +291,10 @@ class TripleDES extends DES /** * Decrypts a message. * - * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() - * @param string $ciphertext * @return string $plaintext + *@see \phpseclib3\Crypt\Common\SymmetricKey::decrypt() */ - public function decrypt($ciphertext) + public function decrypt(string $ciphertext): string { if ($this->mode_3cbc && strlen($this->key) > 8) { return $this->unpad( @@ -354,7 +348,7 @@ class TripleDES extends DES * @see \phpseclib3\Crypt\Common\SymmetricKey::enableContinuousBuffer() * @see self::disableContinuousBuffer() */ - public function enableContinuousBuffer() + public function enableContinuousBuffer(): void { parent::enableContinuousBuffer(); if ($this->mode_3cbc) { @@ -372,7 +366,7 @@ class TripleDES extends DES * @see \phpseclib3\Crypt\Common\SymmetricKey::disableContinuousBuffer() * @see self::enableContinuousBuffer() */ - public function disableContinuousBuffer() + public function disableContinuousBuffer(): void { parent::disableContinuousBuffer(); if ($this->mode_3cbc) { @@ -388,7 +382,7 @@ class TripleDES extends DES * @see \phpseclib3\Crypt\DES::setupKey() * @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey() */ - protected function setupKey() + protected function setupKey(): void { switch (true) { // if $key <= 64bits we configure our internal pure-php cipher engine @@ -419,11 +413,10 @@ class TripleDES extends DES /** * Sets the internal crypt engine * + *@see \phpseclib3\Crypt\Common\SymmetricKey::setPreferredEngine() * @see \phpseclib3\Crypt\Common\SymmetricKey::__construct() - * @see \phpseclib3\Crypt\Common\SymmetricKey::setPreferredEngine() - * @param int $engine */ - public function setPreferredEngine($engine) + public function setPreferredEngine(string $engine): void { if ($this->mode_3cbc) { $this->des[0]->setPreferredEngine($engine); diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index efa47f8c..a2a90514 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -33,6 +33,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Crypt; use phpseclib3\Crypt\Common\BlockCipher; @@ -355,10 +357,9 @@ class Twofish extends BlockCipher /** * Default Constructor. * - * @param string $mode * @throws BadModeException if an invalid / unsupported mode is provided */ - public function __construct($mode) + public function __construct(string $mode) { parent::__construct($mode); @@ -371,10 +372,8 @@ class Twofish extends BlockCipher * Sets the key length. * * Valid key lengths are 128, 192 or 256 bits - * - * @param int $length */ - public function setKeyLength($length) + public function setKeyLength(int $length): void { switch ($length) { case 128: @@ -393,11 +392,10 @@ class Twofish extends BlockCipher * * Rijndael supports five different key lengths * - * @see setKeyLength() - * @param string $key * @throws \LengthException if the key length isn't supported + *@see setKeyLength() */ - public function setKey($key) + public function setKey(string $key): void { switch (strlen($key)) { case 16: @@ -416,7 +414,7 @@ class Twofish extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupKey() */ - protected function setupKey() + protected function setupKey(): void { if (isset($this->kl['key']) && $this->key === $this->kl['key']) { // already expanded @@ -438,8 +436,8 @@ class Twofish extends BlockCipher switch (strlen($this->key)) { case 16: - list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[1], $le_longs[2]); - list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[3], $le_longs[4]); + [$s7, $s6, $s5, $s4] = $this->mdsrem($le_longs[1], $le_longs[2]); + [$s3, $s2, $s1, $s0] = $this->mdsrem($le_longs[3], $le_longs[4]); for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ @@ -463,9 +461,9 @@ class Twofish extends BlockCipher } break; case 24: - list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[1], $le_longs[2]); - list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[3], $le_longs[4]); - list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[5], $le_longs[6]); + [$sb, $sa, $s9, $s8] = $this->mdsrem($le_longs[1], $le_longs[2]); + [$s7, $s6, $s5, $s4] = $this->mdsrem($le_longs[3], $le_longs[4]); + [$s3, $s2, $s1, $s0] = $this->mdsrem($le_longs[5], $le_longs[6]); for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ @@ -489,10 +487,10 @@ class Twofish extends BlockCipher } break; default: // 32 - list($sf, $se, $sd, $sc) = $this->mdsrem($le_longs[1], $le_longs[2]); - list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[3], $le_longs[4]); - list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[5], $le_longs[6]); - list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[7], $le_longs[8]); + [$sf, $se, $sd, $sc] = $this->mdsrem($le_longs[1], $le_longs[2]); + [$sb, $sa, $s9, $s8] = $this->mdsrem($le_longs[3], $le_longs[4]); + [$s7, $s6, $s5, $s4] = $this->mdsrem($le_longs[5], $le_longs[6]); + [$s3, $s2, $s1, $s0] = $this->mdsrem($le_longs[7], $le_longs[8]); for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) { $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ @@ -525,12 +523,10 @@ class Twofish extends BlockCipher /** * _mdsrem function using by the twofish cipher algorithm - * - * @param string $A - * @param string $B - * @return array + * @param string|int $A + * @param string|int $B */ - private function mdsrem($A, $B) + private function mdsrem($A, $B): array { // No gain by unrolling this loop. for ($i = 0; $i < 8; ++$i) { @@ -572,11 +568,8 @@ class Twofish extends BlockCipher /** * Encrypts a block - * - * @param string $in - * @return string */ - protected function encryptBlock($in) + protected function encryptBlock(string $in): string { $S0 = $this->S0; $S1 = $this->S1; @@ -627,11 +620,8 @@ class Twofish extends BlockCipher /** * Decrypts a block - * - * @param string $in - * @return string */ - protected function decryptBlock($in) + protected function decryptBlock(string $in): string { $S0 = $this->S0; $S1 = $this->S1; @@ -685,7 +675,7 @@ class Twofish extends BlockCipher * * @see \phpseclib3\Crypt\Common\SymmetricKey::_setupInlineCrypt() */ - protected function setupInlineCrypt() + protected function setupInlineCrypt(): void { $K = $this->K; $init_crypt = ' diff --git a/phpseclib/Exception/BadConfigurationException.php b/phpseclib/Exception/BadConfigurationException.php index 1aabcae0..3de7fb77 100644 --- a/phpseclib/Exception/BadConfigurationException.php +++ b/phpseclib/Exception/BadConfigurationException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/BadDecryptionException.php b/phpseclib/Exception/BadDecryptionException.php index 88331dce..87976c3a 100644 --- a/phpseclib/Exception/BadDecryptionException.php +++ b/phpseclib/Exception/BadDecryptionException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/BadModeException.php b/phpseclib/Exception/BadModeException.php index 87689b22..60e1b5e7 100644 --- a/phpseclib/Exception/BadModeException.php +++ b/phpseclib/Exception/BadModeException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/ConnectionClosedException.php b/phpseclib/Exception/ConnectionClosedException.php index 6aaccbad..275c4731 100644 --- a/phpseclib/Exception/ConnectionClosedException.php +++ b/phpseclib/Exception/ConnectionClosedException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/FileNotFoundException.php b/phpseclib/Exception/FileNotFoundException.php index 66e72709..7a07fdf0 100644 --- a/phpseclib/Exception/FileNotFoundException.php +++ b/phpseclib/Exception/FileNotFoundException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/InconsistentSetupException.php b/phpseclib/Exception/InconsistentSetupException.php index 23c38fb0..7630a729 100644 --- a/phpseclib/Exception/InconsistentSetupException.php +++ b/phpseclib/Exception/InconsistentSetupException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/InsufficientSetupException.php b/phpseclib/Exception/InsufficientSetupException.php index 4f4114d7..f0fe8cd4 100644 --- a/phpseclib/Exception/InsufficientSetupException.php +++ b/phpseclib/Exception/InsufficientSetupException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/NoKeyLoadedException.php b/phpseclib/Exception/NoKeyLoadedException.php index 7ec2fe9b..0724a2b0 100644 --- a/phpseclib/Exception/NoKeyLoadedException.php +++ b/phpseclib/Exception/NoKeyLoadedException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/NoSupportedAlgorithmsException.php b/phpseclib/Exception/NoSupportedAlgorithmsException.php index b3ea8f38..9f5e71c1 100644 --- a/phpseclib/Exception/NoSupportedAlgorithmsException.php +++ b/phpseclib/Exception/NoSupportedAlgorithmsException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/UnableToConnectException.php b/phpseclib/Exception/UnableToConnectException.php index bfa005b4..b42c80b6 100644 --- a/phpseclib/Exception/UnableToConnectException.php +++ b/phpseclib/Exception/UnableToConnectException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/UnsupportedAlgorithmException.php b/phpseclib/Exception/UnsupportedAlgorithmException.php index 210a9a5c..d42dad24 100644 --- a/phpseclib/Exception/UnsupportedAlgorithmException.php +++ b/phpseclib/Exception/UnsupportedAlgorithmException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/UnsupportedCurveException.php b/phpseclib/Exception/UnsupportedCurveException.php index 99152152..7d83e375 100644 --- a/phpseclib/Exception/UnsupportedCurveException.php +++ b/phpseclib/Exception/UnsupportedCurveException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/UnsupportedFormatException.php b/phpseclib/Exception/UnsupportedFormatException.php index e207d7e2..ecb1f013 100644 --- a/phpseclib/Exception/UnsupportedFormatException.php +++ b/phpseclib/Exception/UnsupportedFormatException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/Exception/UnsupportedOperationException.php b/phpseclib/Exception/UnsupportedOperationException.php index 9a115444..ab8a26f3 100644 --- a/phpseclib/Exception/UnsupportedOperationException.php +++ b/phpseclib/Exception/UnsupportedOperationException.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Exception; /** diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 4f940b76..78327fac 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -16,6 +16,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File; /** @@ -162,11 +164,8 @@ class ANSI * Set terminal width and height * * Resets the screen as well - * - * @param int $x - * @param int $y */ - public function setDimensions($x, $y) + public function setDimensions(int $x, int $y): void { $this->max_x = $x - 1; $this->max_y = $y - 1; @@ -180,20 +179,16 @@ class ANSI /** * Set the number of lines that should be logged past the terminal height - * - * @param int $history */ - public function setHistory($history) + public function setHistory(int $history): void { $this->max_history = $history; } /** * Load a string - * - * @param string $source */ - public function loadString($source) + public function loadString(string $source): void { $this->setDimensions($this->max_x + 1, $this->max_y + 1); $this->appendString($source); @@ -201,10 +196,8 @@ class ANSI /** * Appdend a string - * - * @param string $source */ - public function appendString($source) + public function appendString(string $source): void { $this->tokenization = ['']; for ($i = 0; $i < strlen($source); $i++) { @@ -407,9 +400,8 @@ class ANSI * Add a new line * * Also update the $this->screen and $this->history buffers - * */ - private function newLine() + private function newLine(): void { //if ($this->y < $this->max_y) { // $this->y++; @@ -434,13 +426,8 @@ class ANSI /** * Returns the current coordinate without preformating - * - * @param \stdClass $last_attr - * @param \stdClass $cur_attr - * @param string $char - * @return string */ - private function processCoordinate($last_attr, $cur_attr, $char) + private function processCoordinate(\stdClass $last_attr, \stdClass $cur_attr, string $char): string { $output = ''; @@ -493,17 +480,15 @@ class ANSI /** * Returns the current screen without preformating - * - * @return string */ - private function getScreenHelper() + private function getScreenHelper(): string { $output = ''; $last_attr = $this->base_attr_cell; for ($i = 0; $i <= $this->max_y; $i++) { for ($j = 0; $j <= $this->max_x; $j++) { $cur_attr = $this->attrs[$i][$j]; - $output .= $this->processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : ''); + $output .= $this->processCoordinate($last_attr, $cur_attr, $this->screen[$i][$j] ?? ''); $last_attr = $this->attrs[$i][$j]; } $output .= "\r\n"; @@ -516,27 +501,23 @@ class ANSI /** * Returns the current screen - * - * @return string */ - public function getScreen() + public function getScreen(): string { return '
' . $this->getScreenHelper() . '
'; } /** * Returns the current screen and the x previous lines - * - * @return string */ - public function getHistory() + public function getHistory(): string { $scrollback = ''; $last_attr = $this->base_attr_cell; for ($i = 0; $i < count($this->history); $i++) { for ($j = 0; $j <= $this->max_x + 1; $j++) { $cur_attr = $this->history_attrs[$i][$j]; - $scrollback .= $this->processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : ''); + $scrollback .= $this->processCoordinate($last_attr, $cur_attr, $this->history[$i][$j] ?? ''); $last_attr = $this->history_attrs[$i][$j]; } $scrollback .= "\r\n"; diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 8915ad0b..1c01decf 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -19,6 +19,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File; use DateTime; @@ -191,9 +193,8 @@ abstract class ASN1 * Serves a similar purpose to openssl's asn1parse * * @param Element|string $encoded - * @return array */ - public static function decodeBER($encoded) + public static function decodeBER($encoded): array { if ($encoded instanceof Element) { $encoded = $encoded->element; @@ -214,12 +215,9 @@ abstract class ASN1 * $encoded is passed by reference for the recursive calls done for self::TYPE_BIT_STRING and * self::TYPE_OCTET_STRING. In those cases, the indefinite length is used. * - * @param string $encoded - * @param int $start - * @param int $encoded_pos * @return array|bool */ - private static function decode_ber($encoded, $start = 0, $encoded_pos = 0) + private static function decode_ber(string $encoded, int $start = 0, int $encoded_pos = 0) { $current = ['start' => $start]; @@ -511,12 +509,10 @@ abstract class ASN1 * * "Special" mappings may be applied on a per tag-name basis via $special. * - * @param array $decoded - * @param array $mapping - * @param array $special + * @param array|bool $decoded * @return array|bool|Element|string|null */ - public static function asn1map($decoded, $mapping, $special = []) + public static function asn1map($decoded, array $mapping, array $special = []) { if (!is_array($decoded)) { return false; @@ -729,7 +725,7 @@ abstract class ASN1 } return $map; case self::TYPE_OBJECT_IDENTIFIER: - return isset(self::$oids[$decoded['content']]) ? self::$oids[$decoded['content']] : $decoded['content']; + return self::$oids[$decoded['content']] ?? $decoded['content']; case self::TYPE_UTC_TIME: case self::TYPE_GENERALIZED_TIME: // for explicitly tagged optional stuff @@ -798,8 +794,7 @@ abstract class ASN1 } if (isset($mapping['mapping'])) { $temp = (int) $temp->toString(); - return isset($mapping['mapping'][$temp]) ? - $mapping['mapping'][$temp] : + return $mapping['mapping'][$temp] ?? false; } return $temp; @@ -811,17 +806,14 @@ abstract class ASN1 * * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. - * - * @param string $string - * @return int */ - public static function decodeLength(&$string) + public static function decodeLength(string &$string): int { $length = ord(Strings::shift($string)); if ($length & 0x80) { // definite length, long form $length &= 0x7F; $temp = Strings::shift($string, $length); - list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); + [, $length] = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); } return $length; } @@ -835,11 +827,9 @@ abstract class ASN1 * "Special" mappings can be applied via $special. * * @param Element|string|array $source - * @param array $mapping - * @param array $special * @return string */ - public static function encodeDER($source, $mapping, $special = []) + public static function encodeDER($source, array $mapping, array $special = []) { self::$location = []; return self::encode_der($source, $mapping, null, $special); @@ -849,12 +839,10 @@ abstract class ASN1 * ASN.1 Encode (Helper function) * * @param Element|string|array|null $source - * @param array $mapping - * @param int $idx - * @param array $special + * @param string|int|null $idx * @return string */ - private static function encode_der($source, $mapping, $idx = null, $special = []) + private static function encode_der($source, array $mapping, $idx = null, array $special = []) { if ($source instanceof Element) { return $source->element; @@ -1131,7 +1119,7 @@ abstract class ASN1 } } - return chr($tag) . self::encodeLength(strlen($value)) . $value; + return chr($tag) . self::encodeLength(strlen((string) $value)) . $value; } /** @@ -1139,10 +1127,9 @@ abstract class ASN1 * * Called by _decode_ber() * - * @param string $content * @return string */ - public static function decodeOID($content) + public static function decodeOID(string $content) { static $eighty; if (!$eighty) { @@ -1190,11 +1177,8 @@ abstract class ASN1 * DER-encode the OID * * Called by _encode_der() - * - * @param string $source - * @return string */ - public static function encodeOID($source) + public static function encodeOID(string $source): string { static $mask, $zero, $forty; if (!$mask) { @@ -1204,7 +1188,7 @@ abstract class ASN1 } if (!preg_match('#(?:\d+\.)+#', $source)) { - $oid = isset(self::$reverseOIDs[$source]) ? self::$reverseOIDs[$source] : false; + $oid = self::$reverseOIDs[$source] ?? false; } else { $oid = $source; } @@ -1248,11 +1232,9 @@ abstract class ASN1 * * Called by _decode_ber() and in the case of implicit tags asn1map(). * - * @param string $content - * @param int $tag * @return \DateTime|false */ - private static function decodeTime($content, $tag) + private static function decodeTime(string $content, int $tag) { /* UTCTime: http://tools.ietf.org/html/rfc5280#section-4.1.2.5.1 @@ -1294,10 +1276,8 @@ abstract class ASN1 * Set the time format * * Sets the time / date format for asn1map(). - * - * @param string $format */ - public static function setTimeFormat($format) + public static function setTimeFormat(string $format): void { self::$format = $format; } @@ -1307,10 +1287,8 @@ abstract class ASN1 * * Load the relevant OIDs for a particular ASN.1 semantic mapping. * Previously loaded OIDs are retained. - * - * @param array $oids */ - public static function loadOIDs($oids) + public static function loadOIDs(array $oids): void { self::$reverseOIDs += $oids; self::$oids = array_flip(self::$reverseOIDs); @@ -1321,10 +1299,8 @@ abstract class ASN1 * * See \phpseclib3\File\X509, etc, for an example. * Previously loaded filters are not retained. - * - * @param array $filters */ - public static function setFilters($filters) + public static function setFilters(array $filters): void { self::$filters = $filters; } @@ -1335,12 +1311,9 @@ abstract class ASN1 * This is a lazy conversion, dealing only with character size. * No real conversion table is used. * - * @param string $in - * @param int $from - * @param int $to * @return string */ - public static function convert($in, $from = self::TYPE_UTF8_STRING, $to = self::TYPE_UTF8_STRING) + public static function convert(string $in, int $from = self::TYPE_UTF8_STRING, int $to = self::TYPE_UTF8_STRING) { // isset(self::STRING_TYPE_SIZE[$from] returns a fatal error on PHP 5.6 if (!array_key_exists($from, self::STRING_TYPE_SIZE) || !array_key_exists($to, self::STRING_TYPE_SIZE)) { @@ -1439,11 +1412,8 @@ abstract class ASN1 /** * Extract raw BER from Base64 encoding - * - * @param string $str - * @return string */ - public static function extractBER($str) + public static function extractBER(string $str): string { /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them * above and beyond the ceritificate. @@ -1473,11 +1443,8 @@ abstract class ASN1 * * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. - * - * @param int $length - * @return string */ - public static function encodeLength($length) + public static function encodeLength(int $length): string { if ($length <= 0x7F) { return chr($length); @@ -1501,12 +1468,9 @@ abstract class ASN1 * getOID('2.16.840.1.101.3.4.2.1') == '2.16.840.1.101.3.4.2.1' * getOID('id-sha256') == '2.16.840.1.101.3.4.2.1' * getOID('zzz') == 'zzz' - * - * @param string $name - * @return string */ - public static function getOID($name) + public static function getOID(string $name): string { - return isset(self::$reverseOIDs[$name]) ? self::$reverseOIDs[$name] : $name; + return self::$reverseOIDs[$name] ?? $name; } } diff --git a/phpseclib/File/ASN1/Element.php b/phpseclib/File/ASN1/Element.php index 6540b421..1ccb9895 100644 --- a/phpseclib/File/ASN1/Element.php +++ b/phpseclib/File/ASN1/Element.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1; /** @@ -33,10 +35,9 @@ class Element /** * Constructor * - * @param string $encoded * @return \phpseclib3\File\ASN1\Element */ - public function __construct($encoded) + public function __construct(string $encoded) { $this->element = $encoded; } diff --git a/phpseclib/File/ASN1/Maps/AccessDescription.php b/phpseclib/File/ASN1/Maps/AccessDescription.php index 1cbc5a59..63f1cce7 100644 --- a/phpseclib/File/ASN1/Maps/AccessDescription.php +++ b/phpseclib/File/ASN1/Maps/AccessDescription.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AdministrationDomainName.php b/phpseclib/File/ASN1/Maps/AdministrationDomainName.php index 04183a13..7a8613bd 100644 --- a/phpseclib/File/ASN1/Maps/AdministrationDomainName.php +++ b/phpseclib/File/ASN1/Maps/AdministrationDomainName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php b/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php index 0da7eb10..ebaf29ce 100644 --- a/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php +++ b/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AnotherName.php b/phpseclib/File/ASN1/Maps/AnotherName.php index d96c170b..8a7050e6 100644 --- a/phpseclib/File/ASN1/Maps/AnotherName.php +++ b/phpseclib/File/ASN1/Maps/AnotherName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Attribute.php b/phpseclib/File/ASN1/Maps/Attribute.php index 38a6aeef..a5f53378 100644 --- a/phpseclib/File/ASN1/Maps/Attribute.php +++ b/phpseclib/File/ASN1/Maps/Attribute.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AttributeType.php b/phpseclib/File/ASN1/Maps/AttributeType.php index 5cbc2bcc..1377d128 100644 --- a/phpseclib/File/ASN1/Maps/AttributeType.php +++ b/phpseclib/File/ASN1/Maps/AttributeType.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php b/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php index fe414f16..efd69634 100644 --- a/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php +++ b/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AttributeValue.php b/phpseclib/File/ASN1/Maps/AttributeValue.php index 3b3b6d2e..a6eb5e26 100644 --- a/phpseclib/File/ASN1/Maps/AttributeValue.php +++ b/phpseclib/File/ASN1/Maps/AttributeValue.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Attributes.php b/phpseclib/File/ASN1/Maps/Attributes.php index cd53ecfa..c593ca94 100644 --- a/phpseclib/File/ASN1/Maps/Attributes.php +++ b/phpseclib/File/ASN1/Maps/Attributes.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php b/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php index 3e80a55d..ade5fc8e 100644 --- a/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php +++ b/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php b/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php index e7ec5b28..7e0b3fd2 100644 --- a/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php +++ b/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/BaseDistance.php b/phpseclib/File/ASN1/Maps/BaseDistance.php index e59668ab..8839183a 100644 --- a/phpseclib/File/ASN1/Maps/BaseDistance.php +++ b/phpseclib/File/ASN1/Maps/BaseDistance.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/BasicConstraints.php b/phpseclib/File/ASN1/Maps/BasicConstraints.php index 587ef1b0..059b7c18 100644 --- a/phpseclib/File/ASN1/Maps/BasicConstraints.php +++ b/phpseclib/File/ASN1/Maps/BasicConstraints.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php b/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php index e81bc78e..dd2012ba 100644 --- a/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php +++ b/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php b/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php index 471e88f9..937491cb 100644 --- a/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php +++ b/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php b/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php index 752f400d..69317cc3 100644 --- a/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php +++ b/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CPSuri.php b/phpseclib/File/ASN1/Maps/CPSuri.php index 56e58887..72dc78fb 100644 --- a/phpseclib/File/ASN1/Maps/CPSuri.php +++ b/phpseclib/File/ASN1/Maps/CPSuri.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php b/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php index 79860b2f..ddc71bae 100644 --- a/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php +++ b/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CRLNumber.php b/phpseclib/File/ASN1/Maps/CRLNumber.php index f6cb9567..95481b8a 100644 --- a/phpseclib/File/ASN1/Maps/CRLNumber.php +++ b/phpseclib/File/ASN1/Maps/CRLNumber.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CRLReason.php b/phpseclib/File/ASN1/Maps/CRLReason.php index d3736529..423cf6cd 100644 --- a/phpseclib/File/ASN1/Maps/CRLReason.php +++ b/phpseclib/File/ASN1/Maps/CRLReason.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CertPolicyId.php b/phpseclib/File/ASN1/Maps/CertPolicyId.php index d7e7776e..9e4ee036 100644 --- a/phpseclib/File/ASN1/Maps/CertPolicyId.php +++ b/phpseclib/File/ASN1/Maps/CertPolicyId.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Certificate.php b/phpseclib/File/ASN1/Maps/Certificate.php index 01943a0d..11fca6da 100644 --- a/phpseclib/File/ASN1/Maps/Certificate.php +++ b/phpseclib/File/ASN1/Maps/Certificate.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CertificateIssuer.php b/phpseclib/File/ASN1/Maps/CertificateIssuer.php index ccd68dde..cfceb653 100644 --- a/phpseclib/File/ASN1/Maps/CertificateIssuer.php +++ b/phpseclib/File/ASN1/Maps/CertificateIssuer.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; /** diff --git a/phpseclib/File/ASN1/Maps/CertificateList.php b/phpseclib/File/ASN1/Maps/CertificateList.php index d54ed6d9..536f5489 100644 --- a/phpseclib/File/ASN1/Maps/CertificateList.php +++ b/phpseclib/File/ASN1/Maps/CertificateList.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CertificatePolicies.php b/phpseclib/File/ASN1/Maps/CertificatePolicies.php index ec0fa6b5..251d1cc5 100644 --- a/phpseclib/File/ASN1/Maps/CertificatePolicies.php +++ b/phpseclib/File/ASN1/Maps/CertificatePolicies.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php b/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php index 06ec944c..4efcb491 100644 --- a/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php +++ b/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CertificationRequest.php b/phpseclib/File/ASN1/Maps/CertificationRequest.php index 2da70ed6..0102b1cf 100644 --- a/phpseclib/File/ASN1/Maps/CertificationRequest.php +++ b/phpseclib/File/ASN1/Maps/CertificationRequest.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php b/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php index ce6dc880..52434a62 100644 --- a/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php +++ b/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Characteristic_two.php b/phpseclib/File/ASN1/Maps/Characteristic_two.php index 5bf59bb8..9f57cb6a 100644 --- a/phpseclib/File/ASN1/Maps/Characteristic_two.php +++ b/phpseclib/File/ASN1/Maps/Characteristic_two.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/CountryName.php b/phpseclib/File/ASN1/Maps/CountryName.php index 737d844d..7be8515c 100644 --- a/phpseclib/File/ASN1/Maps/CountryName.php +++ b/phpseclib/File/ASN1/Maps/CountryName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Curve.php b/phpseclib/File/ASN1/Maps/Curve.php index 621f1035..8fcc985f 100644 --- a/phpseclib/File/ASN1/Maps/Curve.php +++ b/phpseclib/File/ASN1/Maps/Curve.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DHParameter.php b/phpseclib/File/ASN1/Maps/DHParameter.php index 26863dbc..d1e13e00 100644 --- a/phpseclib/File/ASN1/Maps/DHParameter.php +++ b/phpseclib/File/ASN1/Maps/DHParameter.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DSAParams.php b/phpseclib/File/ASN1/Maps/DSAParams.php index 7af397bb..136e409f 100644 --- a/phpseclib/File/ASN1/Maps/DSAParams.php +++ b/phpseclib/File/ASN1/Maps/DSAParams.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DSAPrivateKey.php b/phpseclib/File/ASN1/Maps/DSAPrivateKey.php index d97cd023..07e1c5f4 100644 --- a/phpseclib/File/ASN1/Maps/DSAPrivateKey.php +++ b/phpseclib/File/ASN1/Maps/DSAPrivateKey.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DSAPublicKey.php b/phpseclib/File/ASN1/Maps/DSAPublicKey.php index f795747a..b7eb1637 100644 --- a/phpseclib/File/ASN1/Maps/DSAPublicKey.php +++ b/phpseclib/File/ASN1/Maps/DSAPublicKey.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DigestInfo.php b/phpseclib/File/ASN1/Maps/DigestInfo.php index b38ff3c4..fb056c09 100644 --- a/phpseclib/File/ASN1/Maps/DigestInfo.php +++ b/phpseclib/File/ASN1/Maps/DigestInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DirectoryString.php b/phpseclib/File/ASN1/Maps/DirectoryString.php index 45218e3e..9a6f1af2 100644 --- a/phpseclib/File/ASN1/Maps/DirectoryString.php +++ b/phpseclib/File/ASN1/Maps/DirectoryString.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DisplayText.php b/phpseclib/File/ASN1/Maps/DisplayText.php index a13e6a64..5c43b662 100644 --- a/phpseclib/File/ASN1/Maps/DisplayText.php +++ b/phpseclib/File/ASN1/Maps/DisplayText.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DistributionPoint.php b/phpseclib/File/ASN1/Maps/DistributionPoint.php index 4d9af6b5..818fbe82 100644 --- a/phpseclib/File/ASN1/Maps/DistributionPoint.php +++ b/phpseclib/File/ASN1/Maps/DistributionPoint.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DistributionPointName.php b/phpseclib/File/ASN1/Maps/DistributionPointName.php index bc0cec8f..ef7dfb14 100644 --- a/phpseclib/File/ASN1/Maps/DistributionPointName.php +++ b/phpseclib/File/ASN1/Maps/DistributionPointName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/DssSigValue.php b/phpseclib/File/ASN1/Maps/DssSigValue.php index 2af74088..47defa5c 100644 --- a/phpseclib/File/ASN1/Maps/DssSigValue.php +++ b/phpseclib/File/ASN1/Maps/DssSigValue.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ECParameters.php b/phpseclib/File/ASN1/Maps/ECParameters.php index f25f6faa..e39bfcb2 100644 --- a/phpseclib/File/ASN1/Maps/ECParameters.php +++ b/phpseclib/File/ASN1/Maps/ECParameters.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ECPoint.php b/phpseclib/File/ASN1/Maps/ECPoint.php index fb11db83..95de42e9 100644 --- a/phpseclib/File/ASN1/Maps/ECPoint.php +++ b/phpseclib/File/ASN1/Maps/ECPoint.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ECPrivateKey.php b/phpseclib/File/ASN1/Maps/ECPrivateKey.php index 7454f387..cd924985 100644 --- a/phpseclib/File/ASN1/Maps/ECPrivateKey.php +++ b/phpseclib/File/ASN1/Maps/ECPrivateKey.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/EDIPartyName.php b/phpseclib/File/ASN1/Maps/EDIPartyName.php index ea7dcf19..eedbaba1 100644 --- a/phpseclib/File/ASN1/Maps/EDIPartyName.php +++ b/phpseclib/File/ASN1/Maps/EDIPartyName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/EcdsaSigValue.php b/phpseclib/File/ASN1/Maps/EcdsaSigValue.php index 8ab9ff1e..9a2a3b9e 100644 --- a/phpseclib/File/ASN1/Maps/EcdsaSigValue.php +++ b/phpseclib/File/ASN1/Maps/EcdsaSigValue.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/EncryptedData.php b/phpseclib/File/ASN1/Maps/EncryptedData.php index 8d8739e1..0d23ca4f 100644 --- a/phpseclib/File/ASN1/Maps/EncryptedData.php +++ b/phpseclib/File/ASN1/Maps/EncryptedData.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php b/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php index 2c935676..6e7db22e 100644 --- a/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php +++ b/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php b/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php index f9bc5def..a765e3c8 100644 --- a/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php +++ b/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Extension.php b/phpseclib/File/ASN1/Maps/Extension.php index e32668fb..f4a0d1c3 100644 --- a/phpseclib/File/ASN1/Maps/Extension.php +++ b/phpseclib/File/ASN1/Maps/Extension.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ExtensionAttribute.php b/phpseclib/File/ASN1/Maps/ExtensionAttribute.php index 565b36d3..b2600101 100644 --- a/phpseclib/File/ASN1/Maps/ExtensionAttribute.php +++ b/phpseclib/File/ASN1/Maps/ExtensionAttribute.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ExtensionAttributes.php b/phpseclib/File/ASN1/Maps/ExtensionAttributes.php index a2e9bfae..c36878a0 100644 --- a/phpseclib/File/ASN1/Maps/ExtensionAttributes.php +++ b/phpseclib/File/ASN1/Maps/ExtensionAttributes.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Extensions.php b/phpseclib/File/ASN1/Maps/Extensions.php index 5015c976..16293cde 100644 --- a/phpseclib/File/ASN1/Maps/Extensions.php +++ b/phpseclib/File/ASN1/Maps/Extensions.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/FieldElement.php b/phpseclib/File/ASN1/Maps/FieldElement.php index 31734078..3e9b3ed1 100644 --- a/phpseclib/File/ASN1/Maps/FieldElement.php +++ b/phpseclib/File/ASN1/Maps/FieldElement.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/FieldID.php b/phpseclib/File/ASN1/Maps/FieldID.php index e32a9c03..6461f800 100644 --- a/phpseclib/File/ASN1/Maps/FieldID.php +++ b/phpseclib/File/ASN1/Maps/FieldID.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/GeneralName.php b/phpseclib/File/ASN1/Maps/GeneralName.php index 57d86da8..9ef08dc0 100644 --- a/phpseclib/File/ASN1/Maps/GeneralName.php +++ b/phpseclib/File/ASN1/Maps/GeneralName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/GeneralNames.php b/phpseclib/File/ASN1/Maps/GeneralNames.php index 5d931532..1a56e03a 100644 --- a/phpseclib/File/ASN1/Maps/GeneralNames.php +++ b/phpseclib/File/ASN1/Maps/GeneralNames.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/GeneralSubtree.php b/phpseclib/File/ASN1/Maps/GeneralSubtree.php index 5388db55..5f51ec61 100644 --- a/phpseclib/File/ASN1/Maps/GeneralSubtree.php +++ b/phpseclib/File/ASN1/Maps/GeneralSubtree.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/GeneralSubtrees.php b/phpseclib/File/ASN1/Maps/GeneralSubtrees.php index 27548cfe..58301e7e 100644 --- a/phpseclib/File/ASN1/Maps/GeneralSubtrees.php +++ b/phpseclib/File/ASN1/Maps/GeneralSubtrees.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/HashAlgorithm.php b/phpseclib/File/ASN1/Maps/HashAlgorithm.php index deb13cab..b7aa799d 100644 --- a/phpseclib/File/ASN1/Maps/HashAlgorithm.php +++ b/phpseclib/File/ASN1/Maps/HashAlgorithm.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; /** diff --git a/phpseclib/File/ASN1/Maps/HoldInstructionCode.php b/phpseclib/File/ASN1/Maps/HoldInstructionCode.php index 88d6ff3e..6b392fe4 100644 --- a/phpseclib/File/ASN1/Maps/HoldInstructionCode.php +++ b/phpseclib/File/ASN1/Maps/HoldInstructionCode.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/InvalidityDate.php b/phpseclib/File/ASN1/Maps/InvalidityDate.php index f34b5f72..2c89dfeb 100644 --- a/phpseclib/File/ASN1/Maps/InvalidityDate.php +++ b/phpseclib/File/ASN1/Maps/InvalidityDate.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/IssuerAltName.php b/phpseclib/File/ASN1/Maps/IssuerAltName.php index e9d03244..7c895b10 100644 --- a/phpseclib/File/ASN1/Maps/IssuerAltName.php +++ b/phpseclib/File/ASN1/Maps/IssuerAltName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; /** diff --git a/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php b/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php index 415996f5..79ce51e4 100644 --- a/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php +++ b/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/KeyIdentifier.php b/phpseclib/File/ASN1/Maps/KeyIdentifier.php index 82a41519..ff62ccaa 100644 --- a/phpseclib/File/ASN1/Maps/KeyIdentifier.php +++ b/phpseclib/File/ASN1/Maps/KeyIdentifier.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/KeyPurposeId.php b/phpseclib/File/ASN1/Maps/KeyPurposeId.php index b8509f19..c28a7707 100644 --- a/phpseclib/File/ASN1/Maps/KeyPurposeId.php +++ b/phpseclib/File/ASN1/Maps/KeyPurposeId.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/KeyUsage.php b/phpseclib/File/ASN1/Maps/KeyUsage.php index 827ce033..f252de3c 100644 --- a/phpseclib/File/ASN1/Maps/KeyUsage.php +++ b/phpseclib/File/ASN1/Maps/KeyUsage.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php b/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php index ea3f998b..35bee865 100644 --- a/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php +++ b/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; /** diff --git a/phpseclib/File/ASN1/Maps/Name.php b/phpseclib/File/ASN1/Maps/Name.php index a6a9009d..c11c2891 100644 --- a/phpseclib/File/ASN1/Maps/Name.php +++ b/phpseclib/File/ASN1/Maps/Name.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/NameConstraints.php b/phpseclib/File/ASN1/Maps/NameConstraints.php index 80486f94..7c6725cf 100644 --- a/phpseclib/File/ASN1/Maps/NameConstraints.php +++ b/phpseclib/File/ASN1/Maps/NameConstraints.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/NetworkAddress.php b/phpseclib/File/ASN1/Maps/NetworkAddress.php index 6c68df00..ce2f2f72 100644 --- a/phpseclib/File/ASN1/Maps/NetworkAddress.php +++ b/phpseclib/File/ASN1/Maps/NetworkAddress.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/NoticeReference.php b/phpseclib/File/ASN1/Maps/NoticeReference.php index 9eec123a..dbaa9122 100644 --- a/phpseclib/File/ASN1/Maps/NoticeReference.php +++ b/phpseclib/File/ASN1/Maps/NoticeReference.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php b/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php index 635a89dc..35a79df2 100644 --- a/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php +++ b/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ORAddress.php b/phpseclib/File/ASN1/Maps/ORAddress.php index b853abe8..686b1049 100644 --- a/phpseclib/File/ASN1/Maps/ORAddress.php +++ b/phpseclib/File/ASN1/Maps/ORAddress.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php b/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php index 59530248..18113988 100644 --- a/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php +++ b/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/OrganizationName.php b/phpseclib/File/ASN1/Maps/OrganizationName.php index b5cc9491..154ee882 100644 --- a/phpseclib/File/ASN1/Maps/OrganizationName.php +++ b/phpseclib/File/ASN1/Maps/OrganizationName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php b/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php index b3e57809..8c6eec8d 100644 --- a/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php +++ b/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php b/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php index 5d565605..ae9e223c 100644 --- a/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php +++ b/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php b/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php index 9802a808..364858c6 100644 --- a/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php +++ b/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PBEParameter.php b/phpseclib/File/ASN1/Maps/PBEParameter.php index 8eb27cf6..be928486 100644 --- a/phpseclib/File/ASN1/Maps/PBEParameter.php +++ b/phpseclib/File/ASN1/Maps/PBEParameter.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PBES2params.php b/phpseclib/File/ASN1/Maps/PBES2params.php index bd31699f..873afb78 100644 --- a/phpseclib/File/ASN1/Maps/PBES2params.php +++ b/phpseclib/File/ASN1/Maps/PBES2params.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PBKDF2params.php b/phpseclib/File/ASN1/Maps/PBKDF2params.php index 2dafed9c..f124d616 100644 --- a/phpseclib/File/ASN1/Maps/PBKDF2params.php +++ b/phpseclib/File/ASN1/Maps/PBKDF2params.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PBMAC1params.php b/phpseclib/File/ASN1/Maps/PBMAC1params.php index 91319f58..f30df5e9 100644 --- a/phpseclib/File/ASN1/Maps/PBMAC1params.php +++ b/phpseclib/File/ASN1/Maps/PBMAC1params.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PKCS9String.php b/phpseclib/File/ASN1/Maps/PKCS9String.php index 87d0862f..cb166751 100644 --- a/phpseclib/File/ASN1/Maps/PKCS9String.php +++ b/phpseclib/File/ASN1/Maps/PKCS9String.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Pentanomial.php b/phpseclib/File/ASN1/Maps/Pentanomial.php index b8c8c02f..e93d320a 100644 --- a/phpseclib/File/ASN1/Maps/Pentanomial.php +++ b/phpseclib/File/ASN1/Maps/Pentanomial.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PersonalName.php b/phpseclib/File/ASN1/Maps/PersonalName.php index 14e2860e..5b6443ea 100644 --- a/phpseclib/File/ASN1/Maps/PersonalName.php +++ b/phpseclib/File/ASN1/Maps/PersonalName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PolicyInformation.php b/phpseclib/File/ASN1/Maps/PolicyInformation.php index 1625d199..aebe9b4b 100644 --- a/phpseclib/File/ASN1/Maps/PolicyInformation.php +++ b/phpseclib/File/ASN1/Maps/PolicyInformation.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PolicyMappings.php b/phpseclib/File/ASN1/Maps/PolicyMappings.php index d30b8523..df46ec94 100644 --- a/phpseclib/File/ASN1/Maps/PolicyMappings.php +++ b/phpseclib/File/ASN1/Maps/PolicyMappings.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PolicyQualifierId.php b/phpseclib/File/ASN1/Maps/PolicyQualifierId.php index 7b7cd6a7..51d9dc9d 100644 --- a/phpseclib/File/ASN1/Maps/PolicyQualifierId.php +++ b/phpseclib/File/ASN1/Maps/PolicyQualifierId.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php b/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php index d227702e..8f9b30f0 100644 --- a/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php +++ b/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PostalAddress.php b/phpseclib/File/ASN1/Maps/PostalAddress.php index 142b309e..d84ab3cc 100644 --- a/phpseclib/File/ASN1/Maps/PostalAddress.php +++ b/phpseclib/File/ASN1/Maps/PostalAddress.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Prime_p.php b/phpseclib/File/ASN1/Maps/Prime_p.php index 77430344..aa0e48d3 100644 --- a/phpseclib/File/ASN1/Maps/Prime_p.php +++ b/phpseclib/File/ASN1/Maps/Prime_p.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PrivateDomainName.php b/phpseclib/File/ASN1/Maps/PrivateDomainName.php index 195dcaa5..37e8a1c4 100644 --- a/phpseclib/File/ASN1/Maps/PrivateDomainName.php +++ b/phpseclib/File/ASN1/Maps/PrivateDomainName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PrivateKey.php b/phpseclib/File/ASN1/Maps/PrivateKey.php index 3c895941..fd6bc11d 100644 --- a/phpseclib/File/ASN1/Maps/PrivateKey.php +++ b/phpseclib/File/ASN1/Maps/PrivateKey.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php b/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php index b440b78d..255df725 100644 --- a/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php +++ b/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php b/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php index 5b87036e..a5459990 100644 --- a/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php +++ b/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PublicKey.php b/phpseclib/File/ASN1/Maps/PublicKey.php index 48409204..3a99940b 100644 --- a/phpseclib/File/ASN1/Maps/PublicKey.php +++ b/phpseclib/File/ASN1/Maps/PublicKey.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php b/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php index 432581e4..c91f010e 100644 --- a/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php +++ b/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/PublicKeyInfo.php b/phpseclib/File/ASN1/Maps/PublicKeyInfo.php index b39a341f..6a612f31 100644 --- a/phpseclib/File/ASN1/Maps/PublicKeyInfo.php +++ b/phpseclib/File/ASN1/Maps/PublicKeyInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/RC2CBCParameter.php b/phpseclib/File/ASN1/Maps/RC2CBCParameter.php index 48649abd..66dce2c1 100644 --- a/phpseclib/File/ASN1/Maps/RC2CBCParameter.php +++ b/phpseclib/File/ASN1/Maps/RC2CBCParameter.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/RDNSequence.php b/phpseclib/File/ASN1/Maps/RDNSequence.php index 04b071c2..cc3a795b 100644 --- a/phpseclib/File/ASN1/Maps/RDNSequence.php +++ b/phpseclib/File/ASN1/Maps/RDNSequence.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/RSAPrivateKey.php b/phpseclib/File/ASN1/Maps/RSAPrivateKey.php index 8c19c658..735b71a3 100644 --- a/phpseclib/File/ASN1/Maps/RSAPrivateKey.php +++ b/phpseclib/File/ASN1/Maps/RSAPrivateKey.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/RSAPublicKey.php b/phpseclib/File/ASN1/Maps/RSAPublicKey.php index b14c32c4..84272c61 100644 --- a/phpseclib/File/ASN1/Maps/RSAPublicKey.php +++ b/phpseclib/File/ASN1/Maps/RSAPublicKey.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php b/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php index 1a784bf4..67e55a03 100644 --- a/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php +++ b/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/ReasonFlags.php b/phpseclib/File/ASN1/Maps/ReasonFlags.php index 2e62fcdb..218ec19f 100644 --- a/phpseclib/File/ASN1/Maps/ReasonFlags.php +++ b/phpseclib/File/ASN1/Maps/ReasonFlags.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php b/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php index a0421f73..ce3ef28d 100644 --- a/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php +++ b/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/RevokedCertificate.php b/phpseclib/File/ASN1/Maps/RevokedCertificate.php index ff759eb7..714e8900 100644 --- a/phpseclib/File/ASN1/Maps/RevokedCertificate.php +++ b/phpseclib/File/ASN1/Maps/RevokedCertificate.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php b/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php index 0f482a26..2f84a907 100644 --- a/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php +++ b/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php b/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php index 7408a563..6699e296 100644 --- a/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php +++ b/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/SubjectAltName.php b/phpseclib/File/ASN1/Maps/SubjectAltName.php index 39138a94..de3f68d1 100644 --- a/phpseclib/File/ASN1/Maps/SubjectAltName.php +++ b/phpseclib/File/ASN1/Maps/SubjectAltName.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; /** diff --git a/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php b/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php index f2e206f6..2b32bfe2 100644 --- a/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php +++ b/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php b/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php index 1ff241f7..0fce9d43 100644 --- a/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php +++ b/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php b/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php index 0d53d540..d33fbc31 100644 --- a/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php +++ b/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/TBSCertList.php b/phpseclib/File/ASN1/Maps/TBSCertList.php index 49b3cfc5..456750ce 100644 --- a/phpseclib/File/ASN1/Maps/TBSCertList.php +++ b/phpseclib/File/ASN1/Maps/TBSCertList.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/TBSCertificate.php b/phpseclib/File/ASN1/Maps/TBSCertificate.php index 007360c9..852d0e26 100644 --- a/phpseclib/File/ASN1/Maps/TBSCertificate.php +++ b/phpseclib/File/ASN1/Maps/TBSCertificate.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/TerminalIdentifier.php b/phpseclib/File/ASN1/Maps/TerminalIdentifier.php index 7f6d9d2e..d1ea57f4 100644 --- a/phpseclib/File/ASN1/Maps/TerminalIdentifier.php +++ b/phpseclib/File/ASN1/Maps/TerminalIdentifier.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Time.php b/phpseclib/File/ASN1/Maps/Time.php index 744ee704..231a4934 100644 --- a/phpseclib/File/ASN1/Maps/Time.php +++ b/phpseclib/File/ASN1/Maps/Time.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Trinomial.php b/phpseclib/File/ASN1/Maps/Trinomial.php index 33baa91e..c759bbf3 100644 --- a/phpseclib/File/ASN1/Maps/Trinomial.php +++ b/phpseclib/File/ASN1/Maps/Trinomial.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/UniqueIdentifier.php b/phpseclib/File/ASN1/Maps/UniqueIdentifier.php index f4c954bb..278b1a6c 100644 --- a/phpseclib/File/ASN1/Maps/UniqueIdentifier.php +++ b/phpseclib/File/ASN1/Maps/UniqueIdentifier.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/UserNotice.php b/phpseclib/File/ASN1/Maps/UserNotice.php index 98d527b7..75ccf210 100644 --- a/phpseclib/File/ASN1/Maps/UserNotice.php +++ b/phpseclib/File/ASN1/Maps/UserNotice.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/Validity.php b/phpseclib/File/ASN1/Maps/Validity.php index 8ef64cf5..b04338af 100644 --- a/phpseclib/File/ASN1/Maps/Validity.php +++ b/phpseclib/File/ASN1/Maps/Validity.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php b/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php index 2ab15728..e000ec17 100644 --- a/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php +++ b/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/netscape_cert_type.php b/phpseclib/File/ASN1/Maps/netscape_cert_type.php index 49e8da4b..d64431bc 100644 --- a/phpseclib/File/ASN1/Maps/netscape_cert_type.php +++ b/phpseclib/File/ASN1/Maps/netscape_cert_type.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/ASN1/Maps/netscape_comment.php b/phpseclib/File/ASN1/Maps/netscape_comment.php index d3ff4ddf..b0f4d046 100644 --- a/phpseclib/File/ASN1/Maps/netscape_comment.php +++ b/phpseclib/File/ASN1/Maps/netscape_comment.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File\ASN1\Maps; use phpseclib3\File\ASN1; diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 8879c0ab..995b93bb 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -22,6 +22,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\File; use ParagonIE\ConstantTime\Base64; @@ -51,7 +53,6 @@ class X509 * Flag to only accept signatures signed by certificate authorities * * Not really used anymore but retained all the same to suppress E_NOTICEs from old installs - * */ const VALIDATE_SIGNATURE_BY_CA = 1; @@ -429,12 +430,8 @@ class X509 * Load X.509 certificate * * Returns an associative array describing the X.509 cert or a false if the cert failed to load - * - * @param string $cert - * @param int $mode - * @return mixed */ - public function loadX509($cert, $mode = self::FORMAT_AUTO_DETECT) + public function loadX509(string $cert, int $mode = self::FORMAT_AUTO_DETECT) { if (is_array($cert) && isset($cert['tbsCertificate'])) { unset($this->currentCert); @@ -503,11 +500,10 @@ class X509 /** * Save X.509 certificate * - * @param array $cert * @param int $format optional * @return string */ - public function saveX509($cert, $format = self::FORMAT_PEM) + public function saveX509(array $cert, int $format = self::FORMAT_PEM) { if (!is_array($cert) || !isset($cert['tbsCertificate'])) { return false; @@ -575,9 +571,8 @@ class X509 * format. * * @param array $root (by reference) - * @param string $path */ - private function mapInExtensions(&$root, $path) + private function mapInExtensions(array &$root, string $path): void { $extensions = &$this->subArrayUnchecked($root, $path); @@ -623,9 +618,8 @@ class X509 * octet string. * * @param array $root (by reference) - * @param string $path */ - private function mapOutExtensions(&$root, $path) + private function mapOutExtensions(array &$root, string $path): void { $extensions = &$this->subArray($root, $path, !empty($this->extensionValues)); @@ -704,9 +698,8 @@ class X509 * format. * * @param array $root (by reference) - * @param string $path */ - private function mapInAttributes(&$root, $path) + private function mapInAttributes(array &$root, string $path): void { $attributes = &$this->subArray($root, $path); @@ -726,8 +719,8 @@ class X509 if ($mapped !== false) { $values[$j] = $mapped; } - if ($id == 'pkcs-9-at-extensionRequest' && $this->isSubArrayValid($values, $j)) { - $this->mapInExtensions($values, $j); + if ($id == 'pkcs-9-at-extensionRequest' && $this->isSubArrayValid($values, (string) $j)) { + $this->mapInExtensions($values, (string) $j); } } elseif ($map) { $values[$j] = $value; @@ -743,9 +736,8 @@ class X509 * ANY type. * * @param array $root (by reference) - * @param string $path */ - private function mapOutAttributes(&$root, $path) + private function mapOutAttributes(array &$root, string $path): void { $attributes = &$this->subArray($root, $path); @@ -784,9 +776,8 @@ class X509 * format. * * @param array $root (by reference) - * @param string $path */ - private function mapInDNs(&$root, $path) + private function mapInDNs(array &$root, string $path): void { $dns = &$this->subArray($root, $path); @@ -812,9 +803,8 @@ class X509 * ANY type. * * @param array $root (by reference) - * @param string $path */ - private function mapOutDNs(&$root, $path) + private function mapOutDNs(array &$root, string $path): void { $dns = &$this->subArray($root, $path); @@ -839,11 +829,8 @@ class X509 /** * Associate an extension ID to an extension mapping - * - * @param string $extnId - * @return mixed */ - private function getMapping($extnId) + private function getMapping(string $extnId) { if (!is_string($extnId)) { // eg. if it's a \phpseclib3\File\ASN1\Element object return true; @@ -948,11 +935,8 @@ class X509 /** * Load an X.509 certificate as a certificate authority - * - * @param string $cert - * @return bool */ - public function loadCA($cert) + public function loadCA(string $cert): bool { $olddn = $this->dn; $oldcert = $this->currentCert; @@ -1014,11 +998,8 @@ class X509 * character * which is considered to match any single domain name * component or component fragment. E.g., *.a.com matches foo.a.com but * not bar.foo.a.com. f*.com matches foo.com but not bar.com. - * - * @param string $url - * @return bool */ - public function validateURL($url) + public function validateURL(string $url): bool { if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { return false; @@ -1075,9 +1056,8 @@ class X509 * If $date isn't defined it is assumed to be the current date. * * @param \DateTimeInterface|string $date optional - * @return bool */ - public function validateDate($date = null) + public function validateDate($date = null): bool { if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { return false; @@ -1088,10 +1068,10 @@ class X509 } $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore']; - $notBefore = isset($notBefore['generalTime']) ? $notBefore['generalTime'] : $notBefore['utcTime']; + $notBefore = $notBefore['generalTime'] ?? $notBefore['utcTime']; $notAfter = $this->currentCert['tbsCertificate']['validity']['notAfter']; - $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime']; + $notAfter = $notAfter['generalTime'] ?? $notAfter['utcTime']; if (is_string($date)) { $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get())); @@ -1106,10 +1086,9 @@ class X509 /** * Fetches a URL * - * @param string $url * @return bool|string */ - private static function fetchURL($url) + private static function fetchURL(string $url) { if (self::$disable_url_fetch) { return false; @@ -1119,7 +1098,7 @@ class X509 $data = ''; switch ($parts['scheme']) { case 'http': - $fsock = @fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80); + $fsock = @fsockopen($parts['host'], $parts['port'] ?? 80); if (!$fsock) { return false; } @@ -1159,12 +1138,8 @@ class X509 * Validates an intermediate cert as identified via authority info access extension * * See https://tools.ietf.org/html/rfc4325 for more info - * - * @param bool $caonly - * @param int $count - * @return bool */ - private function testForIntermediate($caonly, $count) + private function testForIntermediate(bool $caonly, int $count): bool { $opts = $this->getExtension('id-pe-authorityInfoAccess'); if (!is_array($opts)) { @@ -1228,9 +1203,8 @@ class X509 * The behavior of this function is inspired by {@link http://php.net/openssl-verify openssl_verify}. * * @param bool $caonly optional - * @return mixed */ - public function validateSignature($caonly = true) + public function validateSignature(bool $caonly = true): ?bool { return $this->validateSignatureCountable($caonly, 0); } @@ -1239,12 +1213,8 @@ class X509 * Validate a signature * * Performs said validation whilst keeping track of how many times validation method is called - * - * @param bool $caonly - * @param int $count - * @return mixed */ - private function validateSignatureCountable($caonly, $count) + private function validateSignatureCountable(bool $caonly, int $count): ?bool { if (!is_array($this->currentCert) || !isset($this->signatureSubject)) { return null; @@ -1370,15 +1340,9 @@ class X509 * Returns true if the signature is verified and false if it is not correct. * If the algorithms are unsupposed an exception is thrown. * - * @param string $publicKeyAlgorithm - * @param string $publicKey - * @param string $signatureAlgorithm - * @param string $signature - * @param string $signatureSubject - * @throws \phpseclib3\Exception\UnsupportedAlgorithmException if the algorithm is unsupported - * @return bool + *@throws \phpseclib3\Exception\UnsupportedAlgorithmException if the algorithm is unsupported */ - private function validateSignatureHelper($publicKeyAlgorithm, $publicKey, $signatureAlgorithm, $signature, $signatureSubject) + private function validateSignatureHelper(string $publicKeyAlgorithm, string $publicKey, string $signatureAlgorithm, string $signature, string $signatureSubject): bool { switch ($publicKeyAlgorithm) { case 'id-RSASSA-PSS': @@ -1447,28 +1411,24 @@ class X509 * When validating a signature it may be necessary to download intermediate certs from URI's. * An intermediate cert that linked to itself would result in an infinite loop so to prevent * that we set a recursion limit. A negative number means that there is no recursion limit. - * - * @param int $count */ - public static function setRecurLimit($count) + public static function setRecurLimit(int $count): void { self::$recur_limit = $count; } /** * Prevents URIs from being automatically retrieved - * */ - public static function disableURLFetch() + public static function disableURLFetch(): void { self::$disable_url_fetch = true; } /** * Allows URIs to be automatically retrieved - * */ - public static function enableURLFetch() + public static function enableURLFetch(): void { self::$disable_url_fetch = false; } @@ -1477,11 +1437,8 @@ class X509 * Decodes an IP address * * Takes in a base64 encoded "blob" and returns a human readable IP address - * - * @param string $ip - * @return string */ - public static function decodeIP($ip) + public static function decodeIP(string $ip): string { return inet_ntop($ip); } @@ -1490,11 +1447,8 @@ class X509 * Decodes an IP address in a name constraints extension * * Takes in a base64 encoded "blob" and returns a human readable IP address / mask - * - * @param string $ip - * @return array */ - public static function decodeNameConstraintIP($ip) + public static function decodeNameConstraintIP(string $ip): array { $size = strlen($ip) >> 1; $mask = substr($ip, $size); @@ -1508,9 +1462,8 @@ class X509 * Takes a human readable IP address into a base64-encoded "blob" * * @param string|array $ip - * @return string */ - public static function encodeIP($ip) + public static function encodeIP($ip): string { return is_string($ip) ? inet_pton($ip) : @@ -1519,11 +1472,8 @@ class X509 /** * "Normalizes" a Distinguished Name property - * - * @param string $propName - * @return mixed */ - private function translateDNProp($propName) + private function translateDNProp(string $propName) { switch (strtolower($propName)) { case 'id-at-countryname': @@ -1611,12 +1561,9 @@ class X509 /** * Set a Distinguished Name property * - * @param string $propName - * @param mixed $propValue * @param string $type optional - * @return bool */ - public function setDNProp($propName, $propValue, $type = 'utf8String') + public function setDNProp(string $propName, $propValue, string $type = 'utf8String'): bool { if (empty($this->dn)) { $this->dn = ['rdnSequence' => []]; @@ -1643,10 +1590,8 @@ class X509 /** * Remove Distinguished Name properties - * - * @param string $propName */ - public function removeDNProp($propName) + public function removeDNProp(string $propName): void { if (empty($this->dn)) { return; @@ -1674,12 +1619,10 @@ class X509 /** * Get Distinguished Name properties * - * @param string $propName - * @param array $dn optional + * @param array|null $dn optional * @param bool $withType optional - * @return mixed */ - public function getDNProp($propName, $dn = null, $withType = false) + public function getDNProp(string $propName, array $dn = null, bool $withType = false) { if (!isset($dn)) { $dn = $this->dn; @@ -1735,12 +1678,10 @@ class X509 /** * Set a Distinguished Name * - * @param mixed $dn * @param bool $merge optional * @param string $type optional - * @return bool */ - public function setDN($dn, $merge = false, $type = 'utf8String') + public function setDN($dn, bool $merge = false, string $type = 'utf8String'): bool { if (!$merge) { $this->dn = null; @@ -1778,10 +1719,10 @@ class X509 * Get the Distinguished Name for a certificates subject * * @param mixed $format optional - * @param array $dn optional + * @param array|null $dn optional * @return array|bool|string */ - public function getDN($format = self::DN_ARRAY, $dn = null) + public function getDN($format = self::DN_ARRAY, array $dn = null) { if (!isset($dn)) { $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn; @@ -1920,9 +1861,8 @@ class X509 * Get the Distinguished Name for a certificate/crl issuer * * @param int $format optional - * @return mixed */ - public function getIssuerDN($format = self::DN_ARRAY) + public function getIssuerDN(int $format = self::DN_ARRAY) { switch (true) { case !isset($this->currentCert) || !is_array($this->currentCert): @@ -1941,9 +1881,8 @@ class X509 * Alias of getDN() * * @param int $format optional - * @return mixed */ - public function getSubjectDN($format = self::DN_ARRAY) + public function getSubjectDN(int $format = self::DN_ARRAY) { switch (true) { case !empty($this->dn): @@ -1962,11 +1901,9 @@ class X509 /** * Get an individual Distinguished Name property for a certificate/crl issuer * - * @param string $propName * @param bool $withType optional - * @return mixed */ - public function getIssuerDNProp($propName, $withType = false) + public function getIssuerDNProp(string $propName, bool $withType = false) { switch (true) { case !isset($this->currentCert) || !is_array($this->currentCert): @@ -1983,11 +1920,9 @@ class X509 /** * Get an individual Distinguished Name property for a certificate/csr subject * - * @param string $propName * @param bool $withType optional - * @return mixed */ - public function getSubjectDNProp($propName, $withType = false) + public function getSubjectDNProp(string $propName, bool $withType = false) { switch (true) { case !empty($this->dn): @@ -2005,8 +1940,6 @@ class X509 /** * Get the certificate chain for the current cert - * - * @return mixed */ public function getChain() { @@ -2061,11 +1994,8 @@ class X509 * Set public key * * Key needs to be a \phpseclib3\Crypt\RSA object - * - * @param PublicKey $key - * @return void */ - public function setPublicKey(PublicKey $key) + public function setPublicKey(PublicKey $key): void { $this->publicKey = $key; } @@ -2074,10 +2004,8 @@ class X509 * Set private key * * Key needs to be a \phpseclib3\Crypt\RSA object - * - * @param PrivateKey $key */ - public function setPrivateKey(PrivateKey $key) + public function setPrivateKey(PrivateKey $key): void { $this->privateKey = $key; } @@ -2086,10 +2014,8 @@ class X509 * Set challenge * * Used for SPKAC CSR's - * - * @param string $challenge */ - public function setChallenge($challenge) + public function setChallenge(string $challenge): void { $this->challenge = $challenge; } @@ -2098,8 +2024,6 @@ class X509 * Gets the public key * * Returns a \phpseclib3\Crypt\RSA object or a false. - * - * @return mixed */ public function getPublicKey() { @@ -2144,12 +2068,8 @@ class X509 /** * Load a Certificate Signing Request - * - * @param string $csr - * @param int $mode - * @return mixed */ - public function loadCSR($csr, $mode = self::FORMAT_AUTO_DETECT) + public function loadCSR(string $csr, int $mode = self::FORMAT_AUTO_DETECT) { if (is_array($csr) && isset($csr['certificationRequestInfo'])) { unset($this->currentCert); @@ -2219,11 +2139,10 @@ class X509 /** * Save CSR request * - * @param array $csr * @param int $format optional * @return string */ - public function saveCSR($csr, $format = self::FORMAT_PEM) + public function saveCSR(array $csr, int $format = self::FORMAT_PEM) { if (!is_array($csr) || !isset($csr['certificationRequestInfo'])) { return false; @@ -2264,11 +2183,8 @@ class X509 * SPKAC's are produced by the HTML5 keygen element: * * https://developer.mozilla.org/en-US/docs/HTML/Element/keygen - * - * @param string $spkac - * @return mixed */ - public function loadSPKAC($spkac) + public function loadSPKAC(string $spkac) { if (is_array($spkac) && isset($spkac['publicKeyAndChallenge'])) { unset($this->currentCert); @@ -2328,11 +2244,10 @@ class X509 /** * Save a SPKAC CSR request * - * @param array $spkac * @param int $format optional * @return string */ - public function saveSPKAC($spkac, $format = self::FORMAT_PEM) + public function saveSPKAC(array $spkac, int $format = self::FORMAT_PEM) { if (!is_array($spkac) || !isset($spkac['publicKeyAndChallenge'])) { return false; @@ -2364,12 +2279,8 @@ class X509 /** * Load a Certificate Revocation List - * - * @param string $crl - * @param int $mode - * @return mixed */ - public function loadCRL($crl, $mode = self::FORMAT_AUTO_DETECT) + public function loadCRL(string $crl, int $mode = self::FORMAT_AUTO_DETECT) { if (is_array($crl) && isset($crl['tbsCertList'])) { $this->currentCert = $crl; @@ -2431,11 +2342,10 @@ class X509 /** * Save Certificate Revocation List. * - * @param array $crl * @param int $format optional * @return string */ - public function saveCRL($crl, $format = self::FORMAT_PEM) + public function saveCRL(array $crl, int $format = self::FORMAT_PEM) { if (!is_array($crl) || !isset($crl['tbsCertList'])) { return false; @@ -2489,7 +2399,7 @@ class X509 * - 5.1.2.6 Revoked Certificates * by choosing utcTime iff year of date given is before 2050 and generalTime else. * - * @param string $date in format date('D, d M Y H:i:s O') + * @param Element|string $date in format date('D, d M Y H:i:s O') * @return array|Element */ private function timeField($date) @@ -2515,9 +2425,8 @@ class X509 * * @param \phpseclib3\File\X509 $issuer * @param \phpseclib3\File\X509 $subject - * @return mixed */ - public function sign($issuer, $subject) + public function sign(X509 $issuer, X509 $subject) { if (!is_object($issuer->privateKey) || empty($issuer->dn)) { return false; @@ -2527,8 +2436,8 @@ class X509 return false; } - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; + $currentCert = $this->currentCert ?? null; + $signatureSubject = $this->signatureSubject ?? null; $signatureAlgorithm = self::identifySignatureAlgorithm($issuer->privateKey); if ($signatureAlgorithm != 'id-RSASSA-PSS') { $signatureAlgorithm = ['algorithm' => $signatureAlgorithm]; @@ -2706,8 +2615,6 @@ class X509 /** * Sign a CSR - * - * @return mixed */ public function signCSR() { @@ -2720,8 +2627,8 @@ class X509 $publicKey = $this->formatSubjectPublicKey(); $this->publicKey = $origPublicKey; - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; + $currentCert = $this->currentCert ?? null; + $signatureSubject = $this->signatureSubject ?? null; $signatureAlgorithm = self::identifySignatureAlgorithm($this->privateKey); if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) { @@ -2760,8 +2667,6 @@ class X509 /** * Sign a SPKAC - * - * @return mixed */ public function signSPKAC() { @@ -2774,8 +2679,8 @@ class X509 $publicKey = $this->formatSubjectPublicKey(); $this->publicKey = $origPublicKey; - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; + $currentCert = $this->currentCert ?? null; + $signatureSubject = $this->signatureSubject ?? null; $signatureAlgorithm = self::identifySignatureAlgorithm($this->privateKey); // re-signing a SPKAC seems silly but since everything else supports re-signing why not? @@ -2825,16 +2730,15 @@ class X509 * * @param \phpseclib3\File\X509 $issuer * @param \phpseclib3\File\X509 $crl - * @return mixed */ - public function signCRL($issuer, $crl) + public function signCRL(X509 $issuer, X509 $crl) { if (!is_object($issuer->privateKey) || empty($issuer->dn)) { return false; } - $currentCert = isset($this->currentCert) ? $this->currentCert : null; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; + $currentCert = $this->currentCert ?? null; + $signatureSubject = $this->signatureSubject ?? null; $signatureAlgorithm = self::identifySignatureAlgorithm($issuer->privateKey); $thisUpdate = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get())); @@ -2884,7 +2788,7 @@ class X509 $this->removeExtension('id-ce-issuerAltName'); // Be sure version >= v2 if some extension found. - $version = isset($tbsCertList['version']) ? $tbsCertList['version'] : 0; + $version = $tbsCertList['version'] ?? 0; if (!$version) { if (!empty($tbsCertList['crlExtensions'])) { $version = 1; // v2. @@ -2954,11 +2858,9 @@ class X509 /** * Identify signature algorithm from key settings * - * @param PrivateKey $key * @throws \phpseclib3\Exception\UnsupportedAlgorithmException if the algorithm is unsupported - * @return string */ - private static function identifySignatureAlgorithm(PrivateKey $key) + private static function identifySignatureAlgorithm(PrivateKey $key): string { if ($key instanceof RSA) { if ($key->getPadding() & RSA::SIGNATURE_PSS) { @@ -2999,7 +2901,7 @@ class X509 case 'sha256': case 'sha384': case 'sha512': - return 'ecdsa-with-' . strtoupper($key->getHash()); + return 'ecdsa-with-' . strtoupper($key->getHash()->__toString()); } throw new UnsupportedAlgorithmException('The only supported hash algorithms for EC are: sha1, sha224, sha256, sha384, sha512'); } @@ -3012,7 +2914,7 @@ class X509 * * @param \DateTimeInterface|string $date */ - public function setStartDate($date) + public function setStartDate($date): void { if (!is_object($date) || !($date instanceof \DateTimeInterface)) { $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get())); @@ -3026,7 +2928,7 @@ class X509 * * @param \DateTimeInterface|string $date */ - public function setEndDate($date) + public function setEndDate($date): void { /* To indicate that a certificate has no well-defined expiration date, @@ -3051,19 +2953,17 @@ class X509 /** * Set Serial Number * - * @param string $serial * @param int $base optional */ - public function setSerialNumber($serial, $base = -256) + public function setSerialNumber(string $serial, int $base = -256): void { $this->serialNumber = new BigInteger($serial, $base); } /** * Turns the certificate into a certificate authority - * */ - public function makeCA() + public function makeCA(): void { $this->caFlag = true; } @@ -3075,11 +2975,9 @@ class X509 * implementing the checks included in _subArray() but without copying * a potentially large array by passing its reference by-value to is_array(). * - * @param array $root - * @param string $path * @return boolean */ - private function isSubArrayValid($root, $path) + private function isSubArrayValid(array $root, string $path): bool { if (!is_array($root)) { return false; @@ -3110,12 +3008,11 @@ class X509 * Passing a reference (i.e. $root) by-value (i.e. to is_array()) * creates a copy. If $root is an especially large array, this is expensive. * - * @param array $root * @param string $path absolute path with / as component separator * @param bool $create optional * @return array|false */ - private function &subArrayUnchecked(&$root, $path, $create = false) + private function &subArrayUnchecked(array &$root, string $path, bool $create = false) { $false = false; @@ -3137,12 +3034,11 @@ class X509 /** * Get a reference to a subarray * - * @param array $root * @param string $path absolute path with / as component separator * @param bool $create optional * @return array|false */ - private function &subArray(&$root, $path, $create = false) + private function &subArray(?array &$root, string $path, bool $create = false) { $false = false; @@ -3172,12 +3068,11 @@ class X509 /** * Get a reference to an extension subarray * - * @param array $root - * @param string $path optional absolute path with / as component separator + * @param string|null $path optional absolute path with / as component separator * @param bool $create optional * @return array|false */ - private function &extensions(&$root, $path = null, $create = false) + private function &extensions(?array &$root, string $path = null, bool $create = false) { if (!isset($root)) { $root = $this->currentCert; @@ -3226,11 +3121,9 @@ class X509 /** * Remove an Extension * - * @param string $id - * @param string $path optional - * @return bool + * @param string|null $path optional */ - private function removeExtensionHelper($id, $path = null) + private function removeExtensionHelper(string $id, string $path = null): bool { $extensions = &$this->extensions($this->currentCert, $path); @@ -3259,12 +3152,10 @@ class X509 * * Returns the extension if it exists and false if not * - * @param string $id - * @param array $cert optional - * @param string $path optional - * @return mixed + * @param array|null $cert optional + * @param string|null $path optional */ - private function getExtensionHelper($id, $cert = null, $path = null) + private function getExtensionHelper(string $id, array $cert = null, string $path = null) { $extensions = $this->extensions($cert, $path); @@ -3284,11 +3175,10 @@ class X509 /** * Returns a list of all extensions in use * - * @param array $cert optional - * @param string $path optional - * @return array + * @param array|null $cert optional + * @param string|null $path optional */ - private function getExtensionsHelper($cert = null, $path = null) + private function getExtensionsHelper(array $cert = null, string $path = null): array { $exts = $this->extensions($cert, $path); $extensions = []; @@ -3305,14 +3195,11 @@ class X509 /** * Set an Extension * - * @param string $id - * @param mixed $value * @param bool $critical optional * @param bool $replace optional - * @param string $path optional - * @return bool + * @param string|null $path optional */ - private function setExtensionHelper($id, $value, $critical = false, $replace = true, $path = null) + private function setExtensionHelper(string $id, $value, bool $critical = false, bool $replace = true, string $path = null): bool { $extensions = &$this->extensions($this->currentCert, $path, true); @@ -3339,11 +3226,8 @@ class X509 /** * Remove a certificate, CSR or CRL Extension - * - * @param string $id - * @return bool */ - public function removeExtension($id) + public function removeExtension(string $id): bool { return $this->removeExtensionHelper($id); } @@ -3353,12 +3237,9 @@ class X509 * * Returns the extension if it exists and false if not * - * @param string $id - * @param array $cert optional - * @param string $path - * @return mixed + * @param array|null $cert optional */ - public function getExtension($id, $cert = null, $path = null) + public function getExtension(string $id, array $cert = null, string $path = null) { return $this->getExtensionHelper($id, $cert, $path); } @@ -3366,11 +3247,10 @@ class X509 /** * Returns a list of all extensions in use in certificate, CSR or CRL * - * @param array $cert optional - * @param string $path optional - * @return array + * @param array|null $cert optional + * @param string|null $path optional */ - public function getExtensions($cert = null, $path = null) + public function getExtensions(array $cert = null, string $path = null): array { return $this->getExtensionsHelper($cert, $path); } @@ -3378,13 +3258,10 @@ class X509 /** * Set a certificate, CSR or CRL Extension * - * @param string $id - * @param mixed $value * @param bool $critical optional * @param bool $replace optional - * @return bool */ - public function setExtension($id, $value, $critical = false, $replace = true) + public function setExtension(string $id, $value, bool $critical = false, bool $replace = true): bool { return $this->setExtensionHelper($id, $value, $critical, $replace); } @@ -3392,11 +3269,9 @@ class X509 /** * Remove a CSR attribute. * - * @param string $id * @param int $disposition optional - * @return bool */ - public function removeAttribute($id, $disposition = self::ATTR_ALL) + public function removeAttribute(string $id, int $disposition = self::ATTR_ALL): bool { $attributes = &$this->subArray($this->currentCert, 'certificationRequestInfo/attributes'); @@ -3441,12 +3316,10 @@ class X509 * * Returns the attribute if it exists and false if not * - * @param string $id * @param int $disposition optional - * @param array $csr optional - * @return mixed + * @param array|null $csr optional */ - public function getAttribute($id, $disposition = self::ATTR_ALL, $csr = null) + public function getAttribute(string $id, int $disposition = self::ATTR_ALL, array $csr = null) { if (empty($csr)) { $csr = $this->currentCert; @@ -3482,10 +3355,9 @@ class X509 /** * Returns a list of all CSR attributes in use * - * @param array $csr optional - * @return array + * @param array|null $csr optional */ - public function getAttributes($csr = null) + public function getAttributes(array $csr = null): array { if (empty($csr)) { $csr = $this->currentCert; @@ -3506,12 +3378,9 @@ class X509 /** * Set a CSR attribute * - * @param string $id - * @param mixed $value * @param int $disposition optional - * @return bool */ - public function setAttribute($id, $value, $disposition = self::ATTR_ALL) + public function setAttribute(string $id, $value, int $disposition = self::ATTR_ALL): bool { $attributes = &$this->subArray($this->currentCert, 'certificationRequestInfo/attributes', true); @@ -3563,10 +3432,8 @@ class X509 * Sets the subject key identifier * * This is used by the id-ce-authorityKeyIdentifier and the id-ce-subjectKeyIdentifier extensions. - * - * @param string $value */ - public function setKeyIdentifier($value) + public function setKeyIdentifier(string $value): void { if (empty($value)) { unset($this->currentKeyIdentifier); @@ -3592,7 +3459,7 @@ class X509 * @param int $method optional * @return string binary key identifier */ - public function computeKeyIdentifier($key = null, $method = 1) + public function computeKeyIdentifier($key = null, int $method = 1) { if (is_null($key)) { $key = $this; @@ -3641,7 +3508,7 @@ class X509 } // If in PEM format, convert to binary. - $key = ASN1::extractBER($key); + $key = ASN1::extractBER(is_string($key) ? $key : $key->__toString()); // Now we have the key string: compute its sha-1 sum. $hash = new Hash('sha1'); @@ -3681,11 +3548,8 @@ class X509 /** * Set the domain name's which the cert is to be valid for - * - * @param mixed ...$domains - * @return void */ - public function setDomain(...$domains) + public function setDomain(...$domains): void { $this->domains = $domains; $this->removeDNProp('id-at-commonName'); @@ -3697,7 +3561,7 @@ class X509 * * @param mixed[] ...$ipAddresses */ - public function setIPAddress(...$ipAddresses) + public function setIPAddress(...$ipAddresses): void { $this->ipAddresses = $ipAddresses; /* @@ -3710,11 +3574,8 @@ class X509 /** * Helper function to build domain array - * - * @param string $domain - * @return array */ - private static function dnsName($domain) + private static function dnsName(string $domain): array { return ['dNSName' => $domain]; } @@ -3723,11 +3584,8 @@ class X509 * Helper function to build IP Address array * * (IPv6 is not currently supported) - * - * @param string $address - * @return array */ - private function iPAddress($address) + private function iPAddress(string $address): array { return ['iPAddress' => $address]; } @@ -3735,12 +3593,10 @@ class X509 /** * Get the index of a revoked certificate. * - * @param array $rclist - * @param string $serial * @param bool $create optional * @return int|false */ - private function revokedCertificate(&$rclist, $serial, $create = false) + private function revokedCertificate(array &$rclist, string $serial, bool $create = false) { $serial = new BigInteger($serial); @@ -3764,11 +3620,9 @@ class X509 /** * Revoke a certificate. * - * @param string $serial - * @param string $date optional - * @return bool + * @param string|null $date optional */ - public function revoke($serial, $date = null) + public function revoke(string $serial, string $date = null): bool { if (isset($this->currentCert['tbsCertList'])) { if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) { @@ -3789,11 +3643,8 @@ class X509 /** * Unrevoke a certificate. - * - * @param string $serial - * @return bool */ - public function unrevoke($serial) + public function unrevoke(string $serial): bool { if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { if (($i = $this->revokedCertificate($rclist, $serial)) !== false) { @@ -3808,11 +3659,8 @@ class X509 /** * Get a revoked certificate. - * - * @param string $serial - * @return mixed */ - public function getRevoked($serial) + public function getRevoked(string $serial) { if (is_array($rclist = $this->subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { if (($i = $this->revokedCertificate($rclist, $serial)) !== false) { @@ -3826,10 +3674,10 @@ class X509 /** * List revoked certificates * - * @param array $crl optional + * @param array|null $crl optional * @return array|bool */ - public function listRevoked($crl = null) + public function listRevoked(array $crl = null) { if (!isset($crl)) { $crl = $this->currentCert; @@ -3852,12 +3700,8 @@ class X509 /** * Remove a Revoked Certificate Extension - * - * @param string $serial - * @param string $id - * @return bool */ - public function removeRevokedCertificateExtension($serial, $id) + public function removeRevokedCertificateExtension(string $serial, string $id): bool { if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { if (($i = $this->revokedCertificate($rclist, $serial)) !== false) { @@ -3873,12 +3717,9 @@ class X509 * * Returns the extension if it exists and false if not * - * @param string $serial - * @param string $id - * @param array $crl optional - * @return mixed + * @param array|null $crl optional */ - public function getRevokedCertificateExtension($serial, $id, $crl = null) + public function getRevokedCertificateExtension(string $serial, string $id, array $crl = null) { if (!isset($crl)) { $crl = $this->currentCert; @@ -3896,11 +3737,10 @@ class X509 /** * Returns a list of all extensions in use for a given revoked certificate * - * @param string $serial - * @param array $crl optional + * @param array|null $crl optional * @return array|bool */ - public function getRevokedCertificateExtensions($serial, $crl = null) + public function getRevokedCertificateExtensions(string $serial, array $crl = null) { if (!isset($crl)) { $crl = $this->currentCert; @@ -3918,14 +3758,10 @@ class X509 /** * Set a Revoked Certificate Extension * - * @param string $serial - * @param string $id - * @param mixed $value * @param bool $critical optional * @param bool $replace optional - * @return bool */ - public function setRevokedCertificateExtension($serial, $id, $value, $critical = false, $replace = true) + public function setRevokedCertificateExtension(string $serial, string $id, $value, bool $critical = false, bool $replace = true): bool { if (isset($this->currentCert['tbsCertList'])) { if (is_array($rclist = &$this->subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) { @@ -3940,11 +3776,8 @@ class X509 /** * Register the mapping for a custom/unsupported extension. - * - * @param string $id - * @param array $mapping */ - public static function registerExtension($id, array $mapping) + public static function registerExtension(string $id, array $mapping): void { if (isset(self::$extensions[$id]) && self::$extensions[$id] !== $mapping) { throw new \RuntimeException( @@ -3957,25 +3790,16 @@ class X509 /** * Register the mapping for a custom/unsupported extension. - * - * @param string $id - * - * @return array|null */ - public static function getRegisteredExtension($id) + public static function getRegisteredExtension(string $id): ?array { - return isset(self::$extensions[$id]) ? self::$extensions[$id] : null; + return self::$extensions[$id] ?? null; } /** * Register the mapping for a custom/unsupported extension. - * - * @param string $id - * @param mixed $value - * @param bool $critical - * @param bool $replace */ - public function setExtensionValue($id, $value, $critical = false, $replace = false) + public function setExtensionValue(string $id, $value, bool $critical = false, bool $replace = false): void { $this->extensionValues[$id] = compact('critical', 'replace', 'value'); } diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index b3ab84a8..88860838 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -25,6 +25,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Math; use phpseclib3\Exception\BadConfigurationException; @@ -82,11 +84,9 @@ class BigInteger implements \JsonSerializable * * Throws an exception if the type is invalid * - * @param string $main * @param list $modexps optional - * @return void */ - public static function setEngine($main, array $modexps = ['DefaultEngine']) + public static function setEngine(string $main, array $modexps = ['DefaultEngine']): void { self::$engines = []; @@ -126,7 +126,7 @@ class BigInteger implements \JsonSerializable * * @return string[] */ - public static function getEngine() + public static function getEngine(): array { self::initialize_static_variables(); @@ -136,7 +136,7 @@ class BigInteger implements \JsonSerializable /** * Initialize static variables */ - private static function initialize_static_variables() + private static function initialize_static_variables(): void { if (!isset(self::$mainEngine)) { $engines = [ @@ -147,7 +147,7 @@ class BigInteger implements \JsonSerializable ]; foreach ($engines as $engine) { try { - self::setEngine($engine[0], isset($engine[1]) ? $engine[1] : []); + self::setEngine($engine[0], $engine[1] ?? []); break; } catch (\Exception $e) { } @@ -162,9 +162,8 @@ class BigInteger implements \JsonSerializable * two's compliment. The sole exception to this is -10, which is treated the same as 10 is. * * @param string|int|BigInteger\Engines\Engine $x Base-10 number or base-$base number if $base set. - * @param int $base */ - public function __construct($x = 0, $base = 10) + public function __construct($x = 0, int $base = 10) { self::initialize_static_variables(); @@ -180,10 +179,8 @@ class BigInteger implements \JsonSerializable /** * Converts a BigInteger to a base-10 number. - * - * @return string */ - public function toString() + public function toString(): string { return $this->value->toString(); } @@ -208,22 +205,16 @@ class BigInteger implements \JsonSerializable /** * Converts a BigInteger to a byte string (eg. base-256). - * - * @param bool $twos_compliment - * @return string */ - public function toBytes($twos_compliment = false) + public function toBytes(bool $twos_compliment = false): string { return $this->value->toBytes($twos_compliment); } /** * Converts a BigInteger to a hex string (eg. base-16). - * - * @param bool $twos_compliment - * @return string */ - public function toHex($twos_compliment = false) + public function toHex(bool $twos_compliment = false): string { return $this->value->toHex($twos_compliment); } @@ -233,44 +224,32 @@ class BigInteger implements \JsonSerializable * * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're * saved as two's compliment. - * - * @param bool $twos_compliment - * @return string */ - public function toBits($twos_compliment = false) + public function toBits(bool $twos_compliment = false): string { return $this->value->toBits($twos_compliment); } /** * Adds two BigIntegers. - * - * @param BigInteger $y - * @return BigInteger */ - public function add(BigInteger $y) + public function add(BigInteger $y): BigInteger { return new static($this->value->add($y->value)); } /** * Subtracts two BigIntegers. - * - * @param BigInteger $y - * @return BigInteger */ - public function subtract(BigInteger $y) + public function subtract(BigInteger $y): BigInteger { return new static($this->value->subtract($y->value)); } /** * Multiplies two BigIntegers - * - * @param BigInteger $x - * @return BigInteger */ - public function multiply(BigInteger $x) + public function multiply(BigInteger $x): BigInteger { return new static($this->value->multiply($x->value)); } @@ -297,12 +276,11 @@ class BigInteger implements \JsonSerializable * ?> * * - * @param BigInteger $y * @return BigInteger[] */ - public function divide(BigInteger $y) + public function divide(BigInteger $y): array { - list($q, $r) = $this->value->divide($y->value); + [$q, $r] = $this->value->divide($y->value); return [ new static($q), new static($r) @@ -313,11 +291,8 @@ class BigInteger implements \JsonSerializable * Calculates modular inverses. * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * - * @param BigInteger $n - * @return BigInteger */ - public function modInverse(BigInteger $n) + public function modInverse(BigInteger $n): BigInteger { return new static($this->value->modInverse($n->value)); } @@ -327,10 +302,9 @@ class BigInteger implements \JsonSerializable * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. * - * @param BigInteger $n * @return BigInteger[] */ - public function extendedGCD(BigInteger $n) + public function extendedGCD(BigInteger $n): array { extract($this->value->extendedGCD($n->value)); /** @@ -349,21 +323,16 @@ class BigInteger implements \JsonSerializable * Calculates the greatest common divisor * * Say you have 693 and 609. The GCD is 21. - * - * @param BigInteger $n - * @return BigInteger */ - public function gcd(BigInteger $n) + public function gcd(BigInteger $n): BigInteger { return new static($this->value->gcd($n->value)); } /** * Absolute value. - * - * @return BigInteger */ - public function abs() + public function abs(): BigInteger { return new static($this->value->abs()); } @@ -373,10 +342,8 @@ class BigInteger implements \JsonSerializable * * Some bitwise operations give different results depending on the precision being used. Examples include left * shift, not, and rotates. - * - * @param int $bits */ - public function setPrecision($bits) + public function setPrecision(int $bits): void { $this->value->setPrecision($bits); } @@ -423,7 +390,7 @@ class BigInteger implements \JsonSerializable * * Will be called, automatically, when unserialize() is called on a BigInteger object. */ - public function __wakeup() + public function __wakeup(): void { $temp = new static($this->hex, -16); $this->value = $temp->value; @@ -439,7 +406,7 @@ class BigInteger implements \JsonSerializable * Will be called, automatically, when json_encode() is called on a BigInteger object. */ #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): array { $result = ['hex' => $this->toHex(true)]; if ($this->precision > 0) { @@ -450,24 +417,16 @@ class BigInteger implements \JsonSerializable /** * Performs modular exponentiation. - * - * @param BigInteger $e - * @param BigInteger $n - * @return BigInteger */ - public function powMod(BigInteger $e, BigInteger $n) + public function powMod(BigInteger $e, BigInteger $n): BigInteger { return new static($this->value->powMod($e->value, $n->value)); } /** * Performs modular exponentiation. - * - * @param BigInteger $e - * @param BigInteger $n - * @return BigInteger */ - public function modPow(BigInteger $e, BigInteger $n) + public function modPow(BigInteger $e, BigInteger $n): BigInteger { return new static($this->value->modPow($e->value, $n->value)); } @@ -486,11 +445,10 @@ class BigInteger implements \JsonSerializable * * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} * - * @param BigInteger $y * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. * @see self::equals() */ - public function compare(BigInteger $y) + public function compare(BigInteger $y): int { return $this->value->compare($y->value); } @@ -499,54 +457,40 @@ class BigInteger implements \JsonSerializable * Tests the equality of two numbers. * * If you need to see if one number is greater than or less than another number, use BigInteger::compare() - * - * @param BigInteger $x - * @return bool */ - public function equals(BigInteger $x) + public function equals(BigInteger $x): bool { return $this->value->equals($x->value); } /** * Logical Not - * - * @return BigInteger */ - public function bitwise_not() + public function bitwise_not(): BigInteger { return new static($this->value->bitwise_not()); } /** * Logical And - * - * @param BigInteger $x - * @return BigInteger */ - public function bitwise_and(BigInteger $x) + public function bitwise_and(BigInteger $x): BigInteger { return new static($this->value->bitwise_and($x->value)); } /** * Logical Or - * - * @param BigInteger $x - * @return BigInteger */ - public function bitwise_or(BigInteger $x) + public function bitwise_or(BigInteger $x): BigInteger { return new static($this->value->bitwise_or($x->value)); } /** * Logical Exclusive Or - * - * @param BigInteger $x - * @return BigInteger */ - public function bitwise_xor(BigInteger $x) + public function bitwise_xor(BigInteger $x): BigInteger { return new static($this->value->bitwise_xor($x->value)); } @@ -555,11 +499,8 @@ class BigInteger implements \JsonSerializable * Logical Right Shift * * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift. - * - * @param int $shift - * @return BigInteger */ - public function bitwise_rightShift($shift) + public function bitwise_rightShift(int $shift): BigInteger { return new static($this->value->bitwise_rightShift($shift)); } @@ -568,11 +509,8 @@ class BigInteger implements \JsonSerializable * Logical Left Shift * * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift. - * - * @param int $shift - * @return BigInteger */ - public function bitwise_leftShift($shift) + public function bitwise_leftShift(int $shift): BigInteger { return new static($this->value->bitwise_leftShift($shift)); } @@ -581,11 +519,8 @@ class BigInteger implements \JsonSerializable * Logical Left Rotate * * Instead of the top x bits being dropped they're appended to the shifted bit string. - * - * @param int $shift - * @return BigInteger */ - public function bitwise_leftRotate($shift) + public function bitwise_leftRotate(int $shift): BigInteger { return new static($this->value->bitwise_leftRotate($shift)); } @@ -594,11 +529,8 @@ class BigInteger implements \JsonSerializable * Logical Right Rotate * * Instead of the bottom x bits being dropped they're prepended to the shifted bit string. - * - * @param int $shift - * @return BigInteger */ - public function bitwise_rightRotate($shift) + public function bitwise_rightRotate(int $shift): BigInteger { return new static($this->value->bitwise_rightRotate($shift)); } @@ -606,10 +538,9 @@ class BigInteger implements \JsonSerializable /** * Returns the smallest and largest n-bit number * - * @param int $bits * @return BigInteger[] */ - public static function minMaxBits($bits) + public static function minMaxBits(int $bits): array { self::initialize_static_variables(); @@ -626,20 +557,16 @@ class BigInteger implements \JsonSerializable /** * Return the size of a BigInteger in bits - * - * @return int */ - public function getLength() + public function getLength(): int { return $this->value->getLength(); } /** * Return the size of a BigInteger in bytes - * - * @return int */ - public function getLengthInBytes() + public function getLengthInBytes(): int { return $this->value->getLengthInBytes(); } @@ -648,11 +575,8 @@ class BigInteger implements \JsonSerializable * Generates a random number of a certain size * * Bit length is equal to $size - * - * @param int $size - * @return BigInteger */ - public static function random($size) + public static function random(int $size): BigInteger { self::initialize_static_variables(); @@ -664,11 +588,8 @@ class BigInteger implements \JsonSerializable * Generates a random prime number of a certain size * * Bit length is equal to $size - * - * @param int $size - * @return BigInteger */ - public static function randomPrime($size) + public static function randomPrime(int $size): BigInteger { self::initialize_static_variables(); @@ -681,8 +602,6 @@ class BigInteger implements \JsonSerializable * * If there's not a prime within the given range, false will be returned. * - * @param BigInteger $min - * @param BigInteger $max * @return false|BigInteger */ public static function randomRangePrime(BigInteger $min, BigInteger $max) @@ -699,12 +618,8 @@ class BigInteger implements \JsonSerializable * * BigInteger::randomRange($min, $max) * BigInteger::randomRange($max, $min) - * - * @param BigInteger $min - * @param BigInteger $max - * @return BigInteger */ - public static function randomRange(BigInteger $min, BigInteger $max) + public static function randomRange(BigInteger $min, BigInteger $max): BigInteger { $class = self::$mainEngine; return new static($class::randomRange($min->value, $max->value)); @@ -718,9 +633,8 @@ class BigInteger implements \JsonSerializable * on a website instead of just one. * * @param int|bool $t - * @return bool */ - public function isPrime($t = false) + public function isPrime($t = false): bool { return $this->value->isPrime($t); } @@ -731,31 +645,24 @@ class BigInteger implements \JsonSerializable * Returns the nth root of a positive biginteger, where n defaults to 2 * * @param int $n optional - * @return BigInteger */ - public function root($n = 2) + public function root(int $n = 2): BigInteger { return new static($this->value->root($n)); } /** * Performs exponentiation. - * - * @param BigInteger $n - * @return BigInteger */ - public function pow(BigInteger $n) + public function pow(BigInteger $n): BigInteger { return new static($this->value->pow($n->value)); } /** * Return the minimum BigInteger between an arbitrary number of BigIntegers. - * - * @param BigInteger ...$nums - * @return BigInteger */ - public static function min(BigInteger ...$nums) + public static function min(BigInteger ...$nums): BigInteger { $class = self::$mainEngine; $nums = array_map(function ($num) { @@ -766,11 +673,8 @@ class BigInteger implements \JsonSerializable /** * Return the maximum BigInteger between an arbitrary number of BigIntegers. - * - * @param BigInteger ...$nums - * @return BigInteger */ - public static function max(BigInteger ...$nums) + public static function max(BigInteger ...$nums): BigInteger { $class = self::$mainEngine; $nums = array_map(function ($num) { @@ -781,12 +685,8 @@ class BigInteger implements \JsonSerializable /** * Tests BigInteger to see if it is between two integers, inclusive - * - * @param BigInteger $min - * @param BigInteger $max - * @return bool */ - public function between(BigInteger $min, BigInteger $max) + public function between(BigInteger $min, BigInteger $max): bool { return $this->value->between($min->value, $max->value); } @@ -801,31 +701,24 @@ class BigInteger implements \JsonSerializable /** * Is Odd? - * - * @return bool */ - public function isOdd() + public function isOdd(): bool { return $this->value->isOdd(); } /** * Tests if a bit is set - * - * @param int $x - * @return bool */ - public function testBit($x) + public function testBit(int $x): bool { return $this->value->testBit($x); } /** * Is Negative? - * - * @return bool */ - public function isNegative() + public function isNegative(): bool { return $this->value->isNegative(); } @@ -834,10 +727,8 @@ class BigInteger implements \JsonSerializable * Negate * * Given $k, returns -$k - * - * @return BigInteger */ - public function negate() + public function negate(): BigInteger { return new static($this->value->negate()); } @@ -846,11 +737,8 @@ class BigInteger implements \JsonSerializable * Scan for 1 and right shift by that amount * * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); - * - * @param BigInteger $r - * @return int */ - public static function scan1divide(BigInteger $r) + public static function scan1divide(BigInteger $r): int { $class = self::$mainEngine; return $class::scan1divide($r->value); @@ -877,10 +765,9 @@ class BigInteger implements \JsonSerializable * * Splits BigInteger's into chunks of $split bits * - * @param int $split * @return BigInteger[] */ - public function bitwise_split($split) + public function bitwise_split(int $split): array { return array_map(function ($val) { return new static($val); diff --git a/phpseclib/Math/BigInteger/Engines/BCMath.php b/phpseclib/Math/BigInteger/Engines/BCMath.php index 3f0355f4..e6fbf5ae 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines; use ParagonIE\ConstantTime\Hex; @@ -41,10 +43,9 @@ class BCMath extends Engine /** * Test for engine validity * - * @return bool * @see parent::__construct() */ - public static function isValidEngine() + public static function isValidEngine(): bool { return extension_loaded('bcmath'); } @@ -53,10 +54,9 @@ class BCMath extends Engine * Default constructor * * @param mixed $x integer Base-10 number or base-$base number if $base set. - * @param int $base * @see parent::__construct() */ - public function __construct($x = 0, $base = 10) + public function __construct($x = 0, int $base = 10) { if (!isset(static::$isValidEngine[static::class])) { static::$isValidEngine[static::class] = self::isValidEngine(); @@ -73,10 +73,9 @@ class BCMath extends Engine /** * Initialize a BCMath BigInteger Engine instance * - * @param int $base * @see parent::__construct() */ - protected function initialize($base) + protected function initialize(int $base): void { switch (abs($base)) { case 256: @@ -90,9 +89,7 @@ class BCMath extends Engine $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32 $this->value = bcadd( $this->value, - 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord( - $x[$i + 2] - ) << 8) | ord($x[$i + 3])), + (string) (0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3]))), 0 ); } @@ -116,10 +113,8 @@ class BCMath extends Engine /** * Converts a BigInteger to a base-10 number. - * - * @return string */ - public function toString() + public function toString(): string { if ($this->value === '0') { return '0'; @@ -130,11 +125,8 @@ class BCMath extends Engine /** * Converts a BigInteger to a byte string (eg. base-256). - * - * @param bool $twos_compliment - * @return string */ - public function toBytes($twos_compliment = false) + public function toBytes(bool $twos_compliment = false): string { if ($twos_compliment) { return $this->toBytesHelper(); @@ -149,7 +141,7 @@ class BCMath extends Engine while (bccomp($current, '0', 0) > 0) { $temp = bcmod($current, '16777216'); - $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value; + $value = chr($temp >> 16) . chr($temp >> 8) . chr((int) $temp) . $value; $current = bcdiv($current, '16777216', 0); } @@ -160,11 +152,8 @@ class BCMath extends Engine /** * Adds two BigIntegers. - * - * @param BCMath $y - * @return BCMath */ - public function add(BCMath $y) + public function add(BCMath $y): BCMath { $temp = new self(); $temp->value = bcadd($this->value, $y->value); @@ -174,11 +163,8 @@ class BCMath extends Engine /** * Subtracts two BigIntegers. - * - * @param BCMath $y - * @return BCMath */ - public function subtract(BCMath $y) + public function subtract(BCMath $y): BCMath { $temp = new self(); $temp->value = bcsub($this->value, $y->value); @@ -188,11 +174,8 @@ class BCMath extends Engine /** * Multiplies two BigIntegers. - * - * @param BCMath $x - * @return BCMath */ - public function multiply(BCMath $x) + public function multiply(BCMath $x): BCMath { $temp = new self(); $temp->value = bcmul($this->value, $x->value); @@ -208,10 +191,9 @@ class BCMath extends Engine * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder * and the divisor (basically, the "common residue" is the first positive modulo). * - * @param BCMath $y * @return array{static, static} */ - public function divide(BCMath $y) + public function divide(BCMath $y): array { $quotient = new self(); $remainder = new self(); @@ -231,7 +213,6 @@ class BCMath extends Engine * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. * - * @param BCMath $n * @return false|BCMath */ public function modInverse(BCMath $n) @@ -247,10 +228,9 @@ class BCMath extends Engine * combination is returned is dependent upon which mode is in use. See * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information. * - * @param BCMath $n * @return array{gcd: static, x: static, y: static} */ - public function extendedGCD(BCMath $n) + public function extendedGCD(BCMath $n): array { // it might be faster to use the binary xGCD algorithim here, as well, but (1) that algorithim works // best when the base is a power of 2 and (2) i don't think it'd make much difference, anyway. as is, @@ -291,11 +271,8 @@ class BCMath extends Engine * Calculates the greatest common divisor * * Say you have 693 and 609. The GCD is 21. - * - * @param BCMath $n - * @return BCMath */ - public function gcd(BCMath $n) + public function gcd(BCMath $n): BCMath { extract($this->extendedGCD($n)); /** @var BCMath $gcd */ @@ -304,10 +281,8 @@ class BCMath extends Engine /** * Absolute value. - * - * @return BCMath */ - public function abs() + public function abs(): BCMath { $temp = new static(); $temp->value = strlen($this->value) && $this->value[0] == '-' ? @@ -319,33 +294,24 @@ class BCMath extends Engine /** * Logical And - * - * @param BCMath $x - * @return BCMath */ - public function bitwise_and(BCMath $x) + public function bitwise_and(BCMath $x): BCMath { return $this->bitwiseAndHelper($x); } /** * Logical Or - * - * @param BCMath $x - * @return BCMath */ - public function bitwise_or(BCMath $x) + public function bitwise_or(BCMath $x): BCMath { return $this->bitwiseXorHelper($x); } /** * Logical Exclusive Or - * - * @param BCMath $x - * @return BCMath */ - public function bitwise_xor(BCMath $x) + public function bitwise_xor(BCMath $x): BCMath { return $this->bitwiseXorHelper($x); } @@ -354,14 +320,11 @@ class BCMath extends Engine * Logical Right Shift * * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift. - * - * @param int $shift - * @return BCMath */ - public function bitwise_rightShift($shift) + public function bitwise_rightShift(int $shift): BCMath { $temp = new static(); - $temp->value = bcdiv($this->value, bcpow('2', $shift, 0), 0); + $temp->value = bcdiv($this->value, bcpow('2', (string)$shift, 0), 0); return $this->normalize($temp); } @@ -370,14 +333,11 @@ class BCMath extends Engine * Logical Left Shift * * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift. - * - * @param int $shift - * @return BCMath */ - public function bitwise_leftShift($shift) + public function bitwise_leftShift(int $shift): BCMath { $temp = new static(); - $temp->value = bcmul($this->value, bcpow('2', $shift, 0), 0); + $temp->value = bcmul($this->value, bcpow('2', (string) $shift, 0), 0); return $this->normalize($temp); } @@ -396,11 +356,10 @@ class BCMath extends Engine * * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} * - * @param BCMath $y * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. * @see self::equals() */ - public function compare(BCMath $y) + public function compare(BCMath $y): int { return bccomp($this->value, $y->value, 0); } @@ -409,23 +368,16 @@ class BCMath extends Engine * Tests the equality of two numbers. * * If you need to see if one number is greater than or less than another number, use BigInteger::compare() - * - * @param BCMath $x - * @return bool */ - public function equals(BCMath $x) + public function equals(BCMath $x): bool { return $this->value == $x->value; } /** * Performs modular exponentiation. - * - * @param BCMath $e - * @param BCMath $n - * @return BCMath */ - public function modPow(BCMath $e, BCMath $n) + public function modPow(BCMath $e, BCMath $n): BCMath { return $this->powModOuter($e, $n); } @@ -434,24 +386,16 @@ class BCMath extends Engine * Performs modular exponentiation. * * Alias for modPow(). - * - * @param BCMath $e - * @param BCMath $n - * @return BCMath */ - public function powMod(BCMath $e, BCMath $n) + public function powMod(BCMath $e, BCMath $n): BCMath { return $this->powModOuter($e, $n); } /** * Performs modular exponentiation. - * - * @param BCMath $e - * @param BCMath $n - * @return BCMath */ - protected function powModInner(BCMath $e, BCMath $n) + protected function powModInner(BCMath $e, BCMath $n): BCMath { try { $class = static::$modexpEngine[static::class]; @@ -465,11 +409,8 @@ class BCMath extends Engine * Normalize * * Removes leading zeros and truncates (if necessary) to maintain the appropriate precision - * - * @param BCMath $result - * @return BCMath */ - protected function normalize(BCMath $result) + protected function normalize(BCMath $result): BCMath { $result->precision = $this->precision; $result->bitmask = $this->bitmask; @@ -486,8 +427,6 @@ class BCMath extends Engine * * If there's not a prime within the given range, false will be returned. * - * @param BCMath $min - * @param BCMath $max * @return false|BCMath */ public static function randomRangePrime(BCMath $min, BCMath $max) @@ -503,12 +442,8 @@ class BCMath extends Engine * * BigInteger::randomRange($min, $max) * BigInteger::randomRange($max, $min) - * - * @param BCMath $min - * @param BCMath $max - * @return BCMath */ - public static function randomRange(BCMath $min, BCMath $max) + public static function randomRange(BCMath $min, BCMath $max): BCMath { return self::randomRangeHelper($min, $max); } @@ -520,7 +455,7 @@ class BCMath extends Engine * * @see self::randomPrime() */ - protected function make_odd() + protected function make_odd(): void { if (!$this->isOdd()) { $this->value = bcadd($this->value, '1'); @@ -532,7 +467,7 @@ class BCMath extends Engine * * @see self::isPrime() */ - protected function testSmallPrimes() + protected function testSmallPrimes(): bool { if ($this->value === '1') { return false; @@ -547,7 +482,7 @@ class BCMath extends Engine $value = $this->value; foreach (self::PRIMES as $prime) { - $r = bcmod($this->value, $prime); + $r = bcmod($this->value, (string)$prime); if ($r == '0') { return $this->value == $prime; } @@ -561,11 +496,9 @@ class BCMath extends Engine * * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); * - * @param BCMath $r - * @return int * @see self::isPrime() */ - public static function scan1divide(BCMath $r) + public static function scan1divide(BCMath $r): int { $r_value = &$r->value; $s = 0; @@ -580,11 +513,8 @@ class BCMath extends Engine /** * Performs exponentiation. - * - * @param BCMath $n - * @return BCMath */ - public function pow(BCMath $n) + public function pow(BCMath $n): BCMath { $temp = new self(); $temp->value = bcpow($this->value, $n->value); @@ -594,34 +524,24 @@ class BCMath extends Engine /** * Return the minimum BigInteger between an arbitrary number of BigIntegers. - * - * @param BCMath ...$nums - * @return BCMath */ - public static function min(BCMath ...$nums) + public static function min(BCMath ...$nums): BCMath { return self::minHelper($nums); } /** * Return the maximum BigInteger between an arbitrary number of BigIntegers. - * - * @param BCMath ...$nums - * @return BCMath */ - public static function max(BCMath ...$nums) + public static function max(BCMath ...$nums): BCMath { return self::maxHelper($nums); } /** * Tests BigInteger to see if it is between two integers, inclusive - * - * @param BCMath $min - * @param BCMath $max - * @return bool */ - public function between(BCMath $min, BCMath $max) + public function between(BCMath $min, BCMath $max): bool { return $this->compare($min) >= 0 && $this->compare($max) <= 0; } @@ -629,11 +549,9 @@ class BCMath extends Engine /** * Set Bitmask * - * @param int $bits - * @return Engine * @see self::setPrecision() */ - protected static function setBitmask($bits) + protected static function setBitmask(int $bits): Engine { $temp = parent::setBitmask($bits); return $temp->add(static::$one[static::class]); @@ -641,20 +559,16 @@ class BCMath extends Engine /** * Is Odd? - * - * @return bool */ - public function isOdd() + public function isOdd(): bool { return $this->value[strlen($this->value) - 1] % 2 == 1; } /** * Tests if a bit is set - * - * @return bool */ - public function testBit($x) + public function testBit($x): bool { return bccomp( bcmod($this->value, bcpow('2', $x + 1, 0)), @@ -665,10 +579,8 @@ class BCMath extends Engine /** * Is Negative? - * - * @return bool */ - public function isNegative() + public function isNegative(): bool { return strlen($this->value) && $this->value[0] == '-'; } @@ -677,10 +589,8 @@ class BCMath extends Engine * Negate * * Given $k, returns -$k - * - * @return BCMath */ - public function negate() + public function negate(): BCMath { $temp = clone $this; diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Base.php b/phpseclib/Math/BigInteger/Engines/BCMath/Base.php index fe21e041..01955285 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Base.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Base.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\BCMath; use phpseclib3\Math\BigInteger\Engines\BCMath; @@ -26,35 +28,25 @@ abstract class Base extends BCMath * Cache constants * * $cache[self::VARIABLE] tells us whether or not the cached data is still valid. - * */ const VARIABLE = 0; /** * $cache[self::DATA] contains the cached data. - * */ const DATA = 1; /** * Test for engine validity - * - * @return bool */ - public static function isValidEngine() + public static function isValidEngine(): bool { return static::class != __CLASS__; } /** * Performs modular exponentiation. - * - * @param BCMath $x - * @param BCMath $e - * @param BCMath $n - * @param string $class - * @return BCMath */ - protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class) + protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n, string $class): BCMath { if (empty($e->value)) { $temp = new $class(); @@ -68,13 +60,9 @@ abstract class Base extends BCMath /** * Modular reduction preparation * - * @param string $x - * @param string $n - * @param string $class - * @see self::slidingWindow() - * @return string + *@see self::slidingWindow() */ - protected static function prepareReduce($x, $n, $class) + protected static function prepareReduce(string $x, string $n, string $class): string { return static::reduce($x, $n); } @@ -82,14 +70,9 @@ abstract class Base extends BCMath /** * Modular multiply * - * @param string $x - * @param string $y - * @param string $n - * @param string $class - * @see self::slidingWindow() - * @return string + *@see self::slidingWindow() */ - protected static function multiplyReduce($x, $y, $n, $class) + protected static function multiplyReduce(string $x, string $y, string $n, string $class): string { return static::reduce(bcmul($x, $y), $n); } @@ -97,13 +80,9 @@ abstract class Base extends BCMath /** * Modular square * - * @param string $x - * @param string $n - * @param string $class - * @see self::slidingWindow() - * @return string + *@see self::slidingWindow() */ - protected static function squareReduce($x, $n, $class) + protected static function squareReduce(string $x, string $n, string $class): string { return static::reduce(bcmul($x, $x), $n); } diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php b/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php index b7ca8a2c..fede15de 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\BCMath; use phpseclib3\Math\BigInteger\Engines\BCMath; @@ -24,13 +26,8 @@ abstract class BuiltIn extends BCMath { /** * Performs modular exponentiation. - * - * @param BCMath $x - * @param BCMath $e - * @param BCMath $n - * @return BCMath */ - protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n) + protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n): BCMath { $temp = new BCMath(); $temp->value = bcpowmod($x->value, $e->value, $n->value); diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php b/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php index b2d9fa95..cda01c8a 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\BCMath; use phpseclib3\Math\BigInteger\Engines\BCMath\Reductions\Barrett; diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php index aed94942..44762836 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\BCMath; use phpseclib3\Math\BigInteger\Engines\OpenSSL as Progenitor; diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php index 0fb7eaeb..d3a77eff 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\BCMath\Reductions; use phpseclib3\Math\BigInteger\Engines\BCMath\Base; @@ -26,12 +28,10 @@ abstract class Barrett extends Base * Cache constants * * $cache[self::VARIABLE] tells us whether or not the cached data is still valid. - * */ const VARIABLE = 0; /** * $cache[self::DATA] contains the cached data. - * */ const DATA = 1; @@ -52,12 +52,8 @@ abstract class Barrett extends Base * radix points, it only works when there are an even number of digits in the denominator. The reason for (2) is that * (x >> 1) + (x >> 1) != x / 2 + x / 2. If x is even, they're the same, but if x is odd, they're not. See the in-line * comments for details. - * - * @param string $n - * @param string $m - * @return string */ - protected static function reduce($n, $m) + protected static function reduce(string $n, string $m): string { static $cache = [ self::VARIABLE => [], @@ -139,12 +135,8 @@ abstract class Barrett extends Base * * For numbers with more than four digits BigInteger::_barrett() is faster. The difference between that and this * is that this function does not fold the denominator into a smaller form. - * - * @param string $x - * @param string $n - * @return string */ - private static function regularBarrett($x, $n) + private static function regularBarrett(string $x, string $n): string { static $cache = [ self::VARIABLE => [], diff --git a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php index e033ba57..a703ea56 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\BCMath\Reductions; use phpseclib3\Math\BigInteger\Engines\BCMath; @@ -35,12 +37,8 @@ abstract class EvalBarrett extends Base * * This calls a dynamically generated loop unrolled function that's specific to a given modulo. * Array lookups are avoided as are if statements testing for how many bits the host OS supports, etc. - * - * @param string $n - * @param string $m - * @return string */ - protected static function reduce($n, $m) + protected static function reduce(string $n, string $m): string { $inline = self::$custom_reduction; return $inline($n); @@ -49,11 +47,9 @@ abstract class EvalBarrett extends Base /** * Generate Custom Reduction * - * @param BCMath $m - * @param string $class * @return callable|void */ - protected static function generateCustomReduction(BCMath $m, $class) + protected static function generateCustomReduction(BCMath $m, string $class) { $m_length = strlen($m); diff --git a/phpseclib/Math/BigInteger/Engines/Engine.php b/phpseclib/Math/BigInteger/Engines/Engine.php index cf907969..10c10f8b 100644 --- a/phpseclib/Math/BigInteger/Engines/Engine.php +++ b/phpseclib/Math/BigInteger/Engines/Engine.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines; use ParagonIE\ConstantTime\Hex; @@ -87,7 +89,7 @@ abstract class Engine implements \JsonSerializable * * @var bool */ - protected $is_negative; + protected $is_negative = false; /** * Precision @@ -125,9 +127,8 @@ abstract class Engine implements \JsonSerializable * Default constructor * * @param int|numeric-string $x integer Base-10 number or base-$base number if $base set. - * @param int $base */ - public function __construct($x = 0, $base = 10) + public function __construct($x = 0, int $base = 10) { if (!array_key_exists(static::class, static::$zero)) { static::$zero[static::class] = null; // Placeholder to prevent infinite loop. @@ -188,7 +189,7 @@ abstract class Engine implements \JsonSerializable // (?value = preg_replace('#(?value = preg_replace('#(?value) || $this->value == '-') { $this->value = '0'; } @@ -222,7 +223,7 @@ abstract class Engine implements \JsonSerializable * * @param class-string $engine */ - public static function setModExpEngine($engine) + public static function setModExpEngine(string $engine): void { $fqengine = '\\phpseclib3\\Math\\BigInteger\\Engines\\' . static::ENGINE_DIR . '\\' . $engine; if (!class_exists($fqengine) || !method_exists($fqengine, 'isValidEngine')) { @@ -239,9 +240,8 @@ abstract class Engine implements \JsonSerializable * * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're * saved as two's compliment. - * @return string */ - protected function toBytesHelper() + protected function toBytesHelper(): string { $comparison = $this->compare(new static()); if ($comparison == 0) { @@ -264,11 +264,8 @@ abstract class Engine implements \JsonSerializable /** * Converts a BigInteger to a hex string (eg. base-16). - * - * @param bool $twos_compliment - * @return string */ - public function toHex($twos_compliment = false) + public function toHex(bool $twos_compliment = false): string { return Hex::encode($this->toBytes($twos_compliment)); } @@ -278,11 +275,8 @@ abstract class Engine implements \JsonSerializable * * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're * saved as two's compliment. - * - * @param bool $twos_compliment - * @return string */ - public function toBits($twos_compliment = false) + public function toBits(bool $twos_compliment = false): string { $hex = $this->toBytes($twos_compliment); $bits = Strings::bin2bits($hex); @@ -303,7 +297,6 @@ abstract class Engine implements \JsonSerializable * * {@internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information.} * - * @param Engine $n * @return static|false */ protected function modInverseHelper(Engine $n) @@ -353,10 +346,8 @@ abstract class Engine implements \JsonSerializable * Serialize * * Will be called, automatically, when unserialize() is called on a BigInteger object. - * - * @return void */ - public function __wakeup() + public function __wakeup(): void { $temp = new static($this->hex, -16); $this->value = $temp->value; @@ -373,7 +364,7 @@ abstract class Engine implements \JsonSerializable * Will be called, automatically, when json_encode() is called on a BigInteger object. */ #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): array { $result = ['hex' => $this->toHex(true)]; if ($this->precision > 0) { @@ -413,10 +404,8 @@ abstract class Engine implements \JsonSerializable * * Some bitwise operations give different results depending on the precision being used. Examples include left * shift, not, and rotates. - * - * @param int $bits */ - public function setPrecision($bits) + public function setPrecision(int $bits): void { if ($bits < 1) { $this->precision = -1; @@ -435,21 +424,19 @@ abstract class Engine implements \JsonSerializable * Get Precision * * Returns the precision if it exists, -1 if it doesn't - * - * @return int */ - public function getPrecision() + public function getPrecision(): int { return $this->precision; } /** * Set Bitmask + * * @return static - * @param int $bits * @see self::setPrecision() */ - protected static function setBitmask($bits) + protected static function setBitmask(int $bits): Engine { return new static(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256); } @@ -496,12 +483,8 @@ abstract class Engine implements \JsonSerializable * Logical Left Shift * * Shifts binary strings $shift bits, essentially multiplying by 2**$shift. - * - * @param string $x - * @param int $shift - * @return void */ - protected static function base256_lshift(&$x, $shift) + protected static function base256_lshift(string &$x, int $shift): void { if ($shift == 0) { return; @@ -524,11 +507,8 @@ abstract class Engine implements \JsonSerializable * Logical Left Rotate * * Instead of the top x bits being dropped they're appended to the shifted bit string. - * - * @param int $shift - * @return Engine */ - public function bitwise_leftRotate($shift) + public function bitwise_leftRotate(int $shift): Engine { $bits = $this->toBytes(); @@ -568,11 +548,8 @@ abstract class Engine implements \JsonSerializable * Logical Right Rotate * * Instead of the bottom x bits being dropped they're prepended to the shifted bit string. - * - * @param int $shift - * @return Engine */ - public function bitwise_rightRotate($shift) + public function bitwise_rightRotate(int $shift): Engine { return $this->bitwise_leftRotate(-$shift); } @@ -580,10 +557,9 @@ abstract class Engine implements \JsonSerializable /** * Returns the smallest and largest n-bit number * - * @param int $bits * @return array{min: static, max: static} */ - public static function minMaxBits($bits) + public static function minMaxBits(int $bits): array { $bytes = $bits >> 3; $min = str_repeat(chr(0), $bytes); @@ -603,20 +579,16 @@ abstract class Engine implements \JsonSerializable /** * Return the size of a BigInteger in bits - * - * @return int */ - public function getLength() + public function getLength(): int { return strlen($this->toBits()); } /** * Return the size of a BigInteger in bytes - * - * @return int */ - public function getLengthInBytes() + public function getLengthInBytes(): int { return strlen($this->toBytes()); } @@ -624,8 +596,6 @@ abstract class Engine implements \JsonSerializable /** * Performs some pre-processing for powMod * - * @param Engine $e - * @param Engine $n * @return static|false */ protected function powModOuter(Engine $e, Engine $n) @@ -655,13 +625,10 @@ abstract class Engine implements \JsonSerializable * As such, this function has the same preconditions that the reductions being used do. * * @template T of Engine - * @param Engine $x - * @param Engine $e - * @param Engine $n * @param class-string $class * @return T */ - protected static function slidingWindow(Engine $x, Engine $e, Engine $n, $class) + protected static function slidingWindow(Engine $x, Engine $e, Engine $n, string $class) { static $window_ranges = [7, 25, 81, 241, 673, 1793]; // from BigInteger.java's oddModPow function //static $window_ranges = [0, 7, 36, 140, 450, 1303, 3529]; // from MPM 7.3.1 @@ -728,11 +695,8 @@ abstract class Engine implements \JsonSerializable * Generates a random number of a certain size * * Bit length is equal to $size - * - * @param int $size - * @return Engine */ - public static function random($size) + public static function random(int $size): Engine { extract(static::minMaxBits($size)); /** @@ -746,11 +710,8 @@ abstract class Engine implements \JsonSerializable * Generates a random prime number of a certain size * * Bit length is equal to $size - * - * @param int $size - * @return Engine */ - public static function randomPrime($size) + public static function randomPrime(int $size): Engine { extract(static::minMaxBits($size)); /** @@ -763,8 +724,6 @@ abstract class Engine implements \JsonSerializable /** * Performs some pre-processing for randomRangePrime * - * @param Engine $min - * @param Engine $max * @return static|false */ protected static function randomRangePrimeOuter(Engine $min, Engine $max) @@ -793,12 +752,8 @@ abstract class Engine implements \JsonSerializable * * BigInteger::randomRange($min, $max) * BigInteger::randomRange($max, $min) - * - * @param Engine $min - * @param Engine $max - * @return Engine */ - protected static function randomRangeHelper(Engine $min, Engine $max) + protected static function randomRangeHelper(Engine $min, Engine $max): Engine { $compare = $max->compare($min); @@ -837,7 +792,7 @@ abstract class Engine implements \JsonSerializable $random_max = new static(chr(1) . str_repeat("\0", $size), 256); $random = new static(Random::string($size), 256); - list($max_multiple) = $random_max->divide($max); + [$max_multiple] = $random_max->divide($max); $max_multiple = $max_multiple->multiply($max); while ($random->compare($max_multiple) >= 0) { @@ -846,10 +801,10 @@ abstract class Engine implements \JsonSerializable $random = $random->bitwise_leftShift(8); $random = $random->add(new static(Random::string(1), 256)); $random_max = $random_max->bitwise_leftShift(8); - list($max_multiple) = $random_max->divide($max); + [$max_multiple] = $random_max->divide($max); $max_multiple = $max_multiple->multiply($max); } - list(, $random) = $random->divide($max); + [, $random] = $random->divide($max); return $random->add($min); } @@ -857,9 +812,6 @@ abstract class Engine implements \JsonSerializable /** * Performs some post-processing for randomRangePrime * - * @param Engine $x - * @param Engine $min - * @param Engine $max * @return static|false */ protected static function randomRangePrimeInner(Engine $x, Engine $min, Engine $max) @@ -903,10 +855,8 @@ abstract class Engine implements \JsonSerializable /** * Sets the $t parameter for primality testing - * - * @return int */ - protected function setupIsPrime() + protected function setupIsPrime(): int { $length = $this->getLengthInBytes(); @@ -934,11 +884,8 @@ abstract class Engine implements \JsonSerializable * * Uses the {@link http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Miller-Rabin primality test}. * See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=8 HAC 4.24} for more info. - * - * @param int $t - * @return bool */ - protected function testPrimality($t) + protected function testPrimality(int $t): bool { if (!$this->testSmallPrimes()) { return false; @@ -980,9 +927,8 @@ abstract class Engine implements \JsonSerializable * on a website instead of just one. * * @param int|bool $t - * @return bool */ - public function isPrime($t = false) + public function isPrime($t = false): bool { if (!$t) { $t = $this->setupIsPrime(); @@ -992,11 +938,8 @@ abstract class Engine implements \JsonSerializable /** * Performs a few preliminary checks on root - * - * @param int $n - * @return Engine */ - protected function rootHelper($n) + protected function rootHelper(int $n): Engine { if ($n < 1) { return clone static::$zero[static::class]; @@ -1017,11 +960,8 @@ abstract class Engine implements \JsonSerializable * Returns the nth root of a positive biginteger, where n defaults to 2 * * {@internal This function is based off of {@link http://mathforum.org/library/drmath/view/52605.html this page} and {@link http://stackoverflow.com/questions/11242920/calculating-nth-root-with-bcmath-in-php this stackoverflow question}.} - * - * @param int $n - * @return Engine */ - protected function rootInner($n) + protected function rootInner(int $n): Engine { $n = new static($n); @@ -1075,22 +1015,16 @@ abstract class Engine implements \JsonSerializable /** * Calculates the nth root of a biginteger. - * - * @param int $n - * @return Engine */ - public function root($n = 2) + public function root(int $n = 2): Engine { return $this->rootHelper($n); } /** * Return the minimum BigInteger between an arbitrary number of BigIntegers. - * - * @param array $nums - * @return Engine */ - protected static function minHelper(array $nums) + protected static function minHelper(array $nums): Engine { if (count($nums) == 1) { return $nums[0]; @@ -1104,11 +1038,8 @@ abstract class Engine implements \JsonSerializable /** * Return the minimum BigInteger between an arbitrary number of BigIntegers. - * - * @param array $nums - * @return Engine */ - protected static function maxHelper(array $nums) + protected static function maxHelper(array $nums): Engine { if (count($nums) == 1) { return $nums[0]; @@ -1125,10 +1056,8 @@ abstract class Engine implements \JsonSerializable * * Sometimes it may be desirable to do repeated modulos with the same number outside of * modular exponentiation - * - * @return callable */ - public function createRecurringModuloFunction() + public function createRecurringModuloFunction(): \Closure { $class = static::class; @@ -1154,10 +1083,9 @@ abstract class Engine implements \JsonSerializable /** * Calculates the greatest common divisor and Bezout's identity. * - * @param Engine $n * @return array{gcd: Engine, x: Engine, y: Engine} */ - protected function extendedGCDHelper(Engine $n) + protected function extendedGCDHelper(Engine $n): array { $u = clone $this; $v = clone $n; @@ -1171,7 +1099,7 @@ abstract class Engine implements \JsonSerializable $d = clone $one; while (!$v->equals($zero)) { - list($q) = $u->divide($v); + [$q] = $u->divide($v); $temp = $u; $u = $v; @@ -1198,10 +1126,9 @@ abstract class Engine implements \JsonSerializable * * Splits BigInteger's into chunks of $split bits * - * @param int $split * @return Engine[] */ - public function bitwise_split($split) + public function bitwise_split(int $split): array { if ($split < 1) { throw new \RuntimeException('Offset must be greater than 1'); @@ -1222,11 +1149,8 @@ abstract class Engine implements \JsonSerializable /** * Logical And - * - * @param Engine $x - * @return Engine */ - protected function bitwiseAndHelper(Engine $x) + protected function bitwiseAndHelper(Engine $x): Engine { $left = $this->toBytes(true); $right = $x->toBytes(true); @@ -1241,11 +1165,8 @@ abstract class Engine implements \JsonSerializable /** * Logical Or - * - * @param Engine $x - * @return Engine */ - protected function bitwiseOrHelper(Engine $x) + protected function bitwiseOrHelper(Engine $x): Engine { $left = $this->toBytes(true); $right = $x->toBytes(true); @@ -1260,11 +1181,8 @@ abstract class Engine implements \JsonSerializable /** * Logical Exclusive Or - * - * @param Engine $x - * @return Engine */ - protected function bitwiseXorHelper(Engine $x) + protected function bitwiseXorHelper(Engine $x): Engine { $left = $this->toBytes(true); $right = $x->toBytes(true); diff --git a/phpseclib/Math/BigInteger/Engines/GMP.php b/phpseclib/Math/BigInteger/Engines/GMP.php index f6163629..842e3227 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP.php +++ b/phpseclib/Math/BigInteger/Engines/GMP.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines; use phpseclib3\Exception\BadConfigurationException; @@ -40,10 +42,9 @@ class GMP extends Engine /** * Test for engine validity * - * @return bool * @see parent::__construct() */ - public static function isValidEngine() + public static function isValidEngine(): bool { return extension_loaded('gmp'); } @@ -52,10 +53,9 @@ class GMP extends Engine * Default constructor * * @param mixed $x integer Base-10 number or base-$base number if $base set. - * @param int $base * @see parent::__construct() */ - public function __construct($x = 0, $base = 10) + public function __construct($x = 0, int $base = 10) { if (!isset(static::$isValidEngine[static::class])) { static::$isValidEngine[static::class] = self::isValidEngine(); @@ -77,10 +77,9 @@ class GMP extends Engine /** * Initialize a GMP BigInteger Engine instance * - * @param int $base * @see parent::__construct() */ - protected function initialize($base) + protected function initialize(int $base): void { switch (abs($base)) { case 256: @@ -94,16 +93,14 @@ class GMP extends Engine $this->value = gmp_init($temp); break; case 10: - $this->value = gmp_init(isset($this->value) ? $this->value : '0'); + $this->value = gmp_init($this->value ?? '0'); } } /** * Converts a BigInteger to a base-10 number. - * - * @return string */ - public function toString() + public function toString(): string { return (string)$this->value; } @@ -113,11 +110,8 @@ class GMP extends Engine * * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're * saved as two's compliment. - * - * @param bool $twos_compliment - * @return string */ - public function toBits($twos_compliment = false) + public function toBits(bool $twos_compliment = false): string { $hex = $this->toHex($twos_compliment); @@ -136,11 +130,8 @@ class GMP extends Engine /** * Converts a BigInteger to a byte string (eg. base-256). - * - * @param bool $twos_compliment - * @return string */ - public function toBytes($twos_compliment = false) + public function toBytes(bool $twos_compliment = false): string { if ($twos_compliment) { return $this->toBytesHelper(); @@ -159,11 +150,8 @@ class GMP extends Engine /** * Adds two BigIntegers. - * - * @param GMP $y - * @return GMP */ - public function add(GMP $y) + public function add(GMP $y): GMP { $temp = new self(); $temp->value = $this->value + $y->value; @@ -173,11 +161,8 @@ class GMP extends Engine /** * Subtracts two BigIntegers. - * - * @param GMP $y - * @return GMP */ - public function subtract(GMP $y) + public function subtract(GMP $y): GMP { $temp = new self(); $temp->value = $this->value - $y->value; @@ -187,11 +172,8 @@ class GMP extends Engine /** * Multiplies two BigIntegers. - * - * @param GMP $x - * @return GMP */ - public function multiply(GMP $x) + public function multiply(GMP $x): GMP { $temp = new self(); $temp->value = $this->value * $x->value; @@ -207,15 +189,14 @@ class GMP extends Engine * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder * and the divisor (basically, the "common residue" is the first positive modulo). * - * @param GMP $y * @return array{GMP, GMP} */ - public function divide(GMP $y) + public function divide(GMP $y): array { $quotient = new self(); $remainder = new self(); - list($quotient->value, $remainder->value) = gmp_div_qr($this->value, $y->value); + [$quotient->value, $remainder->value] = gmp_div_qr($this->value, $y->value); if (gmp_sign($remainder->value) < 0) { $remainder->value = $remainder->value + gmp_abs($y->value); @@ -238,11 +219,10 @@ class GMP extends Engine * * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} * - * @param GMP $y * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. * @see self::equals() */ - public function compare(GMP $y) + public function compare(GMP $y): int { $r = gmp_cmp($this->value, $y->value); if ($r < -1) { @@ -258,11 +238,8 @@ class GMP extends Engine * Tests the equality of two numbers. * * If you need to see if one number is greater than or less than another number, use BigInteger::compare() - * - * @param GMP $x - * @return bool */ - public function equals(GMP $x) + public function equals(GMP $x): bool { return $this->value == $x->value; } @@ -272,7 +249,6 @@ class GMP extends Engine * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. * - * @param GMP $n * @return false|GMP */ public function modInverse(GMP $n) @@ -291,10 +267,9 @@ class GMP extends Engine * combination is returned is dependent upon which mode is in use. See * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information. * - * @param GMP $n * @return GMP[] */ - public function extendedGCD(GMP $n) + public function extendedGCD(GMP $n): array { extract(gmp_gcdext($this->value, $n->value)); @@ -309,11 +284,8 @@ class GMP extends Engine * Calculates the greatest common divisor * * Say you have 693 and 609. The GCD is 21. - * - * @param GMP $n - * @return GMP */ - public function gcd(GMP $n) + public function gcd(GMP $n): GMP { $r = gmp_gcd($this->value, $n->value); return $this->normalize(new self($r)); @@ -321,10 +293,8 @@ class GMP extends Engine /** * Absolute value. - * - * @return GMP */ - public function abs() + public function abs(): GMP { $temp = new self(); $temp->value = gmp_abs($this->value); @@ -334,11 +304,8 @@ class GMP extends Engine /** * Logical And - * - * @param GMP $x - * @return GMP */ - public function bitwise_and(GMP $x) + public function bitwise_and(GMP $x): GMP { $temp = new self(); $temp->value = $this->value & $x->value; @@ -348,11 +315,8 @@ class GMP extends Engine /** * Logical Or - * - * @param GMP $x - * @return GMP */ - public function bitwise_or(GMP $x) + public function bitwise_or(GMP $x): GMP { $temp = new self(); $temp->value = $this->value | $x->value; @@ -362,11 +326,8 @@ class GMP extends Engine /** * Logical Exclusive Or - * - * @param GMP $x - * @return GMP */ - public function bitwise_xor(GMP $x) + public function bitwise_xor(GMP $x): GMP { $temp = new self(); $temp->value = $this->value ^ $x->value; @@ -378,11 +339,8 @@ class GMP extends Engine * Logical Right Shift * * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift. - * - * @param int $shift - * @return GMP */ - public function bitwise_rightShift($shift) + public function bitwise_rightShift(int $shift): GMP { // 0xFFFFFFFF >> 2 == -1 (on 32-bit systems) // gmp_init('0xFFFFFFFF') >> 2 == gmp_init('0x3FFFFFFF') @@ -397,11 +355,8 @@ class GMP extends Engine * Logical Left Shift * * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift. - * - * @param int $shift - * @return GMP */ - public function bitwise_leftShift($shift) + public function bitwise_leftShift(int $shift): GMP { $temp = new self(); $temp->value = $this->value << $shift; @@ -411,12 +366,8 @@ class GMP extends Engine /** * Performs modular exponentiation. - * - * @param GMP $e - * @param GMP $n - * @return GMP */ - public function modPow(GMP $e, GMP $n) + public function modPow(GMP $e, GMP $n): GMP { return $this->powModOuter($e, $n); } @@ -425,24 +376,16 @@ class GMP extends Engine * Performs modular exponentiation. * * Alias for modPow(). - * - * @param GMP $e - * @param GMP $n - * @return GMP */ - public function powMod(GMP $e, GMP $n) + public function powMod(GMP $e, GMP $n): GMP { return $this->powModOuter($e, $n); } /** * Performs modular exponentiation. - * - * @param GMP $e - * @param GMP $n - * @return GMP */ - protected function powModInner(GMP $e, GMP $n) + protected function powModInner(GMP $e, GMP $n): GMP { $class = static::$modexpEngine[static::class]; return $class::powModHelper($this, $e, $n); @@ -452,11 +395,8 @@ class GMP extends Engine * Normalize * * Removes leading zeros and truncates (if necessary) to maintain the appropriate precision - * - * @param GMP $result - * @return GMP */ - protected function normalize(GMP $result) + protected function normalize(GMP $result): GMP { $result->precision = $this->precision; $result->bitmask = $this->bitmask; @@ -478,9 +418,6 @@ class GMP extends Engine /** * Performs some post-processing for randomRangePrime * - * @param Engine $x - * @param Engine $min - * @param Engine $max * @return GMP */ protected static function randomRangePrimeInner(Engine $x, Engine $min, Engine $max) @@ -503,8 +440,6 @@ class GMP extends Engine * * If there's not a prime within the given range, false will be returned. * - * @param GMP $min - * @param GMP $max * @return false|GMP */ public static function randomRangePrime(GMP $min, GMP $max) @@ -520,12 +455,8 @@ class GMP extends Engine * * BigInteger::randomRange($min, $max) * BigInteger::randomRange($max, $min) - * - * @param GMP $min - * @param GMP $max - * @return GMP */ - public static function randomRange(GMP $min, GMP $max) + public static function randomRange(GMP $min, GMP $max): GMP { return self::randomRangeHelper($min, $max); } @@ -537,18 +468,15 @@ class GMP extends Engine * * @see self::randomPrime() */ - protected function make_odd() + protected function make_odd(): void { gmp_setbit($this->value, 0); } /** * Tests Primality - * - * @param int $t - * @return bool */ - protected function testPrimality($t) + protected function testPrimality(int $t): bool { return gmp_prob_prime($this->value, $t) != 0; } @@ -557,11 +485,8 @@ class GMP extends Engine * Calculates the nth root of a biginteger. * * Returns the nth root of a positive biginteger, where n defaults to 2 - * - * @param int $n - * @return GMP */ - protected function rootInner($n) + protected function rootInner(int $n): GMP { $root = new self(); $root->value = gmp_root($this->value, $n); @@ -570,11 +495,8 @@ class GMP extends Engine /** * Performs exponentiation. - * - * @param GMP $n - * @return GMP */ - public function pow(GMP $n) + public function pow(GMP $n): GMP { $temp = new self(); $temp->value = $this->value ** $n->value; @@ -584,34 +506,24 @@ class GMP extends Engine /** * Return the minimum BigInteger between an arbitrary number of BigIntegers. - * - * @param GMP ...$nums - * @return GMP */ - public static function min(GMP ...$nums) + public static function min(GMP ...$nums): GMP { return self::minHelper($nums); } /** * Return the maximum BigInteger between an arbitrary number of BigIntegers. - * - * @param GMP ...$nums - * @return GMP */ - public static function max(GMP ...$nums) + public static function max(GMP ...$nums): GMP { return self::maxHelper($nums); } /** * Tests BigInteger to see if it is between two integers, inclusive - * - * @param GMP $min - * @param GMP $max - * @return bool */ - public function between(GMP $min, GMP $max) + public function between(GMP $min, GMP $max): bool { return $this->compare($min) >= 0 && $this->compare($max) <= 0; } @@ -621,10 +533,8 @@ class GMP extends Engine * * Sometimes it may be desirable to do repeated modulos with the same number outside of * modular exponentiation - * - * @return callable */ - public function createRecurringModuloFunction() + public function createRecurringModuloFunction(): \Closure { $temp = $this->value; return function (GMP $x) use ($temp) { @@ -636,11 +546,8 @@ class GMP extends Engine * Scan for 1 and right shift by that amount * * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); - * - * @param GMP $r - * @return int */ - public static function scan1divide(GMP $r) + public static function scan1divide(GMP $r): int { $s = gmp_scan1($r->value, 0); $r->value >>= $s; @@ -649,30 +556,24 @@ class GMP extends Engine /** * Is Odd? - * - * @return bool */ - public function isOdd() + public function isOdd(): bool { return gmp_testbit($this->value, 0); } /** * Tests if a bit is set - * - * @return bool */ - public function testBit($x) + public function testBit($x): bool { return gmp_testbit($this->value, $x); } /** * Is Negative? - * - * @return bool */ - public function isNegative() + public function isNegative(): bool { return gmp_sign($this->value) == -1; } @@ -681,10 +582,8 @@ class GMP extends Engine * Negate * * Given $k, returns -$k - * - * @return GMP */ - public function negate() + public function negate(): GMP { $temp = clone $this; $temp->value = -$this->value; diff --git a/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php b/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php index bc219fbe..f8794137 100644 --- a/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php +++ b/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\GMP; use phpseclib3\Math\BigInteger\Engines\GMP; @@ -24,13 +26,8 @@ abstract class DefaultEngine extends GMP { /** * Performs modular exponentiation. - * - * @param GMP $x - * @param GMP $e - * @param GMP $n - * @return GMP */ - protected static function powModHelper(GMP $x, GMP $e, GMP $n) + protected static function powModHelper(GMP $x, GMP $e, GMP $n): GMP { $temp = new GMP(); $temp->value = gmp_powm($x->value, $e->value, $n->value); diff --git a/phpseclib/Math/BigInteger/Engines/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/OpenSSL.php index e33a9f19..7042037e 100644 --- a/phpseclib/Math/BigInteger/Engines/OpenSSL.php +++ b/phpseclib/Math/BigInteger/Engines/OpenSSL.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines; use phpseclib3\Crypt\RSA\Formats\Keys\PKCS8; @@ -25,23 +27,16 @@ abstract class OpenSSL { /** * Test for engine validity - * - * @return bool */ - public static function isValidEngine() + public static function isValidEngine(): bool { return extension_loaded('openssl') && static::class != __CLASS__; } /** * Performs modular exponentiation. - * - * @param Engine $x - * @param Engine $e - * @param Engine $n - * @return Engine */ - public static function powModHelper(Engine $x, Engine $e, Engine $n) + public static function powModHelper(Engine $x, Engine $e, Engine $n): Engine { if ($n->getLengthInBytes() < 31 || $n->getLengthInBytes() > 16384) { throw new \OutOfRangeException('Only modulo between 31 and 16384 bits are accepted'); diff --git a/phpseclib/Math/BigInteger/Engines/PHP.php b/phpseclib/Math/BigInteger/Engines/PHP.php index bd8df301..e7b953fc 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP.php +++ b/phpseclib/Math/BigInteger/Engines/PHP.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines; use ParagonIE\ConstantTime\Hex; @@ -44,7 +46,6 @@ abstract class PHP extends Engine * Karatsuba Cutoff * * At what point do we switch between Karatsuba multiplication and schoolbook long multiplication? - * */ const KARATSUBA_CUTOFF = 25; @@ -67,11 +68,10 @@ abstract class PHP extends Engine * Default constructor * * @param mixed $x integer Base-10 number or base-$base number if $base set. - * @param int $base * @return PHP * @see parent::__construct() */ - public function __construct($x = 0, $base = 10) + public function __construct($x = 0, int $base = 10) { if (!isset(static::$isValidEngine[static::class])) { static::$isValidEngine[static::class] = static::isValidEngine(); @@ -87,10 +87,9 @@ abstract class PHP extends Engine /** * Initialize a PHP BigInteger Engine instance * - * @param int $base * @see parent::__construct() */ - protected function initialize($base) + protected function initialize(int $base): void { switch (abs($base)) { case 16: @@ -114,12 +113,12 @@ abstract class PHP extends Engine $x = str_pad( $x, strlen($x) + ((static::MAX10LEN - 1) * strlen($x)) % static::MAX10LEN, - 0, + '0', STR_PAD_LEFT ); while (strlen($x)) { $temp = $temp->multiply($multiplier); - $temp = $temp->add(new static($this->int2bytes(substr($x, 0, static::MAX10LEN)), 256)); + $temp = $temp->add(new static($this->int2bytes((int) substr($x, 0, static::MAX10LEN)), 256)); $x = substr($x, static::MAX10LEN); } @@ -129,11 +128,8 @@ abstract class PHP extends Engine /** * Pads strings so that unpack may be used on them - * - * @param string $str - * @return string */ - protected function pad($str) + protected function pad(string $str): string { $length = strlen($str); @@ -144,10 +140,8 @@ abstract class PHP extends Engine /** * Converts a BigInteger to a base-10 number. - * - * @return string */ - public function toString() + public function toString(): string { if (!count($this->value)) { return '0'; @@ -161,9 +155,9 @@ abstract class PHP extends Engine $divisor->value = [static::MAX10]; $result = ''; while (count($temp->value)) { - list($temp, $mod) = $temp->divide($divisor); + [$temp, $mod] = $temp->divide($divisor); $result = str_pad( - isset($mod->value[0]) ? $mod->value[0] : '', + (string) $mod->value[0] ?? '', static::MAX10LEN, '0', STR_PAD_LEFT @@ -183,11 +177,8 @@ abstract class PHP extends Engine /** * Converts a BigInteger to a byte string (eg. base-256). - * - * @param bool $twos_compliment - * @return string */ - public function toBytes($twos_compliment = false) + public function toBytes(bool $twos_compliment = false): string { if ($twos_compliment) { return $this->toBytesHelper(); @@ -212,14 +203,8 @@ abstract class PHP extends Engine /** * Performs addition. - * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return array */ - protected static function addHelper(array $x_value, $x_negative, array $y_value, $y_negative) + protected static function addHelper(array $x_value, bool $x_negative, array $y_value, bool $y_negative): array { $x_size = count($x_value); $y_size = count($y_value); @@ -297,14 +282,8 @@ abstract class PHP extends Engine /** * Performs subtraction. - * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return array */ - public static function subtractHelper(array $x_value, $x_negative, array $y_value, $y_negative) + public static function subtractHelper(array $x_value, bool $x_negative, array $y_value, bool $y_negative): array { $x_size = count($x_value); $y_size = count($y_value); @@ -387,14 +366,8 @@ abstract class PHP extends Engine /** * Performs multiplication. - * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return array */ - protected static function multiplyHelper(array $x_value, $x_negative, array $y_value, $y_negative) + protected static function multiplyHelper(array $x_value, bool $x_negative, array $y_value, bool $y_negative): array { //if ( $x_value == $y_value ) { // return [ @@ -426,12 +399,8 @@ abstract class PHP extends Engine * * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=120 MPM 5.2.3}. - * - * @param array $x_value - * @param array $y_value - * @return array */ - private static function karatsuba(array $x_value, array $y_value) + private static function karatsuba(array $x_value, array $y_value): array { $m = min(count($x_value) >> 1, count($y_value) >> 1); @@ -466,12 +435,8 @@ abstract class PHP extends Engine * Performs long multiplication on two BigIntegers * * Modeled after 'multiply' in MutableBigInteger.java. - * - * @param array $x_value - * @param array $y_value - * @return array */ - protected static function regularMultiply(array $x_value, array $y_value) + protected static function regularMultiply(array $x_value, array $y_value): array { $x_length = count($x_value); $y_length = count($y_value); @@ -526,10 +491,10 @@ abstract class PHP extends Engine * @internal This function is based off of * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}. */ - protected function divideHelper(PHP $y) + protected function divideHelper(PHP $y): array { if (count($y->value) == 1) { - list($q, $r) = $this->divide_digit($this->value, $y->value[0]); + [$q, $r] = $this->divide_digit($this->value, $y->value[0]); $quotient = new static(); $remainder = new static(); $quotient->value = $q; @@ -606,9 +571,9 @@ abstract class PHP extends Engine for ($i = $x_max; $i >= $y_max + 1; --$i) { $x_value = &$x->value; $x_window = [ - isset($x_value[$i]) ? $x_value[$i] : 0, - isset($x_value[$i - 1]) ? $x_value[$i - 1] : 0, - isset($x_value[$i - 2]) ? $x_value[$i - 2] : 0 + $x_value[$i] ?? 0, + $x_value[$i - 1] ?? 0, + $x_value[$i - 2] ?? 0 ]; $y_window = [ $y_value[$y_max], @@ -677,12 +642,8 @@ abstract class PHP extends Engine * Divides a BigInteger by a regular integer * * abc / x = a00 / x + b0 / x + c / x - * - * @param array $dividend - * @param int $divisor - * @return array */ - private static function divide_digit(array $dividend, $divisor) + private static function divide_digit(array $dividend, int $divisor): array { $carry = 0; $result = []; @@ -704,11 +665,9 @@ abstract class PHP extends Engine * have the precision of int64 this is a problem so, when int64 is being used, * we'll guarantee that the dividend is divisible by first subtracting the remainder. * - * @param int $x - * @param int $y * @return int */ - private static function safe_divide($x, $y) + private static function safe_divide(int $x, int $y) { if (static::BASE === 26) { return (int)($x / $y); @@ -722,10 +681,9 @@ abstract class PHP extends Engine /** * Convert an array / boolean to a PHP BigInteger object * - * @param array $arr * @return static */ - protected function convertToObj(array $arr) + protected function convertToObj(array $arr): PHP { $result = new static(); $result->value = $arr[self::VALUE]; @@ -739,10 +697,9 @@ abstract class PHP extends Engine * * Removes leading zeros and truncates (if necessary) to maintain the appropriate precision * - * @param PHP $result * @return static */ - protected function normalize(PHP $result) + protected function normalize(PHP $result): PHP { $result->precision = $this->precision; $result->bitmask = $this->bitmask; @@ -773,14 +730,9 @@ abstract class PHP extends Engine /** * Compares two numbers. * - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @return int * @see static::compare() */ - protected static function compareHelper(array $x_value, $x_negative, array $y_value, $y_negative) + protected static function compareHelper(array $x_value, bool $x_negative, array $y_value, bool $y_negative): int { if ($x_negative != $y_negative) { return (!$x_negative && $y_negative) ? 1 : -1; @@ -807,10 +759,8 @@ abstract class PHP extends Engine /** * Absolute value. - * - * @return PHP */ - public function abs() + public function abs(): PHP { $temp = new static(); $temp->value = $this->value; @@ -826,7 +776,7 @@ abstract class PHP extends Engine * @param list $value * @return list */ - protected static function trim(array $value) + protected static function trim(array $value): array { for ($i = count($value) - 1; $i >= 0; --$i) { if ($value[$i]) { @@ -842,11 +792,8 @@ abstract class PHP extends Engine * Logical Right Shift * * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift. - * - * @param int $shift - * @return PHP */ - public function bitwise_rightShift($shift) + public function bitwise_rightShift(int $shift): PHP { $temp = new static(); @@ -862,11 +809,8 @@ abstract class PHP extends Engine * Logical Left Shift * * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift. - * - * @param int $shift - * @return PHP */ - public function bitwise_leftShift($shift) + public function bitwise_leftShift(int $shift): PHP { $temp = new static(); // could just replace _rshift with this, but then all _lshift() calls would need to be rewritten @@ -879,23 +823,16 @@ abstract class PHP extends Engine /** * Converts 32-bit integers to bytes. - * - * @param int $x - * @return string */ - private static function int2bytes($x) + private static function int2bytes(int $x): string { return ltrim(pack('N', $x), chr(0)); } /** * Array Repeat - * - * @param int $input - * @param int $multiplier - * @return array */ - protected static function array_repeat($input, $multiplier) + protected static function array_repeat(int $input, int $multiplier): array { return $multiplier ? array_fill(0, $multiplier, $input) : []; } @@ -904,10 +841,8 @@ abstract class PHP extends Engine * Logical Left Shift * * Shifts BigInteger's by $shift bits. - * - * @param int $shift */ - protected function lshift($shift) + protected function lshift(int $shift): void { if ($shift == 0) { return; @@ -938,10 +873,8 @@ abstract class PHP extends Engine * Logical Right Shift * * Shifts BigInteger's by $shift bits. - * - * @param int $shift */ - protected function rshift($shift) + protected function rshift(int $shift): void { if ($shift == 0) { return; @@ -969,12 +902,8 @@ abstract class PHP extends Engine /** * Performs modular exponentiation. - * - * @param PHP $e - * @param PHP $n - * @return PHP */ - protected function powModInner(PHP $e, PHP $n) + protected function powModInner(PHP $e, PHP $n): PHP { try { $class = static::$modexpEngine[static::class]; @@ -990,7 +919,7 @@ abstract class PHP extends Engine * @param list $x * @return list */ - protected static function square(array $x) + protected static function square(array $x): array { return count($x) < 2 * self::KARATSUBA_CUTOFF ? self::trim(self::baseSquare($x)) : @@ -1003,11 +932,8 @@ abstract class PHP extends Engine * Squaring can be done faster than multiplying a number by itself can be. See * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=7 HAC 14.2.4} / * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=141 MPM 5.3} for more information. - * - * @param array $value - * @return array */ - protected static function baseSquare(array $value) + protected static function baseSquare(array $value): array { if (empty($value)) { return []; @@ -1041,11 +967,8 @@ abstract class PHP extends Engine * * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=151 MPM 5.3.4}. - * - * @param array $value - * @return array */ - protected static function karatsubaSquare(array $value) + protected static function karatsubaSquare(array $value): array { $m = count($value) >> 1; @@ -1080,7 +1003,7 @@ abstract class PHP extends Engine * * @see self::randomPrime() */ - protected function make_odd() + protected function make_odd(): void { $this->value[0] |= 1; } @@ -1090,7 +1013,7 @@ abstract class PHP extends Engine * * @see self::isPrime() */ - protected function testSmallPrimes() + protected function testSmallPrimes(): bool { if ($this->value == [1]) { return false; @@ -1104,7 +1027,7 @@ abstract class PHP extends Engine $value = $this->value; foreach (static::PRIMES as $prime) { - list(, $r) = self::divide_digit($value, $prime); + [, $r] = self::divide_digit($value, $prime); if (!$r) { return count($value) == 1 && $value[0] == $prime; } @@ -1118,7 +1041,6 @@ abstract class PHP extends Engine * * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); * - * @param PHP $r * @return int * @see self::isPrime() */ @@ -1140,11 +1062,8 @@ abstract class PHP extends Engine /** * Performs exponentiation. - * - * @param PHP $n - * @return PHP */ - protected function powHelper(PHP $n) + protected function powHelper(PHP $n): PHP { if ($n->compare(static::$zero[static::class]) == 0) { return new static(1); @@ -1161,20 +1080,16 @@ abstract class PHP extends Engine /** * Is Odd? - * - * @return bool */ - public function isOdd() + public function isOdd(): bool { return (bool)($this->value[0] & 1); } /** * Tests if a bit is set - * - * @return bool */ - public function testBit($x) + public function testBit($x): bool { $digit = (int) floor($x / static::BASE); $bit = $x % static::BASE; @@ -1188,10 +1103,8 @@ abstract class PHP extends Engine /** * Is Negative? - * - * @return bool */ - public function isNegative() + public function isNegative(): bool { return $this->is_negative; } @@ -1203,7 +1116,7 @@ abstract class PHP extends Engine * * @return static */ - public function negate() + public function negate(): PHP { $temp = clone $this; $temp->is_negative = !$temp->is_negative; @@ -1216,10 +1129,9 @@ abstract class PHP extends Engine * * Splits BigInteger's into chunks of $split bits * - * @param int $split * @return list */ - public function bitwise_split($split) + public function bitwise_split(int $split): array { if ($split < 1) { throw new \RuntimeException('Offset must be greater than 1'); @@ -1248,7 +1160,7 @@ abstract class PHP extends Engine $overflow = $split % static::BASE; if ($overflow) { $mask = (1 << $overflow) - 1; - $temp = isset($val[$i]) ? $val[$i] : 0; + $temp = $val[$i] ?? 0; $digit[] = $temp & $mask; } } else { @@ -1260,7 +1172,7 @@ abstract class PHP extends Engine $tempoverflow = $tempsplit % static::BASE; if ($tempoverflow) { $tempmask = (1 << $tempoverflow) - 1; - $temp = isset($val[$i]) ? $val[$i] : 0; + $temp = $val[$i] ?? 0; $digit[] = $temp & $tempmask; } $newbits = 0; @@ -1283,10 +1195,9 @@ abstract class PHP extends Engine /** * Bitwise Split where $split < static::BASE * - * @param int $split * @return list */ - private function bitwise_small_split($split) + private function bitwise_small_split(int $split): array { $vals = []; $val = $this->value; diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Base.php b/phpseclib/Math/BigInteger/Engines/PHP/Base.php index 40f64bd1..2c5cf3b8 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Base.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Base.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP; use phpseclib3\Math\BigInteger\Engines\PHP; @@ -26,21 +28,17 @@ abstract class Base extends PHP * Cache constants * * $cache[self::VARIABLE] tells us whether or not the cached data is still valid. - * */ const VARIABLE = 0; /** * $cache[self::DATA] contains the cached data. - * */ const DATA = 1; /** * Test for engine validity - * - * @return bool */ - public static function isValidEngine() + public static function isValidEngine(): bool { return static::class != __CLASS__; } @@ -67,14 +65,8 @@ abstract class Base extends PHP * uses a trick involving the Chinese Remainder Theorem to factor the even modulo into two numbers - one odd and * the other, a power of two - and recombine them, later. This is the method that this modPow function uses. * {@link http://islab.oregonstate.edu/papers/j34monex.pdf Montgomery Reduction with Even Modulus} elaborates. - * - * @param PHP $x - * @param PHP $e - * @param PHP $n - * @param string $class - * @return PHP */ - protected static function powModHelper(PHP $x, PHP $e, PHP $n, $class) + protected static function powModHelper(PHP $x, PHP $e, PHP $n, string $class): PHP { if (empty($e->value)) { $temp = new $class(); @@ -83,14 +75,14 @@ abstract class Base extends PHP } if ($e->value == [1]) { - list(, $temp) = $x->divide($n); + [, $temp] = $x->divide($n); return $x->normalize($temp); } if ($e->value == [2]) { $temp = new $class(); $temp->value = $class::square($x->value); - list(, $temp) = $temp->divide($n); + [, $temp] = $temp->divide($n); return $x->normalize($temp); } @@ -100,13 +92,9 @@ abstract class Base extends PHP /** * Modular reduction preparation * - * @param array $x - * @param array $n - * @param string $class - * @see self::slidingWindow() - * @return array + *@see self::slidingWindow() */ - protected static function prepareReduce(array $x, array $n, $class) + protected static function prepareReduce(array $x, array $n, string $class): array { return static::reduce($x, $n, $class); } @@ -114,14 +102,9 @@ abstract class Base extends PHP /** * Modular multiply * - * @param array $x - * @param array $y - * @param array $n - * @param string $class - * @see self::slidingWindow() - * @return array + *@see self::slidingWindow() */ - protected static function multiplyReduce(array $x, array $y, array $n, $class) + protected static function multiplyReduce(array $x, array $y, array $n, string $class): array { $temp = $class::multiplyHelper($x, false, $y, false); return static::reduce($temp[self::VALUE], $n, $class); @@ -130,13 +113,9 @@ abstract class Base extends PHP /** * Modular square * - * @param array $x - * @param array $n - * @param string $class - * @see self::slidingWindow() - * @return array + *@see self::slidingWindow() */ - protected static function squareReduce(array $x, array $n, $class) + protected static function squareReduce(array $x, array $n, string $class): array { return static::reduce($class::square($x), $n, $class); } diff --git a/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php b/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php index 6d33532e..fdce27f8 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP; use phpseclib3\Math\BigInteger\Engines\PHP\Reductions\EvalBarrett; diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php b/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php index 09f825f9..40ddb0ab 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP; use phpseclib3\Math\BigInteger\Engines\Engine; @@ -26,10 +28,8 @@ abstract class Montgomery extends Base { /** * Test for engine validity - * - * @return bool */ - public static function isValidEngine() + public static function isValidEngine(): bool { return static::class != __CLASS__; } @@ -38,13 +38,10 @@ abstract class Montgomery extends Base * Performs modular exponentiation. * * @template T of Engine - * @param Engine $x - * @param Engine $e - * @param Engine $n * @param class-string $class * @return T */ - protected static function slidingWindow(Engine $x, Engine $e, Engine $n, $class) + protected static function slidingWindow(Engine $x, Engine $e, Engine $n, string $class) { // is the modulo odd? if ($n->value[0] & 1) { @@ -82,7 +79,7 @@ abstract class Montgomery extends Base $temp = $temp->multiply($y2); $result = $result->add($temp); - list(, $result) = $result->divide($n); + [, $result] = $result->divide($n); return $result; } diff --git a/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php b/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php index eddd25e2..7b721c75 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP; use phpseclib3\Math\BigInteger\Engines\OpenSSL as Progenitor; diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php index 3518d76f..dd44f89e 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; use phpseclib3\Math\BigInteger\Engines\PHP; @@ -41,12 +43,9 @@ abstract class Barrett extends Base * (x >> 1) + (x >> 1) != x / 2 + x / 2. If x is even, they're the same, but if x is odd, they're not. See the in-line * comments for details. * - * @param array $n - * @param array $m * @param class-string $class - * @return array */ - protected static function reduce(array $n, array $m, $class) + protected static function reduce(array $n, array $m, string $class): array { static $cache = [ self::VARIABLE => [], @@ -61,7 +60,7 @@ abstract class Barrett extends Base $rhs = new $class(); $lhs->value = $n; $rhs->value = $m; - list(, $temp) = $lhs->divide($rhs); + [, $temp] = $lhs->divide($rhs); return $temp->value; } @@ -82,7 +81,7 @@ abstract class Barrett extends Base $rhs = new $class(); $rhs->value = $m; - list($u, $m1) = $lhs->divide($rhs); + [$u, $m1] = $lhs->divide($rhs); $u = $u->value; $m1 = $m1->value; @@ -135,13 +134,8 @@ abstract class Barrett extends Base * * For numbers with more than four digits BigInteger::_barrett() is faster. The difference between that and this * is that this function does not fold the denominator into a smaller form. - * - * @param array $x - * @param array $n - * @param string $class - * @return array */ - private static function regularBarrett(array $x, array $n, $class) + private static function regularBarrett(array $x, array $n, string $class): array { static $cache = [ self::VARIABLE => [], @@ -155,7 +149,7 @@ abstract class Barrett extends Base $rhs = new $class(); $lhs->value = $x; $rhs->value = $n; - list(, $temp) = $lhs->divide($rhs); + [, $temp] = $lhs->divide($rhs); return $temp->value; } @@ -168,7 +162,7 @@ abstract class Barrett extends Base $lhs_value[] = 1; $rhs = new $class(); $rhs->value = $n; - list($temp, ) = $lhs->divide($rhs); // m.length + [$temp, ] = $lhs->divide($rhs); // m.length $cache[self::DATA][] = $temp->value; } @@ -207,15 +201,8 @@ abstract class Barrett extends Base * If you're going to be doing array_slice($product->value, 0, $stop), some cycles can be saved. * * @see self::regularBarrett() - * @param array $x_value - * @param bool $x_negative - * @param array $y_value - * @param bool $y_negative - * @param int $stop - * @param string $class - * @return array */ - private static function multiplyLower(array $x_value, $x_negative, array $y_value, $y_negative, $stop, $class) + private static function multiplyLower(array $x_value, bool $x_negative, array $y_value, bool $y_negative, int $stop, string $class): array { $x_length = count($x_value); $y_length = count($y_value); diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php index 54f3b863..537a9d24 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; use phpseclib3\Math\BigInteger\Engines\PHP\Base; @@ -24,19 +26,14 @@ abstract class Classic extends Base { /** * Regular Division - * - * @param array $x - * @param array $n - * @param string $class - * @return array */ - protected static function reduce(array $x, array $n, $class) + protected static function reduce(array $x, array $n, string $class): array { $lhs = new $class(); $lhs->value = $x; $rhs = new $class(); $rhs->value = $n; - list(, $temp) = $lhs->divide($rhs); + [, $temp] = $lhs->divide($rhs); return $temp->value; } } diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php index 39d7305b..ce709785 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; use phpseclib3\Math\BigInteger\Engines\PHP; @@ -35,13 +37,8 @@ abstract class EvalBarrett extends Base * * This calls a dynamically generated loop unrolled function that's specific to a given modulo. * Array lookups are avoided as are if statements testing for how many bits the host OS supports, etc. - * - * @param array $n - * @param array $m - * @param string $class - * @return array */ - protected static function reduce(array $n, array $m, $class) + protected static function reduce(array $n, array $m, string $class): array { $inline = self::$custom_reduction; return $inline($n); @@ -49,12 +46,8 @@ abstract class EvalBarrett extends Base /** * Generate Custom Reduction - * - * @param PHP $m - * @param string $class - * @return callable */ - protected static function generateCustomReduction(PHP $m, $class) + protected static function generateCustomReduction(PHP $m, string $class): callable { $m_length = count($m->value); @@ -81,7 +74,7 @@ abstract class EvalBarrett extends Base $lhs_value[] = 1; $rhs = new $class(); - list($u, $m1) = $lhs->divide($m); + [$u, $m1] = $lhs->divide($m); if ($class::BASE != 26) { $u = $u->value; @@ -90,7 +83,7 @@ abstract class EvalBarrett extends Base $lhs_value[] = 1; $rhs = new $class(); - list($u) = $lhs->divide($m); + [$u] = $lhs->divide($m); $u = $u->value; } @@ -156,11 +149,8 @@ abstract class EvalBarrett extends Base * Inline Trim * * Removes leading zeros - * - * @param string $name - * @return string */ - private static function generateInlineTrim($name) + private static function generateInlineTrim(string $name): string { return ' for ($i = count($' . $name . ') - 1; $i >= 0; --$i) { @@ -173,14 +163,8 @@ abstract class EvalBarrett extends Base /** * Inline Multiply (unknown, known) - * - * @param string $input - * @param array $arr - * @param string $output - * @param string $class - * @return string */ - private static function generateInlineMultiply($input, array $arr, $output, $class) + private static function generateInlineMultiply(string $input, array $arr, string $output, string $class): string { if (!count($arr)) { return 'return [];'; @@ -248,14 +232,8 @@ abstract class EvalBarrett extends Base /** * Inline Addition - * - * @param string $x - * @param string $y - * @param string $result - * @param string $class - * @return string */ - private static function generateInlineAdd($x, $y, $result, $class) + private static function generateInlineAdd(string $x, string $y, string $result, string $class): string { $code = ' $length = max(count($' . $x . '), count($' . $y . ')); @@ -296,14 +274,8 @@ abstract class EvalBarrett extends Base * Inline Subtraction 2 * * For when $known is more digits than $unknown. This is the harder use case to optimize for. - * - * @param string $known - * @param string $unknown - * @param string $result - * @param string $class - * @return string */ - private static function generateInlineSubtract2($known, $unknown, $result, $class) + private static function generateInlineSubtract2(string $known, string $unknown, string $result, string $class): string { $code = ' $' . $result . ' = $' . $known . '; @@ -355,14 +327,8 @@ abstract class EvalBarrett extends Base * Inline Subtraction 1 * * For when $unknown is more digits than $known. This is the easier use case to optimize for. - * - * @param string $unknown - * @param array $known - * @param string $result - * @param string $class - * @return string */ - private static function generateInlineSubtract1($unknown, array $known, $result, $class) + private static function generateInlineSubtract1(string $unknown, array $known, string $result, string $class): string { $code = '$' . $result . ' = $' . $unknown . ';'; for ($i = 0, $j = 1; $j < count($known); $i += 2, $j += 2) { @@ -419,13 +385,8 @@ abstract class EvalBarrett extends Base * Inline Comparison * * If $unknown >= $known then loop - * - * @param array $known - * @param string $unknown - * @param string $subcode - * @return string */ - private static function generateInlineCompare(array $known, $unknown, $subcode) + private static function generateInlineCompare(array $known, string $unknown, string $subcode): string { $uniqid = uniqid(); $code = 'loop_' . $uniqid . ': @@ -461,9 +422,8 @@ abstract class EvalBarrett extends Base * precision but displayed in this way there will be precision loss, hence the need for this method. * * @param int|float $num - * @return string */ - private static function float2string($num) + private static function float2string($num): string { if (!is_float($num)) { return (string) $num; diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php index a34035e7..bb935557 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; use phpseclib3\Math\BigInteger\Engines\PHP\Montgomery as Progenitor; @@ -24,20 +26,15 @@ abstract class Montgomery extends Progenitor { /** * Prepare a number for use in Montgomery Modular Reductions - * - * @param array $x - * @param array $n - * @param string $class - * @return array */ - protected static function prepareReduce(array $x, array $n, $class) + protected static function prepareReduce(array $x, array $n, string $class): array { $lhs = new $class(); $lhs->value = array_merge(self::array_repeat(0, count($n)), $x); $rhs = new $class(); $rhs->value = $n; - list(, $temp) = $lhs->divide($rhs); + [, $temp] = $lhs->divide($rhs); return $temp->value; } @@ -46,13 +43,8 @@ abstract class Montgomery extends Progenitor * * Interleaves the montgomery reduction and long multiplication algorithms together as described in * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=13 HAC 14.36} - * - * @param array $x - * @param array $n - * @param string $class - * @return array */ - protected static function reduce(array $x, array $n, $class) + protected static function reduce(array $x, array $n, string $class): array { static $cache = [ self::VARIABLE => [], @@ -106,12 +98,8 @@ abstract class Montgomery extends Progenitor * 40 bits, which only 64-bit floating points will support. * * Thanks to Pedro Gimeno Fortea for input! - * - * @param array $x - * @param string $class - * @return int */ - protected static function modInverse67108864(array $x, $class) // 2**26 == 67,108,864 + protected static function modInverse67108864(array $x, string $class): int // 2**26 == 67,108,864 { $x = -$x[0]; $result = $x & 0x3; // x**-1 mod 2**2 diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php index 4fed3c3f..b8fe81c9 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; use phpseclib3\Math\BigInteger\Engines\PHP; @@ -28,15 +30,11 @@ abstract class MontgomeryMult extends Montgomery * Interleaves the montgomery reduction and long multiplication algorithms together as described in * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=13 HAC 14.36} * - * @see self::_prepMontgomery() - * @see self::_montgomery() - * @param array $x - * @param array $y - * @param array $m * @param class-string $class - * @return array + *@see self::_prepMontgomery() + * @see self::_montgomery() */ - public static function multiplyReduce(array $x, array $y, array $m, $class) + public static function multiplyReduce(array $x, array $y, array $m, string $class): array { // the following code, although not callable, can be run independently of the above code // although the above code performed better in my benchmarks the following could might diff --git a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php index 9da133a1..16caf01b 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php +++ b/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines\PHP\Reductions; use phpseclib3\Math\BigInteger\Engines\PHP\Base; @@ -24,26 +26,16 @@ abstract class PowerOfTwo extends Base { /** * Prepare a number for use in Montgomery Modular Reductions - * - * @param array $x - * @param array $n - * @param string $class - * @return array */ - protected static function prepareReduce(array $x, array $n, $class) + protected static function prepareReduce(array $x, array $n, string $class): array { return self::reduce($x, $n, $class); } /** * Power Of Two Reduction - * - * @param array $x - * @param array $n - * @param string $class - * @return array */ - protected static function reduce(array $x, array $n, $class) + protected static function reduce(array $x, array $n, string $class): array { $lhs = new $class(); $lhs->value = $x; diff --git a/phpseclib/Math/BigInteger/Engines/PHP32.php b/phpseclib/Math/BigInteger/Engines/PHP32.php index 964cd170..81fe4297 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP32.php +++ b/phpseclib/Math/BigInteger/Engines/PHP32.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines; /** @@ -44,13 +46,13 @@ class PHP32 extends PHP /** * Initialize a PHP32 BigInteger Engine instance * - * @param int $base * @see parent::initialize() */ - protected function initialize($base) + protected function initialize(int $base): void { if ($base != 256 && $base != -256) { - return parent::initialize($base); + parent::initialize($base); + return; } $val = $this->value; @@ -74,7 +76,7 @@ class PHP32 extends PHP } $i = 0; } - list(, $digit) = unpack('N', substr($val, $i, 4)); + [, $digit] = unpack('N', substr($val, $i, 4)); if ($digit < 0) { $digit += 0xFFFFFFFF + 1; } @@ -98,20 +100,16 @@ class PHP32 extends PHP * Test for engine validity * * @see parent::__construct() - * @return bool */ - public static function isValidEngine() + public static function isValidEngine(): bool { return PHP_INT_SIZE >= 4; } /** * Adds two BigIntegers. - * - * @param PHP32 $y - * @return PHP32 */ - public function add(PHP32 $y) + public function add(PHP32 $y): PHP32 { $temp = self::addHelper($this->value, $this->is_negative, $y->value, $y->is_negative); @@ -120,11 +118,8 @@ class PHP32 extends PHP /** * Subtracts two BigIntegers. - * - * @param PHP32 $y - * @return PHP32 */ - public function subtract(PHP32 $y) + public function subtract(PHP32 $y): PHP32 { $temp = self::subtractHelper($this->value, $this->is_negative, $y->value, $y->is_negative); @@ -133,11 +128,8 @@ class PHP32 extends PHP /** * Multiplies two BigIntegers. - * - * @param PHP32 $y - * @return PHP32 */ - public function multiply(PHP32 $y) + public function multiply(PHP32 $y): PHP32 { $temp = self::multiplyHelper($this->value, $this->is_negative, $y->value, $y->is_negative); @@ -152,10 +144,9 @@ class PHP32 extends PHP * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder * and the divisor (basically, the "common residue" is the first positive modulo). * - * @param PHP32 $y * @return array{PHP32, PHP32} */ - public function divide(PHP32 $y) + public function divide(PHP32 $y): array { return $this->divideHelper($y); } @@ -164,7 +155,6 @@ class PHP32 extends PHP * Calculates modular inverses. * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * @param PHP32 $n * @return false|PHP32 */ public function modInverse(PHP32 $n) @@ -176,10 +166,9 @@ class PHP32 extends PHP * Calculates modular inverses. * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * @param PHP32 $n * @return PHP32[] */ - public function extendedGCD(PHP32 $n) + public function extendedGCD(PHP32 $n): array { return $this->extendedGCDHelper($n); } @@ -188,44 +177,32 @@ class PHP32 extends PHP * Calculates the greatest common divisor * * Say you have 693 and 609. The GCD is 21. - * - * @param PHP32 $n - * @return PHP32 */ - public function gcd(PHP32 $n) + public function gcd(PHP32 $n): PHP32 { return $this->extendedGCD($n)['gcd']; } /** * Logical And - * - * @param PHP32 $x - * @return PHP32 */ - public function bitwise_and(PHP32 $x) + public function bitwise_and(PHP32 $x): PHP32 { return $this->bitwiseAndHelper($x); } /** * Logical Or - * - * @param PHP32 $x - * @return PHP32 */ - public function bitwise_or(PHP32 $x) + public function bitwise_or(PHP32 $x): PHP32 { return $this->bitwiseOrHelper($x); } /** * Logical Exclusive Or - * - * @param PHP32 $x - * @return PHP32 */ - public function bitwise_xor(PHP32 $x) + public function bitwise_xor(PHP32 $x): PHP32 { return $this->bitwiseXorHelper($x); } @@ -244,11 +221,10 @@ class PHP32 extends PHP * * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} * - * @param PHP32 $y * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. * @see self::equals() */ - public function compare(PHP32 $y) + public function compare(PHP32 $y): int { return $this->compareHelper($this->value, $this->is_negative, $y->value, $y->is_negative); } @@ -257,23 +233,16 @@ class PHP32 extends PHP * Tests the equality of two numbers. * * If you need to see if one number is greater than or less than another number, use BigInteger::compare() - * - * @param PHP32 $x - * @return bool */ - public function equals(PHP32 $x) + public function equals(PHP32 $x): bool { return $this->value === $x->value && $this->is_negative == $x->is_negative; } /** * Performs modular exponentiation. - * - * @param PHP32 $e - * @param PHP32 $n - * @return PHP32 */ - public function modPow(PHP32 $e, PHP32 $n) + public function modPow(PHP32 $e, PHP32 $n): PHP32 { return $this->powModOuter($e, $n); } @@ -282,12 +251,8 @@ class PHP32 extends PHP * Performs modular exponentiation. * * Alias for modPow(). - * - * @param PHP32 $e - * @param PHP32 $n - * @return PHP32 */ - public function powMod(PHP32 $e, PHP32 $n) + public function powMod(PHP32 $e, PHP32 $n): PHP32 { return $this->powModOuter($e, $n); } @@ -297,8 +262,6 @@ class PHP32 extends PHP * * If there's not a prime within the given range, false will be returned. * - * @param PHP32 $min - * @param PHP32 $max * @return false|PHP32 */ public static function randomRangePrime(PHP32 $min, PHP32 $max) @@ -314,57 +277,40 @@ class PHP32 extends PHP * * BigInteger::randomRange($min, $max) * BigInteger::randomRange($max, $min) - * - * @param PHP32 $min - * @param PHP32 $max - * @return PHP32 */ - public static function randomRange(PHP32 $min, PHP32 $max) + public static function randomRange(PHP32 $min, PHP32 $max): PHP32 { return self::randomRangeHelper($min, $max); } /** * Performs exponentiation. - * - * @param PHP32 $n - * @return PHP32 */ - public function pow(PHP32 $n) + public function pow(PHP32 $n): PHP32 { return $this->powHelper($n); } /** * Return the minimum BigInteger between an arbitrary number of BigIntegers. - * - * @param PHP32 ...$nums - * @return PHP32 */ - public static function min(PHP32 ...$nums) + public static function min(PHP32 ...$nums): PHP32 { return self::minHelper($nums); } /** * Return the maximum BigInteger between an arbitrary number of BigIntegers. - * - * @param PHP32 ...$nums - * @return PHP32 */ - public static function max(PHP32 ...$nums) + public static function max(PHP32 ...$nums): PHP32 { return self::maxHelper($nums); } /** * Tests BigInteger to see if it is between two integers, inclusive - * - * @param PHP32 $min - * @param PHP32 $max - * @return bool */ - public function between(PHP32 $min, PHP32 $max) + public function between(PHP32 $min, PHP32 $max): bool { return $this->compare($min) >= 0 && $this->compare($max) <= 0; } diff --git a/phpseclib/Math/BigInteger/Engines/PHP64.php b/phpseclib/Math/BigInteger/Engines/PHP64.php index ca11c08d..1fd52cd8 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP64.php +++ b/phpseclib/Math/BigInteger/Engines/PHP64.php @@ -11,6 +11,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math\BigInteger\Engines; /** @@ -44,13 +46,13 @@ class PHP64 extends PHP /** * Initialize a PHP64 BigInteger Engine instance * - * @param int $base * @see parent::initialize() */ - protected function initialize($base) + protected function initialize(int $base): void { if ($base != 256 && $base != -256) { - return parent::initialize($base); + parent::initialize($base); + return; } $val = $this->value; @@ -74,7 +76,7 @@ class PHP64 extends PHP } $i = 0; } - list(, $digit) = unpack('N', substr($val, $i, 4)); + [, $digit] = unpack('N', substr($val, $i, 4)); $step = count($vals) & 7; if (!$step) { $digit &= static::MAX_DIGIT; @@ -99,20 +101,16 @@ class PHP64 extends PHP * Test for engine validity * * @see parent::__construct() - * @return bool */ - public static function isValidEngine() + public static function isValidEngine(): bool { return PHP_INT_SIZE >= 8; } /** * Adds two BigIntegers. - * - * @param PHP64 $y - * @return PHP64 */ - public function add(PHP64 $y) + public function add(PHP64 $y): PHP64 { $temp = self::addHelper($this->value, $this->is_negative, $y->value, $y->is_negative); @@ -121,11 +119,8 @@ class PHP64 extends PHP /** * Subtracts two BigIntegers. - * - * @param PHP64 $y - * @return PHP64 */ - public function subtract(PHP64 $y) + public function subtract(PHP64 $y): PHP64 { $temp = self::subtractHelper($this->value, $this->is_negative, $y->value, $y->is_negative); @@ -134,11 +129,8 @@ class PHP64 extends PHP /** * Multiplies two BigIntegers. - * - * @param PHP64 $y - * @return PHP64 */ - public function multiply(PHP64 $y) + public function multiply(PHP64 $y): PHP64 { $temp = self::multiplyHelper($this->value, $this->is_negative, $y->value, $y->is_negative); @@ -153,10 +145,9 @@ class PHP64 extends PHP * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder * and the divisor (basically, the "common residue" is the first positive modulo). * - * @param PHP64 $y * @return array{PHP64, PHP64} */ - public function divide(PHP64 $y) + public function divide(PHP64 $y): array { return $this->divideHelper($y); } @@ -165,7 +156,6 @@ class PHP64 extends PHP * Calculates modular inverses. * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * @param PHP64 $n * @return false|PHP64 */ public function modInverse(PHP64 $n) @@ -177,10 +167,9 @@ class PHP64 extends PHP * Calculates modular inverses. * * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. - * @param PHP64 $n * @return PHP64[] */ - public function extendedGCD(PHP64 $n) + public function extendedGCD(PHP64 $n): array { return $this->extendedGCDHelper($n); } @@ -189,44 +178,32 @@ class PHP64 extends PHP * Calculates the greatest common divisor * * Say you have 693 and 609. The GCD is 21. - * - * @param PHP64 $n - * @return PHP64 */ - public function gcd(PHP64 $n) + public function gcd(PHP64 $n): PHP64 { return $this->extendedGCD($n)['gcd']; } /** * Logical And - * - * @param PHP64 $x - * @return PHP64 */ - public function bitwise_and(PHP64 $x) + public function bitwise_and(PHP64 $x): PHP64 { return $this->bitwiseAndHelper($x); } /** * Logical Or - * - * @param PHP64 $x - * @return PHP64 */ - public function bitwise_or(PHP64 $x) + public function bitwise_or(PHP64 $x): PHP64 { return $this->bitwiseOrHelper($x); } /** * Logical Exclusive Or - * - * @param PHP64 $x - * @return PHP64 */ - public function bitwise_xor(PHP64 $x) + public function bitwise_xor(PHP64 $x): PHP64 { return $this->bitwiseXorHelper($x); } @@ -245,11 +222,10 @@ class PHP64 extends PHP * * {@internal Could return $this->subtract($x), but that's not as fast as what we do do.} * - * @param PHP64 $y * @return int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. * @see self::equals() */ - public function compare(PHP64 $y) + public function compare(PHP64 $y): int { return parent::compareHelper($this->value, $this->is_negative, $y->value, $y->is_negative); } @@ -258,23 +234,16 @@ class PHP64 extends PHP * Tests the equality of two numbers. * * If you need to see if one number is greater than or less than another number, use BigInteger::compare() - * - * @param PHP64 $x - * @return bool */ - public function equals(PHP64 $x) + public function equals(PHP64 $x): bool { return $this->value === $x->value && $this->is_negative == $x->is_negative; } /** * Performs modular exponentiation. - * - * @param PHP64 $e - * @param PHP64 $n - * @return PHP64 */ - public function modPow(PHP64 $e, PHP64 $n) + public function modPow(PHP64 $e, PHP64 $n): PHP64 { return $this->powModOuter($e, $n); } @@ -284,8 +253,6 @@ class PHP64 extends PHP * * Alias for modPow(). * - * @param PHP64 $e - * @param PHP64 $n * @return PHP64|false */ public function powMod(PHP64 $e, PHP64 $n) @@ -298,8 +265,6 @@ class PHP64 extends PHP * * If there's not a prime within the given range, false will be returned. * - * @param PHP64 $min - * @param PHP64 $max * @return false|PHP64 */ public static function randomRangePrime(PHP64 $min, PHP64 $max) @@ -315,57 +280,40 @@ class PHP64 extends PHP * * BigInteger::randomRange($min, $max) * BigInteger::randomRange($max, $min) - * - * @param PHP64 $min - * @param PHP64 $max - * @return PHP64 */ - public static function randomRange(PHP64 $min, PHP64 $max) + public static function randomRange(PHP64 $min, PHP64 $max): PHP64 { return self::randomRangeHelper($min, $max); } /** * Performs exponentiation. - * - * @param PHP64 $n - * @return PHP64 */ - public function pow(PHP64 $n) + public function pow(PHP64 $n): PHP64 { return $this->powHelper($n); } /** * Return the minimum BigInteger between an arbitrary number of BigIntegers. - * - * @param PHP64 ...$nums - * @return PHP64 */ - public static function min(PHP64 ...$nums) + public static function min(PHP64 ...$nums): PHP64 { return self::minHelper($nums); } /** * Return the maximum BigInteger between an arbitrary number of BigIntegers. - * - * @param PHP64 ...$nums - * @return PHP64 */ - public static function max(PHP64 ...$nums) + public static function max(PHP64 ...$nums): PHP64 { return self::maxHelper($nums); } /** * Tests BigInteger to see if it is between two integers, inclusive - * - * @param PHP64 $min - * @param PHP64 $max - * @return bool */ - public function between(PHP64 $min, PHP64 $max) + public function between(PHP64 $min, PHP64 $max): bool { return $this->compare($min) >= 0 && $this->compare($max) <= 0; } diff --git a/phpseclib/Math/BinaryField.php b/phpseclib/Math/BinaryField.php index 3e21a67a..ed8f71ed 100644 --- a/phpseclib/Math/BinaryField.php +++ b/phpseclib/Math/BinaryField.php @@ -12,6 +12,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Math; use phpseclib3\Common\Functions\Strings; @@ -55,13 +57,13 @@ class BinaryField extends FiniteField $modulo = static::base2ToBase256(strrev($val)); $mStart = 2 * $m - 2; - $t = ceil($m / 8); + $t = (int) ceil($m / 8); $finalMask = chr((1 << ($m % 8)) - 1); if ($finalMask == "\0") { $finalMask = "\xFF"; } $bitLen = $mStart + 1; - $pad = ceil($bitLen / 8); + $pad = (int) ceil($bitLen / 8); $h = $bitLen & 7; $h = $h ? 8 - $h : 0; @@ -111,20 +113,17 @@ class BinaryField extends FiniteField /** * Returns an instance of a dynamically generated PrimeFieldInteger class * - * @param string $num - * @return Integer + * @param BigInteger|string $num */ - public function newInteger($num) + public function newInteger($num): Integer { return new Integer($this->instanceID, $num instanceof BigInteger ? $num->toBytes() : $num); } /** * Returns an integer on the finite field between one and the prime modulo - * - * @return Integer */ - public function randomInteger() + public function randomInteger(): Integer { static $one; if (!isset($one)) { @@ -136,32 +135,24 @@ class BinaryField extends FiniteField /** * Returns the length of the modulo in bytes - * - * @return int */ - public function getLengthInBytes() + public function getLengthInBytes(): int { return strlen(Integer::getModulo($this->instanceID)); } /** * Returns the length of the modulo in bits - * - * @return int */ - public function getLength() + public function getLength(): int { return strlen(Integer::getModulo($this->instanceID)) << 3; } /** * Converts a base-2 string to a base-256 string - * - * @param string $x - * @param int|null $size - * @return string */ - public static function base2ToBase256($x, $size = null) + public static function base2ToBase256(string $x, int $size = null): string { $str = Strings::bits2bin($x); @@ -179,11 +170,8 @@ class BinaryField extends FiniteField /** * Converts a base-256 string to a base-2 string - * - * @param string $x - * @return string */ - public static function base256ToBase2($x) + public static function base256ToBase2(string $x): string { if (function_exists('gmp_import')) { return gmp_strval(gmp_import($x), 2); diff --git a/phpseclib/Math/BinaryField/Integer.php b/phpseclib/Math/BinaryField/Integer.php index f95b2dd3..d59c9a6b 100644 --- a/phpseclib/Math/BinaryField/Integer.php +++ b/phpseclib/Math/BinaryField/Integer.php @@ -18,6 +18,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Math\BinaryField; use ParagonIE\ConstantTime\Hex; @@ -76,10 +78,8 @@ class Integer extends Base /** * Set the modulo for a given instance - * @param int $instanceID - * @param string $modulo */ - public static function setModulo($instanceID, $modulo) + public static function setModulo(int $instanceID, string $modulo): void { static::$modulo[$instanceID] = $modulo; } @@ -87,7 +87,7 @@ class Integer extends Base /** * Set the modulo for a given instance */ - public static function setRecurringModuloFunction($instanceID, callable $function) + public static function setRecurringModuloFunction($instanceID, callable $function): void { static::$reduce[$instanceID] = $function; } @@ -97,7 +97,7 @@ class Integer extends Base * * Throws an exception if the incorrect class is being utilized */ - private static function checkInstance(self $x, self $y) + private static function checkInstance(self $x, self $y): void { if ($x->instanceID != $y->instanceID) { throw new \UnexpectedValueException('The instances of the two BinaryField\Integer objects do not match'); @@ -106,10 +106,8 @@ class Integer extends Base /** * Tests the equality of two numbers. - * - * @return bool */ - public function equals(self $x) + public function equals(self $x): bool { static::checkInstance($this, $x); @@ -118,10 +116,8 @@ class Integer extends Base /** * Compares two numbers. - * - * @return int */ - public function compare(self $x) + public function compare(self $x): int { static::checkInstance($this, $x); @@ -139,10 +135,9 @@ class Integer extends Base /** * Returns the degree of the polynomial * - * @param string $x * @return int */ - private static function deg($x) + private static function deg(string $x) { $x = ltrim($x, "\0"); $xbit = decbin(ord($x[0])); @@ -160,7 +155,7 @@ class Integer extends Base * @return string[] * @link https://en.wikipedia.org/wiki/Polynomial_greatest_common_divisor#Euclidean_division */ - private static function polynomialDivide($x, $y) + private static function polynomialDivide($x, $y): array { // in wikipedia's description of the algorithm, lc() is the leading coefficient. over a binary field that's // always going to be 1. @@ -187,10 +182,9 @@ class Integer extends Base /** * Perform polynomial multiplation in the traditional way * - * @return string * @link https://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplication */ - private static function regularPolynomialMultiply($x, $y) + private static function regularPolynomialMultiply($x, $y): string { $precomputed = [ltrim($x, "\0")]; $x = strrev(BinaryField::base256ToBase2($x)); @@ -226,10 +220,9 @@ class Integer extends Base * * Uses karatsuba multiplication to reduce x-bit multiplications to a series of 32-bit multiplications * - * @return string * @link https://en.wikipedia.org/wiki/Karatsuba_algorithm */ - private static function polynomialMultiply($x, $y) + private static function polynomialMultiply($x, $y): string { if (strlen($x) == strlen($y)) { $length = strlen($x); @@ -277,12 +270,9 @@ class Integer extends Base * Perform polynomial multiplication on 2x 32-bit numbers, returning * a 64-bit number * - * @param string $x - * @param string $y - * @return string * @link https://www.bearssl.org/constanttime.html#ghash-for-gcm */ - private static function subMultiply($x, $y) + private static function subMultiply(string $x, string $y): string { $x = unpack('N', $x)[1]; $y = unpack('N', $y)[1]; @@ -314,12 +304,8 @@ class Integer extends Base /** * Adds two numbers - * - * @param string $x - * @param string $y - * @return string */ - private static function subAdd2($x, $y) + private static function subAdd2(string $x, string $y): string { $length = max(strlen($x), strlen($y)); $x = str_pad($x, $length, "\0", STR_PAD_LEFT); @@ -329,12 +315,8 @@ class Integer extends Base /** * Adds three numbers - * - * @param string $x - * @param string $y - * @return string */ - private static function subAdd3($x, $y, $z) + private static function subAdd3(string $x, string $y, $z): string { $length = max(strlen($x), strlen($y), strlen($z)); $x = str_pad($x, $length, "\0", STR_PAD_LEFT); @@ -348,7 +330,7 @@ class Integer extends Base * * @return static */ - public function add(self $y) + public function add(self $y): Integer { static::checkInstance($this, $y); @@ -365,7 +347,7 @@ class Integer extends Base * * @return static */ - public function subtract(self $x) + public function subtract(self $x): Integer { return $this->add($x); } @@ -375,7 +357,7 @@ class Integer extends Base * * @return static */ - public function multiply(self $y) + public function multiply(self $y): Integer { static::checkInstance($this, $y); @@ -387,7 +369,7 @@ class Integer extends Base * * @return static */ - public function modInverse() + public function modInverse(): Integer { $remainder0 = static::$modulo[$this->instanceID]; $remainder1 = $this->value; @@ -399,7 +381,7 @@ class Integer extends Base $aux0 = "\0"; $aux1 = "\1"; while ($remainder1 != "\1") { - list($q, $r) = static::polynomialDivide($remainder0, $remainder1); + [$q, $r] = static::polynomialDivide($remainder0, $remainder1); $remainder0 = $remainder1; $remainder1 = $r; // the auxiliary in row n is given by the sum of the auxiliary in @@ -422,7 +404,7 @@ class Integer extends Base * * @return static */ - public function divide(self $x) + public function divide(self $x): Integer { static::checkInstance($this, $x); @@ -447,40 +429,32 @@ class Integer extends Base /** * Returns the modulo - * - * @return string */ - public static function getModulo($instanceID) + public static function getModulo($instanceID): string { return static::$modulo[$instanceID]; } /** * Converts an Integer to a byte string (eg. base-256). - * - * @return string */ - public function toBytes() + public function toBytes(): string { return str_pad($this->value, strlen(static::$modulo[$this->instanceID]), "\0", STR_PAD_LEFT); } /** * Converts an Integer to a hex string (eg. base-16). - * - * @return string */ - public function toHex() + public function toHex(): string { return Hex::encode($this->toBytes()); } /** * Converts an Integer to a bit string (eg. base-2). - * - * @return string */ - public function toBits() + public function toBits(): string { //return str_pad(BinaryField::base256ToBase2($this->value), strlen(static::$modulo[$this->instanceID]), '0', STR_PAD_LEFT); return BinaryField::base256ToBase2($this->value); @@ -498,7 +472,6 @@ class Integer extends Base /** * __toString() magic method - * */ public function __toString() { @@ -507,7 +480,6 @@ class Integer extends Base /** * __debugInfo() magic method - * */ public function __debugInfo() { diff --git a/phpseclib/Math/Common/FiniteField/Integer.php b/phpseclib/Math/Common/FiniteField/Integer.php index 4197ed37..c2badb6a 100644 --- a/phpseclib/Math/Common/FiniteField/Integer.php +++ b/phpseclib/Math/Common/FiniteField/Integer.php @@ -28,15 +28,13 @@ abstract class Integer implements \JsonSerializable * serialized as well and that just sounds like too much */ #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): array { return ['hex' => $this->toHex(true)]; } /** * Converts an Integer to a hex string (eg. base-16). - * - * @return string */ - abstract public function toHex(); + abstract public function toHex(): string; } diff --git a/phpseclib/Math/PrimeField.php b/phpseclib/Math/PrimeField.php index 227bfd34..0b21a82b 100644 --- a/phpseclib/Math/PrimeField.php +++ b/phpseclib/Math/PrimeField.php @@ -13,6 +13,8 @@ * @link http://pear.php.net/package/Math_BigInteger */ +declare(strict_types=1); + namespace phpseclib3\Math; use phpseclib3\Math\Common\FiniteField; @@ -57,30 +59,24 @@ class PrimeField extends FiniteField /** * Use a custom defined modular reduction function - * - * @return void */ - public function setReduction(\Closure $func) + public function setReduction(\Closure $func): void { $this->reduce = $func->bindTo($this, $this); } /** * Returns an instance of a dynamically generated PrimeFieldInteger class - * - * @return Integer */ - public function newInteger(BigInteger $num) + public function newInteger(BigInteger $num): Integer { return new Integer($this->instanceID, $num); } /** * Returns an integer on the finite field between one and the prime modulo - * - * @return Integer */ - public function randomInteger() + public function randomInteger(): Integer { static $one; if (!isset($one)) { @@ -92,20 +88,16 @@ class PrimeField extends FiniteField /** * Returns the length of the modulo in bytes - * - * @return int */ - public function getLengthInBytes() + public function getLengthInBytes(): int { return Integer::getModulo($this->instanceID)->getLengthInBytes(); } /** * Returns the length of the modulo in bits - * - * @return int */ - public function getLength() + public function getLength(): int { return Integer::getModulo($this->instanceID)->getLength(); } diff --git a/phpseclib/Math/PrimeField/Integer.php b/phpseclib/Math/PrimeField/Integer.php index 0aa05417..f3730997 100644 --- a/phpseclib/Math/PrimeField/Integer.php +++ b/phpseclib/Math/PrimeField/Integer.php @@ -60,10 +60,8 @@ class Integer extends Base /** * Default constructor - * - * @param int $instanceID */ - public function __construct($instanceID, BigInteger $num = null) + public function __construct(int $instanceID, BigInteger $num = null) { $this->instanceID = $instanceID; if (!isset($num)) { @@ -76,22 +74,16 @@ class Integer extends Base /** * Set the modulo for a given instance - * - * @param int $instanceID - * @return void */ - public static function setModulo($instanceID, BigInteger $modulo) + public static function setModulo(int $instanceID, BigInteger $modulo): void { static::$modulo[$instanceID] = $modulo; } /** * Set the modulo for a given instance - * - * @param int $instanceID - * @return void */ - public static function setRecurringModuloFunction($instanceID, callable $function) + public static function setRecurringModuloFunction(int $instanceID, callable $function): void { static::$reduce[$instanceID] = $function; if (!isset(static::$zero[static::class])) { @@ -102,7 +94,7 @@ class Integer extends Base /** * Delete the modulo for a given instance */ - public static function cleanupCache($instanceID) + public static function cleanupCache($instanceID): void { unset(static::$modulo[$instanceID]); unset(static::$reduce[$instanceID]); @@ -110,11 +102,8 @@ class Integer extends Base /** * Returns the modulo - * - * @param int $instanceID - * @return BigInteger */ - public static function getModulo($instanceID) + public static function getModulo(int $instanceID): BigInteger { return static::$modulo[$instanceID]; } @@ -123,10 +112,8 @@ class Integer extends Base * Tests a parameter to see if it's of the right instance * * Throws an exception if the incorrect class is being utilized - * - * @return void */ - public static function checkInstance(self $x, self $y) + public static function checkInstance(self $x, self $y): void { if ($x->instanceID != $y->instanceID) { throw new \UnexpectedValueException('The instances of the two PrimeField\Integer objects do not match'); @@ -135,10 +122,8 @@ class Integer extends Base /** * Tests the equality of two numbers. - * - * @return bool */ - public function equals(self $x) + public function equals(self $x): bool { static::checkInstance($this, $x); @@ -147,10 +132,8 @@ class Integer extends Base /** * Compares two numbers. - * - * @return int */ - public function compare(self $x) + public function compare(self $x): int { static::checkInstance($this, $x); @@ -162,7 +145,7 @@ class Integer extends Base * * @return static */ - public function add(self $x) + public function add(self $x): Integer { static::checkInstance($this, $x); @@ -180,7 +163,7 @@ class Integer extends Base * * @return static */ - public function subtract(self $x) + public function subtract(self $x): Integer { static::checkInstance($this, $x); @@ -198,7 +181,7 @@ class Integer extends Base * * @return static */ - public function multiply(self $x) + public function multiply(self $x): Integer { static::checkInstance($this, $x); @@ -210,7 +193,7 @@ class Integer extends Base * * @return static */ - public function divide(self $x) + public function divide(self $x): Integer { static::checkInstance($this, $x); @@ -223,7 +206,7 @@ class Integer extends Base * * @return static */ - public function pow(BigInteger $x) + public function pow(BigInteger $x): Integer { $temp = new static($this->instanceID); $temp->value = $this->value->powMod($x, static::$modulo[$this->instanceID]); @@ -248,7 +231,7 @@ class Integer extends Base $p_1 = static::$modulo[$this->instanceID]->subtract($one); $q = clone $p_1; $s = BigInteger::scan1divide($q); - list($pow) = $p_1->divide($two); + [$pow] = $p_1->divide($two); for ($z = $one; !$z->equals(static::$modulo[$this->instanceID]); $z = $z->add($one)) { $temp = $z->powMod($pow, static::$modulo[$this->instanceID]); if ($temp->equals($p_1)) { @@ -259,7 +242,7 @@ class Integer extends Base $m = new BigInteger($s); $c = $z->powMod($q, static::$modulo[$this->instanceID]); $t = $this->value->powMod($q, static::$modulo[$this->instanceID]); - list($temp) = $q->add($one)->divide($two); + [$temp] = $q->add($one)->divide($two); $r = $this->value->powMod($temp, static::$modulo[$this->instanceID]); while (!$t->equals($one)) { @@ -284,10 +267,8 @@ class Integer extends Base /** * Is Odd? - * - * @return bool */ - public function isOdd() + public function isOdd(): bool { return $this->value->isOdd(); } @@ -300,17 +281,15 @@ class Integer extends Base * * @return static */ - public function negate() + public function negate(): Integer { return new static($this->instanceID, static::$modulo[$this->instanceID]->subtract($this->value)); } /** * Converts an Integer to a byte string (eg. base-256). - * - * @return string */ - public function toBytes() + public function toBytes(): string { $length = static::$modulo[$this->instanceID]->getLengthInBytes(); return str_pad($this->value->toBytes(), $length, "\0", STR_PAD_LEFT); @@ -318,20 +297,16 @@ class Integer extends Base /** * Converts an Integer to a hex string (eg. base-16). - * - * @return string */ - public function toHex() + public function toHex(): string { return Hex::encode($this->toBytes()); } /** * Converts an Integer to a bit string (eg. base-2). - * - * @return string */ - public function toBits() + public function toBits(): string { // return $this->value->toBits(); static $length; @@ -348,7 +323,7 @@ class Integer extends Base * @param int $w optional * @return array */ - public function getNAF($w = 1) + public function getNAF(int $w = 1): array { $w++; @@ -386,10 +361,8 @@ class Integer extends Base /** * Converts an Integer to a BigInteger - * - * @return BigInteger */ - public function toBigInteger() + public function toBigInteger(): BigInteger { return clone $this->value; } diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index dac72a65..be96095f 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -31,6 +31,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Net; use phpseclib3\Common\Functions\Strings; @@ -301,10 +303,8 @@ class SFTP extends SSH2 * Connects to an SFTP server * * @param string $host - * @param int $port - * @param int $timeout */ - public function __construct($host, $port = 22, $timeout = 10) + public function __construct($host, int $port = 22, int $timeout = 10) { parent::__construct($host, $port, $timeout); @@ -320,10 +320,8 @@ class SFTP extends SSH2 /** * Check a few things before SFTP functions are called - * - * @return bool */ - private function precheck() + private function precheck(): bool { if (!($this->bitmap & SSH2::MASK_LOGIN)) { return false; @@ -340,9 +338,8 @@ class SFTP extends SSH2 * Partially initialize an SFTP connection * * @throws \UnexpectedValueException on receipt of unexpected packets - * @return bool */ - private function partial_init_sftp_connection() + private function partial_init_sftp_connection(): bool { $this->window_size_server_to_client[self::CHANNEL] = $this->window_size; @@ -415,9 +412,9 @@ class SFTP extends SSH2 $this->use_request_id = true; - list($this->defaultVersion) = Strings::unpackSSH2('N', $response); + [$this->defaultVersion] = Strings::unpackSSH2('N', $response); while (!empty($response)) { - list($key, $value) = Strings::unpackSSH2('ss', $response); + [$key, $value] = Strings::unpackSSH2('ss', $response); $this->extensions[$key] = $value; } @@ -428,10 +425,8 @@ class SFTP extends SSH2 /** * (Re)initializes the SFTP channel - * - * @return bool */ - private function init_sftp_connection() + private function init_sftp_connection(): bool { if (!$this->partial_init && !$this->partial_init_sftp_connection()) { return false; @@ -481,7 +476,7 @@ class SFTP extends SSH2 throw new \UnexpectedValueException('Expected PacketType::STATUS. ' . 'Got packet type: ' . $this->packet_type); } - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); throw new \UnexpectedValueException('Expected StatusCode::OK. ' @@ -527,36 +522,32 @@ class SFTP extends SSH2 /** * Disable the stat cache - * */ - public function disableStatCache() + public function disableStatCache(): void { $this->use_stat_cache = false; } /** * Enable the stat cache - * */ - public function enableStatCache() + public function enableStatCache(): void { $this->use_stat_cache = true; } /** * Clear the stat cache - * */ - public function clearStatCache() + public function clearStatCache(): void { $this->stat_cache = []; } /** * Enable path canonicalization - * */ - public function enablePathCanonicalization() + public function enablePathCanonicalization(): void { $this->canonicalize_paths = true; } @@ -565,27 +556,24 @@ class SFTP extends SSH2 * Disable path canonicalization * * If this is enabled then $sftp->pwd() will not return the canonicalized absolute path - * */ - public function disablePathCanonicalization() + public function disablePathCanonicalization(): void { $this->canonicalize_paths = false; } /** * Enable arbitrary length packets - * */ - public function enableArbitraryLengthPackets() + public function enableArbitraryLengthPackets(): void { $this->allow_arbitrary_length_packets = true; } /** * Disable arbitrary length packets - * */ - public function disableArbitraryLengthPackets() + public function disableArbitraryLengthPackets(): void { $this->allow_arbitrary_length_packets = false; } @@ -606,20 +594,17 @@ class SFTP extends SSH2 /** * Logs errors - * - * @param string $response - * @param int $status */ - private function logError($response, $status = -1) + private function logError(string $response, int $status = -1): void { if ($status == -1) { - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); } $error = StatusCode::getConstantNameByValue($status); if ($this->version > 2) { - list($message) = Strings::unpackSSH2('s', $response); + [$message] = Strings::unpackSSH2('s', $response); $this->sftp_errors[] = "$error: $message"; } else { $this->sftp_errors[] = $error; @@ -634,13 +619,11 @@ class SFTP extends SSH2 * * If canonicalize_paths has been disabled using disablePathCanonicalization(), $path is returned as-is. * - * @see self::chdir() - * @see self::disablePathCanonicalization() - * @param string $path * @throws \UnexpectedValueException on receipt of unexpected packets - * @return mixed + *@see self::chdir() + * @see self::disablePathCanonicalization() */ - public function realpath($path) + public function realpath(string $path) { if ($this->precheck() === false) { return false; @@ -685,7 +668,7 @@ class SFTP extends SSH2 // although SSH_FXP_NAME is implemented differently in SFTPv3 than it is in SFTPv4+, the following // should work on all SFTP versions since the only part of the SSH_FXP_NAME packet the following looks // at is the first part and that part is defined the same in SFTP versions 3 through 6. - list(, $filename) = Strings::unpackSSH2('Ns', $response); + [, $filename] = Strings::unpackSSH2('Ns', $response); return $filename; case SFTPPacketType::STATUS: $this->logError($response); @@ -723,11 +706,9 @@ class SFTP extends SSH2 /** * Changes the current directory * - * @param string $dir - * @throws \UnexpectedValueException on receipt of unexpected packets - * @return bool + *@throws \UnexpectedValueException on receipt of unexpected packets */ - public function chdir($dir) + public function chdir(string $dir): bool { if (!$this->precheck()) { return false; @@ -783,11 +764,9 @@ class SFTP extends SSH2 /** * Returns a list of files in the given directory * - * @param string $dir - * @param bool $recursive * @return array|false */ - public function nlist($dir = '.', $recursive = false) + public function nlist(string $dir = '.', bool $recursive = false) { return $this->nlist_helper($dir, $recursive, ''); } @@ -795,12 +774,9 @@ class SFTP extends SSH2 /** * Helper method for nlist * - * @param string $dir - * @param bool $recursive - * @param string $relativeDir * @return array|false */ - private function nlist_helper($dir, $recursive, $relativeDir) + private function nlist_helper(string $dir, bool $recursive, string $relativeDir) { $files = $this->readlist($dir, false); @@ -829,11 +805,9 @@ class SFTP extends SSH2 /** * Returns a detailed list of files in the given directory * - * @param string $dir - * @param bool $recursive * @return array|false */ - public function rawlist($dir = '.', $recursive = false) + public function rawlist(string $dir = '.', bool $recursive = false) { $files = $this->readlist($dir, true); if (!$recursive || $files === false) { @@ -872,12 +846,10 @@ class SFTP extends SSH2 /** * Reads a list, be it detailed or not, of files in the given directory * - * @param string $dir - * @param bool $raw * @return array|false * @throws \UnexpectedValueException on receipt of unexpected packets */ - private function readlist($dir, $raw = true) + private function readlist(string $dir, bool $raw = true) { if (!$this->precheck()) { return false; @@ -920,13 +892,13 @@ class SFTP extends SSH2 $response = $this->get_sftp_packet(); switch ($this->packet_type) { case SFTPPacketType::NAME: - list($count) = Strings::unpackSSH2('N', $response); + [$count] = Strings::unpackSSH2('N', $response); for ($i = 0; $i < $count; $i++) { - list($shortname) = Strings::unpackSSH2('s', $response); + [$shortname] = Strings::unpackSSH2('s', $response); // SFTPv4 "removed the long filename from the names structure-- it can now be // built from information available in the attrs structure." if ($this->version < 4) { - list($longname) = Strings::unpackSSH2('s', $response); + [$longname] = Strings::unpackSSH2('s', $response); } $attributes = $this->parseAttributes($response); if (!isset($attributes['type']) && $this->version < 4) { @@ -952,7 +924,7 @@ class SFTP extends SSH2 } break; case SFTPPacketType::STATUS: - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::EOF) { $this->logError($response, $status); return false; @@ -980,11 +952,9 @@ class SFTP extends SSH2 * * Intended for use with uasort() * - * @param array $a - * @param array $b * @return int */ - private function comparator($a, $b) + private function comparator(array $a, array $b) { switch (true) { case $a['filename'] === '.' || $b['filename'] === '.': @@ -1058,7 +1028,7 @@ class SFTP extends SSH2 * * @param string ...$args */ - public function setListOrder(...$args) + public function setListOrder(...$args): void { $this->sortOptions = []; if (empty($args)) { @@ -1075,11 +1045,8 @@ class SFTP extends SSH2 /** * Save files / directories to cache - * - * @param string $path - * @param mixed $value */ - private function update_stat_cache($path, $value) + private function update_stat_cache(string $path, $value): void { if ($this->use_stat_cache === false) { return; @@ -1118,11 +1085,8 @@ class SFTP extends SSH2 /** * Remove files / directories from cache - * - * @param string $path - * @return bool */ - private function remove_from_stat_cache($path) + private function remove_from_stat_cache(string $path): bool { $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $path)); @@ -1147,11 +1111,8 @@ class SFTP extends SSH2 * Checks cache for path * * Mainly used by file_exists - * - * @param string $path - * @return mixed */ - private function query_stat_cache($path) + private function query_stat_cache(string $path) { $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $path)); @@ -1173,10 +1134,9 @@ class SFTP extends SSH2 * * Returns an array on success and false otherwise. * - * @param string $filename * @return array|false */ - public function stat($filename) + public function stat(string $filename) { if (!$this->precheck()) { return false; @@ -1229,10 +1189,9 @@ class SFTP extends SSH2 * * Returns an array on success and false otherwise. * - * @param string $filename * @return array|false */ - public function lstat($filename) + public function lstat(string $filename) { if (!$this->precheck()) { return false; @@ -1294,12 +1253,10 @@ class SFTP extends SSH2 * Determines information without calling \phpseclib3\Net\SFTP::realpath(). * The second parameter can be either PacketType::STAT or PacketType::LSTAT. * - * @param string $filename - * @param int $type - * @throws \UnexpectedValueException on receipt of unexpected packets * @return array|false + *@throws \UnexpectedValueException on receipt of unexpected packets */ - private function stat_helper($filename, $type) + private function stat_helper(string $filename, int $type) { // SFTPv4+ adds an additional 32-bit integer field - flags - to the following: $packet = Strings::packSSH2('s', $filename); @@ -1320,12 +1277,8 @@ class SFTP extends SSH2 /** * Truncates a file to a given length - * - * @param string $filename - * @param int $new_size - * @return bool */ - public function truncate($filename, $new_size) + public function truncate(string $filename, int $new_size): bool { $attr = Strings::packSSH2('NQ', Attribute::SIZE, $new_size); @@ -1337,13 +1290,9 @@ class SFTP extends SSH2 * * If the file does not exist, it will be created. * - * @param string $filename - * @param int $time - * @param int $atime - * @throws \UnexpectedValueException on receipt of unexpected packets - * @return bool + *@throws \UnexpectedValueException on receipt of unexpected packets */ - public function touch($filename, $time = null, $atime = null) + public function touch(string $filename, int $time = null, int $atime = null): bool { if (!$this->precheck()) { return false; @@ -1398,12 +1347,9 @@ class SFTP extends SSH2 * * Returns true on success or false on error. * - * @param string $filename * @param int|string $uid - * @param bool $recursive - * @return bool */ - public function chown($filename, $uid, $recursive = false) + public function chown(string $filename, $uid, bool $recursive = false): bool { /* quoting , @@ -1445,12 +1391,9 @@ class SFTP extends SSH2 * * Returns true on success or false on error. * - * @param string $filename * @param int|string $gid - * @param bool $recursive - * @return bool */ - public function chgrp($filename, $gid, $recursive = false) + public function chgrp(string $filename, $gid, bool $recursive = false): bool { $attr = $this->version < 4 ? pack('N3', Attribute::UIDGID, -1, $gid) : @@ -1465,13 +1408,9 @@ class SFTP extends SSH2 * Returns the new file permissions on success or false on error. * If $recursive is true than this just returns true or false. * - * @param int $mode - * @param string $filename - * @param bool $recursive * @throws \UnexpectedValueException on receipt of unexpected packets - * @return mixed */ - public function chmod($mode, $filename, $recursive = false) + public function chmod(int $mode, string $filename, bool $recursive = false) { if (is_string($mode) && is_int($filename)) { $temp = $mode; @@ -1511,13 +1450,9 @@ class SFTP extends SSH2 /** * Sets information about a file * - * @param string $filename - * @param string $attr - * @param bool $recursive - * @throws \UnexpectedValueException on receipt of unexpected packets - * @return bool + *@throws \UnexpectedValueException on receipt of unexpected packets */ - private function setstat($filename, $attr, $recursive) + private function setstat(string $filename, string $attr, bool $recursive): bool { if (!$this->precheck()) { return false; @@ -1556,7 +1491,7 @@ class SFTP extends SSH2 . 'Got packet type: ' . $this->packet_type); } - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); return false; @@ -1569,13 +1504,8 @@ class SFTP extends SSH2 * Recursively sets information on directories on the SFTP server * * Minimizes directory lookups and SSH_FXP_STATUS requests for speed. - * - * @param string $path - * @param string $attr - * @param int $i - * @return bool */ - private function setstat_recursive($path, $attr, &$i) + private function setstat_recursive(string $path, string $attr, int &$i): bool { if (!$this->read_put_responses($i)) { return false; @@ -1643,11 +1573,9 @@ class SFTP extends SSH2 /** * Return the target of a symbolic link * - * @param string $link * @throws \UnexpectedValueException on receipt of unexpected packets - * @return mixed */ - public function readlink($link) + public function readlink(string $link) { if (!$this->precheck()) { return false; @@ -1669,13 +1597,13 @@ class SFTP extends SSH2 . 'Got packet type: ' . $this->packet_type); } - list($count) = Strings::unpackSSH2('N', $response); + [$count] = Strings::unpackSSH2('N', $response); // the file isn't a symlink if (!$count) { return false; } - list($filename) = Strings::unpackSSH2('s', $response); + [$filename] = Strings::unpackSSH2('s', $response); return $filename; } @@ -1685,12 +1613,9 @@ class SFTP extends SSH2 * * symlink() creates a symbolic link to the existing target with the specified name link. * - * @param string $target - * @param string $link - * @throws \UnexpectedValueException on receipt of unexpected packets - * @return bool + *@throws \UnexpectedValueException on receipt of unexpected packets */ - public function symlink($target, $link) + public function symlink(string $target, string $link): bool { if (!$this->precheck()) { return false; @@ -1737,7 +1662,7 @@ class SFTP extends SSH2 . 'Got packet type: ' . $this->packet_type); } - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); return false; @@ -1748,13 +1673,8 @@ class SFTP extends SSH2 /** * Creates a directory. - * - * @param string $dir - * @param int $mode - * @param bool $recursive - * @return bool */ - public function mkdir($dir, $mode = -1, $recursive = false) + public function mkdir(string $dir, int $mode = -1, bool $recursive = false): bool { if (!$this->precheck()) { return false; @@ -1781,12 +1701,8 @@ class SFTP extends SSH2 /** * Helper function for directory creation - * - * @param string $dir - * @param int $mode - * @return bool */ - private function mkdir_helper($dir, $mode) + private function mkdir_helper(string $dir, int $mode): bool { // send SSH_FXP_MKDIR without any attributes (that's what the \0\0\0\0 is doing) $this->send_sftp_packet(SFTPPacketType::MKDIR, Strings::packSSH2('s', $dir) . "\0\0\0\0"); @@ -1797,7 +1713,7 @@ class SFTP extends SSH2 . 'Got packet type: ' . $this->packet_type); } - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); return false; @@ -1813,11 +1729,9 @@ class SFTP extends SSH2 /** * Removes a directory. * - * @param string $dir - * @throws \UnexpectedValueException on receipt of unexpected packets - * @return bool + *@throws \UnexpectedValueException on receipt of unexpected packets */ - public function rmdir($dir) + public function rmdir(string $dir): bool { if (!$this->precheck()) { return false; @@ -1836,7 +1750,7 @@ class SFTP extends SSH2 . 'Got packet type: ' . $this->packet_type); } - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED? $this->logError($response, $status); @@ -1890,18 +1804,12 @@ class SFTP extends SSH2 * * {@internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - \phpseclib3\Net\SFTP::setMode().} * - * @param string $remote_file - * @param string|resource $data - * @param int $mode - * @param int $start - * @param int $local_start - * @param callable|null $progressCallback + * @param resource|array|string $data * @throws \UnexpectedValueException on receipt of unexpected packets * @throws \BadFunctionCallException if you're uploading via a callback and the callback function is invalid * @throws \phpseclib3\Exception\FileNotFoundException if you're uploading via a file and the file doesn't exist - * @return bool */ - public function put($remote_file, $data, $mode = self::SOURCE_STRING, $start = -1, $local_start = -1, $progressCallback = null) + public function put(string $remote_file, $data, int $mode = self::SOURCE_STRING, int $start = -1, int $local_start = -1, callable $progressCallback = null): bool { if (!$this->precheck()) { return false; @@ -2085,11 +1993,9 @@ class SFTP extends SSH2 * Sending an SSH_FXP_WRITE packet and immediately reading its response isn't as efficient as blindly sending out $i * SSH_FXP_WRITEs, in succession, and then reading $i responses. * - * @param int $i - * @return bool * @throws \UnexpectedValueException on receipt of unexpected packets */ - private function read_put_responses($i) + private function read_put_responses(int $i): bool { while ($i--) { $response = $this->get_sftp_packet(); @@ -2098,7 +2004,7 @@ class SFTP extends SSH2 . 'Got packet type: ' . $this->packet_type); } - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); break; @@ -2111,11 +2017,9 @@ class SFTP extends SSH2 /** * Close handle * - * @param string $handle - * @return bool * @throws \UnexpectedValueException on receipt of unexpected packets */ - private function close_handle($handle) + private function close_handle(string $handle): bool { $this->send_sftp_packet(SFTPPacketType::CLOSE, pack('Na*', strlen($handle), $handle)); @@ -2127,7 +2031,7 @@ class SFTP extends SSH2 . 'Got packet type: ' . $this->packet_type); } - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); return false; @@ -2145,15 +2049,11 @@ class SFTP extends SSH2 * * $offset and $length can be used to download files in chunks. * - * @param string $remote_file * @param string|bool|resource|callable $local_file - * @param int $offset - * @param int $length - * @param callable|null $progressCallback - * @throws \UnexpectedValueException on receipt of unexpected packets * @return string|bool + *@throws \UnexpectedValueException on receipt of unexpected packets */ - public function get($remote_file, $local_file = false, $offset = 0, $length = -1, $progressCallback = null) + public function get(string $remote_file, $local_file = false, int $offset = 0, int $length = -1, callable $progressCallback = null) { if (!$this->precheck()) { return false; @@ -2306,18 +2206,15 @@ class SFTP extends SSH2 } // if $content isn't set that means a file was written to - return isset($content) ? $content : true; + return $content ?? true; } /** * Deletes a file on the SFTP server. * - * @param string $path - * @param bool $recursive - * @return bool * @throws \UnexpectedValueException on receipt of unexpected packets */ - public function delete($path, $recursive = true) + public function delete(string $path, bool $recursive = true): bool { if (!$this->precheck()) { return false; @@ -2347,7 +2244,7 @@ class SFTP extends SSH2 } // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); if (!$recursive) { @@ -2369,12 +2266,8 @@ class SFTP extends SSH2 * Recursively deletes directories on the SFTP server * * Minimizes directory lookups and SSH_FXP_STATUS requests for speed. - * - * @param string $path - * @param int $i - * @return bool */ - private function delete_recursive($path, &$i) + private function delete_recursive(string $path, int &$i): bool { if (!$this->read_put_responses($i)) { return false; @@ -2431,11 +2324,8 @@ class SFTP extends SSH2 /** * Checks whether a file or directory exists - * - * @param string $path - * @return bool */ - public function file_exists($path) + public function file_exists(string $path): bool { if ($this->use_stat_cache) { if (!$this->precheck()) { @@ -2457,11 +2347,8 @@ class SFTP extends SSH2 /** * Tells whether the filename is a directory - * - * @param string $path - * @return bool */ - public function is_dir($path) + public function is_dir(string $path): bool { $result = $this->get_stat_cache_prop($path, 'type'); if ($result === false) { @@ -2472,11 +2359,8 @@ class SFTP extends SSH2 /** * Tells whether the filename is a regular file - * - * @param string $path - * @return bool */ - public function is_file($path) + public function is_file(string $path): bool { $result = $this->get_stat_cache_prop($path, 'type'); if ($result === false) { @@ -2487,11 +2371,8 @@ class SFTP extends SSH2 /** * Tells whether the filename is a symbolic link - * - * @param string $path - * @return bool */ - public function is_link($path) + public function is_link(string $path): bool { $result = $this->get_lstat_cache_prop($path, 'type'); if ($result === false) { @@ -2502,11 +2383,8 @@ class SFTP extends SSH2 /** * Tells whether a file exists and is readable - * - * @param string $path - * @return bool */ - public function is_readable($path) + public function is_readable(string $path): bool { if (!$this->precheck()) { return false; @@ -2529,11 +2407,8 @@ class SFTP extends SSH2 /** * Tells whether the filename is writable - * - * @param string $path - * @return bool */ - public function is_writable($path) + public function is_writable(string $path): bool { if (!$this->precheck()) { return false; @@ -2558,77 +2433,56 @@ class SFTP extends SSH2 * Tells whether the filename is writeable * * Alias of is_writable - * - * @param string $path - * @return bool */ - public function is_writeable($path) + public function is_writeable(string $path): bool { return $this->is_writable($path); } /** * Gets last access time of file - * - * @param string $path - * @return mixed */ - public function fileatime($path) + public function fileatime(string $path) { return $this->get_stat_cache_prop($path, 'atime'); } /** * Gets file modification time - * - * @param string $path - * @return mixed */ - public function filemtime($path) + public function filemtime(string $path) { return $this->get_stat_cache_prop($path, 'mtime'); } /** * Gets file permissions - * - * @param string $path - * @return mixed */ - public function fileperms($path) + public function fileperms(string $path) { return $this->get_stat_cache_prop($path, 'mode'); } /** * Gets file owner - * - * @param string $path - * @return mixed */ - public function fileowner($path) + public function fileowner(string $path) { return $this->get_stat_cache_prop($path, 'uid'); } /** * Gets file group - * - * @param string $path - * @return mixed */ - public function filegroup($path) + public function filegroup(string $path) { return $this->get_stat_cache_prop($path, 'gid'); } /** * Gets file size - * - * @param string $path - * @return mixed */ - public function filesize($path) + public function filesize(string $path) { return $this->get_stat_cache_prop($path, 'size'); } @@ -2636,10 +2490,9 @@ class SFTP extends SSH2 /** * Gets file type * - * @param string $path * @return string|false */ - public function filetype($path) + public function filetype(string $path) { $type = $this->get_stat_cache_prop($path, 'type'); if ($type === false) { @@ -2668,12 +2521,8 @@ class SFTP extends SSH2 * Return a stat properity * * Uses cache if appropriate. - * - * @param string $path - * @param string $prop - * @return mixed */ - private function get_stat_cache_prop($path, $prop) + private function get_stat_cache_prop(string $path, string $prop) { return $this->get_xstat_cache_prop($path, $prop, 'stat'); } @@ -2682,12 +2531,8 @@ class SFTP extends SSH2 * Return an lstat properity * * Uses cache if appropriate. - * - * @param string $path - * @param string $prop - * @return mixed */ - private function get_lstat_cache_prop($path, $prop) + private function get_lstat_cache_prop(string $path, string $prop) { return $this->get_xstat_cache_prop($path, $prop, 'lstat'); } @@ -2696,13 +2541,8 @@ class SFTP extends SSH2 * Return a stat or lstat properity * * Uses cache if appropriate. - * - * @param string $path - * @param string $prop - * @param string $type - * @return mixed */ - private function get_xstat_cache_prop($path, $prop, $type) + private function get_xstat_cache_prop(string $path, string $prop, string $type) { if (!$this->precheck()) { return false; @@ -2732,12 +2572,9 @@ class SFTP extends SSH2 * * If the file already exists this will return false * - * @param string $oldname - * @param string $newname - * @return bool * @throws \UnexpectedValueException on receipt of unexpected packets */ - public function rename($oldname, $newname) + public function rename(string $oldname, string $newname): bool { if (!$this->precheck()) { return false; @@ -2772,7 +2609,7 @@ class SFTP extends SSH2 } // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); return false; @@ -2791,18 +2628,13 @@ class SFTP extends SSH2 * Parse Time * * See '7.7. Times' of draft-ietf-secsh-filexfer-13 for more info. - * - * @param string $key - * @param int $flags - * @param string $response - * @return array */ - private function parseTime($key, $flags, &$response) + private function parseTime(string $key, int $flags, string &$response): array { $attr = []; - list($attr[$key]) = Strings::unpackSSH2('Q', $response); + [$attr[$key]] = Strings::unpackSSH2('Q', $response); if ($flags & Attribute::SUBSECOND_TIMES) { - list($attr[$key . '-nseconds']) = Strings::unpackSSH2('N', $response); + [$attr[$key . '-nseconds']] = Strings::unpackSSH2('N', $response); } return $attr; } @@ -2811,16 +2643,13 @@ class SFTP extends SSH2 * Parse Attributes * * See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info. - * - * @param string $response - * @return array */ - protected function parseAttributes(&$response) + protected function parseAttributes(string &$response): array { if ($this->version >= 4) { - list($flags, $attr['type']) = Strings::unpackSSH2('NC', $response); + [$flags, $attr['type']] = Strings::unpackSSH2('NC', $response); } else { - list($flags) = Strings::unpackSSH2('N', $response); + [$flags] = Strings::unpackSSH2('N', $response); } foreach (Attribute::getConstants() as $value => $key) { @@ -2862,13 +2691,13 @@ class SFTP extends SSH2 // IEEE 754 binary64 "double precision" on such platforms and // as such can represent integers of at least 2^50 without loss // of precision. Interpreted in filesize, 2^50 bytes = 1024 TiB. - list($attr['size']) = Strings::unpackSSH2('Q', $response); + [$attr['size']] = Strings::unpackSSH2('Q', $response); break; case Attribute::UIDGID: // 0x00000002 (SFTPv3 only) - list($attr['uid'], $attr['gid']) = Strings::unpackSSH2('NN', $response); + [$attr['uid'], $attr['gid']] = Strings::unpackSSH2('NN', $response); break; case Attribute::PERMISSIONS: // 0x00000004 - list($attr['mode']) = Strings::unpackSSH2('N', $response); + [$attr['mode']] = Strings::unpackSSH2('N', $response); $fileType = $this->parseMode($attr['mode']); if ($this->version < 4 && $fileType !== false) { $attr += ['type' => $fileType]; @@ -2879,7 +2708,7 @@ class SFTP extends SSH2 $attr += $this->parseTime('atime', $flags, $response); break; } - list($attr['atime'], $attr['mtime']) = Strings::unpackSSH2('NN', $response); + [$attr['atime'], $attr['mtime']] = Strings::unpackSSH2('NN', $response); break; case Attribute::CREATETIME: // 0x00000010 (SFTPv4+) $attr += $this->parseTime('createtime', $flags, $response); @@ -2891,13 +2720,13 @@ class SFTP extends SSH2 // access control list // see https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-04#section-5.7 // currently unsupported - list($count) = Strings::unpackSSH2('N', $response); + [$count] = Strings::unpackSSH2('N', $response); for ($i = 0; $i < $count; $i++) { - list($type, $flag, $mask, $who) = Strings::unpackSSH2('N3s', $result); + [$type, $flag, $mask, $who] = Strings::unpackSSH2('N3s', $result); } break; case Attribute::OWNERGROUP: // 0x00000080 - list($attr['owner'], $attr['$group']) = Strings::unpackSSH2('ss', $response); + [$attr['owner'], $attr['$group']] = Strings::unpackSSH2('ss', $response); break; case Attribute::SUBSECOND_TIMES: // 0x00000100 break; @@ -2907,7 +2736,7 @@ class SFTP extends SSH2 // tells if you file is: // readonly, system, hidden, case inensitive, archive, encrypted, compressed, sparse // append only, immutable, sync - list($attrib_bits, $attrib_bits_valid) = Strings::unpackSSH2('N2', $response); + [$attrib_bits, $attrib_bits_valid] = Strings::unpackSSH2('N2', $response); // if we were actually gonna implement the above it ought to be // $attr['attrib-bits'] and $attr['attrib-bits-valid'] // eg. - instead of _ @@ -2916,26 +2745,26 @@ class SFTP extends SSH2 // see https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-7.4 // represents the number of bytes that the file consumes on the disk. will // usually be larger than the 'size' field - list($attr['allocation-size']) = Strings::unpackSSH2('Q', $response); + [$attr['allocation-size']] = Strings::unpackSSH2('Q', $response); break; case Attribute::TEXT_HINT: // 0x00000800 // https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-7.10 // currently unsupported // tells if file is "known text", "guessed text", "known binary", "guessed binary" - list($text_hint) = Strings::unpackSSH2('C', $response); + [$text_hint] = Strings::unpackSSH2('C', $response); // the above should be $attr['text-hint'] break; case Attribute::MIME_TYPE: // 0x00001000 // see https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-7.11 - list($attr['mime-type']) = Strings::unpackSSH2('s', $response); + [$attr['mime-type']] = Strings::unpackSSH2('s', $response); break; case Attribute::LINK_COUNT: // 0x00002000 // see https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-7.12 - list($attr['link-count']) = Strings::unpackSSH2('N', $response); + [$attr['link-count']] = Strings::unpackSSH2('N', $response); break; case Attribute::UNTRANSLATED_NAME:// 0x00004000 // see https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-7.13 - list($attr['untranslated-name']) = Strings::unpackSSH2('s', $response); + [$attr['untranslated-name']] = Strings::unpackSSH2('s', $response); break; case Attribute::CTIME: // 0x00008000 // 'ctime' contains the last time the file attributes were changed. The @@ -2943,9 +2772,9 @@ class SFTP extends SSH2 $attr += $this->parseTime('ctime', $flags, $response); break; case Attribute::EXTENDED: // 0x80000000 - list($count) = Strings::unpackSSH2('N', $response); + [$count] = Strings::unpackSSH2('N', $response); for ($i = 0; $i < $count; $i++) { - list($key, $value) = Strings::unpackSSH2('ss', $response); + [$key, $value] = Strings::unpackSSH2('ss', $response); $attr[$key] = $value; } } @@ -2958,10 +2787,9 @@ class SFTP extends SSH2 * * Quoting the SFTP RFC, "Implementations MUST NOT send bits that are not defined" but they seem to anyway * - * @param int $mode * @return int */ - private function parseMode($mode) + private function parseMode(int $mode) { // values come from http://lxr.free-electrons.com/source/include/uapi/linux/stat.h#L12 // see, also, http://linux.die.net/man/2/stat @@ -3003,11 +2831,8 @@ class SFTP extends SSH2 * {@link http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 SFTPv4 type constants}. * * If the longname is in an unrecognized format bool(false) is returned. - * - * @param string $longname - * @return mixed */ - private function parseLongname($longname) + private function parseLongname(string $longname) { // http://en.wikipedia.org/wiki/Unix_file_types // http://en.wikipedia.org/wiki/Filesystem_permissions#Notation_of_traditional_Unix_permissions @@ -3032,14 +2857,10 @@ class SFTP extends SSH2 * * See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info. * - * @param int $type - * @param string $data - * @param int $request_id * @see self::_get_sftp_packet() * @see self::send_channel_packet() - * @return void */ - private function send_sftp_packet($type, $data, $request_id = 1) + private function send_sftp_packet(int $type, string $data, int $request_id = 1): void { // in SSH2.php the timeout is cumulative per function call. eg. exec() will // timeout after 10s. but for SFTP.php it's cumulative per packet @@ -3082,10 +2903,8 @@ class SFTP extends SSH2 /** * Resets a connection for re-use - * - * @param int $reason */ - protected function reset_connection($reason) + protected function reset_connection(int $reason): void { parent::reset_connection($reason); $this->use_request_id = false; @@ -3239,20 +3058,16 @@ class SFTP extends SSH2 /** * Returns all errors - * - * @return array */ - public function getSFTPErrors() + public function getSFTPErrors(): array { return $this->sftp_errors; } /** * Returns the last error - * - * @return string */ - public function getLastSFTPError() + public function getLastSFTPError(): string { return count($this->sftp_errors) ? $this->sftp_errors[count($this->sftp_errors) - 1] : ''; } @@ -3299,10 +3114,8 @@ class SFTP extends SSH2 * If you're preferred version isn't supported then the highest supported * version of SFTP will be utilized. Set to null or false or int(0) to * unset the preferred version - * - * @param int $version */ - public function setPreferredVersion($version) + public function setPreferredVersion(int $version): void { $this->preferredVersion = $version; } @@ -3310,10 +3123,9 @@ class SFTP extends SSH2 /** * Disconnect * - * @param int $reason * @return false */ - protected function disconnect_helper($reason) + protected function disconnect_helper(int $reason): bool { $this->pwd = false; return parent::disconnect_helper($reason); @@ -3321,18 +3133,16 @@ class SFTP extends SSH2 /** * Enable Date Preservation - * */ - public function enableDatePreservation() + public function enableDatePreservation(): void { $this->preserveTime = true; } /** * Disable Date Preservation - * */ - public function disableDatePreservation() + public function disableDatePreservation(): void { $this->preserveTime = false; } diff --git a/phpseclib/Net/SFTP/Attribute.php b/phpseclib/Net/SFTP/Attribute.php index 1feb4eac..f58f6219 100644 --- a/phpseclib/Net/SFTP/Attribute.php +++ b/phpseclib/Net/SFTP/Attribute.php @@ -1,5 +1,7 @@ getConstants(); diff --git a/phpseclib/Net/SFTP/FileType.php b/phpseclib/Net/SFTP/FileType.php index 5cebc893..05e17c4f 100644 --- a/phpseclib/Net/SFTP/FileType.php +++ b/phpseclib/Net/SFTP/FileType.php @@ -1,5 +1,7 @@ 22]); @@ -234,14 +234,8 @@ class Stream /** * Opens file or URL - * - * @param string $path - * @param string $mode - * @param int $options - * @param string $opened_path - * @return bool */ - private function _stream_open($path, $mode, $options, &$opened_path) + private function _stream_open(string $path, string $mode): bool { $path = $this->parse_path($path); @@ -278,11 +272,8 @@ class Stream /** * Read from stream - * - * @param int $count - * @return mixed */ - private function _stream_read($count) + private function _stream_read(int $count) { switch ($this->mode) { case 'w': @@ -320,10 +311,9 @@ class Stream /** * Write to stream * - * @param string $data * @return int|false */ - private function _stream_write($data) + private function _stream_write(string $data) { switch ($this->mode) { case 'r': @@ -353,10 +343,8 @@ class Stream /** * Retrieve the current position of a stream - * - * @return int */ - private function _stream_tell() + private function _stream_tell(): int { return $this->pos; } @@ -370,22 +358,16 @@ class Stream * Only fgets / fread, however, results in feof() returning true. do fputs($fp, 'aaa') on a blank file and feof() * will return false. do fread($fp, 1) and feof() will then return true. do fseek($fp, 10) on ablank file and feof() * will return false. do fread($fp, 1) and feof() will then return true. - * - * @return bool */ - private function _stream_eof() + private function _stream_eof(): bool { return $this->eof; } /** * Seeks to specific location in a stream - * - * @param int $offset - * @param int $whence - * @return bool */ - private function _stream_seek($offset, $whence) + private function _stream_seek(int $offset, int $whence): bool { switch ($whence) { case SEEK_SET: @@ -407,13 +389,8 @@ class Stream /** * Change stream options - * - * @param string $path - * @param int $option - * @param mixed $var - * @return bool */ - private function _stream_metadata($path, $option, $var) + private function _stream_metadata(string $path, int $option, $var): bool { $path = $this->parse_path($path); if ($path === false) { @@ -425,8 +402,8 @@ class Stream // and https://github.com/php/php-src/blob/master/main/php_streams.h#L592 switch ($option) { case 1: // PHP_STREAM_META_TOUCH - $time = isset($var[0]) ? $var[0] : null; - $atime = isset($var[1]) ? $var[1] : null; + $time = $var[0] ?? null; + $atime = $var[1] ?? null; return $this->sftp->touch($path, $time, $atime); case 2: // PHP_STREAM_OWNER_NAME case 3: // PHP_STREAM_GROUP_NAME @@ -443,21 +420,17 @@ class Stream /** * Retrieve the underlaying resource * - * @param int $cast_as * @return resource */ - private function _stream_cast($cast_as) + private function _stream_cast(int $cast_as) { return $this->sftp->fsock; } /** * Advisory file locking - * - * @param int $operation - * @return bool */ - private function _stream_lock($operation) + private function _stream_lock(int $operation): bool { return false; } @@ -468,12 +441,8 @@ class Stream * Attempts to rename oldname to newname, moving it between directories if necessary. * If newname exists, it will be overwritten. This is a departure from what \phpseclib3\Net\SFTP * does. - * - * @param string $path_from - * @param string $path_to - * @return bool */ - private function _rename($path_from, $path_to) + private function _rename(string $path_from, string $path_to): bool { $path1 = parse_url($path_from); $path2 = parse_url($path_to); @@ -519,12 +488,8 @@ class Stream * string filename * string longname * ATTRS attrs - * - * @param string $path - * @param int $options - * @return bool */ - private function _dir_opendir($path, $options) + private function _dir_opendir(string $path, int $options): bool { $path = $this->parse_path($path); if ($path === false) { @@ -537,8 +502,6 @@ class Stream /** * Read entry from directory handle - * - * @return mixed */ private function _dir_readdir() { @@ -550,10 +513,8 @@ class Stream /** * Rewind directory handle - * - * @return bool */ - private function _dir_rewinddir() + private function _dir_rewinddir(): bool { $this->pos = 0; return true; @@ -561,10 +522,8 @@ class Stream /** * Close directory handle - * - * @return bool */ - private function _dir_closedir() + private function _dir_closedir(): bool { return true; } @@ -573,13 +532,8 @@ class Stream * Create a directory * * Only valid $options is STREAM_MKDIR_RECURSIVE - * - * @param string $path - * @param int $mode - * @param int $options - * @return bool */ - private function _mkdir($path, $mode, $options) + private function _mkdir(string $path, int $mode, int $options): bool { $path = $this->parse_path($path); if ($path === false) { @@ -596,12 +550,8 @@ class Stream * does not have a $recursive parameter as mkdir() does so I don't know how * STREAM_MKDIR_RECURSIVE is supposed to be set. Also, when I try it out with rmdir() I get 8 as * $options. What does 8 correspond to? - * - * @param string $path - * @param int $options - * @return bool */ - private function _rmdir($path, $options) + private function _rmdir(string $path, int $options): bool { $path = $this->parse_path($path); if ($path === false) { @@ -615,20 +565,16 @@ class Stream * Flushes the output * * See . Always returns true because \phpseclib3\Net\SFTP doesn't cache stuff before writing - * - * @return bool */ - private function _stream_flush() + private function _stream_flush(): bool { return true; } /** * Retrieve information about a file resource - * - * @return mixed */ - private function _stream_stat() + private function _stream_stat(): bool { $results = $this->sftp->stat($this->path); if ($results === false) { @@ -639,11 +585,8 @@ class Stream /** * Delete a file - * - * @param string $path - * @return bool */ - private function _unlink($path) + private function _unlink(string $path): bool { $path = $this->parse_path($path); if ($path === false) { @@ -659,12 +602,8 @@ class Stream * Ignores the STREAM_URL_STAT_QUIET flag because the entirety of \phpseclib3\Net\SFTP\Stream is quiet by default * might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll * cross that bridge when and if it's reached - * - * @param string $path - * @param int $flags - * @return mixed */ - private function _url_stat($path, $flags) + private function _url_stat(string $path, int $flags): bool { $path = $this->parse_path($path); if ($path === false) { @@ -681,11 +620,8 @@ class Stream /** * Truncate stream - * - * @param int $new_size - * @return bool */ - private function _stream_truncate($new_size) + private function _stream_truncate(int $new_size): bool { if (!$this->sftp->truncate($this->path, $new_size)) { return false; @@ -702,22 +638,16 @@ class Stream * * STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't. * The other two aren't supported because of limitations in \phpseclib3\Net\SFTP. - * - * @param int $option - * @param int $arg1 - * @param int $arg2 - * @return bool */ - private function _stream_set_option($option, $arg1, $arg2) + private function _stream_set_option(int $option, int $arg1, int $arg2): bool { return false; } /** * Close an resource - * */ - private function _stream_close() + private function _stream_close(): void { } @@ -730,12 +660,8 @@ class Stream * * If NET_SFTP_STREAM_LOGGING is defined all calls will be output on the screen and then (regardless of whether or not * NET_SFTP_STREAM_LOGGING is enabled) the parameters will be passed through to the appropriate method. - * - * @param string $name - * @param array $arguments - * @return mixed */ - public function __call($name, $arguments) + public function __call(string $name, array $arguments) { if (defined('NET_SFTP_STREAM_LOGGING')) { echo $name . '('; diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 4b9c5703..f0790a1b 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -43,6 +43,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\Net; use phpseclib3\Common\Functions\Strings; @@ -1043,12 +1045,9 @@ class SSH2 * * $host can either be a string, representing the host, or a stream resource. * - * @param mixed $host - * @param int $port - * @param int $timeout * @see self::login() */ - public function __construct($host, $port = 22, $timeout = 10) + public function __construct($host, int $port = 22, int $timeout = 10) { /** * Typehint is required due to a bug in Psalm: https://github.com/vimeo/psalm/issues/7508 @@ -1075,10 +1074,8 @@ class SSH2 * * Possible $engine values: * OpenSSL, mcrypt, Eval, PHP - * - * @param int $engine */ - public static function setCryptoEngine($engine) + public static function setCryptoEngine(int $engine): void { self::$crypto_engine = $engine; } @@ -1089,9 +1086,8 @@ class SSH2 * https://tools.ietf.org/html/rfc4253#section-4.2 says "when the connection has been established, * both sides MUST send an identification string". It does not say which side sends it first. In * theory it shouldn't matter but it is a fact of life that some SSH servers are simply buggy - * */ - public function sendIdentificationStringFirst() + public function sendIdentificationStringFirst(): void { $this->send_id_string_first = true; } @@ -1102,9 +1098,8 @@ class SSH2 * https://tools.ietf.org/html/rfc4253#section-4.2 says "when the connection has been established, * both sides MUST send an identification string". It does not say which side sends it first. In * theory it shouldn't matter but it is a fact of life that some SSH servers are simply buggy - * */ - public function sendIdentificationStringLast() + public function sendIdentificationStringLast(): void { $this->send_id_string_first = false; } @@ -1115,9 +1110,8 @@ class SSH2 * https://tools.ietf.org/html/rfc4253#section-7.1 says "key exchange begins by each sending * sending the [SSH_MSG_KEXINIT] packet". It does not say which side sends it first. In theory * it shouldn't matter but it is a fact of life that some SSH servers are simply buggy - * */ - public function sendKEXINITFirst() + public function sendKEXINITFirst(): void { $this->send_kex_first = true; } @@ -1128,9 +1122,8 @@ class SSH2 * https://tools.ietf.org/html/rfc4253#section-7.1 says "key exchange begins by each sending * sending the [SSH_MSG_KEXINIT] packet". It does not say which side sends it first. In theory * it shouldn't matter but it is a fact of life that some SSH servers are simply buggy - * */ - public function sendKEXINITLast() + public function sendKEXINITLast(): void { $this->send_kex_first = false; } @@ -1282,10 +1275,8 @@ class SSH2 * Generates the SSH identifier * * You should overwrite this method in your own class if you want to use another identifier - * - * @return string */ - private function generate_identifier() + private function generate_identifier(): string { $identifier = 'SSH-2.0-phpseclib_3.0'; @@ -1316,40 +1307,31 @@ class SSH2 /** * Key Exchange * - * @return bool * @param string|bool $kexinit_payload_server optional * @throws \UnexpectedValueException on receipt of unexpected packets * @throws \RuntimeException on other errors * @throws \phpseclib3\Exception\NoSupportedAlgorithmsException when none of the algorithms phpseclib has loaded are compatible */ - private function key_exchange($kexinit_payload_server = false) + private function key_exchange($kexinit_payload_server = false): bool { $preferred = $this->preferred; $send_kex = true; - $kex_algorithms = isset($preferred['kex']) ? - $preferred['kex'] : + $kex_algorithms = $preferred['kex'] ?? SSH2::getSupportedKEXAlgorithms(); - $server_host_key_algorithms = isset($preferred['hostkey']) ? - $preferred['hostkey'] : + $server_host_key_algorithms = $preferred['hostkey'] ?? SSH2::getSupportedHostKeyAlgorithms(); - $s2c_encryption_algorithms = isset($preferred['server_to_client']['crypt']) ? - $preferred['server_to_client']['crypt'] : + $s2c_encryption_algorithms = $preferred['server_to_client']['crypt'] ?? SSH2::getSupportedEncryptionAlgorithms(); - $c2s_encryption_algorithms = isset($preferred['client_to_server']['crypt']) ? - $preferred['client_to_server']['crypt'] : + $c2s_encryption_algorithms = $preferred['client_to_server']['crypt'] ?? SSH2::getSupportedEncryptionAlgorithms(); - $s2c_mac_algorithms = isset($preferred['server_to_client']['mac']) ? - $preferred['server_to_client']['mac'] : + $s2c_mac_algorithms = $preferred['server_to_client']['mac'] ?? SSH2::getSupportedMACAlgorithms(); - $c2s_mac_algorithms = isset($preferred['client_to_server']['mac']) ? - $preferred['client_to_server']['mac'] : + $c2s_mac_algorithms = $preferred['client_to_server']['mac'] ?? SSH2::getSupportedMACAlgorithms(); - $s2c_compression_algorithms = isset($preferred['server_to_client']['comp']) ? - $preferred['server_to_client']['comp'] : + $s2c_compression_algorithms = $preferred['server_to_client']['comp'] ?? SSH2::getSupportedCompressionAlgorithms(); - $c2s_compression_algorithms = isset($preferred['client_to_server']['comp']) ? - $preferred['client_to_server']['comp'] : + $c2s_compression_algorithms = $preferred['client_to_server']['comp'] ?? SSH2::getSupportedCompressionAlgorithms(); // some SSH servers have buggy implementations of some of the above algorithms @@ -1410,7 +1392,7 @@ class SSH2 Strings::shift($response, 1); // skip past the message number (it should be SSH_MSG_KEXINIT) $server_cookie = Strings::shift($response, 16); - list( + [ $this->kex_algorithms, $this->server_host_key_algorithms, $this->encryption_algorithms_client_to_server, @@ -1422,7 +1404,7 @@ class SSH2 $this->languages_client_to_server, $this->languages_server_to_client, $first_kex_packet_follows - ) = Strings::unpackSSH2('L10C', $response); + ] = Strings::unpackSSH2('L10C', $response); if ($send_kex) { $this->send_binary_packet($kexinit_payload_client); @@ -1543,7 +1525,7 @@ class SSH2 $response = $this->get_binary_packet(); - list($type, $primeBytes, $gBytes) = Strings::unpackSSH2('Css', $response); + [$type, $primeBytes, $gBytes] = Strings::unpackSSH2('Css', $response); if ($type != MessageTypeExtra::KEXDH_GEX_GROUP) { $this->disconnect_helper(DisconnectReason::PROTOCOL_ERROR); throw new \UnexpectedValueException('Expected SSH_MSG_KEX_DH_GEX_GROUP'); @@ -1588,12 +1570,12 @@ class SSH2 $response = $this->get_binary_packet(); - list( + [ $type, $server_public_host_key, $theirPublicBytes, $this->signature - ) = Strings::unpackSSH2('Csss', $response); + ] = Strings::unpackSSH2('Csss', $response); if ($type != $serverKexReplyMessage) { $this->disconnect_helper(DisconnectReason::PROTOCOL_ERROR); @@ -1608,7 +1590,7 @@ class SSH2 } $this->server_public_host_key = $server_public_host_key; - list($public_key_format) = Strings::unpackSSH2('s', $server_public_host_key); + [$public_key_format] = Strings::unpackSSH2('s', $server_public_host_key); if (strlen($this->signature) < 4) { throw new \LengthException('The signature needs at least four bytes'); } @@ -1673,7 +1655,7 @@ class SSH2 throw new ConnectionClosedException('Connection closed by server'); } - list($type) = Strings::unpackSSH2('C', $response); + [$type] = Strings::unpackSSH2('C', $response); if ($type != MessageType::NEWKEYS) { $this->disconnect_helper(DisconnectReason::PROTOCOL_ERROR); throw new \UnexpectedValueException('Expected SSH_MSG_NEWKEYS'); @@ -1787,7 +1769,7 @@ class SSH2 } if (!$this->encrypt->usesNonce()) { - list($this->hmac_create, $createKeyLength) = self::mac_algorithm_to_hash_instance($mac_algorithm_out); + [$this->hmac_create, $createKeyLength] = self::mac_algorithm_to_hash_instance($mac_algorithm_out); } else { $this->hmac_create = new \stdClass(); $this->hmac_create_name = $mac_algorithm_out; @@ -1806,7 +1788,7 @@ class SSH2 } if (!$this->decrypt->usesNonce()) { - list($this->hmac_check, $checkKeyLength) = self::mac_algorithm_to_hash_instance($mac_algorithm_in); + [$this->hmac_check, $checkKeyLength] = self::mac_algorithm_to_hash_instance($mac_algorithm_in); $this->hmac_size = $this->hmac_check->getLengthInBytes(); } else { $this->hmac_check = new \stdClass(); @@ -1837,7 +1819,7 @@ class SSH2 * @param string $algorithm Name of the encryption algorithm * @return int|null Number of bytes as an integer or null for unknown */ - private function encryption_algorithm_to_key_size($algorithm) + private function encryption_algorithm_to_key_size(string $algorithm): ?int { if ($this->bad_key_size_fix && self::bad_algorithm_candidate($algorithm)) { return 16; @@ -1884,7 +1866,7 @@ class SSH2 * @param string $algorithm Name of the encryption algorithm * @return SymmetricKey|null */ - private static function encryption_algorithm_to_crypt_instance($algorithm) + private static function encryption_algorithm_to_crypt_instance(string $algorithm) { switch ($algorithm) { case '3des-cbc': @@ -1932,7 +1914,7 @@ class SSH2 * @param string $algorithm Name of the encryption algorithm * @return array{Hash, int}|null */ - private static function mac_algorithm_to_hash_instance($algorithm) + private static function mac_algorithm_to_hash_instance(string $algorithm): ?array { switch ($algorithm) { case 'umac-64@openssh.com': @@ -1967,7 +1949,7 @@ class SSH2 * @param string $algorithm Name of the encryption algorithm * @return bool */ - private static function bad_algorithm_candidate($algorithm) + private static function bad_algorithm_candidate($algorithm): bool { switch ($algorithm) { case 'arcfour256': @@ -1984,18 +1966,19 @@ class SSH2 * * The $password parameter can be a plaintext password, a \phpseclib3\Crypt\RSA|EC|DSA object, a \phpseclib3\System\SSH\Agent object or an array * - * @param string $username * @param string|AsymmetricKey|array[]|Agent|null ...$args - * @return bool * @see self::_login() */ - public function login($username, ...$args) + public function login(string $username, ...$args): bool { $this->auth[] = func_get_args(); // try logging with 'none' as an authentication method first since that's what // PuTTY does - if (substr($this->server_identifier, 0, 15) != 'SSH-2.0-CoreFTP' && $this->auth_methods_to_continue === null) { + if ( + substr($this->server_identifier ?: '', 0, 15) !== 'SSH-2.0-CoreFTP' && + $this->auth_methods_to_continue === null + ) { if ($this->sublogin($username)) { return true; } @@ -2009,12 +1992,10 @@ class SSH2 /** * Login Helper * - * @param string $username * @param string ...$args - * @return bool * @see self::_login_helper() */ - protected function sublogin($username, ...$args) + protected function sublogin(string $username, ...$args): bool { if (!($this->bitmap & self::MASK_CONSTRUCTOR)) { $this->connect(); @@ -2105,13 +2086,10 @@ class SSH2 * {@internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} * by sending dummy SSH_MSG_IGNORE messages.} * - * @param string $username - * @param string|AsymmetricKey|array[]|Agent|null ...$args - * @return bool * @throws \UnexpectedValueException on receipt of unexpected packets * @throws \RuntimeException on other errors */ - private function login_helper($username, $password = null) + private function login_helper(string $username, $password = null): bool { if (!($this->bitmap & self::MASK_CONNECTED)) { return false; @@ -2133,7 +2111,7 @@ class SSH2 throw new ConnectionClosedException('Connection closed by server'); } - list($type, $service) = Strings::unpackSSH2('Cs', $response); + [$type, $service] = Strings::unpackSSH2('Cs', $response); if ($type != MessageType::SERVICE_ACCEPT || $service != 'ssh-userauth') { $this->disconnect_helper(DisconnectReason::PROTOCOL_ERROR); throw new \UnexpectedValueException('Expected SSH_MSG_SERVICE_ACCEPT'); @@ -2174,13 +2152,13 @@ class SSH2 $response = $this->get_binary_packet(); - list($type) = Strings::unpackSSH2('C', $response); + [$type] = Strings::unpackSSH2('C', $response); switch ($type) { case MessageType::USERAUTH_SUCCESS: $this->bitmap |= self::MASK_LOGIN; return true; case MessageType::USERAUTH_FAILURE: - list($auth_methods) = Strings::unpackSSH2('L', $response); + [$auth_methods] = Strings::unpackSSH2('L', $response); $this->auth_methods_to_continue = $auth_methods; // fall-through default: @@ -2219,19 +2197,19 @@ class SSH2 if ($response === false) { return false; } - list($type) = Strings::unpackSSH2('C', $response); + [$type] = Strings::unpackSSH2('C', $response); switch ($type) { case MessageTypeExtra::USERAUTH_PASSWD_CHANGEREQ: // in theory, the password can be changed $this->updateLogHistory('SSH_MSG_USERAUTH_INFO_REQUEST', 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ'); - list($message) = Strings::unpackSSH2('s', $response); + [$message] = Strings::unpackSSH2('s', $response); $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: ' . $message; return $this->disconnect_helper(DisconnectReason::AUTH_CANCELLED_BY_USER); case MessageType::USERAUTH_FAILURE: // can we use keyboard-interactive authentication? if not then either the login is bad or the server employees // multi-factor authentication - list($auth_methods, $partial_success) = Strings::unpackSSH2('Lb', $response); + [$auth_methods, $partial_success] = Strings::unpackSSH2('Lb', $response); $this->auth_methods_to_continue = $auth_methods; if (!$partial_success && in_array('keyboard-interactive', $auth_methods)) { if ($this->keyboard_interactive_login($username, $password)) { @@ -2254,11 +2232,9 @@ class SSH2 * * See {@link http://tools.ietf.org/html/rfc4256 RFC4256} for details. This is not a full-featured keyboard-interactive authenticator. * - * @param string $username * @param string|array $password - * @return bool */ - private function keyboard_interactive_login($username, $password) + private function keyboard_interactive_login(string $username, $password): bool { $packet = Strings::packSSH2( 'Cs5', @@ -2278,10 +2254,9 @@ class SSH2 * Handle the keyboard-interactive requests / responses. * * @param string|array ...$responses - * @return bool * @throws \RuntimeException on connection error */ - private function keyboard_interactive_process(...$responses) + private function keyboard_interactive_process(...$responses): bool { if (strlen($this->last_interactive_response)) { $response = $this->last_interactive_response; @@ -2289,15 +2264,15 @@ class SSH2 $orig = $response = $this->get_binary_packet(); } - list($type) = Strings::unpackSSH2('C', $response); + [$type] = Strings::unpackSSH2('C', $response); switch ($type) { case MessageType::USERAUTH_INFO_REQUEST: - list( + [ , // name; may be empty , // instruction; may be empty , // language tag; may be empty $num_prompts - ) = Strings::unpackSSH2('s3N', $response); + ] = Strings::unpackSSH2('s3N', $response); for ($i = 0; $i < count($responses); $i++) { if (is_array($responses[$i])) { @@ -2311,10 +2286,10 @@ class SSH2 if (isset($this->keyboard_requests_responses)) { for ($i = 0; $i < $num_prompts; $i++) { - list( + [ $prompt, // prompt - ie. "Password: "; must not be empty // echo - ) = Strings::unpackSSH2('sC', $response); + ] = Strings::unpackSSH2('sC', $response); foreach ($this->keyboard_requests_responses as $key => $value) { if (substr($prompt, 0, strlen($key)) == $key) { $responses[] = $value; @@ -2362,7 +2337,7 @@ class SSH2 case MessageType::USERAUTH_SUCCESS: return true; case MessageType::USERAUTH_FAILURE: - list($auth_methods) = Strings::unpackSSH2('L', $response); + [$auth_methods] = Strings::unpackSSH2('L', $response); $this->auth_methods_to_continue = $auth_methods; return false; } @@ -2372,12 +2347,8 @@ class SSH2 /** * Login with an ssh-agent provided key - * - * @param string $username - * @param \phpseclib3\System\SSH\Agent $agent - * @return bool */ - private function ssh_agent_login($username, Agent $agent) + private function ssh_agent_login(string $username, Agent $agent): bool { $this->agent = $agent; $keys = $agent->requestIdentities(); @@ -2396,12 +2367,9 @@ class SSH2 * {@internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} * by sending dummy SSH_MSG_IGNORE messages.} * - * @param string $username - * @param \phpseclib3\Crypt\Common\PrivateKey $privatekey - * @return bool * @throws \RuntimeException on connection error */ - private function privatekey_login($username, PrivateKey $privatekey) + private function privatekey_login(string $username, PrivateKey $privatekey): bool { $publickey = $privatekey->getPublicKey(); @@ -2476,10 +2444,10 @@ class SSH2 $response = $this->get_binary_packet(); - list($type) = Strings::unpackSSH2('C', $response); + [$type] = Strings::unpackSSH2('C', $response); switch ($type) { case MessageType::USERAUTH_FAILURE: - list($auth_methods) = Strings::unpackSSH2('L', $response); + [$auth_methods] = Strings::unpackSSH2('L', $response); $this->auth_methods_to_continue = $auth_methods; $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE'; return false; @@ -2508,11 +2476,11 @@ class SSH2 $response = $this->get_binary_packet(); - list($type) = Strings::unpackSSH2('C', $response); + [$type] = Strings::unpackSSH2('C', $response); switch ($type) { case MessageType::USERAUTH_FAILURE: // either the login is bad or the server employs multi-factor authentication - list($auth_methods) = Strings::unpackSSH2('L', $response); + [$auth_methods] = Strings::unpackSSH2('L', $response); $this->auth_methods_to_continue = $auth_methods; return false; case MessageType::USERAUTH_SUCCESS: @@ -2529,10 +2497,8 @@ class SSH2 * * $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. * Setting $timeout to false or 0 will mean there is no timeout. - * - * @param mixed $timeout */ - public function setTimeout($timeout) + public function setTimeout($timeout): void { $this->timeout = $this->curTimeout = $timeout; } @@ -2541,19 +2507,16 @@ class SSH2 * Set Keep Alive * * Sends an SSH2_MSG_IGNORE message every x seconds, if x is a positive non-zero number. - * - * @param int $interval */ - public function setKeepAlive($interval) + public function setKeepAlive(int $interval): void { $this->keepAlive = $interval; } /** * Get the output from stdError - * */ - public function getStdError() + public function getStdError(): string { return $this->stdErrorLog; } @@ -2564,12 +2527,11 @@ class SSH2 * If $callback is set to false then \phpseclib3\Net\SSH2::get_channel_packet(self::CHANNEL_EXEC) will need to be called manually. * In all likelihood, this is not a feature you want to be taking advantage of. * - * @param string $command * @return string|bool * @psalm-return ($callback is callable ? bool : string|bool) * @throws \RuntimeException on connection error */ - public function exec($command, callable $callback = null) + public function exec(string $command, callable $callback = null) { $this->curTimeout = $this->timeout; $this->is_timeout = false; @@ -2690,11 +2652,10 @@ class SSH2 * * @see self::read() * @see self::write() - * @return bool * @throws \UnexpectedValueException on receipt of unexpected packets * @throws \RuntimeException on other errors */ - private function initShell() + private function initShell(): bool { if ($this->in_request_pty_exec === true) { return true; @@ -2767,9 +2728,8 @@ class SSH2 * * @see self::read() * @see self::write() - * @return int */ - private function get_interactive_channel() + private function get_interactive_channel(): int { switch (true) { case $this->in_subsystem: @@ -2800,10 +2760,8 @@ class SSH2 /** * Request agent forwarding of remote server - * - * @return bool */ - public function requestAgentForwarding() + public function requestAgentForwarding(): bool { $request_channel = $this->get_open_channel(); if ($request_channel === false) { @@ -2837,13 +2795,11 @@ class SSH2 * Returns when there's a match for $expect, which can take the form of a string literal or, * if $mode == self::READ_REGEX, a regular expression. * - * @see self::write() - * @param string $expect - * @param int $mode * @return string|bool|null * @throws \RuntimeException on connection error + *@see self::write() */ - public function read($expect = '', $mode = self::READ_SIMPLE) + public function read(string $expect = '', int $mode = self::READ_SIMPLE) { $this->curTimeout = $this->timeout; $this->is_timeout = false; @@ -2866,7 +2822,7 @@ class SSH2 while (true) { if ($mode == self::READ_REGEX) { preg_match($expect, substr($this->interactiveBuffer, -1024), $matches); - $match = isset($matches[0]) ? $matches[0] : ''; + $match = $matches[0] ?? ''; } $pos = strlen($match) ? strpos($this->interactiveBuffer, $match) : false; if ($pos !== false) { @@ -2885,12 +2841,10 @@ class SSH2 /** * Inputs a command into an interactive shell. * - * @see SSH2::read() - * @param string $cmd - * @return void * @throws \RuntimeException on connection error + *@see SSH2::read() */ - public function write($cmd) + public function write(string $cmd): void { if (!$this->isAuthenticated()) { throw new InsufficientSetupException('Operation disallowed prior to login()'); @@ -2912,11 +2866,9 @@ class SSH2 * returns that and then that that was passed into stopSubsystem() but that'll be saved for a future date and implemented * if there's sufficient demand for such a feature. * - * @see self::stopSubsystem() - * @param string $subsystem - * @return bool + *@see self::stopSubsystem() */ - public function startSubsystem($subsystem) + public function startSubsystem(string $subsystem): bool { $this->window_size_server_to_client[self::CHANNEL_SUBSYSTEM] = $this->window_size; @@ -2963,9 +2915,8 @@ class SSH2 * Stops a subsystem. * * @see self::startSubsystem() - * @return bool */ - public function stopSubsystem() + public function stopSubsystem(): bool { $this->in_subsystem = false; $this->close_channel(self::CHANNEL_SUBSYSTEM); @@ -2976,9 +2927,8 @@ class SSH2 * Closes a channel * * If read() timed out you might want to just close the channel and have it auto-restart on the next read() call - * */ - public function reset() + public function reset(): void { $this->close_channel($this->get_interactive_channel()); } @@ -2987,18 +2937,16 @@ class SSH2 * Is timeout? * * Did exec() or read() return because they timed out or because they encountered the end? - * */ - public function isTimeout() + public function isTimeout(): bool { return $this->is_timeout; } /** * Disconnect - * */ - public function disconnect() + public function disconnect(): void { $this->disconnect_helper(DisconnectReason::BY_APPLICATION); if (isset($this->realtime_log_file) && is_resource($this->realtime_log_file)) { @@ -3012,7 +2960,6 @@ class SSH2 * * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call * disconnect(). - * */ public function __destruct() { @@ -3021,20 +2968,16 @@ class SSH2 /** * Is the connection still active? - * - * @return bool */ - public function isConnected() + public function isConnected(): bool { return (bool) ($this->bitmap & self::MASK_CONNECTED); } /** * Have you successfully been logged in? - * - * @return bool */ - public function isAuthenticated() + public function isAuthenticated(): bool { return (bool) ($this->bitmap & self::MASK_LOGIN); } @@ -3043,10 +2986,8 @@ class SSH2 * Pings a server connection, or tries to reconnect if the connection has gone down * * Inspired by http://php.net/manual/en/mysqli.ping.php - * - * @return bool */ - public function ping() + public function ping(): bool { if (!$this->isAuthenticated()) { if (!empty($this->auth)) { @@ -3085,7 +3026,7 @@ class SSH2 * * @return boolean */ - private function reconnect() + private function reconnect(): bool { $this->reset_connection(DisconnectReason::CONNECTION_LOST); $this->retry_connect = true; @@ -3098,10 +3039,8 @@ class SSH2 /** * Resets a connection for re-use - * - * @param int $reason */ - protected function reset_connection($reason) + protected function reset_connection(int $reason): void { $this->disconnect_helper($reason); $this->decrypt = $this->encrypt = false; @@ -3118,11 +3057,10 @@ class SSH2 * * See '6. Binary Packet Protocol' of rfc4253 for more info. * - * @see self::_send_binary_packet() - * @param bool $skip_channel_filter * @return bool|string + *@see self::_send_binary_packet() */ - private function get_binary_packet($skip_channel_filter = false) + private function get_binary_packet(bool $skip_channel_filter = false) { if ($skip_channel_filter) { if (!is_resource($this->fsock)) { @@ -3372,11 +3310,10 @@ class SSH2 /** * Read Remaining Bytes * - * @see self::get_binary_packet() - * @param int $remaining_length * @return string + *@see self::get_binary_packet() */ - private function read_remaining_bytes($remaining_length) + private function read_remaining_bytes(int $remaining_length) { if (!$remaining_length) { return ''; @@ -3430,17 +3367,15 @@ class SSH2 * * Because some binary packets need to be ignored... * - * @see self::_get_binary_packet() - * @param string $payload - * @param bool $skip_channel_filter * @return string|bool + *@see self::_get_binary_packet() */ - private function filter($payload, $skip_channel_filter) + private function filter(string $payload, bool $skip_channel_filter) { switch (ord($payload[0])) { case MessageType::DISCONNECT: Strings::shift($payload, 1); - list($reason_code, $message) = Strings::unpackSSH2('Ns', $payload); + [$reason_code, $message] = Strings::unpackSSH2('Ns', $payload); $this->errors[] = 'SSH_MSG_DISCONNECT: SSH_DISCONNECT_' . DisconnectReason::getConstantNameByValue($reason_code) . "\r\n$message"; $this->bitmap = 0; return false; @@ -3449,7 +3384,7 @@ class SSH2 break; case MessageType::DEBUG: Strings::shift($payload, 2); // second byte is "always_display" - list($message) = Strings::unpackSSH2('s', $payload); + [$message] = Strings::unpackSSH2('s', $payload); $this->errors[] = "SSH_MSG_DEBUG: $message"; $payload = $this->get_binary_packet($skip_channel_filter); break; @@ -3468,7 +3403,7 @@ class SSH2 // see http://tools.ietf.org/html/rfc4252#section-5.4; only called when the encryption has been activated and when we haven't already logged in if (($this->bitmap & self::MASK_CONNECTED) && !$this->isAuthenticated() && !is_bool($payload) && ord($payload[0]) == MessageType::USERAUTH_BANNER) { Strings::shift($payload, 1); - list($this->banner_message) = Strings::unpackSSH2('s', $payload); + [$this->banner_message] = Strings::unpackSSH2('s', $payload); $payload = $this->get_binary_packet(); } @@ -3502,7 +3437,7 @@ class SSH2 break; case MessageType::GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 Strings::shift($payload, 1); - list($request_name) = Strings::unpackSSH2('s', $payload); + [$request_name] = Strings::unpackSSH2('s', $payload); $this->errors[] = "SSH_MSG_GLOBAL_REQUEST: $request_name"; try { @@ -3515,17 +3450,17 @@ class SSH2 break; case MessageType::CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1 Strings::shift($payload, 1); - list($data, $server_channel) = Strings::unpackSSH2('sN', $payload); + [$data, $server_channel] = Strings::unpackSSH2('sN', $payload); switch ($data) { case 'auth-agent': case 'auth-agent@openssh.com': if (isset($this->agent)) { $new_channel = self::CHANNEL_AGENT_FORWARD; - list( + [ $remote_window_size, $remote_maximum_packet_size - ) = Strings::unpackSSH2('NN', $payload); + ] = Strings::unpackSSH2('NN', $payload); $this->packet_size_client_to_server[$new_channel] = $remote_window_size; $this->window_size_server_to_client[$new_channel] = $remote_maximum_packet_size; @@ -3568,7 +3503,7 @@ class SSH2 break; case MessageType::CHANNEL_WINDOW_ADJUST: Strings::shift($payload, 1); - list($channel, $window_size) = Strings::unpackSSH2('NN', $payload); + [$channel, $window_size] = Strings::unpackSSH2('NN', $payload); $this->window_size_client_to_server[$channel] += $window_size; @@ -3583,9 +3518,8 @@ class SSH2 * Enable Quiet Mode * * Suppress stderr from output - * */ - public function enableQuietMode() + public function enableQuietMode(): void { $this->quiet_mode = true; } @@ -3594,9 +3528,8 @@ class SSH2 * Disable Quiet Mode * * Show stderr in output - * */ - public function disableQuietMode() + public function disableQuietMode(): void { $this->quiet_mode = false; } @@ -3606,27 +3539,24 @@ class SSH2 * * @see self::enableQuietMode() * @see self::disableQuietMode() - * @return bool */ - public function isQuietModeEnabled() + public function isQuietModeEnabled(): bool { return $this->quiet_mode; } /** * Enable request-pty when using exec() - * */ - public function enablePTY() + public function enablePTY(): void { $this->request_pty = true; } /** * Disable request-pty when using exec() - * */ - public function disablePTY() + public function disablePTY(): void { if ($this->in_request_pty_exec) { $this->close_channel(self::CHANNEL_EXEC); @@ -3640,9 +3570,8 @@ class SSH2 * * @see self::enablePTY() * @see self::disablePTY() - * @return bool */ - public function isPTYEnabled() + public function isPTYEnabled(): bool { return $this->request_pty; } @@ -3661,12 +3590,9 @@ class SSH2 * * - if the channel status is CHANNEL_REQUEST and the response was CHANNEL_FAILURE * - * @param int $client_channel - * @param bool $skip_extended - * @return mixed * @throws \RuntimeException on connection error */ - protected function get_channel_packet($client_channel, $skip_extended = false) + protected function get_channel_packet(int $client_channel, bool $skip_extended = false) { if (!empty($this->channel_buffers[$client_channel])) { switch ($this->channel_status[$client_channel]) { @@ -3706,7 +3632,7 @@ class SSH2 if ($client_channel == -1 && $response === true) { return true; } - list($type, $channel) = Strings::unpackSSH2('CN', $response); + [$type, $channel] = Strings::unpackSSH2('CN', $response); // will not be setup yet on incoming channel open request if (isset($channel) && isset($this->channel_status[$channel]) && isset($this->window_size_server_to_client[$channel])) { @@ -3729,7 +3655,7 @@ class SSH2 } */ // currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR - list($data_type_code, $data) = Strings::unpackSSH2('Ns', $response); + [$data_type_code, $data] = Strings::unpackSSH2('Ns', $response); $this->stdErrorLog .= $data; if ($skip_extended || $this->quiet_mode) { continue 2; @@ -3744,15 +3670,15 @@ class SSH2 if ($this->channel_status[$channel] == MessageType::CHANNEL_CLOSE) { continue 2; } - list($value) = Strings::unpackSSH2('s', $response); + [$value] = Strings::unpackSSH2('s', $response); switch ($value) { case 'exit-signal': - list( + [ , // FALSE $signal_name, , // core dumped $error_message - ) = Strings::unpackSSH2('bsbs', $response); + ] = Strings::unpackSSH2('bsbs', $response); $this->errors[] = "SSH_MSG_CHANNEL_REQUEST (exit-signal): $signal_name"; if (strlen($error_message)) { @@ -3766,7 +3692,7 @@ class SSH2 continue 3; case 'exit-status': - list(, $this->exit_status) = Strings::unpackSSH2('CN', $response); + [, $this->exit_status] = Strings::unpackSSH2('CN', $response); // "The client MAY ignore these messages." // -- http://tools.ietf.org/html/rfc4254#section-6.10 @@ -3783,11 +3709,11 @@ class SSH2 case MessageType::CHANNEL_OPEN: switch ($type) { case MessageType::CHANNEL_OPEN_CONFIRMATION: - list( + [ $this->server_channels[$channel], $window_size, $this->packet_size_client_to_server[$channel] - ) = Strings::unpackSSH2('NNN', $response); + ] = Strings::unpackSSH2('NNN', $response); if ($window_size < 0) { $window_size &= 0x7FFFFFFF; @@ -3815,7 +3741,7 @@ class SSH2 case MessageType::CHANNEL_FAILURE: return false; case MessageType::CHANNEL_DATA: - list($data) = Strings::unpackSSH2('s', $response); + [$data] = Strings::unpackSSH2('s', $response); $this->channel_buffers[$channel][] = chr($type) . $data; return $this->get_channel_packet($client_channel, $skip_extended); default: @@ -3840,7 +3766,7 @@ class SSH2 $this->send_channel_packet($channel, chr(0)); } */ - list($data) = Strings::unpackSSH2('s', $response); + [$data] = Strings::unpackSSH2('s', $response); if ($channel == self::CHANNEL_AGENT_FORWARD) { $agent_response = $this->agent->forwardData($data); @@ -3884,12 +3810,9 @@ class SSH2 * * See '6. Binary Packet Protocol' of rfc4253 for more info. * - * @param string $data - * @param string $logged * @see self::_get_binary_packet() - * @return void */ - protected function send_binary_packet($data, $logged = null) + protected function send_binary_packet(string $data, string $logged = null): void { if (!is_resource($this->fsock) || feof($this->fsock)) { $this->bitmap = 0; @@ -4034,11 +3957,8 @@ class SSH2 * Logs data packets * * Makes sure that only the last 1MB worth of packets will be logged - * - * @param string $message_number - * @param string $message */ - private function append_log($message_number, $message) + private function append_log(string $message_number, string $message): void { if (!defined('NET_SSH2_LOGGING')) { return; @@ -4114,12 +4034,8 @@ class SSH2 * Sends channel data * * Spans multiple SSH_MSG_CHANNEL_DATAs if appropriate - * - * @param int $client_channel - * @param string $data - * @return void */ - protected function send_channel_packet($client_channel, $data) + protected function send_channel_packet(int $client_channel, string $data): void { while (strlen($data)) { if (!$this->window_size_client_to_server[$client_channel]) { @@ -4156,12 +4072,8 @@ class SSH2 * \phpseclib3\Net\SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server * and for SFTP channels are presumably closed when the client disconnects. This functions is intended * for SCP more than anything. - * - * @param int $client_channel - * @param bool $want_reply - * @return void */ - private function close_channel($client_channel, $want_reply = false) + private function close_channel(int $client_channel, bool $want_reply = false): void { // see http://tools.ietf.org/html/rfc4254#section-5.3 @@ -4194,10 +4106,9 @@ class SSH2 /** * Disconnect * - * @param int $reason * @return false */ - protected function disconnect_helper($reason) + protected function disconnect_helper(int $reason): bool { if ($this->bitmap & self::MASK_CONNECTED) { $data = Strings::packSSH2('CNss', MessageType::DISCONNECT, $reason, '', ''); @@ -4241,12 +4152,8 @@ class SSH2 /** * Formats a log for printing - * - * @param array $message_log - * @param array $message_number_log - * @return string */ - protected function format_log($message_log, $message_number_log) + protected function format_log(array $message_log, array $message_number_log): string { $output = ''; for ($i = 0; $i < count($message_log); $i++) { @@ -4280,9 +4187,8 @@ class SSH2 * Used when channels are created to inform agent * of said channel opening. Must be called after * channel open confirmation received - * */ - private function on_channel_open() + private function on_channel_open(): void { if (isset($this->agent)) { $this->agent->registerChannelOpen($this); @@ -4293,11 +4199,9 @@ class SSH2 * Returns the first value of the intersection of two arrays or false if * the intersection is empty. The order is defined by the first parameter. * - * @param array $array1 - * @param array $array2 * @return mixed False if intersection is empty, else intersected value. */ - private static function array_intersect_first($array1, $array2) + private static function array_intersect_first(array $array1, array $array2) { foreach ($array1 as $value) { if (in_array($value, $array2)) { @@ -4312,17 +4216,15 @@ class SSH2 * * @return string[] */ - public function getErrors() + public function getErrors(): array { return $this->errors; } /** * Returns the last error - * - * @return string */ - public function getLastError() + public function getLastError(): string { $count = count($this->errors); @@ -4345,10 +4247,8 @@ class SSH2 /** * Returns a list of algorithms the server supports - * - * @return array */ - public function getServerAlgorithms() + public function getServerAlgorithms(): array { $this->connect(); @@ -4372,10 +4272,8 @@ class SSH2 /** * Returns a list of KEX algorithms that phpseclib supports - * - * @return array */ - public static function getSupportedKEXAlgorithms() + public static function getSupportedKEXAlgorithms(): array { $kex_algorithms = [ // Elliptic Curve Diffie-Hellman Key Agreement (ECDH) using @@ -4408,10 +4306,8 @@ class SSH2 /** * Returns a list of host key algorithms that phpseclib supports - * - * @return array */ - public static function getSupportedHostKeyAlgorithms() + public static function getSupportedHostKeyAlgorithms(): array { return [ 'ssh-ed25519', // https://tools.ietf.org/html/draft-ietf-curdle-ssh-ed25519-02 @@ -4427,10 +4323,8 @@ class SSH2 /** * Returns a list of symmetric key algorithms that phpseclib supports - * - * @return array */ - public static function getSupportedEncryptionAlgorithms() + public static function getSupportedEncryptionAlgorithms(): array { $algos = [ // from : @@ -4502,7 +4396,7 @@ class SSH2 foreach ($algos as $algo) { $obj = self::encryption_algorithm_to_crypt_instance($algo); if ($obj instanceof Rijndael) { - $obj->setKeyLength(preg_replace('#[^\d]#', '', $algo)); + $obj->setKeyLength((int) preg_replace('#[^\d]#', '', $algo)); } switch ($algo) { case 'chacha20-poly1305@openssh.com': @@ -4531,10 +4425,8 @@ class SSH2 /** * Returns a list of MAC algorithms that phpseclib supports - * - * @return array */ - public static function getSupportedMACAlgorithms() + public static function getSupportedMACAlgorithms(): array { return [ 'hmac-sha2-256-etm@openssh.com', @@ -4561,10 +4453,8 @@ class SSH2 /** * Returns a list of compression algorithms that phpseclib supports - * - * @return array */ - public static function getSupportedCompressionAlgorithms() + public static function getSupportedCompressionAlgorithms(): array { $algos = ['none']; // REQUIRED no compression if (function_exists('deflate_init')) { @@ -4578,10 +4468,8 @@ class SSH2 * Return list of negotiated algorithms * * Uses the same format as https://www.php.net/ssh2-methods-negotiated - * - * @return array */ - public function getAlgorithmsNegotiated() + public function getAlgorithmsNegotiated(): array { $this->connect(); @@ -4609,10 +4497,8 @@ class SSH2 /** * Allows you to set the terminal - * - * @param string $term */ - public function setTerminal($term) + public function setTerminal(string $term): void { $this->term = $term; } @@ -4620,10 +4506,8 @@ class SSH2 /** * Accepts an associative array with up to four parameters as described at * - * - * @param array $methods */ - public function setPreferredAlgorithms(array $methods) + public function setPreferredAlgorithms(array $methods): void { $preferred = $methods; @@ -4706,10 +4590,8 @@ class SSH2 * * Quoting from the RFC, "in some jurisdictions, sending a warning message before * authentication may be relevant for getting legal protection." - * - * @return string */ - public function getBannerMessage() + public function getBannerMessage(): string { return $this->banner_message; } @@ -4774,7 +4656,7 @@ class SSH2 // could be ssh-rsa, rsa-sha2-256, rsa-sha2-512 // we don't check here because we already checked in key_exchange // some signatures have the type embedded within the message and some don't - list(, $signature) = Strings::unpackSSH2('ss', $signature); + [, $signature] = Strings::unpackSSH2('ss', $signature); $key = RSA::loadFormat('OpenSSH', $server_public_host_key) ->withPadding(RSA::SIGNATURE_PKCS1); @@ -4818,51 +4700,40 @@ class SSH2 /** * Returns the number of columns for the terminal window size. - * - * @return int */ - public function getWindowColumns() + public function getWindowColumns(): int { return $this->windowColumns; } /** * Returns the number of rows for the terminal window size. - * - * @return int */ - public function getWindowRows() + public function getWindowRows(): int { return $this->windowRows; } /** * Sets the number of columns for the terminal window size. - * - * @param int $value */ - public function setWindowColumns($value) + public function setWindowColumns(int $value): void { $this->windowColumns = $value; } /** * Sets the number of rows for the terminal window size. - * - * @param int $value */ - public function setWindowRows($value) + public function setWindowRows(int $value): void { $this->windowRows = $value; } /** * Sets the number of columns and rows for the terminal window size. - * - * @param int $columns - * @param int $rows */ - public function setWindowSize($columns = 80, $rows = 24) + public function setWindowSize(int $columns = 80, int $rows = 24): void { $this->windowColumns = $columns; $this->windowRows = $rows; @@ -4886,10 +4757,8 @@ class SSH2 * {@link http://tools.ietf.org/html/rfc3986#section-2 RFC}. * It will safe us from any conflicts, because otherwise regexp will * match all alphanumeric domains. - * - * @return string */ - public function getResourceId() + public function getResourceId(): string { return '{' . spl_object_hash($this) . '}'; } @@ -4897,11 +4766,9 @@ class SSH2 /** * Return existing connection * - * @param string $id - * * @return bool|SSH2 will return false if no such connection */ - public static function getConnectionByResourceId($id) + public static function getConnectionByResourceId(string $id) { if (isset(self::$connections[$id])) { return self::$connections[$id] instanceof \WeakReference ? self::$connections[$id]->get() : self::$connections[$id]; @@ -4914,7 +4781,7 @@ class SSH2 * * @return array */ - public static function getConnections() + public static function getConnections(): array { if (!class_exists('WeakReference')) { /** @var array */ @@ -4929,11 +4796,8 @@ class SSH2 /** * Update packet types in log history - * - * @param string $old - * @param string $new */ - private function updateLogHistory($old, $new) + private function updateLogHistory(string $old, string $new): void { if (defined('NET_SSH2_LOGGING') && NET_SSH2_LOGGING == self::LOG_COMPLEX) { $this->message_number_log[count($this->message_number_log) - 1] = str_replace( @@ -4948,9 +4812,8 @@ class SSH2 * Return the list of authentication methods that may productively continue authentication. * * @see https://tools.ietf.org/html/rfc4252#section-5.1 - * @return array|null */ - public function getAuthMethodsToContinue() + public function getAuthMethodsToContinue(): ?array { return $this->auth_methods_to_continue; } @@ -4958,7 +4821,7 @@ class SSH2 /** * Enables "smart" multi-factor authentication (MFA) */ - public function enableSmartMFA() + public function enableSmartMFA(): void { $this->smartMFA = true; } @@ -4966,7 +4829,7 @@ class SSH2 /** * Disables "smart" multi-factor authentication (MFA) */ - public function disableSmartMFA() + public function disableSmartMFA(): void { $this->smartMFA = false; } diff --git a/phpseclib/Net/SSH2/ChannelConnectionFailureReason.php b/phpseclib/Net/SSH2/ChannelConnectionFailureReason.php index d83453c5..e759b2d2 100644 --- a/phpseclib/Net/SSH2/ChannelConnectionFailureReason.php +++ b/phpseclib/Net/SSH2/ChannelConnectionFailureReason.php @@ -1,5 +1,7 @@ fsock) { return []; @@ -164,16 +165,16 @@ class Agent $length = current(unpack('N', $this->readBytes(4))); $packet = $this->readBytes($length); - list($type, $keyCount) = Strings::unpackSSH2('CN', $packet); + [$type, $keyCount] = Strings::unpackSSH2('CN', $packet); if ($type != self::SSH_AGENT_IDENTITIES_ANSWER) { throw new \RuntimeException('Unable to request identities'); } $identities = []; for ($i = 0; $i < $keyCount; $i++) { - list($key_blob, $comment) = Strings::unpackSSH2('ss', $packet); + [$key_blob, $comment] = Strings::unpackSSH2('ss', $packet); $temp = $key_blob; - list($key_type) = Strings::unpackSSH2('s', $temp); + [$key_type] = Strings::unpackSSH2('s', $temp); switch ($key_type) { case 'ssh-rsa': case 'ssh-dss': @@ -199,10 +200,8 @@ class Agent /** * Signal that agent forwarding should * be requested when a channel is opened - * - * @return void */ - public function startSSHForwarding() + public function startSSHForwarding(): void { if ($this->forward_status == self::FORWARD_NONE) { $this->forward_status = self::FORWARD_REQUEST; @@ -211,11 +210,8 @@ class Agent /** * Request agent forwarding of remote server - * - * @param \phpseclib3\Net\SSH2 $ssh - * @return bool */ - private function request_forwarding($ssh) + private function request_forwarding(\phpseclib3\Net\SSH2 $ssh): bool { if (!$ssh->requestAgentForwarding()) { return false; @@ -232,10 +228,8 @@ class Agent * This method is called upon successful channel * open to give the SSH Agent an opportunity * to take further action. i.e. request agent forwarding - * - * @param \phpseclib3\Net\SSH2 $ssh */ - public function registerChannelOpen($ssh) + public function registerChannelOpen(\phpseclib3\Net\SSH2 $ssh): void { if ($this->forward_status == self::FORWARD_REQUEST) { $this->request_forwarding($ssh); @@ -245,11 +239,10 @@ class Agent /** * Forward data to SSH Agent and return data reply * - * @param string $data * @return string Data from SSH Agent * @throws \RuntimeException on connection errors */ - public function forwardData($data) + public function forwardData(string $data) { if ($this->expected_bytes > 0) { $this->socket_buffer .= $data; diff --git a/phpseclib/System/SSH/Agent/Identity.php b/phpseclib/System/SSH/Agent/Identity.php index a7979f06..804a0097 100644 --- a/phpseclib/System/SSH/Agent/Identity.php +++ b/phpseclib/System/SSH/Agent/Identity.php @@ -13,6 +13,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\System\SSH\Agent; use phpseclib3\Common\Functions\Strings; @@ -105,10 +107,8 @@ class Identity implements PrivateKey * Set Public Key * * Called by \phpseclib3\System\SSH\Agent::requestIdentities() - * - * @param \phpseclib3\Crypt\Common\PublicKey $key */ - public function withPublicKey($key) + public function withPublicKey(PublicKey $key): Identity { if ($key instanceof EC) { if (is_array($key->getCurve()) || !isset(self::$curveAliases[$key->getCurve()])) { @@ -126,10 +126,8 @@ class Identity implements PrivateKey * * Called by \phpseclib3\System\SSH\Agent::requestIdentities(). The key blob could be extracted from $this->key * but this saves a small amount of computation. - * - * @param string $key_blob */ - public function withPublicKeyBlob($key_blob) + public function withPublicKeyBlob(string $key_blob): Identity { $new = clone $this; $new->key_blob = $key_blob; @@ -142,19 +140,16 @@ class Identity implements PrivateKey * Wrapper for $this->key->getPublicKey() * * @param string $type optional - * @return mixed */ - public function getPublicKey($type = 'PKCS8') + public function getPublicKey(string $type = 'PKCS8'): PublicKey { return $this->key; } /** * Sets the hash - * - * @param string $hash */ - public function withHash($hash) + public function withHash(string $hash): Identity { $new = clone $this; @@ -204,10 +199,8 @@ class Identity implements PrivateKey * Sets the padding * * Only PKCS1 padding is supported - * - * @param string $padding */ - public function withPadding($padding) + public function withPadding(int $padding): Identity { if (!$this->key instanceof RSA) { throw new UnsupportedAlgorithmException('Only RSA keys support padding'); @@ -222,10 +215,8 @@ class Identity implements PrivateKey * Determines the signature padding mode * * Valid values are: ASN1, SSH2, Raw - * - * @param string $format */ - public function withSignatureFormat($format) + public function withSignatureFormat(string $format): Identity { if ($this->key instanceof RSA) { throw new UnsupportedAlgorithmException('Only DSA and EC keys support signature format setting'); @@ -259,11 +250,10 @@ class Identity implements PrivateKey * See "2.6.2 Protocol 2 private key signature request" * * @param string $message - * @return string * @throws \RuntimeException on connection errors * @throws \phpseclib3\Exception\UnsupportedAlgorithmException if the algorithm is unsupported */ - public function sign($message) + public function sign($message): string { // the last parameter (currently 0) is for flags and ssh-agent only defines one flag (for ssh-dss): SSH_AGENT_OLD_SIGNATURE $packet = Strings::packSSH2( @@ -281,7 +271,7 @@ class Identity implements PrivateKey $length = current(unpack('N', $this->readBytes(4))); $packet = $this->readBytes($length); - list($type, $signature_blob) = Strings::unpackSSH2('Cs', $packet); + [$type, $signature_blob] = Strings::unpackSSH2('Cs', $packet); if ($type != Agent::SSH_AGENT_SIGN_RESPONSE) { throw new \RuntimeException('Unable to retrieve signature'); } @@ -290,7 +280,7 @@ class Identity implements PrivateKey return $signature_blob; } - list($type, $signature_blob) = Strings::unpackSSH2('ss', $signature_blob); + [$type, $signature_blob] = Strings::unpackSSH2('ss', $signature_blob); return $signature_blob; } @@ -298,11 +288,9 @@ class Identity implements PrivateKey /** * Returns the private key * - * @param string $type * @param array $options optional - * @return string */ - public function toString($type, array $options = []) + public function toString(string $type, array $options = []): string { throw new \RuntimeException('ssh-agent does not provide a mechanism to get the private key'); } diff --git a/phpseclib/System/SSH/Common/Traits/ReadBytes.php b/phpseclib/System/SSH/Common/Traits/ReadBytes.php index 6fd032bd..6e1ef5b5 100644 --- a/phpseclib/System/SSH/Common/Traits/ReadBytes.php +++ b/phpseclib/System/SSH/Common/Traits/ReadBytes.php @@ -11,6 +11,8 @@ * @link http://phpseclib.sourceforge.net */ +declare(strict_types=1); + namespace phpseclib3\System\SSH\Common\Traits; /** @@ -23,10 +25,9 @@ trait ReadBytes /** * Read data * - * @param int $length * @throws \RuntimeException on connection errors */ - public function readBytes($length) + public function readBytes(int $length) { $temp = fread($this->fsock, $length); if (strlen($temp) != $length) { diff --git a/tests/Functional/Net/SFTPLargeFileTest.php b/tests/Functional/Net/SFTPLargeFileTest.php index f99bb3ae..b1d2f216 100644 --- a/tests/Functional/Net/SFTPLargeFileTest.php +++ b/tests/Functional/Net/SFTPLargeFileTest.php @@ -6,13 +6,15 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Functional\Net; use phpseclib3\Net\SFTP; class SFTPLargeFileTest extends SFTPTestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!extension_loaded('mcrypt') && !extension_loaded('openssl')) { self::markTestSkipped('This test depends on mcrypt or openssl for performance.'); @@ -26,7 +28,7 @@ class SFTPLargeFileTest extends SFTPTestCase * @group github455 * @group github457 */ - public function testPutSizeLocalFile() + public function testPutSizeLocalFile(): void { $tmp_filename = $this->createTempFile(128, 1024 * 1024); $filename = 'file-large-from-local.txt'; diff --git a/tests/Functional/Net/SFTPStreamTest.php b/tests/Functional/Net/SFTPStreamTest.php index c8a5c1a5..c219f53d 100644 --- a/tests/Functional/Net/SFTPStreamTest.php +++ b/tests/Functional/Net/SFTPStreamTest.php @@ -6,19 +6,21 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Functional\Net; use phpseclib3\Net\SFTP\Stream; class SFTPStreamTest extends SFTPTestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { Stream::register(); parent::setUpBeforeClass(); } - public function testFopenFcloseCreatesFile() + public function testFopenFcloseCreatesFile(): void { $context = stream_context_create([ 'sftp' => ['session' => $this->sftp], @@ -32,7 +34,7 @@ class SFTPStreamTest extends SFTPTestCase /** * @group github778 */ - public function testFilenameWithHash() + public function testFilenameWithHash(): void { $context = stream_context_create([ 'sftp' => ['session' => $this->sftp], @@ -48,7 +50,7 @@ class SFTPStreamTest extends SFTPTestCase * Tests connection reuse functionality same as ssh2 extension: * {@link http://php.net/manual/en/wrappers.ssh2.php#refsect1-wrappers.ssh2-examples} */ - public function testConnectionReuse() + public function testConnectionReuse(): void { $originalConnectionsCount = count(\phpseclib3\Net\SSH2::getConnections()); $session = $this->sftp; @@ -60,7 +62,7 @@ class SFTPStreamTest extends SFTPTestCase /** * @group github1552 */ - public function testStreamSelect() + public function testStreamSelect(): void { $context = stream_context_create([ 'sftp' => ['session' => $this->sftp], @@ -71,7 +73,7 @@ class SFTPStreamTest extends SFTPTestCase stream_select($read, $write, $except, 0); } - protected function buildUrl($suffix) + protected function buildUrl($suffix): string { return sprintf( 'sftp://via-context/%s/%s', diff --git a/tests/Functional/Net/SFTPTestCase.php b/tests/Functional/Net/SFTPTestCase.php index 3ee9d487..4db99063 100644 --- a/tests/Functional/Net/SFTPTestCase.php +++ b/tests/Functional/Net/SFTPTestCase.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Functional\Net; use phpseclib3\Net\SFTP; @@ -22,7 +24,7 @@ abstract class SFTPTestCase extends PhpseclibFunctionalTestCase protected $sftp; protected $scratchDir; - public function setUp() + public function setUp(): void { parent::setUp(); $this->scratchDir = uniqid('phpseclib-sftp-scratch-'); @@ -36,7 +38,7 @@ abstract class SFTPTestCase extends PhpseclibFunctionalTestCase $this->assertTrue($this->sftp->chdir($this->scratchDir)); } - public function tearDown() + public function tearDown(): void { if ($this->sftp) { $this->sftp->chdir($this->getEnv('SSH_HOME')); diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 63e0d942..e69fc61b 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Functional\Net; use phpseclib3\Net\SFTP; @@ -19,7 +21,7 @@ class SFTPUserStoryTest extends PhpseclibFunctionalTestCase protected static $exampleDataLength; protected static $buffer; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -29,7 +31,7 @@ class SFTPUserStoryTest extends PhpseclibFunctionalTestCase self::$exampleDataLength = 10000; } - public function testConstructor() + public function testConstructor(): SFTP { $sftp = new SFTP($this->getEnv('SSH_HOSTNAME')); @@ -781,7 +783,7 @@ class SFTPUserStoryTest extends PhpseclibFunctionalTestCase /** * @depends testRawlistDisabledStatCache */ - public function testChownChgrp($sftp) + public function testChownChgrp($sftp): void { $stat = $sftp->stat(self::$scratchDir); $this->assertTrue($sftp->chown(self::$scratchDir, $stat['uid'])); diff --git a/tests/Functional/Net/SFTPWrongServerTest.php b/tests/Functional/Net/SFTPWrongServerTest.php index 5b4f57dc..96ae7d74 100644 --- a/tests/Functional/Net/SFTPWrongServerTest.php +++ b/tests/Functional/Net/SFTPWrongServerTest.php @@ -1,5 +1,7 @@ login('username', 'password'); diff --git a/tests/Functional/Net/SSH2AgentTest.php b/tests/Functional/Net/SSH2AgentTest.php index 1b0a62d5..77a44145 100644 --- a/tests/Functional/Net/SSH2AgentTest.php +++ b/tests/Functional/Net/SSH2AgentTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Functional\Net; use phpseclib3\Net\SSH2; @@ -14,7 +16,7 @@ use phpseclib3\Tests\PhpseclibFunctionalTestCase; class SSH2AgentTest extends PhpseclibFunctionalTestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!isset($_SERVER['SSH_AUTH_SOCK'])) { self::markTestSkipped( @@ -24,7 +26,7 @@ class SSH2AgentTest extends PhpseclibFunctionalTestCase parent::setUpBeforeClass(); } - public function testAgentLogin() + public function testAgentLogin(): array { $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); $agent = new Agent(); diff --git a/tests/Functional/Net/SSH2Test.php b/tests/Functional/Net/SSH2Test.php index 0995ded4..38e615e7 100644 --- a/tests/Functional/Net/SSH2Test.php +++ b/tests/Functional/Net/SSH2Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Functional\Net; use phpseclib3\Net\SSH2; @@ -13,7 +15,7 @@ use phpseclib3\Tests\PhpseclibFunctionalTestCase; class SSH2Test extends PhpseclibFunctionalTestCase { - public function testConstructor() + public function testConstructor(): SSH2 { $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); @@ -30,7 +32,7 @@ class SSH2Test extends PhpseclibFunctionalTestCase * @group github408 * @group github412 */ - public function testPreLogin(SSH2 $ssh) + public function testPreLogin(SSH2 $ssh): SSH2 { $this->assertFalse( $ssh->isConnected(), @@ -63,7 +65,7 @@ class SSH2Test extends PhpseclibFunctionalTestCase /** * @depends testPreLogin */ - public function testBadPassword(SSH2 $ssh) + public function testBadPassword(SSH2 $ssh): SSH2 { $username = $this->getEnv('SSH_USERNAME'); $password = $this->getEnv('SSH_PASSWORD'); @@ -88,7 +90,7 @@ class SSH2Test extends PhpseclibFunctionalTestCase /** * @depends testBadPassword */ - public function testPasswordLogin(SSH2 $ssh) + public function testPasswordLogin(SSH2 $ssh): SSH2 { $username = $this->getEnv('SSH_USERNAME'); $password = $this->getEnv('SSH_PASSWORD'); @@ -109,7 +111,7 @@ class SSH2Test extends PhpseclibFunctionalTestCase * @depends testPasswordLogin * @group github280 */ - public function testExecWithMethodCallback(SSH2 $ssh) + public function testExecWithMethodCallback(SSH2 $ssh): SSH2 { $callbackObject = $this->getMockBuilder('stdClass') ->setMethods(['callbackMethod']) @@ -123,14 +125,14 @@ class SSH2Test extends PhpseclibFunctionalTestCase return $ssh; } - public function testGetServerPublicHostKey() + public function testGetServerPublicHostKey(): void { $ssh = new SSH2($this->getEnv('SSH_HOSTNAME')); $this->assertIsString($ssh->getServerPublicHostKey()); } - public function testOpenSocketConnect() + public function testOpenSocketConnect(): void { $fsock = fsockopen($this->getEnv('SSH_HOSTNAME'), 22); $ssh = new SSH2($fsock); @@ -147,7 +149,7 @@ class SSH2Test extends PhpseclibFunctionalTestCase * @depends testExecWithMethodCallback * @group github1009 */ - public function testDisablePTY(SSH2 $ssh) + public function testDisablePTY(SSH2 $ssh): SSH2 { $ssh->enablePTY(); $ssh->exec('ls -latr'); @@ -163,7 +165,7 @@ class SSH2Test extends PhpseclibFunctionalTestCase * @depends testDisablePTY * @group github1167 */ - public function testChannelDataAfterOpen(SSH2 $ssh) + public function testChannelDataAfterOpen(SSH2 $ssh): void { // Ubuntu's OpenSSH from 5.8 to 6.9 didn't work with multiple channels. see // https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1334916 for more info. diff --git a/tests/PhpseclibFunctionalTestCase.php b/tests/PhpseclibFunctionalTestCase.php index 8c069bc7..810a4201 100644 --- a/tests/PhpseclibFunctionalTestCase.php +++ b/tests/PhpseclibFunctionalTestCase.php @@ -6,17 +6,16 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests; abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase { /** - * @param string $variable - * @param string|null $message - * * @return null */ - protected function requireEnv($variable, $message = null) + protected function requireEnv(string $variable, string $message = null) { if ($this->_getEnv($variable) === false) { $msg = $message ? $message : sprintf( @@ -28,11 +27,9 @@ abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase } /** - * @param string $variable * - * @return string */ - protected function getEnv($variable) + protected function getEnv(string $variable): string { $this->requireEnv($variable); return $this->_getEnv($variable); @@ -43,7 +40,7 @@ abstract class PhpseclibFunctionalTestCase extends PhpseclibTestCase return getenv($this->_prefixEnvVariable($variable)); } - private function _prefixEnvVariable($variable) + private function _prefixEnvVariable($variable): string { return 'PHPSECLIB_' . $variable; } diff --git a/tests/PhpseclibTestCase.php b/tests/PhpseclibTestCase.php index f40f395f..4c273100 100644 --- a/tests/PhpseclibTestCase.php +++ b/tests/PhpseclibTestCase.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests; use PHPUnit\Framework\TestCase; @@ -14,7 +16,7 @@ abstract class PhpseclibTestCase extends TestCase { protected $tempFilesToUnlinkOnTearDown = []; - public function tearDown() + public function tearDown(): void { foreach ($this->tempFilesToUnlinkOnTearDown as $filename) { if (!file_exists($filename) || unlink($filename)) { @@ -30,13 +32,8 @@ abstract class PhpseclibTestCase extends TestCase * write $number_of_writes * $bytes_per_write times the character 'a' to the * temporary file. All files created using this method will be deleted from * the filesystem on tearDown(), i.e. after each test method was run. - * - * @param int $number_of_writes - * @param int $bytes_per_write - * - * @return string */ - protected function createTempFile($number_of_writes = 0, $bytes_per_write = 0) + protected function createTempFile(int $number_of_writes = 0, int $bytes_per_write = 0): string { $filename = tempnam(sys_get_temp_dir(), 'phpseclib-test-'); $this->assertTrue(file_exists($filename)); @@ -53,12 +50,9 @@ abstract class PhpseclibTestCase extends TestCase } /** - * @param string $constant - * @param mixed $expected - * * @return null */ - protected static function ensureConstant($constant, $expected) + protected static function ensureConstant(string $constant, $expected) { if (defined($constant)) { $value = constant($constant); @@ -103,7 +97,7 @@ abstract class PhpseclibTestCase extends TestCase } // assertIsArray was not introduced until PHPUnit 8 - public static function assertIsArray($actual, $message = '') + public static function assertIsArray($actual, string $message = ''): void { if (method_exists(parent::class, 'assertIsArray')) { parent::assertIsArray($actual, $message); @@ -114,7 +108,7 @@ abstract class PhpseclibTestCase extends TestCase } // assertIsString was not introduced until PHPUnit 8 - public static function assertIsString($actual, $message = '') + public static function assertIsString($actual, string $message = ''): void { if (method_exists(parent::class, 'assertIsString')) { parent::assertIsString($actual, $message); @@ -125,7 +119,7 @@ abstract class PhpseclibTestCase extends TestCase } // assertIsResource was not introduced until PHPUnit 8 - public static function assertIsResource($actual, $message = '') + public static function assertIsResource($actual, string $message = ''): void { if (method_exists(parent::class, 'assertIsResource')) { parent::assertIsResource($actual, $message); @@ -136,7 +130,7 @@ abstract class PhpseclibTestCase extends TestCase } // assertIsObject was not introduced until PHPUnit 8 - public static function assertIsObject($actual, $message = '') + public static function assertIsObject($actual, string $message = ''): void { if (method_exists(parent::class, 'assertIsObject')) { parent::assertIsObject($actual, $message); @@ -147,7 +141,7 @@ abstract class PhpseclibTestCase extends TestCase } // assertContains is deprecated for strings in PHPUnit 8 - public static function assertStringContainsString($needle, $haystack, $message = '') + public static function assertStringContainsString(string $needle, string $haystack, string $message = ''): void { if (method_exists(parent::class, 'assertStringContainsString')) { parent::assertStringContainsString($needle, $haystack, $message); @@ -158,7 +152,7 @@ abstract class PhpseclibTestCase extends TestCase } // assertNotContains is deprecated for strings in PHPUnit 8 - public static function assertStringNotContainsString($needle, $haystack, $message = '') + public static function assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void { if (method_exists(parent::class, 'assertStringContainsString')) { parent::assertStringNotContainsString($needle, $haystack, $message); @@ -170,13 +164,8 @@ abstract class PhpseclibTestCase extends TestCase /** * assertRegExp() was deprecated in favor of assertMatchesRegularExpression(). - * - * @param string $pattern - * @param string $string - * @param string $message - * @return void */ - public static function assertMatchesRegularExpression($pattern, $string, $message = '') + public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void { if (method_exists(parent::class, 'assertMatchesRegularExpression')) { parent::assertMatchesRegularExpression($pattern, $string, $message); diff --git a/tests/Unit/Crypt/AES/EvalTest.php b/tests/Unit/Crypt/AES/EvalTest.php index cbde2956..b48f24cb 100644 --- a/tests/Unit/Crypt/AES/EvalTest.php +++ b/tests/Unit/Crypt/AES/EvalTest.php @@ -6,11 +6,13 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\AES; class EvalTest extends TestCase { - protected function setUp() + protected function setUp(): void { $this->engine = 'Eval'; } diff --git a/tests/Unit/Crypt/AES/McryptTest.php b/tests/Unit/Crypt/AES/McryptTest.php index a1a0b8b0..e4d74eca 100644 --- a/tests/Unit/Crypt/AES/McryptTest.php +++ b/tests/Unit/Crypt/AES/McryptTest.php @@ -6,11 +6,13 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\AES; class McryptTest extends TestCase { - protected function setUp() + protected function setUp(): void { $this->engine = 'mcrypt'; } diff --git a/tests/Unit/Crypt/AES/OpenSSLTest.php b/tests/Unit/Crypt/AES/OpenSSLTest.php index 5fef17eb..ced59ccd 100644 --- a/tests/Unit/Crypt/AES/OpenSSLTest.php +++ b/tests/Unit/Crypt/AES/OpenSSLTest.php @@ -6,11 +6,13 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\AES; class OpenSSLTest extends TestCase { - protected function setUp() + protected function setUp(): void { $this->engine = 'OpenSSL'; } diff --git a/tests/Unit/Crypt/AES/PurePHPTest.php b/tests/Unit/Crypt/AES/PurePHPTest.php index ede8a9b1..d5b5be0b 100644 --- a/tests/Unit/Crypt/AES/PurePHPTest.php +++ b/tests/Unit/Crypt/AES/PurePHPTest.php @@ -6,11 +6,13 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\AES; class PurePHPTest extends TestCase { - protected function setUp() + protected function setUp(): void { $this->engine = 'PHP'; } diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index e42fbc3f..5d9e30fa 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\AES; use phpseclib3\Crypt\AES; @@ -18,7 +20,7 @@ abstract class TestCase extends PhpseclibTestCase { protected $engine; - private function _checkEngine($aes) + private function _checkEngine($aes): void { if ($aes->getEngine() != $this->engine) { self::markTestSkipped('Unable to initialize ' . $this->engine . ' engine'); @@ -27,10 +29,8 @@ abstract class TestCase extends PhpseclibTestCase /** * Produces all combinations of test values. - * - * @return array */ - public function continuousBufferCombos() + public function continuousBufferCombos(): array { $modes = [ 'ctr', @@ -73,7 +73,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @dataProvider continuousBufferCombos */ - public function testEncryptDecryptWithContinuousBuffer($mode, $plaintext, $iv, $key) + public function testEncryptDecryptWithContinuousBuffer($mode, $plaintext, $iv, $key): void { $aes = new AES($mode); $aes->setPreferredEngine($this->engine); @@ -94,7 +94,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @group github451 */ - public function testKeyPaddingRijndael() + public function testKeyPaddingRijndael(): void { // this test case is from the following URL: // https://web.archive.org/web/20070209120224/http://fp.gladman.plus.com/cryptography_technology/rijndael/aesdvec.zip @@ -112,7 +112,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @group github451 */ - public function testKeyPaddingAES() + public function testKeyPaddingAES(): void { $this->expectException('LengthException'); @@ -133,7 +133,7 @@ abstract class TestCase extends PhpseclibTestCase * * @return list */ - public function continuousBufferBatteryCombos() + public function continuousBufferBatteryCombos(): array { $modes = [ 'ctr', @@ -176,7 +176,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @return array */ - public function continuousBufferBatteryCombosWithoutSingleCombos() + public function continuousBufferBatteryCombosWithoutSingleCombos(): array { return array_filter($this->continuousBufferBatteryCombos(), function (array $continuousBufferBatteryCombo) { return count($continuousBufferBatteryCombo[2]) > 1; @@ -186,7 +186,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @dataProvider continuousBufferBatteryCombos */ - public function testContinuousBufferBattery($op, $mode, $test) + public function testContinuousBufferBattery($op, $mode, $test): void { $iv = str_repeat('x', 16); $key = str_repeat('a', 16); @@ -231,7 +231,7 @@ abstract class TestCase extends PhpseclibTestCase * * @dataProvider continuousBufferBatteryCombosWithoutSingleCombos */ - public function testNonContinuousBufferBattery($op, $mode, $test) + public function testNonContinuousBufferBattery($op, $mode, $test): void { $iv = str_repeat('x', 16); $key = str_repeat('a', 16); @@ -271,7 +271,7 @@ abstract class TestCase extends PhpseclibTestCase } // from http://csrc.nist.gov/groups/STM/cavp/documents/aes/AESAVS.pdf#page=16 - public function testGFSBox128() + public function testGFSBox128(): void { $aes = new AES('cbc'); @@ -298,7 +298,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($result, '08a4e2efec8a8e3312ca7460b9040bbf'); } - public function testGFSBox192() + public function testGFSBox192(): void { $aes = new AES('cbc'); @@ -323,7 +323,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($result, '067cd9d3749207791841562507fa9626'); } - public function testGFSBox256() + public function testGFSBox256(): void { $aes = new AES('cbc'); @@ -346,20 +346,20 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($result, '1bc704f1bce135ceb810341b216d7abe'); } - public function testGetKeyLengthDefault() + public function testGetKeyLengthDefault(): void { $aes = new AES('cbc'); $this->assertSame($aes->getKeyLength(), 128); } - public function testGetKeyLengthWith192BitKey() + public function testGetKeyLengthWith192BitKey(): void { $aes = new AES('cbc'); $aes->setKey(str_repeat('a', 24)); $this->assertSame($aes->getKeyLength(), 192); } - public function testSetKeyLengthWithLargerKey() + public function testSetKeyLengthWithLargerKey(): void { $this->expectException(InconsistentSetupException::class); @@ -373,7 +373,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($aes->getKeyLength(), 128); } - public function testSetKeyLengthWithSmallerKey() + public function testSetKeyLengthWithSmallerKey(): void { $this->expectException(InconsistentSetupException::class); @@ -390,7 +390,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @group github938 */ - public function testContinuousBuffer() + public function testContinuousBuffer(): void { $aes = new AES('cbc'); $aes->disablePadding(); @@ -403,7 +403,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($plaintext, $expected); } - public function testECBDecrypt() + public function testECBDecrypt(): void { $aes = new AES('ecb'); $aes->setPreferredEngine($this->engine); @@ -418,7 +418,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertEquals($plaintext, $actual); } - public function testNoKey() + public function testNoKey(): void { $this->expectException(InsufficientSetupException::class); diff --git a/tests/Unit/Crypt/BlowfishTest.php b/tests/Unit/Crypt/BlowfishTest.php index f97dab3e..b9cb7534 100644 --- a/tests/Unit/Crypt/BlowfishTest.php +++ b/tests/Unit/Crypt/BlowfishTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\Blowfish; @@ -14,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class BlowfishTest extends PhpseclibTestCase { - public function engineVectors() + public function engineVectors(): array { $engines = [ 'PHP', @@ -76,7 +78,7 @@ class BlowfishTest extends PhpseclibTestCase /** * @dataProvider engineVectors */ - public function testVectors($engine, $key, $plaintext, $expected) + public function testVectors($engine, $key, $plaintext, $expected): void { $bf = new Blowfish('cbc'); $bf->setKey($key); @@ -92,7 +94,7 @@ class BlowfishTest extends PhpseclibTestCase $this->assertEquals($result, $expected, "Failed asserting that $plaintext yielded expected output in $engine engine"); } - public function testKeySizes() + public function testKeySizes(): void { $objects = $engines = []; $temp = new Blowfish('ctr'); diff --git a/tests/Unit/Crypt/ChaCha20Test.php b/tests/Unit/Crypt/ChaCha20Test.php index 0573473a..56244092 100644 --- a/tests/Unit/Crypt/ChaCha20Test.php +++ b/tests/Unit/Crypt/ChaCha20Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\ChaCha20; @@ -14,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class ChaCha20Test extends PhpseclibTestCase { // see https://tools.ietf.org/html/rfc8439#section-2.3.2 - public function test232() + public function test232(): void { $key = implode('', range("\00", "\x1f")); @@ -45,7 +47,7 @@ class ChaCha20Test extends PhpseclibTestCase } // see https://tools.ietf.org/html/rfc8439#section-2.4.2 - public function test242() + public function test242(): void { $key = implode('', range("\00", "\x1f")); @@ -83,7 +85,7 @@ class ChaCha20Test extends PhpseclibTestCase } // see https://tools.ietf.org/html/rfc8439#section-2.5.2 - public function test252() + public function test252(): void { $key = '85:d6:be:78:57:55:6d:33:7f:44:52:fe:42:d5:06:a8:01:0' . '3:80:8a:fb:0d:b2:fd:4a:bf:f6:af:41:49:f5:1b'; @@ -109,7 +111,7 @@ class ChaCha20Test extends PhpseclibTestCase } // see https://tools.ietf.org/html/rfc8439#section-2.6.2 - public function test262() + public function test262(): void { $key = implode('', range("\x80", "\x9f")); @@ -139,7 +141,7 @@ class ChaCha20Test extends PhpseclibTestCase } // https://tools.ietf.org/html/rfc8439#section-2.8.2 - public function test282() + public function test282(): void { $key = implode('', range("\x80", "\x9f")); @@ -184,7 +186,7 @@ class ChaCha20Test extends PhpseclibTestCase } } - public function testContinuousBuffer() + public function testContinuousBuffer(): void { $key = str_repeat("\0", 16); $nonce = str_repeat("\0", 8); diff --git a/tests/Unit/Crypt/DHTest.php b/tests/Unit/Crypt/DHTest.php index 79fc528d..070d191c 100644 --- a/tests/Unit/Crypt/DHTest.php +++ b/tests/Unit/Crypt/DHTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\AES; @@ -19,10 +21,10 @@ use phpseclib3\Tests\PhpseclibTestCase; class DHTest extends PhpseclibTestCase { - public function testParametersWithString() + public function testParametersWithString(): void { $a = DH::createParameters('diffie-hellman-group1-sha1'); - $a = str_replace("\r\n", "\n", trim($a)); + $a = str_replace("\r\n", "\n", trim($a->__toString())); $b = str_replace("\r\n", "\n", '-----BEGIN DH PARAMETERS----- MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL @@ -31,13 +33,13 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL $this->assertSame($b, "$a"); } - public function testParametersWithInteger() + public function testParametersWithInteger(): void { $a = DH::createParameters(512); $this->assertIsString("$a"); } - public function testParametersWithBigIntegers() + public function testParametersWithBigIntegers(): void { $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . @@ -46,7 +48,7 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL $prime = new BigInteger($prime, 16); $base = new BigInteger(2); $a = DH::createParameters($prime, $base); - $a = str_replace("\r\n", "\n", trim($a)); + $a = str_replace("\r\n", "\n", trim($a->__toString())); $b = str_replace("\r\n", "\n", '-----BEGIN DH PARAMETERS----- MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL @@ -55,7 +57,7 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL $this->assertSame($b, "$a"); } - public function testCreateKey() + public function testCreateKey(): void { $param = DH::createParameters('diffie-hellman-group1-sha1'); $key = DH::createKey($param); @@ -63,7 +65,7 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL $this->assertIsString((string) $key->getPublicKey()); } - public function testLoadPrivate() + public function testLoadPrivate(): void { $a = DH::load('-----BEGIN PRIVATE KEY----- MIIBIgIBADCBlQYJKoZIhvcNAQMBMIGHAoGBAP//////////yQ/aoiFowjTExmKL @@ -79,7 +81,7 @@ eKDXQq5i $this->assertInstanceOf(Parameters::class, $a->getParameters()); } - public function testLoadPublic() + public function testLoadPublic(): void { $a = DH::load('-----BEGIN PUBLIC KEY----- MIIBHzCBlQYJKoZIhvcNAQMBMIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc @@ -93,7 +95,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU $this->assertInstanceOf(PublicKey::class, $a); } - public function testLoadParameters() + public function testLoadParameters(): void { $a = DH::load('-----BEGIN DH PARAMETERS----- MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR @@ -103,7 +105,7 @@ Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL $this->assertInstanceOf(Parameters::class, $a); } - public function testComputeSecretWithPublicKey() + public function testComputeSecretWithPublicKey(): void { $ourPriv = DH::load('-----BEGIN PRIVATE KEY----- MIIBIgIBADCBlQYJKoZIhvcNAQMBMIGHAoGBAP//////////yQ/aoiFowjTExmKL @@ -126,7 +128,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU $this->assertIsString(DH::computeSecret($ourPriv, $theirPub)); } - public function testComputeSecret() + public function testComputeSecret(): void { // Ed25519 isn't normally used for DH (that honor goes to Curve25519) but that's not to say it can't // be used @@ -138,7 +140,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU } } - public function testEphemeralECDH() + public function testEphemeralECDH(): void { // an RSA like hybrid cryptosystem can be done with ephemeral key ECDH @@ -174,7 +176,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU $this->assertSame($plaintext, $aes->decrypt(substr($encrypted, 32))); } - public function testMultiPartyDH() + public function testMultiPartyDH(): void { // in multi party (EC)DH everyone, for each public key, everyone (save for the public key owner) "applies" // their private key to it. they do so in series (as opposed to in parallel) and then everyone winds up @@ -205,7 +207,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU } } - public function testCurve25519() + public function testCurve25519(): void { // utilizing test vector from https://tools.ietf.org/html/rfc7748#section-6.1 @@ -231,7 +233,7 @@ Q3ADAIcv9LEmTBnSAOsCs1K9ExAmSv/T2/4+9dW28UYb+p/uV477d1wf+nCWS6VU $this->assertSame($expected, DH::computeSecret($bobPrivate, $alicePublic)); } - public function testCurve448() + public function testCurve448(): void { // utilizing test vector from https://tools.ietf.org/html/rfc7748#section-6.2 diff --git a/tests/Unit/Crypt/DSA/CreateKeyTest.php b/tests/Unit/Crypt/DSA/CreateKeyTest.php index 9f652956..6f10e6a6 100644 --- a/tests/Unit/Crypt/DSA/CreateKeyTest.php +++ b/tests/Unit/Crypt/DSA/CreateKeyTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\DSA; use phpseclib3\Crypt\DSA; @@ -41,7 +43,7 @@ class CreateKeyTest extends PhpseclibTestCase /** * @depends testCreateParameters */ - public function testCreateKey($params) + public function testCreateKey($params): void { $privatekey = DSA::createKey(); $this->assertInstanceOf(PrivateKey::class, $privatekey); diff --git a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php index cbe7c664..d3fe7dd1 100644 --- a/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php +++ b/tests/Unit/Crypt/DSA/LoadDSAKeyTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\DSA; use phpseclib3\Crypt\DSA\Parameters; @@ -17,7 +19,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class LoadDSAKeyTest extends PhpseclibTestCase { - public function testBadKey() + public function testBadKey(): void { $this->expectException(NoKeyLoadedException::class); @@ -25,7 +27,7 @@ class LoadDSAKeyTest extends PhpseclibTestCase PublicKeyLoader::load($key); } - public function testPuTTYKey() + public function testPuTTYKey(): void { $key = 'PuTTY-User-Key-File-2: ssh-dss Encryption: none @@ -65,7 +67,7 @@ Private-MAC: 62b92ddd8b341b9414d640c24ba6ae929a78e039 $this->assertGreaterThan(0, strlen("$dsa")); } - public function testPKCS1Key() + public function testPKCS1Key(): void { $key = '-----BEGIN DSA PRIVATE KEY----- MIIDPQIBAAKCAQEAiwfUDxLuCgQSd5boP/MleHXPKllGUqXDu81onvJeL2+pSQqd @@ -96,7 +98,7 @@ Eb2s9fDOpnMhj+WqwcQgs18= $this->assertIsString((string) $dsa->getParameters()); } - public function testParameters() + public function testParameters(): void { $key = '-----BEGIN DSA PARAMETERS----- MIIBHgKBgQDandMycPZNOEwDXpIDSdFODWOQVO5tlnt38wK0X33TJh4wQdqOSiVF @@ -115,7 +117,7 @@ L1cwyXx0KMaaampd34MzOIHbC44SHY+cE3aVVUsnmt6Ur1nQaVYVszl+AO6m8bPm $this->assertSame($key, str_replace(["\n", "\r"], '', (string) $dsa->getParameters())); } - public function testPKCS8Public() + public function testPKCS8Public(): void { $key = '-----BEGIN PUBLIC KEY----- MIIBtjCCASsGByqGSM44BAEwggEeAoGBANqd0zJw9k04TANekgNJ0U4NY5BU7m2W @@ -136,7 +138,7 @@ ZpmyOpXM/0opRMIRdmqVW4ardBFNokmlqngwcbaptfRnk9W2cQtx0lmKy6X/vnis $this->assertIsString("$dsa"); } - public function testPKCS8Private() + public function testPKCS8Private(): void { $key = '-----BEGIN PRIVATE KEY----- MIIBSgIBADCCASsGByqGSM44BAEwggEeAoGBANqd0zJw9k04TANekgNJ0U4NY5BU @@ -156,7 +158,7 @@ Syea3pSvWdBpVhWzOX4A7qbxs+bhWAQWAhQiF7sFfCtZ7oOgCb2aJ9ySC9sTug== $this->assertInstanceOf(Parameters::class, $dsa->getParameters()); } - public function testPuTTYBadMAC() + public function testPuTTYBadMAC(): void { $this->expectException(NoKeyLoadedException::class); @@ -190,7 +192,7 @@ Private-MAC: aaaaaadd8b341b9414d640c24ba6ae929a78e039 PublicKeyLoader::load($key); } - public function testXML() + public function testXML(): void { $key = '-----BEGIN PUBLIC KEY----- MIIBtjCCASsGByqGSM44BAEwggEeAoGBANqd0zJw9k04TANekgNJ0U4NY5BU7m2W @@ -218,7 +220,7 @@ ZpmyOpXM/0opRMIRdmqVW4ardBFNokmlqngwcbaptfRnk9W2cQtx0lmKy6X/vnis ); } - public function testOpenSSHPrivate() + public function testOpenSSHPrivate(): void { $key = '-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABswAAAAdzc2gtZH diff --git a/tests/Unit/Crypt/DSA/SignatureTest.php b/tests/Unit/Crypt/DSA/SignatureTest.php index b7bd7727..430836dd 100644 --- a/tests/Unit/Crypt/DSA/SignatureTest.php +++ b/tests/Unit/Crypt/DSA/SignatureTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\DSA; use phpseclib3\Crypt\DSA; @@ -14,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class SignatureTest extends PhpseclibTestCase { - public function testPKCSSignature() + public function testPKCSSignature(): void { $message = 'hello, world!'; @@ -69,7 +71,7 @@ TzUkQjFI9UY7kZeK $this->assertFalse($dsa->verify('zzzz', $signature)); } - public function testRandomSignature() + public function testRandomSignature(): void { $message = 'hello, world!'; @@ -108,7 +110,7 @@ kBniZHdFBAZBTE14YJUBkw== $this->assertTrue($public->verify($message, $signature)); } - public function testSSHSignature() + public function testSSHSignature(): void { $dsa = PublicKeyLoader::load('AAAAB3NzaC1kc3MAAACBAPyzZzm4oqmY12lxmHwNcfYDNyXr38M1lU6xy9I792U1YSKgX27nUW9eXdJ8Mrn63Le5rrBRfg2Niycx' . 'JF2IwDpwCi7YpIv79uwT3RtA0chQDS4vx8qi8BWBzy7PZC9hmqY62+mgfj8ooga1sr+JpMh+8r4j3KjPM+wE37khkgkvAAAAFQDn' . diff --git a/tests/Unit/Crypt/EC/CurveTest.php b/tests/Unit/Crypt/EC/CurveTest.php index bf201b4e..c3ac5bbb 100644 --- a/tests/Unit/Crypt/EC/CurveTest.php +++ b/tests/Unit/Crypt/EC/CurveTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\EC; use phpseclib3\Crypt\EC; @@ -16,7 +18,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class CurveTest extends PhpseclibTestCase { - public function curves() + public function curves(): array { $curves = []; foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) { @@ -38,7 +40,7 @@ class CurveTest extends PhpseclibTestCase return $curves; } - public function allCurves() + public function allCurves(): array { $curves = []; foreach (new \DirectoryIterator(__DIR__ . '/../../../../phpseclib/Crypt/EC/Curves/') as $file) { @@ -55,7 +57,7 @@ class CurveTest extends PhpseclibTestCase return $curves; } - public function curvesWithOIDs() + public function curvesWithOIDs(): array { $class = new \ReflectionClass('phpseclib3\Crypt\EC\Formats\Keys\PKCS8'); @@ -80,7 +82,7 @@ class CurveTest extends PhpseclibTestCase * * @dataProvider curves */ - public function testBasePoint($name) + public function testBasePoint($name): void { $class = 'phpseclib3\Crypt\EC\Curves\\' . $name; $curve = new $class(); @@ -93,7 +95,7 @@ class CurveTest extends PhpseclibTestCase * @dataProvider curves * @requires PHP 7.0 */ - public function testKeyGeneration($name) + public function testKeyGeneration($name): void { $class = 'phpseclib3\Crypt\EC\Curves\\' . $name; $curve = new $class(); @@ -107,7 +109,7 @@ class CurveTest extends PhpseclibTestCase * * @dataProvider curvesWithOIDs */ - public function testCurveExistance($name) + public function testCurveExistance($name): void { $this->assertFileExists(__DIR__ . "/../../../../phpseclib/Crypt/EC/Curves/$name.php"); } @@ -117,7 +119,7 @@ class CurveTest extends PhpseclibTestCase * * @dataProvider allCurves */ - public function testOIDExistance($name) + public function testOIDExistance($name): void { switch ($name) { case 'Ed25519': @@ -133,7 +135,7 @@ class CurveTest extends PhpseclibTestCase * @dataProvider curves * @requires PHP 7.0 */ - public function testInternalSign($name) + public function testInternalSign($name): void { // tests utilizing dataProvider only seem to output when all the dataProvider input // has been exhausted. ie. when this test has been ran on every curve. on my local @@ -159,7 +161,7 @@ class CurveTest extends PhpseclibTestCase $this->assertTrue($publickey->verify($plaintext, $sig)); } - public function testCanSignWithAnEncryptedPrivateKey() + public function testCanSignWithAnEncryptedPrivateKey(): void { EC::useBestEngine(); @@ -178,7 +180,7 @@ class CurveTest extends PhpseclibTestCase * @dataProvider curves * @requires PHP 7.0 */ - public function testInternalVerify($name) + public function testInternalVerify($name): void { if (substr($name, 0, 4) == 'sect') { self::markTestSkipped('Binary field curves are being skipped'); @@ -198,7 +200,7 @@ class CurveTest extends PhpseclibTestCase /** * Ed448 test vectors from https://tools.ietf.org/html/rfc8032#section-7.4 */ - public function testEd448TestVectors() + public function testEd448TestVectors(): void { EC::addFileFormat(Ed448PublicKey::class); EC::addFileFormat(Ed448PrivateKey::class); @@ -313,7 +315,7 @@ class CurveTest extends PhpseclibTestCase /** * Ed25519 test vectors from https://tools.ietf.org/html/rfc8032#section-7.1 (and 7.2) */ - public function testEd25519TestVectors() + public function testEd25519TestVectors(): void { EC::useBestEngine(); @@ -462,7 +464,7 @@ class CurveTest extends PhpseclibTestCase $this->assertTrue($publicKey->verify($message, $sig)); } - public function testRandomSignature() + public function testRandomSignature(): void { $message = 'hello, world!'; $private = PublicKeyLoader::load('PuTTY-User-Key-File-2: ecdsa-sha2-nistp256 @@ -499,7 +501,7 @@ Private-MAC: b85ca0eb7c612df5d18af85128821bd53faaa3ef'); $this->assertTrue($public->verify($message, $signature, 'Raw')); } - public function testBadRSEd25519() + public function testBadRSEd25519(): void { // see https://research.nccgroup.com/2021/11/08/technical-advisory-arbitrary-signature-forgery-in-stark-bank-ecdsa-libraries/ $public = PublicKeyLoader::load('-----BEGIN PUBLIC KEY----- diff --git a/tests/Unit/Crypt/EC/Ed448PrivateKey.php b/tests/Unit/Crypt/EC/Ed448PrivateKey.php index b748be87..cf4f4cd4 100644 --- a/tests/Unit/Crypt/EC/Ed448PrivateKey.php +++ b/tests/Unit/Crypt/EC/Ed448PrivateKey.php @@ -1,5 +1,7 @@ assertSameNL('Ed25519', $key->getPublicKey()->getCurve()); } - public function testPuTTYnistp256() + public function testPuTTYnistp256(): void { $key = PublicKeyLoader::load($expected = 'PuTTY-User-Key-File-2: ecdsa-sha2-nistp256 Encryption: none @@ -328,7 +330,7 @@ Private-MAC: b85ca0eb7c612df5d18af85128821bd53faaa3ef $this->assertSameNL($expected, $key->toString('OpenSSH')); } - public function testPuTTYnistp384() + public function testPuTTYnistp384(): void { $key = PublicKeyLoader::load($expected = 'PuTTY-User-Key-File-2: ecdsa-sha2-nistp384 Encryption: none @@ -354,7 +356,7 @@ Private-MAC: 97a990a3d5f6b8f268d4be9c4ab9ebfd8fa79849 $this->assertSameNL($expected, $key->toString('OpenSSH')); } - public function testPuTTYnistp521() + public function testPuTTYnistp521(): void { $key = PublicKeyLoader::load($expected = 'PuTTY-User-Key-File-2: ecdsa-sha2-nistp521 Encryption: none @@ -381,7 +383,7 @@ Private-MAC: 6d49ce289b85549a43d74422dd8bb3ba8798c72c $this->assertSameNL($expected, $key->toString('OpenSSH')); } - public function testPuTTYed25519() + public function testPuTTYed25519(): void { $key = PublicKeyLoader::load($expected = 'PuTTY-User-Key-File-2: ssh-ed25519 Encryption: none @@ -405,7 +407,7 @@ Private-MAC: 8a06821a1c8b8b40fc40f876e543c4ea3fb81bb9 $this->assertSameNL($expected, $key->toString('OpenSSH')); } - public function testlibsodium() + public function testlibsodium(): void { if (!function_exists('sodium_crypto_sign_keypair')) { self::markTestSkipped('libsodium extension is not available.'); @@ -423,7 +425,7 @@ Private-MAC: 8a06821a1c8b8b40fc40f876e543c4ea3fb81bb9 } // ssh-keygen -t ed25519 - public function testOpenSSHPrivateKey() + public function testOpenSSHPrivateKey(): void { $key = PublicKeyLoader::load('-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW @@ -446,7 +448,7 @@ pomV7r6gmoMYteGVABfgAAAAD3ZhZ3JhbnRAdmFncmFudAECAwQFBg== } // from https://www.w3.org/TR/xmldsig-core/#sec-RFC4050Compat - public function testXMLKey() + public function testXMLKey(): void { $key = PublicKeyLoader::load($orig = ' @@ -474,14 +476,14 @@ pomV7r6gmoMYteGVABfgAAAAD3ZhZ3JhbnRAdmFncmFudAECAwQFBg== $this->assertSameNL($expected, $actual); } - public function assertSameNL($expected, $actual, $message = '') + public function assertSameNL($expected, $actual, $message = ''): void { $expected = str_replace("\r\n", "\n", $expected); $actual = str_replace("\r\n", "\n", $actual); $this->assertSame($expected, $actual, $message); } - public function testOpenSSHPrivateEC() + public function testOpenSSHPrivateEC(): void { $key = '-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAaAAAABNlY2RzYS @@ -506,7 +508,7 @@ AQIDBA== $this->assertTrue($key->verify('zzz', $sig)); } - public function testOpenSSHPrivateEd25519() + public function testOpenSSHPrivateEd25519(): void { $key = '-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW @@ -530,7 +532,7 @@ lEIq93iMVzIArjGaKrFDAAAADHJvb3RAdmFncmFudAE= /** * @group github1712 */ - public function testKeyTooLarge() + public function testKeyTooLarge(): void { $this->expectException('RangeException'); @@ -565,7 +567,7 @@ MIIEDwIBADATBgcqhkjOPQIBBggqhkjOPQMBBwSCA/MwggPvAgEBBIID6P////// /** * @group github1712 */ - public function testLargeCurve25519Key() + public function testLargeCurve25519Key(): void { $raw = pack('H*', '8426220e7a57dc8d685d3966e3a23600e32563ce6033e07d0c89dbb5bd296577'); $key = EC::loadFormat('MontgomeryPrivate', $raw); diff --git a/tests/Unit/Crypt/GCMTest.php b/tests/Unit/Crypt/GCMTest.php index 7e2260bc..8fa43530 100644 --- a/tests/Unit/Crypt/GCMTest.php +++ b/tests/Unit/Crypt/GCMTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\AES; @@ -15,10 +17,8 @@ class GCMTest extends PhpseclibTestCase { /** * Produces all combinations of test values. - * - * @return array */ - public function engine128Vectors() + public function engine128Vectors(): array { $engines = [ 'PHP', @@ -107,7 +107,7 @@ class GCMTest extends PhpseclibTestCase /** * @dataProvider engine128Vectors */ - public function test128Vectors($engine, $key, $plaintext, $nonce, $aad, $ciphertext, $tag) + public function test128Vectors($engine, $key, $plaintext, $nonce, $aad, $ciphertext, $tag): void { $aes = new AES('gcm'); $aes->setKey($key); @@ -128,10 +128,8 @@ class GCMTest extends PhpseclibTestCase /** * Produces all combinations of test values. - * - * @return array */ - public function engine256Vectors() + public function engine256Vectors(): array { $engines = [ 'PHP', @@ -220,7 +218,7 @@ class GCMTest extends PhpseclibTestCase /** * @dataProvider engine256Vectors */ - public function test256Vectors($engine, $key, $plaintext, $nonce, $aad, $ciphertext, $tag) + public function test256Vectors($engine, $key, $plaintext, $nonce, $aad, $ciphertext, $tag): void { $aes = new AES('gcm'); $aes->setKey($key); diff --git a/tests/Unit/Crypt/HashTest.php b/tests/Unit/Crypt/HashTest.php index 836fcbfb..92090232 100644 --- a/tests/Unit/Crypt/HashTest.php +++ b/tests/Unit/Crypt/HashTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\Hash; @@ -14,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class HashTest extends PhpseclibTestCase { - protected function assertHashesTo($hash, $message, $expected) + protected function assertHashesTo($hash, $message, $expected): void { $hash = new Hash($hash); @@ -25,7 +27,7 @@ class HashTest extends PhpseclibTestCase ); } - protected function assertHMACsTo($hash, $key, $message, $expected) + protected function assertHMACsTo($hash, $key, $message, $expected): void { $hash = new Hash($hash); $hash->setKey($key); @@ -42,7 +44,7 @@ class HashTest extends PhpseclibTestCase ); } - public static function hashData() + public static function hashData(): array { return [ ['md5', '', 'd41d8cd98f00b204e9800998ecf8427e'], @@ -171,7 +173,7 @@ class HashTest extends PhpseclibTestCase /** * @dataProvider hmacData() */ - public function testHMAC($hash, $key, $message, $result) + public function testHMAC($hash, $key, $message, $result): void { $this->assertHMACsTo($hash, $key, $message, $result); } @@ -179,12 +181,12 @@ class HashTest extends PhpseclibTestCase /** * @dataProvider hmacData() */ - public function testHMAC96($hash, $key, $message, $result) + public function testHMAC96($hash, $key, $message, $result): void { $this->assertHMACsTo($hash . '-96', $key, $message, substr($result, 0, 24)); } - public static function hmacData() + public static function hmacData(): array { return [ ['md5', '', '', '74e6f7298a9c2d168935f58c001bad88'], @@ -372,7 +374,7 @@ class HashTest extends PhpseclibTestCase /** * @dataProvider hashData() */ - public function testHash($hash, $message, $result) + public function testHash($hash, $message, $result): void { $this->assertHashesTo($hash, $message, $result); } @@ -380,7 +382,7 @@ class HashTest extends PhpseclibTestCase /** * @dataProvider hashData() */ - public function testHash96($hash, $message, $result) + public function testHash96($hash, $message, $result): void { if (preg_match('#^sha3-\d+#', $hash) || preg_match('#^shake(?:128|256)-\d+#', $hash) || $hash === 'keccak256') { self::markTestSkipped($hash . '-96 not supported'); @@ -388,20 +390,20 @@ class HashTest extends PhpseclibTestCase $this->assertHashesTo($hash . '-96', $message, substr($result, 0, 24)); } - public function testConstructorDefault() + public function testConstructorDefault(): void { $hash = new Hash(); $this->assertSame($hash->getHash(), 'sha256'); } - public function testConstructorArgumentInvalid() + public function testConstructorArgumentInvalid(): void { $this->expectException(UnsupportedAlgorithmException::class); new Hash('abcdefghijklmnopqrst'); } - public function testSetHashInvalid() + public function testSetHashInvalid(): void { $this->expectException(UnsupportedAlgorithmException::class); @@ -409,7 +411,7 @@ class HashTest extends PhpseclibTestCase $hash->setHash('abcdefghijklmnopqrst-96'); } - public function testSetHashValid() + public function testSetHashValid(): void { $hash = new Hash('md5'); $this->assertSame($hash->getHash(), 'md5'); @@ -420,13 +422,13 @@ class HashTest extends PhpseclibTestCase /** * @dataProvider lengths */ - public function testGetLengthKnown($algorithm, $length) + public function testGetLengthKnown($algorithm, $length): void { $hash = new Hash($algorithm); $this->assertSame($hash->getLengthInBytes(), $length); } - public function lengths() + public function lengths(): array { return [ // known @@ -439,7 +441,7 @@ class HashTest extends PhpseclibTestCase ]; } - public function UMACs() + public function UMACs(): array { return [ ['', 'umac-32', '113145FB', "umac-32 and message of "], @@ -473,7 +475,7 @@ class HashTest extends PhpseclibTestCase /** * @dataProvider UMACs */ - public function testUMACs($message, $algo, $tag, $error) + public function testUMACs($message, $algo, $tag, $error): void { $k = 'abcdefghijklmnop'; // A 16-byte UMAC key $n = 'bcdefghi'; // An 8-byte nonce diff --git a/tests/Unit/Crypt/RC2Test.php b/tests/Unit/Crypt/RC2Test.php index 9b424a8e..3b7ed4ff 100644 --- a/tests/Unit/Crypt/RC2Test.php +++ b/tests/Unit/Crypt/RC2Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\RC2; @@ -20,7 +22,7 @@ class RC2Test extends PhpseclibTestCase 'OpenSSL', ]; - public function engineVectors() + public function engineVectors(): array { // tests from https://tools.ietf.org/html/rfc2268#page-8 $tests = [ @@ -47,7 +49,7 @@ class RC2Test extends PhpseclibTestCase } // this test is just confirming RC2's key expansion - public function testEncryptPadding() + public function testEncryptPadding(): void { $rc2 = new RC2('ecb'); @@ -112,7 +114,7 @@ class RC2Test extends PhpseclibTestCase /** * @dataProvider engineVectors */ - public function testVectors($engine, $key, $keyLen, $plaintext, $ciphertext) + public function testVectors($engine, $key, $keyLen, $plaintext, $ciphertext): void { $rc2 = new RC2('cbc'); $rc2->disablePadding(); diff --git a/tests/Unit/Crypt/RC4Test.php b/tests/Unit/Crypt/RC4Test.php index 5fec1f7d..193f59d2 100644 --- a/tests/Unit/Crypt/RC4Test.php +++ b/tests/Unit/Crypt/RC4Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\Random; @@ -14,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class RC4Test extends PhpseclibTestCase { - public function engineVectors() + public function engineVectors(): array { $engines = [ 'PHP', @@ -203,7 +205,7 @@ class RC4Test extends PhpseclibTestCase /** * @dataProvider engineVectors */ - public function testVectors($engine, $key, $offset, $expected) + public function testVectors($engine, $key, $offset, $expected): void { $rc4 = new RC4(); $rc4->setPreferredEngine($engine); @@ -215,7 +217,7 @@ class RC4Test extends PhpseclibTestCase $this->assertEquals(bin2hex(substr($result, -16)), $expected, "Failed asserting that key $key yielded expected output at offset $offset in $engine engine"); } - public function testKeySizes() + public function testKeySizes(): void { $objects = $engines = []; $temp = new RC4(RC4::MODE_CTR); diff --git a/tests/Unit/Crypt/RSA/CreateKeyTest.php b/tests/Unit/Crypt/RSA/CreateKeyTest.php index c25cd928..0de159ad 100644 --- a/tests/Unit/Crypt/RSA/CreateKeyTest.php +++ b/tests/Unit/Crypt/RSA/CreateKeyTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\RSA; use phpseclib3\Crypt\RSA; @@ -17,7 +19,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class CreateKeyTest extends PhpseclibTestCase { - public function testCreateKey() + public function testCreateKey(): array { $privatekey = RSA::createKey(768); $publickey = $privatekey->getPublicKey(); @@ -34,7 +36,7 @@ class CreateKeyTest extends PhpseclibTestCase /** * @depends testCreateKey */ - public function testEncryptDecrypt($args) + public function testEncryptDecrypt($args): void { list($publickey, $privatekey) = $args; $ciphertext = $publickey->encrypt('zzz'); @@ -43,7 +45,7 @@ class CreateKeyTest extends PhpseclibTestCase $this->assertSame($plaintext, 'zzz'); } - public function testMultiPrime() + public function testMultiPrime(): void { RSA::useInternalEngine(); RSA::setSmallestPrime(256); @@ -71,7 +73,7 @@ class CreateKeyTest extends PhpseclibTestCase RSA::useBestEngine(); } - public function test3DESPKCS8Encryption() + public function test3DESPKCS8Encryption(): void { $key = RSA::createKey(768) ->withPassword('demo') diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index 639a3b25..a9a8c849 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\RSA; use phpseclib3\Crypt\PublicKeyLoader; @@ -24,13 +26,13 @@ use phpseclib3\Tests\PhpseclibTestCase; class LoadKeyTest extends PhpseclibTestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { PuTTY::setComment('phpseclib-generated-key'); OpenSSH::setComment('phpseclib-generated-key'); } - public function testBadKey() + public function testBadKey(): void { $this->expectException(NoKeyLoadedException::class); @@ -38,7 +40,7 @@ class LoadKeyTest extends PhpseclibTestCase PublicKeyLoader::load($key); } - public function testLoadModulusAndExponent() + public function testLoadModulusAndExponent(): void { $rsa = PublicKeyLoader::load([ 'e' => new BigInteger('123', 16), @@ -49,7 +51,7 @@ class LoadKeyTest extends PhpseclibTestCase $this->assertIsString("$rsa"); } - public function testPKCS1Key() + public function testPKCS1Key(): void { $key = '-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp @@ -71,7 +73,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertIsString("$rsa"); } - public function testPKCS1SpacesKey() + public function testPKCS1SpacesKey(): void { $key = '-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp @@ -94,7 +96,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertIsString("$rsa"); } - public function testPKCS1NoHeaderKey() + public function testPKCS1NoHeaderKey(): void { $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5 @@ -114,7 +116,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertIsString("$rsa"); } - public function testPKCS1NoWhitespaceNoHeaderKey() + public function testPKCS1NoWhitespaceNoHeaderKey(): void { $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' . 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' . @@ -134,7 +136,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertIsString("$rsa"); } - public function testRawPKCS1Key() + public function testRawPKCS1Key(): void { $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' . 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' . @@ -155,7 +157,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertIsString("$rsa"); } - public function testLoadPKCS8PrivateKey() + public function testLoadPKCS8PrivateKey(): void { $key = '-----BEGIN ENCRYPTED PRIVATE KEY----- MIIE6TAbBgkqhkiG9w0BBQMwDgQIcWWgZeQYPTcCAggABIIEyLoa5b3ktcPmy4VB @@ -193,7 +195,7 @@ xryZaRDVmtMuf/OZBQ== $this->assertIsString("$rsa"); } - public function testSavePKCS8PrivateKey() + public function testSavePKCS8PrivateKey(): void { $key = '-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp @@ -219,7 +221,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertInstanceOf(PrivateKey::class, $rsa); } - public function testPubKey1() + public function testPubKey1(): void { $key = '-----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEA61BjmfXGEvWmegnBGSuS+rU9soUg2FnODva32D1AqhwdziwHINFa @@ -234,7 +236,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB $this->assertInstanceOf(PublicKey::class, $rsa); } - public function testPubKey2() + public function testPubKey2(): void { $key = '-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA61BjmfXGEvWmegnBGSuS @@ -251,7 +253,7 @@ ZQIDAQAB } - public function testPubKeyPssWithoutParams() + public function testPubKeyPssWithoutParams(): void { // extracted from a SubjectPublicKeyInfo of a CSR created by OpenSSL $key = '-----BEGIN PUBLIC KEY----- @@ -271,7 +273,7 @@ AwEAAQ== $this->assertIsString("$rsa"); } - public function testPrivateKeyPssWithoutParams() + public function testPrivateKeyPssWithoutParams(): void { $key = '-----BEGIN PRIVATE KEY----- MIIEugIBADALBgkqhkiG9w0BAQoEggSmMIIEogIBAAKCAQEA0c89/m2NOYQe1C/O @@ -310,7 +312,7 @@ BocC2CO6SNi4Qjr3NlM= $this->assertIsString("$rsa"); } - public function testPubPrivateKey() + public function testPubPrivateKey(): void { $key = '-----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEA61BjmfXGEvWmegnBGSuS+rU9soUg2FnODva32D1AqhwdziwHINFa @@ -326,7 +328,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB $this->assertIsString($rsa->sign('zzz')); } - public function testSSHPubKey() + public function testSSHPubKey(): void { $key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4e' . 'CZ0FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMS' . @@ -337,7 +339,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB $this->assertInstanceOf(PublicKey::class, $rsa); } - public function testSSHPubKeyFingerprint() + public function testSSHPubKeyFingerprint(): void { $key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD9K+ebJRMN10kGanhi6kDz6EYFqZttZWZh0' . 'YoEbIbbere9N2Yvfc7oIoCTHYowhXND9WSJaIs1E4bx0085CZnofWaqf4NbZTzAh18iZup08ec' . @@ -352,7 +354,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB $this->assertSame($rsa->getFingerprint('sha256'), 'N9sV2uSNZEe8TITODku0pRI27l+Zk0IY0TrRTw3ozwM'); } - public function testSetPrivate() + public function testSetPrivate(): void { $key = '-----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEA61BjmfXGEvWmegnBGSuS+rU9soUg2FnODva32D1AqhwdziwHINFa @@ -376,7 +378,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB * * @group github468 */ - public function testUnsignedXML() + public function testUnsignedXML(): void { $key = ' v5OxcEgxPUfa701NpxnScCmlRkbwSGBiTWobHkIWZEB+AlRTHaVoZg/D8l6YzR7VdQidG6gF+nuUMjY75dBXgY/XcyVq0Hccf1jTfgARuNuq4GGG3hnCJVi2QsOgcf9R7TeXn+p1RKIhjQoWCiEQeEBTotNbJhcabNcPGSEJw+s= @@ -392,7 +394,7 @@ Ao8eayMp6FcvNucIpUndo1X8dKMv3Y26ZQIDAQAB /** * @group github468 */ - public function testSignedPKCS1() + public function testSignedPKCS1(): void { $key = '-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC/k7FwSDE9R9rvTU2nGdJwKaVG @@ -410,7 +412,7 @@ JWrQdxx/WNN+ABG426rgYYbeGcIlWLZCw6Bx/1HtN5ef6nVEoiGNChYKIRB4QFOi /** * @group github861 */ - public function testPKCS8Only() + public function testPKCS8Only(): void { $key = '-----BEGIN PRIVATE KEY----- MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKB0yPMAbUHKqJxP @@ -434,7 +436,7 @@ Z2sKniRCcDT1ZP4= $this->assertInstanceOf(PrivateKey::class, $rsa); } - public function testPKCS1EncryptionChange() + public function testPKCS1EncryptionChange(): void { $key = 'PuTTY-User-Key-File-2: ssh-rsa Encryption: none @@ -473,7 +475,7 @@ Private-MAC: 03e2cb74e1d67652fbad063d2ed0478f31bdf256 $this->assertSame($key, $key2); } - public function testRawComment() + public function testRawComment(): void { $key = 'PuTTY-User-Key-File-2: ssh-rsa Encryption: aes256-cbc @@ -499,7 +501,7 @@ Private-MAC: 35134b7434bf828b21404099861d455e660e8740'; $this->assertEquals($raw['comment'], 'phpseclib-generated-key'); } - public function testPrivateMSBlob() + public function testPrivateMSBlob(): void { $key = 'BwIAAACkAABSU0EyAAQAAAEAAQAnh6FFs6kYe/gmb9dzqsQKmtjFE9mxNAe9mEU3OwOEEfyI' . 'wkAx0/8dwh12fuP4wzNbdZAq4mmqCE6Lo8wTNNIJVNYEhKq5chHg1+hPDgfETFgtEO54JZSg' . @@ -530,7 +532,7 @@ Private-MAC: 35134b7434bf828b21404099861d455e660e8740'; $this->assertSame($privKey->decrypt($ciphertext), $plaintext); } - public function testNakedOpenSSHKey() + public function testNakedOpenSSHKey(): void { $key = 'AAAAB3NzaC1yc2EAAAABIwAAAIEA/NcGSQFZ0ZgN1EbDusV6LLwLnQjs05ljKcVVP7Z6aKIJUyhUDHE30uJa5XfwPPBsZ3L3Q7S0yycVcuuHjdauugmpn9xx+gyoYs7UiV5G5rvxNcA/Tc+MofGhAMiTmNicorNAs5mv6fRoVbkpIONRXPz6WK0kjx/X04EV42Vm9Qk='; @@ -541,7 +543,7 @@ Private-MAC: 35134b7434bf828b21404099861d455e660e8740'; $this->assertGreaterThanOrEqual(1, strlen("$rsa")); } - public function testPuttyPublicKey() + public function testPuttyPublicKey(): void { $key = '---- BEGIN SSH2 PUBLIC KEY ---- Comment: "rsa-key-20151023" @@ -561,7 +563,7 @@ ILaEujU= /** * @group github980 */ - public function testZeroComponents() + public function testZeroComponents(): void { $key = '-----BEGIN RSA PRIVATE KEY----- MIGaAgEAAkEAt5yrcHAAjhglnCEn6yecMWPeUXcMyo0+itXrLlkpcKIIyqPw546b @@ -581,7 +583,7 @@ AAIBAAIBAAIBAAIBAA== ); } - public function pkcs8tester($key, $pass) + public function pkcs8tester($key, $pass): void { $rsa = PublicKeyLoader::load($key, $pass); $r = PKCS8::load($key, $pass); @@ -613,7 +615,7 @@ AAIBAAIBAAIBAAIBAA== $this->assertSame("$rsa", "$rsa2"); } - public function testPKCS8AES256CBC() + public function testPKCS8AES256CBC(): void { // openssl pkcs8 -in private.pem -topk8 -v2 aes-256-cbc -v2prf hmacWithSHA256 -out enckey.pem @@ -656,7 +658,7 @@ mKVKf5kPx2aR2W2KAcgw3TJIu1QX7N+l3kFrf9Owtz1a $this->pkcs8tester($key, $pass); } - public function testPKCS8RC2CBC() + public function testPKCS8RC2CBC(): void { // openssl pkcs8 -in private.pem -topk8 -v2 rc2 -out enckey.pem @@ -699,7 +701,7 @@ khzefbnNRDL5PIJnTfM7vSQ4nUzdAxs/7YzX6GMx1DaCtBANbUVUoIE+3oKdqpGV $this->pkcs8tester($key, $pass); } - public function testPKCS83DES() + public function testPKCS83DES(): void { // openssl pkcs8 -in private.pem -topk8 -v1 PBE-SHA1-3DES -out enckey.pem @@ -740,7 +742,7 @@ aENeUJKn2r8X3Tpz92U= $this->pkcs8tester($key, $pass); } - public function testPKCS82DES() + public function testPKCS82DES(): void { // openssl pkcs8 -in private.pem -topk8 -v1 PBE-SHA1-2DES -out enckey.pem @@ -781,7 +783,7 @@ rcONqwmUGJOjrfhUyJA= $this->pkcs8tester($key, $pass); } - public function testPKCS8RC2() + public function testPKCS8RC2(): void { // openssl pkcs8 -in private.pem -topk8 -v1 PBE-SHA1-RC2-128 -out enckey.pem @@ -821,7 +823,7 @@ Pu3ed6UvXDfotj3v8rE= $this->pkcs8tester($key, $pass); } - public function testPKCS8RC240() + public function testPKCS8RC240(): void { // openssl pkcs8 -in private.pem -topk8 -v1 PBE-SHA1-RC2-40 -out enckey.pem @@ -861,7 +863,7 @@ GxyNlS3BiKQ22CLvbjc= $this->pkcs8tester($key, $pass); } - public function testPKCS8RC4() + public function testPKCS8RC4(): void { // openssl pkcs8 -in private.pem -topk8 -v1 PBE-SHA1-RC4-128 -out enckey.pem @@ -901,7 +903,7 @@ OvndKFWbSnE= $this->pkcs8tester($key, $pass); } - public function testPKCS8RC440() + public function testPKCS8RC440(): void { // openssl pkcs8 -in private.pem -topk8 -v1 PBE-SHA1-RC4-40 -out enckey.pem @@ -941,7 +943,7 @@ OFLPBrLe4Hw= $this->pkcs8tester($key, $pass); } - public function testXMLDeclaration() + public function testXMLDeclaration(): void { $key = ' @@ -960,7 +962,7 @@ OFLPBrLe4Hw= $this->assertInstanceOf(PublicKey::class, $rsa->getPublicKey()); } - public function testPSS() + public function testPSS(): void { $key = '-----BEGIN PRIVATE KEY----- MIIE7QIBADA9BgkqhkiG9w0BAQowMKANMAsGCWCGSAFlAwQCAaEaMBgGCSqGSIb3 @@ -1006,7 +1008,7 @@ IBgv3a3Lyb+IQtT75LE1yjE= $this->assertSame($r['saltLength'], $r2['saltLength']); } - public function testOpenSSHPrivate() + public function testOpenSSHPrivate(): void { $key = '-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn @@ -1060,7 +1062,7 @@ Vyaqr/WTPzxdXJAAAADHJvb3RAdmFncmFudAECAwQFBg== $this->assertTrue($key->verify('zzz', $sig)); } - public function testPuTTYPublic() + public function testPuTTYPublic(): void { $orig = '---- BEGIN SSH2 PUBLIC KEY ---- Comment: "phpseclib-generated-key" @@ -1095,7 +1097,7 @@ YYFw8pfGesIFoEuVth4HKyF8k1y4mRUnYHP1XNMNMJl1JcEArC2asV8sHf6zSPVffozZ $this->assertInstanceOf(PublicKey::class, $key); } - public function testSavePasswordXML() + public function testSavePasswordXML(): void { $this->expectException(UnsupportedFormatException::class); @@ -1112,7 +1114,7 @@ v/Ow5T0q5gIJAiEAyS4RaI9YG8EWx/2w0T67ZUVAw8eOMB6BIUg0Xcu+3okCIBOs $key->withPassword('demo')->toString('XML'); } - public function testPublicAsPrivatePKCS1() + public function testPublicAsPrivatePKCS1(): void { $key = '-----BEGIN RSA PRIVATE KEY----- MIGJAoGBANOV2sOh8KgK9ENJMCzkIQ+UogWU7GP4JMpGxT6aEoxE3O5zUo2D1asv @@ -1127,7 +1129,7 @@ n9dyFZYXxil/cgFG/PDMnuXy1Wcl8hb8iwQag4Y7ohiLXVTJa/0BAgMBAAE= /** * @group github1579 */ - public function testNakedPKCS1PublicKey() + public function testNakedPKCS1PublicKey(): void { $key = '3082020a0282020100d595c09fbc635612b3ef6a0067d74cb76fa9af62a9272400c2a896f1335b920b88a9accaffe915e38542d296c1a559a586223521da8977030888a8d076910f59489a3a4a10bf950bf2b83278810e4c3bfc027b6b6cb75736cfaabaa83de15c619b8e9f65a60f4cfeba11fb5bf5e93abff68468695948b1843e2e09504281651475f7eff1c30fcb17026f13f04109fc930e489c14a1ef80ec51be6bb73f1679d258c2db535b04f4be82790ac01b4b0e9cb68a9bb5afab4363b5f33ff143ef13d1b2a292a72881d68d765a6c1fc981da0a2644ed284607d19f39802b3967bf9308da1f6515b59a2b0a1c57c14d661a62672f3b9453f931b62c446267d912c0987b7fb4c4fe085e3573ddfd9761ec2c035fa560c6c98343e9d448667b724a919780be2fd8666115d8a75b29e6c1e216cd73a693192f551f72fdf9eac0bb5bda83b11b5159151419249915e6006e6018bc1cda20960d4f1c7df7d401afd322656b4f0810348b8d20d506b08dd8752a0a721efa750b785fb2cb40930d33dd70bd8ad83883470851bd664c648da3f102545f1c54fa803cea5ba3edb51c3b894bd8fbd48d4ed97c251b3eed1d4e636d487a711d3859946acc14f808d777bcc3c5594ac2cd7dcf278ef4e7d3badea740f757a0669f213dadf46e9ff0eeb10720af086ce29e27e0ca2a639f4f3c5825ea5e2774bb3e722ce40e7cf6e2075857797c13d2d50203010001'; $key = PublicKeyLoader::load(hex2bin($key)); @@ -1137,11 +1139,11 @@ n9dyFZYXxil/cgFG/PDMnuXy1Wcl8hb8iwQag4Y7ohiLXVTJa/0BAgMBAAE= /** * @group github1711 */ - public function testRawPrivateKey() + public function testRawPrivateKey(): void { $key = RSA::createKey(512); $str1 = "$key"; - $key = $key->toString('Raw'); + $key = unserialize($key->toString('Raw')); $key = [ 'e' => $key['e'], 'n' => $key['n'], @@ -1155,7 +1157,7 @@ n9dyFZYXxil/cgFG/PDMnuXy1Wcl8hb8iwQag4Y7ohiLXVTJa/0BAgMBAAE= $this->assertSame($str1, $str2); } - public function testPuTTYV3NoPW() + public function testPuTTYV3NoPW(): void { $key = 'PuTTY-User-Key-File-3: ssh-rsa Encryption: none @@ -1188,7 +1190,7 @@ Private-MAC: 7979eb6f604fb3e0bd191295479517f641598649167835402c6cbfde6cbf21ef'; $this->assertInstanceOf(PrivateKey::class, $key); } - public function testPuTTYV3PW() + public function testPuTTYV3PW(): void { if (!function_exists('sodium_crypto_pwhash')) { self::markTestSkipped('sodium_crypto_pwhash() function is not available.'); diff --git a/tests/Unit/Crypt/RSA/ModeTest.php b/tests/Unit/Crypt/RSA/ModeTest.php index 27292730..fdb447b2 100644 --- a/tests/Unit/Crypt/RSA/ModeTest.php +++ b/tests/Unit/Crypt/RSA/ModeTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt\RSA; use phpseclib3\Crypt\PublicKeyLoader; @@ -16,7 +18,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class ModeTest extends PhpseclibTestCase { - public function testEncryptionModeNone() + public function testEncryptionModeNone(): void { $plaintext = 'a'; @@ -53,7 +55,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ /** * @group github768 */ - public function testPSSSigs() + public function testPSSSigs(): void { $rsa = PublicKeyLoader::load('-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVx @@ -71,7 +73,7 @@ p0GbMJDyR4e9T04ZZwIDAQAB $this->assertTrue($rsa->verify('zzzz', $sig)); } - public function testSmallModulo() + public function testSmallModulo(): void { $this->expectException('LengthException'); @@ -86,7 +88,7 @@ p0GbMJDyR4e9T04ZZwIDAQAB $rsa->encrypt($plaintext); } - public function testPKCS1LooseVerify() + public function testPKCS1LooseVerify(): void { $rsa = PublicKeyLoader::load('-----BEGIN RSA PUBLIC KEY----- MIGJAoGBAMuqkz8ij+ESAaNvgocVGmapjlrIldmhRo4h2NX4e6IXiCLTSxASQtY4 @@ -106,7 +108,7 @@ m4k72G75QXhZ+I40ZG7cjBf1/9egakR0a0X0MpeOrKCzMBLv9+mpAgMBAAE= $this->assertTrue($rsa->verify($message, $sig)); } - public function testZeroLengthSalt() + public function testZeroLengthSalt(): void { $plaintext = 'a'; @@ -139,7 +141,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ /** * @group github1423 */ - public function testPSSSigsWithNonPowerOf2Key() + public function testPSSSigsWithNonPowerOf2Key(): void { $pub = <<assertTrue($rsa->verify($payload, $sig)); } - public function testHash() + public function testHash(): void { $pub = <<assertEquals('sha1', $rsa->getMGFHash()); } - public function testPKCS1SigWithoutNull() + public function testPKCS1SigWithoutNull(): void { $rsa = PublicKeyLoader::load([ 'n' => new BigInteger( @@ -214,7 +216,7 @@ HERE; /** * @group github1669 */ - public function testOAEPWithLabel() + public function testOAEPWithLabel(): void { $publicKey = PublicKeyLoader::load('-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnkFHQbt801+kMnxn0VmMVljp8 diff --git a/tests/Unit/Crypt/RandomTest.php b/tests/Unit/Crypt/RandomTest.php index 856e47d1..1bc1d9f1 100644 --- a/tests/Unit/Crypt/RandomTest.php +++ b/tests/Unit/Crypt/RandomTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\Random; @@ -13,7 +15,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class RandomTest extends PhpseclibTestCase { - public function stringLengthData() + public function stringLengthData(): array { return array_map([$this, 'wrap'], [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 20, 23, 29, 31, 37, @@ -23,7 +25,7 @@ class RandomTest extends PhpseclibTestCase } /** @dataProvider stringLengthData */ - public function testStringLength($length) + public function testStringLength($length): void { $this->assertSame( $length, @@ -36,7 +38,7 @@ class RandomTest extends PhpseclibTestCase * Takes a set of random values of length 128 bits and asserts all taken * values are unique. */ - public function testStringUniqueness() + public function testStringUniqueness(): void { $values = []; for ($i = 0; $i < 10000; ++$i) { @@ -51,7 +53,7 @@ class RandomTest extends PhpseclibTestCase } } - protected function wrap($x) + protected function wrap($x): array { // array() is not a function, but $this->wrap() is. return [$x]; diff --git a/tests/Unit/Crypt/Salsa20Test.php b/tests/Unit/Crypt/Salsa20Test.php index 7bced092..6082bfef 100644 --- a/tests/Unit/Crypt/Salsa20Test.php +++ b/tests/Unit/Crypt/Salsa20Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\Salsa20; @@ -13,7 +15,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class Salsa20Test extends PhpseclibTestCase { - public function engineVectors() + public function engineVectors(): array { $engines = [ 'PHP', @@ -147,7 +149,7 @@ class Salsa20Test extends PhpseclibTestCase /** * @dataProvider engineVectors */ - public function testVectors($engine, $key, $iv, $expected) + public function testVectors($engine, $key, $iv, $expected): void { $cipher = new Salsa20(); $cipher->setPreferredEngine($engine); diff --git a/tests/Unit/Crypt/TripleDESTest.php b/tests/Unit/Crypt/TripleDESTest.php index b226f779..f9f98848 100644 --- a/tests/Unit/Crypt/TripleDESTest.php +++ b/tests/Unit/Crypt/TripleDESTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\TripleDES; @@ -20,7 +22,7 @@ class TripleDESTest extends PhpseclibTestCase 'OpenSSL', ]; - public function engineVectors() + public function engineVectors(): array { // tests from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf#page=273 $tests = [ @@ -106,7 +108,7 @@ class TripleDESTest extends PhpseclibTestCase /** * @dataProvider engineVectors */ - public function testVectors($engine, $key, $plaintext, $expected) + public function testVectors($engine, $key, $plaintext, $expected): void { $des = new TripleDES('cbc'); if (!$des->isValidEngine($engine)) { @@ -121,7 +123,7 @@ class TripleDESTest extends PhpseclibTestCase $this->assertEquals($result, $expected, "Failed asserting that $plaintext yielded expected output in $engine engine"); } - public function engineIVVectors() + public function engineIVVectors(): array { $engines = [ 'PHP', @@ -159,7 +161,7 @@ class TripleDESTest extends PhpseclibTestCase /** * @dataProvider engineIVVectors */ - public function testVectorsWithIV($engine, $key, $iv, $plaintext, $expected) + public function testVectorsWithIV($engine, $key, $iv, $plaintext, $expected): void { $des = new TripleDES('cbc'); if (!$des->isValidEngine($engine)) { @@ -174,7 +176,7 @@ class TripleDESTest extends PhpseclibTestCase $this->assertEquals($result, $expected, "Failed asserting that $plaintext yielded expected output in $engine engine"); } - public function testInnerChaining() + public function testInnerChaining(): void { // regular CBC returns // e089b6d84708c6bc80be6c2da82bd19a79ffe11f02933ac1 @@ -196,11 +198,8 @@ class TripleDESTest extends PhpseclibTestCase /** * @dataProvider provideForCorrectSelfUseInLambda - * @param string $key - * @param string $expectedCiphertext - * @return void */ - public function testCorrectSelfUseInLambda($key, $expectedCiphertext) + public function testCorrectSelfUseInLambda(string $key, string $expectedCiphertext): void { $td = new TripleDES('ecb'); $td->setPreferredEngine('Eval'); @@ -212,7 +211,7 @@ class TripleDESTest extends PhpseclibTestCase /** * @return list */ - public function provideForCorrectSelfUseInLambda() + public function provideForCorrectSelfUseInLambda(): array { return [ ['YWFhYWFhYWFhYWFhYWFhYWFhYWG9l9gm', 'fDSmC5bbLdx8NKYLltst3Hw0pguW2y3cfDSmC5bbLdxmhqEOIeS2ig=='], diff --git a/tests/Unit/Crypt/TwofishTest.php b/tests/Unit/Crypt/TwofishTest.php index 916d7d79..a8645d20 100644 --- a/tests/Unit/Crypt/TwofishTest.php +++ b/tests/Unit/Crypt/TwofishTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Crypt; use phpseclib3\Crypt\Twofish; @@ -13,7 +15,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class TwofishTest extends PhpseclibTestCase { - public function testVectors() + public function testVectors(): void { $engines = [ 'PHP', diff --git a/tests/Unit/File/ANSITest.php b/tests/Unit/File/ANSITest.php index 2d0d1755..5a541a30 100644 --- a/tests/Unit/File/ANSITest.php +++ b/tests/Unit/File/ANSITest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\File; use phpseclib3\File\ANSI; @@ -13,7 +15,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class ANSITest extends PhpseclibTestCase { - public function testCase1() + public function testCase1(): void { $str = "\x1B[07m"; // turn reverse video on $str .= "aaaaaaaaaaaaaaaaaa"; @@ -33,7 +35,7 @@ class ANSITest extends PhpseclibTestCase $this->assertSame($ansi->getScreen(), $expected); } - public function testCaseJ() + public function testCaseJ(): void { $str = "\x1B[H"; // Move cursor to upper left corner $str .= "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -49,7 +51,7 @@ class ANSITest extends PhpseclibTestCase $this->assertSame($ansi->getScreen(), $expected); } - public function testLineOverflow() + public function testLineOverflow(): void { $str = ''; foreach (range('a', 'y') as $char) { diff --git a/tests/Unit/File/ASN1Test.php b/tests/Unit/File/ASN1Test.php index a6419584..8a9a016e 100644 --- a/tests/Unit/File/ASN1Test.php +++ b/tests/Unit/File/ASN1Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\File; use phpseclib3\File\ASN1; @@ -17,7 +19,7 @@ class ASN1Test extends PhpseclibTestCase * on older versions of \phpseclib3\File\ASN1 this would yield a PHP Warning * @group github275 */ - public function testAnyString() + public function testAnyString(): void { $KDC_REP = [ 'type' => ASN1::TYPE_SEQUENCE, @@ -89,7 +91,7 @@ class ASN1Test extends PhpseclibTestCase * on older versions of \phpseclib3\File\ASN1 this would produce a null instead of an array * @group github275 */ - public function testIncorrectString() + public function testIncorrectString(): void { $PA_DATA = [ 'type' => ASN1::TYPE_SEQUENCE, @@ -239,13 +241,13 @@ class ASN1Test extends PhpseclibTestCase /** * older versions of ASN1 didn't handle indefinite length tags very well */ - public function testIndefiniteLength() + public function testIndefiniteLength(): void { $decoded = ASN1::decodeBER(file_get_contents(dirname(__FILE__) . '/ASN1/FE.pdf.p7m')); $this->assertCount(5, $decoded[0]['content'][1]['content'][0]['content']); // older versions would have returned 3 } - public function testDefiniteLength() + public function testDefiniteLength(): void { // the following base64-encoded string is the X.509 cert from $str = 'MIIDITCCAoqgAwIBAgIQT52W2WawmStUwpV8tBV9TTANBgkqhkiG9w0BAQUFADBM' . @@ -272,7 +274,7 @@ class ASN1Test extends PhpseclibTestCase /** * @group github477 */ - public function testContextSpecificNonConstructed() + public function testContextSpecificNonConstructed(): void { $decoded = ASN1::decodeBER(base64_decode('MBaAFJtUo7c00HsI5EPZ4bkICfkOY2Pv')); $this->assertIsString($decoded[0]['content'][0]['content']); @@ -281,7 +283,7 @@ class ASN1Test extends PhpseclibTestCase /** * @group github602 */ - public function testEmptyContextTag() + public function testEmptyContextTag(): void { $decoded = ASN1::decodeBER("\xa0\x00"); $this->assertIsArray($decoded); @@ -291,7 +293,7 @@ class ASN1Test extends PhpseclibTestCase /** * @group github1027 */ - public function testInfiniteLoop() + public function testInfiniteLoop(): void { $data = base64_decode('MD6gJQYKKwYBBAGCNxQCA6AXDBVvZmZpY2VAY2VydGRpZ2l0YWwucm+BFW9mZmljZUBjZXJ0ZGlnaXRhbC5ybw=='); self::assertSame( @@ -300,9 +302,9 @@ class ASN1Test extends PhpseclibTestCase ); } - public function testMaps() + public function testMaps(): void { - $files = scandir('phpseclib/File/ASN1/Maps'); + $files = scandir(__DIR__ . '/../../../phpseclib/File/ASN1/Maps'); self::assertNotEmpty($files); foreach ($files as $file) { if ($file == '.' || $file == '..') { @@ -312,7 +314,7 @@ class ASN1Test extends PhpseclibTestCase } } - public function testApplicationTag() + public function testApplicationTag(): void { $map = [ 'type' => ASN1::TYPE_SEQUENCE, @@ -346,7 +348,7 @@ class ASN1Test extends PhpseclibTestCase /** * @group github1296 */ - public function testInvalidCertificate() + public function testInvalidCertificate(): void { $data = 'a' . base64_decode('MD6gJQYKKwYBBAGCNxQCA6AXDBVvZmZpY2VAY2VydGRpZ2l0YWwucm+BFW9mZmljZUBjZXJ0ZGlnaXRhbC5ybw=='); self::assertSame( @@ -358,7 +360,7 @@ class ASN1Test extends PhpseclibTestCase /** * @group github1367 */ - public function testOIDs() + public function testOIDs(): void { // from the example in 8.19.5 in the following: // https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=22 @@ -378,7 +380,7 @@ class ASN1Test extends PhpseclibTestCase /** * @group github1388 */ - public function testExplicitImplicitDate() + public function testExplicitImplicitDate(): void { $map = [ 'type' => ASN1::TYPE_SEQUENCE, @@ -403,7 +405,7 @@ class ASN1Test extends PhpseclibTestCase $this->assertIsArray($a); } - public function testNullGarbage() + public function testNullGarbage(): void { $em = pack('H*', '3080305c0609608648016503040201054f8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888804207509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9'); $decoded = ASN1::decodeBER($em); @@ -414,7 +416,7 @@ class ASN1Test extends PhpseclibTestCase $this->assertFalse($decoded[0]); } - public function testOIDGarbage() + public function testOIDGarbage(): void { $em = pack('H*', '3080305c065860864801650304020188888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888050004207509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9'); $decoded = ASN1::decodeBER($em); @@ -425,7 +427,7 @@ class ASN1Test extends PhpseclibTestCase $this->assertFalse($decoded[0]); } - public function testConstructedMismatch() + public function testConstructedMismatch(): void { $em = pack('H*', '1031300d0609608648016503040201050004207509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9'); $decoded = ASN1::decodeBER($em); @@ -444,7 +446,7 @@ class ASN1Test extends PhpseclibTestCase $this->assertFalse($decoded[0]); } - public function testBadTagSecondOctet() + public function testBadTagSecondOctet(): void { $em = pack('H*', '3033300f1f808080060960864801650304020104207509e5bda0c762d2bac7f90d758b5b2263fa01ccbc542ab5e3df163be08e6ca9'); $decoded = ASN1::decodeBER($em); diff --git a/tests/Unit/File/X509/CRLTest.php b/tests/Unit/File/X509/CRLTest.php index 2670621e..8c6f808f 100644 --- a/tests/Unit/File/X509/CRLTest.php +++ b/tests/Unit/File/X509/CRLTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\File\X509; use phpseclib3\File\X509; @@ -13,7 +15,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class CRLTest extends PhpseclibTestCase { - public function testLoadCRL() + public function testLoadCRL(): void { $test = file_get_contents(__DIR__ . '/crl.bin'); diff --git a/tests/Unit/File/X509/CSRTest.php b/tests/Unit/File/X509/CSRTest.php index 3120a5ae..26298125 100644 --- a/tests/Unit/File/X509/CSRTest.php +++ b/tests/Unit/File/X509/CSRTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\File\X509; use phpseclib3\Crypt\PublicKeyLoader; @@ -15,7 +17,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class CSRTest extends PhpseclibTestCase { - public function testLoadCSR() + public function testLoadCSR(): void { $test = '-----BEGIN CERTIFICATE REQUEST----- MIIBWzCBxQIBADAeMRwwGgYDVQQKDBNwaHBzZWNsaWIgZGVtbyBjZXJ0MIGdMAsG @@ -35,7 +37,7 @@ v5RwaQHmQEzHofTzF7I+ $this->assertIsArray($spkac); } - public function testCSRWithAttributes() + public function testCSRWithAttributes(): void { $test = '-----BEGIN NEW CERTIFICATE REQUEST----- MIIFGDCCAwACAQAwOjEWMBQGCgmSJomT8ixkARkWBnNlY3VyZTEgMB4GA1UEAxMX @@ -75,7 +77,7 @@ draiRBZruwMPwPIP $this->assertIsArray($csr); } - public function testCSRDER() + public function testCSRDER(): void { $csr = 'MIICdzCCAV8CAQEwDDEKMAgGA1UEAwwBeDCCASIwDQYJKoZIhvcNAQEBBQADggEP' . 'ADCCAQoCggEBALtcrFDD2AHe3x2bR00wPDsPH6FJLxr5uc1ybb+ldDB5xNVImC8P' . @@ -101,7 +103,7 @@ draiRBZruwMPwPIP } // on PHP 7.1, with older versions of phpseclib, this would produce a "A non-numeric value encountered" warning - public function testNewCSR() + public function testNewCSR(): void { $x509 = new X509(); @@ -132,7 +134,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ /** * @group github1675 */ - public function testPKCS1CSR() + public function testPKCS1CSR(): void { $x509 = new X509(); $x509->loadCSR('-----BEGIN CERTIFICATE REQUEST----- @@ -158,7 +160,7 @@ fUQvcGEA9FSQ8Y0nfF9vzzcCjLtOI6xJluYL9XCk8WVEBEawA2zmHWTzzuHFHHEM /** * @group github1675 */ - public function testPSSCSR() + public function testPSSCSR(): void { $x509 = new X509(); $x509->loadCSR('-----BEGIN CERTIFICATE REQUEST----- diff --git a/tests/Unit/File/X509/SPKACTest.php b/tests/Unit/File/X509/SPKACTest.php index 6cd57252..3b9a4fed 100644 --- a/tests/Unit/File/X509/SPKACTest.php +++ b/tests/Unit/File/X509/SPKACTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\File\X509; use phpseclib3\Crypt\RSA; @@ -14,7 +16,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class SPKACTest extends PhpseclibTestCase { - public function testLoadSPKAC() + public function testLoadSPKAC(): void { $test = 'MIICQDCCASgwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQChgo9mWzQm3TSwGgpZnIc54' . 'TZ8gYpfAO/AI0etvyWDqnFfdNCUQsqxTdSi6/rtrJdLGBsszRGrRIc/0JqmjM+jCHGYutLeo4xwgr' . @@ -48,7 +50,7 @@ class SPKACTest extends PhpseclibTestCase $this->assertIsString("$pubKey"); } - public function testSaveSPKAC() + public function testSaveSPKAC(): void { $privatekey = RSA::createKey(512) ->withPadding(RSA::SIGNATURE_PKCS1) @@ -72,7 +74,7 @@ class SPKACTest extends PhpseclibTestCase $this->assertIsString($x509->saveSPKAC($spkac)); } - public function testBadSignatureSPKAC() + public function testBadSignatureSPKAC(): void { $test = 'MIICQDCCASgwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQChgo9mWzQm3TSwGgpZnIc54' . 'TZ8gYpfAO/AI0etvyWDqnFfdNCUQsqxTdSi6/rtrJdLGBsszRGrRIc/0JqmjM+jCHGYutLeo4xwgr' . diff --git a/tests/Unit/File/X509/X509ExtensionTest.php b/tests/Unit/File/X509/X509ExtensionTest.php index c8b0c60e..373d284a 100644 --- a/tests/Unit/File/X509/X509ExtensionTest.php +++ b/tests/Unit/File/X509/X509ExtensionTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\File\X509; use phpseclib3\Crypt\EC; @@ -16,7 +18,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class X509ExtensionTest extends PhpseclibTestCase { - public function testCustomExtension() + public function testCustomExtension(): void { $customExtensionData = [ 'toggle' => true, @@ -88,7 +90,7 @@ class X509ExtensionTest extends PhpseclibTestCase $this->assertSame($customExtensionMapping, X509::getRegisteredExtension($customExtensionName)); } - public function testCustomExtensionRegisterTwiceTheSame() + public function testCustomExtensionRegisterTwiceTheSame(): void { $customExtensionMapping = [ 'type' => ASN1::TYPE_SEQUENCE, @@ -111,7 +113,7 @@ class X509ExtensionTest extends PhpseclibTestCase $this->assertSame($customExtensionMapping, X509::getRegisteredExtension('foo')); } - public function testCustomExtensionRegisterConflict() + public function testCustomExtensionRegisterConflict(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Extension bar has already been defined with a different mapping.'); @@ -120,7 +122,7 @@ class X509ExtensionTest extends PhpseclibTestCase X509::registerExtension('bar', ['type' => ASN1::TYPE_ANY]); } - public function testExtensionsAreInitializedIfMissing() + public function testExtensionsAreInitializedIfMissing(): void { $issuerKey = EC::createKey('ed25519'); $subjectKey = EC::createKey('ed25519')->getPublicKey(); diff --git a/tests/Unit/File/X509/X509Test.php b/tests/Unit/File/X509/X509Test.php index 8d03c686..5b38fedc 100644 --- a/tests/Unit/File/X509/X509Test.php +++ b/tests/Unit/File/X509/X509Test.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\File\X509; use phpseclib3\Crypt\PublicKeyLoader; @@ -17,7 +19,7 @@ use phpseclib3\Tests\PhpseclibTestCase; class X509Test extends PhpseclibTestCase { - public function testExtensionMapping() + public function testExtensionMapping(): void { $test = '-----BEGIN CERTIFICATE----- MIIG1jCCBL6gAwIBAgITUAAAAA0qg8bE6DhrLAAAAAAADTANBgkqhkiG9w0BAQsF @@ -66,7 +68,7 @@ k6m17mi63YW/+iPCGOWZ2qXmY5HPEyyF2L4L4IDryFJ+8xLyw3pH9/yp5aHZDtp6 $this->assertIsArray($cert['tbsCertificate']['extensions'][3]['extnValue']); } - public function testLoadUnsupportedExtension() + public function testLoadUnsupportedExtension(): void { $test = '-----BEGIN CERTIFICATE----- MIIG1jCCBL6gAwIBAgITUAAAAA0qg8bE6DhrLAAAAAAADTANBgkqhkiG9w0BAQsF @@ -115,7 +117,7 @@ k6m17mi63YW/+iPCGOWZ2qXmY5HPEyyF2L4L4IDryFJ+8xLyw3pH9/yp5aHZDtp6 $this->assertEquals(base64_decode('MDUwDgYIKoZIhvcNAwICAgCAMA4GCCqGSIb3DQMEAgIAgDAHBgUrDgMCBzAKBggqhkiG9w0DBw=='), $cert['tbsCertificate']['extensions'][8]['extnValue']); } - public function testSaveUnsupportedExtension() + public function testSaveUnsupportedExtension(): void { $x509 = new X509(); $cert = $x509->loadX509('-----BEGIN CERTIFICATE----- @@ -154,7 +156,7 @@ IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q== /** * @group github705 */ - public function testSaveNullRSAParam() + public function testSaveNullRSAParam(): void { $privKey = PublicKeyLoader::load('-----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQDMswfEpAgnUDWA74zZw5XcPsWh1ly1Vk99tsqwoFDkLF7jvXy1 @@ -197,7 +199,7 @@ aBtsWpliLSex/HHhtRW9AkBGcq67zKmEpJ9kXcYLEjJii3flFS+Ct/rNm+Hhm1l7 $this->assertArrayHasKey('parameters', $cert['tbsCertificate']['signature']); } - public function testGetOID() + public function testGetOID(): void { // load the OIDs new X509(); @@ -206,7 +208,7 @@ aBtsWpliLSex/HHhtRW9AkBGcq67zKmEpJ9kXcYLEjJii3flFS+Ct/rNm+Hhm1l7 $this->assertEquals(ASN1::getOID('zzz'), 'zzz'); } - public function testIPAddressSubjectAltNamesDecoding() + public function testIPAddressSubjectAltNamesDecoding(): void { $test = '-----BEGIN CERTIFICATE----- MIIEcTCCAlmgAwIBAgIBDjANBgkqhkiG9w0BAQsFADAfMR0wGwYDVQQDDBQuU2Vj @@ -241,7 +243,7 @@ NDEuGt30Vl2de7G1glnhaceB6Q9KfH7p2gAwNP9JMTtx3PtEcA== $this->assertEquals($cert['tbsCertificate']['extensions'][3]['extnValue'][1]['iPAddress'], '2001:470:f309:9::3'); } - public function testPostalAddress() + public function testPostalAddress(): void { $x509 = new X509(); $decoded = $x509->loadX509('-----BEGIN CERTIFICATE----- @@ -293,7 +295,7 @@ Mj93S $this->assertEquals($x509->getDN(X509::DN_STRING), $expected); } - public function testStrictComparison() + public function testStrictComparison(): void { $x509 = new X509(); $x509->loadCA('-----BEGIN CERTIFICATE----- @@ -361,7 +363,7 @@ Mj93S } // fixed by #1104 - public function testMultipleDomainNames() + public function testMultipleDomainNames(): void { $privatekey = RSA::createKey(512) ->withPadding(RSA::SIGNATURE_PKCS1) @@ -382,7 +384,7 @@ Mj93S self::assertTrue(true); } - public function testUtcTimeWithoutSeconds() + public function testUtcTimeWithoutSeconds(): void { $test = '-----BEGIN CERTIFICATE----- MIIGFDCCBPygAwIBAgIDKCHVMA0GCSqGSIb3DQEBBQUAMIHcMQswCQYDVQQGEwJVUzEQMA4GA1UE @@ -424,7 +426,7 @@ F7xAUxmPUnNb2teatMf2Rmj0fs+d $this->assertEquals($cert['tbsCertificate']['validity']['notAfter']['utcTime'], 'Fri, 01 Apr 2016 07:00:00 +0000'); } - public function testValidateURL() + public function testValidateURL(): void { $test = '-----BEGIN CERTIFICATE----- MIIEgDCCA2igAwIBAgIIPUwrl6kGL2QwDQYJKoZIhvcNAQELBQAwSTELMAkGA1UE @@ -461,7 +463,7 @@ C47x9g== $this->assertTrue($x509->validateURL('https://www.google.com')); } - public function testValidateSignatureWithoutKeyIdentifier() + public function testValidateSignatureWithoutKeyIdentifier(): void { $x509 = new X509(); $x509->loadX509('-----BEGIN CERTIFICATE----- @@ -511,7 +513,7 @@ HI8pYRZmT7tKW3HxlZLJGGVo5CgBawdiWngK5v+LwWiNRTqxJA== $this->assertTrue($x509->validateSignature()); } - public function testValidateSignatureSelfSignedWithoutKeyIdentifier() + public function testValidateSignatureSelfSignedWithoutKeyIdentifier(): void { $x509 = new X509(); $x509->loadX509('-----BEGIN CERTIFICATE----- @@ -544,7 +546,7 @@ HI8pYRZmT7tKW3HxlZLJGGVo5CgBawdiWngK5v+LwWiNRTqxJA== /** * @group github1243 */ - public function testExtensionRemoval() + public function testExtensionRemoval(): void { // Load the CA and its private key. $pemcakey = '-----BEGIN RSA PRIVATE KEY----- @@ -615,7 +617,7 @@ Fqfy+n5VpXOdrjic4yZ52yS5sUaq05s6ZZvnmdU= $newcert->saveX509($crt); } - public function testAuthorityInfoAccess() + public function testAuthorityInfoAccess(): void { $x509 = new X509(); $x509->loadCA('-----BEGIN CERTIFICATE----- @@ -687,7 +689,7 @@ M0qaEPsM2o3CSTfxSJQQIyEe+izV3UQqYSyWkNqCCFPN $this->assertTrue($x509->validateSignature()); } - public function testValidateDate() + public function testValidateDate(): void { $x509 = new X509(); $x509->loadX509('-----BEGIN CERTIFICATE----- @@ -714,7 +716,7 @@ IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q== $this->assertTrue($x509->validateDate('Nov 22, 2012')); } - public function testDSALoad() + public function testDSALoad(): void { // openssl dsaparam -out params.pem 3072 // openssl gendsa -out key.pem params.pem @@ -764,7 +766,7 @@ pMAUPdvLhVjjTvw4ypYrNMc4Z3z5n3bfCVzIQL5Z $this->assertTrue($x509->validateSignature(false)); } - public function testECLoad() + public function testECLoad(): void { // openssl req -x509 -nodes -days 3650 -newkey ec:<(openssl ecparam -name prime256v1) -keyout ecdsakey.pem -out ecdsacert.pem @@ -789,7 +791,7 @@ f11dQP8CIDoB2AbvB3Yk/iGduWpw+3FwNAZ1y/rTqQK6+XgZCt6K $this->assertTrue($x509->validateSignature(false)); } - public function testPSSLoad() + public function testPSSLoad(): void { // openssl genpkey -algorithm rsa-pss -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 -pkeyopt rsa_pss_keygen_md:sha256 -pkeyopt rsa_pss_keygen_mgf1_md:sha512 -pkeyopt rsa_pss_keygen_saltlen:5 -out CA.priKey // openssl req -x509 -new -key CA.priKey -subj "/CN=CA" -sha256 -pkeyopt rsa_pss_keygen_md:sha256 -pkeyopt rsa_pss_keygen_mgf1_md:sha512 -pkeyopt rsa_pss_keygen_saltlen:5 -out CA.cer @@ -824,7 +826,7 @@ edu9tyNNr2vvZjshoY5y58+hVIjee/Pzxa7GX0LDEmK8FdFBxWeNx0g/TsZj6GE= $this->assertTrue($x509->validateSignature(false)); } - public function testDSASave() + public function testDSASave(): void { $private = '-----BEGIN DSA PRIVATE KEY----- MIIE1QIBAAKCAYEAwuma6tTTvSg9HUXseAquivUpXyEvyKmIf0XU/EOn4Y6EryoF @@ -878,7 +880,7 @@ uhPlgkgknwIgdDqqKIAF60ouiynsbU53ERS0TwpjeFiYGA48SwYW3Nk= $this->assertSame('id-dsa-with-sha256', $r['signatureAlgorithm']['algorithm']); } - public function testECSave() + public function testECSave(): void { $private = '-----BEGIN PRIVATE KEY----- MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgQ0o1byJQbAcuklBt @@ -909,7 +911,7 @@ wkwhE/JaQAEHq2PHnEmvwyBiJcHSdLXkcLzYlg19Ho0BPqVKdulx8GAk $this->assertSame('ecdsa-with-SHA256', $r['signatureAlgorithm']['algorithm']); } - public function testPSSSave() + public function testPSSSave(): void { $private = '-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp @@ -951,7 +953,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertArrayHasKey('parameters', $r['signatureAlgorithm']); } - public function testPKCS1Save() + public function testPKCS1Save(): void { $private = '-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp @@ -992,7 +994,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ $this->assertSame('sha256WithRSAEncryption', $r['signatureAlgorithm']['algorithm']); } - public function testLongTagOnBadCert() + public function testLongTagOnBadCert(): void { // the problem with this cert is that it'd cause an infinite loop $x509 = new X509(); @@ -1014,7 +1016,7 @@ A9bhRA0cVk7bAEU2c44CYg== /** * @group github1387 */ - public function testNameConstraintIP() + public function testNameConstraintIP(): void { $x509 = new X509(); $r = $x509->loadX509('-----BEGIN CERTIFICATE----- @@ -1056,7 +1058,7 @@ ut3+b2Xvzq8yzmHMFtLIJ6Afu1jJpqD82BUAFcvi5vhnP8M7b974R18WCOpgNQvXDI+2/8ZINeU= /** * @group github1456 */ - public function testRandomString() + public function testRandomString(): void { $a = 'da7e705569d4196cd49cf3b3d92cd435ca34ccbe'; $a = pack('H*', $a); @@ -1070,7 +1072,7 @@ ut3+b2Xvzq8yzmHMFtLIJ6Afu1jJpqD82BUAFcvi5vhnP8M7b974R18WCOpgNQvXDI+2/8ZINeU= /** * @group github1542 */ - public function testMultiCertPEM() + public function testMultiCertPEM(): void { $a = '-----BEGIN CERTIFICATE----- MIILODCCCSCgAwIBAgIQDh0LGipJ++wxFLj8X5MXKDANBgkqhkiG9w0BAQsFADCB @@ -1186,7 +1188,7 @@ qzFkAKWjJj4KjfrbZX4C0Spfxw== <<<<<<< HEAD * @group github1586 */ - public function testComputeKeyIdentifier() + public function testComputeKeyIdentifier(): void { $key = RSA::createKey(512); $key = ASN1::extractBER("$key"); @@ -1200,7 +1202,7 @@ qzFkAKWjJj4KjfrbZX4C0Spfxw== /** * @group github1665 */ - public function testImplicitV1() + public function testImplicitV1(): void { $x509 = new X509(); $r = $x509->loadX509('-----BEGIN CERTIFICATE----- @@ -1230,7 +1232,7 @@ itRo91vT68U= /** * @group github1657 */ - public function signWithEncryptedPSS() + public function signWithEncryptedPSS(): void { $private = PublicKeyLoader::load('-----BEGIN ENCRYPTED PRIVATE KEY----- MIIBvTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIpZHwLtkYRb4CAggA @@ -1260,7 +1262,7 @@ o2UiZsxgoMYuq02T07DOknc= /** * @group github1676 */ - public function testMalformedExt() + public function testMalformedExt(): void { $a = '-----BEGIN CERTIFICATE----- MIIDtjCCAmmgAwIBAgIUOynecffcNv1/7oqCfu98x899PhwwQgYJKoZIhvcNAQEK diff --git a/tests/Unit/Math/BigInteger/BCMathTest.php b/tests/Unit/Math/BigInteger/BCMathTest.php index 5f5d9a25..a155ee40 100644 --- a/tests/Unit/Math/BigInteger/BCMathTest.php +++ b/tests/Unit/Math/BigInteger/BCMathTest.php @@ -6,13 +6,15 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Math\BigInteger; use phpseclib3\Math\BigInteger\Engines\BCMath; class BCMathTest extends TestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!BCMath::isValidEngine()) { self::markTestSkipped('BCMath extension is not available.'); @@ -20,12 +22,12 @@ class BCMathTest extends TestCase BCMath::setModExpEngine('DefaultEngine'); } - public function getInstance($x = 0, $base = 10) + public function getInstance($x = 0, $base = 10): BCMath { return new BCMath($x, $base); } - public static function getStaticClass() + public static function getStaticClass(): string { return 'phpseclib3\Math\BigInteger\Engines\BCMath'; } diff --git a/tests/Unit/Math/BigInteger/DefaultTest.php b/tests/Unit/Math/BigInteger/DefaultTest.php index 03f88505..219ee5df 100644 --- a/tests/Unit/Math/BigInteger/DefaultTest.php +++ b/tests/Unit/Math/BigInteger/DefaultTest.php @@ -6,18 +6,20 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Math\BigInteger; use phpseclib3\Math\BigInteger; class DefaultTest extends TestCase { - public function getInstance($x = 0, $base = 10) + public function getInstance($x = 0, $base = 10): BigInteger { return new BigInteger($x, $base); } - public static function getStaticClass() + public static function getStaticClass(): string { return 'phpseclib3\Math\BigInteger'; } diff --git a/tests/Unit/Math/BigInteger/GMPTest.php b/tests/Unit/Math/BigInteger/GMPTest.php index 4a2eda15..f81cc3c9 100644 --- a/tests/Unit/Math/BigInteger/GMPTest.php +++ b/tests/Unit/Math/BigInteger/GMPTest.php @@ -6,13 +6,15 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Math\BigInteger; use phpseclib3\Math\BigInteger\Engines\GMP; class GMPTest extends TestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!GMP::isValidEngine()) { self::markTestSkipped('GNU Multiple Precision (GMP) extension is not available.'); @@ -20,12 +22,12 @@ class GMPTest extends TestCase GMP::setModExpEngine('DefaultEngine'); } - public function getInstance($x = 0, $base = 10) + public function getInstance($x = 0, $base = 10): GMP { return new GMP($x, $base); } - public static function getStaticClass() + public static function getStaticClass(): string { return 'phpseclib3\Math\BigInteger\Engines\GMP'; } diff --git a/tests/Unit/Math/BigInteger/PHP32Test.php b/tests/Unit/Math/BigInteger/PHP32Test.php index 5319bc92..755e7a31 100644 --- a/tests/Unit/Math/BigInteger/PHP32Test.php +++ b/tests/Unit/Math/BigInteger/PHP32Test.php @@ -6,13 +6,15 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Math\BigInteger; use phpseclib3\Math\BigInteger\Engines\PHP32; class PHP32Test extends TestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (version_compare(PHP_VERSION, '7.0.0') < 0) { self::markTestSkipped('32-bit integers slow things down too much on PHP 5.6'); @@ -21,12 +23,12 @@ class PHP32Test extends TestCase PHP32::setModExpEngine('DefaultEngine'); } - public function getInstance($x = 0, $base = 10) + public function getInstance($x = 0, $base = 10): PHP32 { return new PHP32($x, $base); } - public function testInternalRepresentation() + public function testInternalRepresentation(): void { $x = new PHP32('FFFFFFFFFFFFFFFFC90FDA', 16); $y = new PHP32("$x"); @@ -34,7 +36,7 @@ class PHP32Test extends TestCase $this->assertEquals(self::getVar($x, 'value'), self::getVar($y, 'value')); } - public static function getStaticClass() + public static function getStaticClass(): string { return 'phpseclib3\Math\BigInteger\Engines\PHP32'; } diff --git a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php index ba595196..0239cc13 100644 --- a/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php +++ b/tests/Unit/Math/BigInteger/PHP64OpenSSLTest.php @@ -6,6 +6,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Math\BigInteger; use phpseclib3\Exception\BadConfigurationException; @@ -13,7 +15,7 @@ use phpseclib3\Math\BigInteger\Engines\PHP64; class PHP64OpenSSLTest extends TestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!PHP64::isValidEngine()) { self::markTestSkipped('64-bit integers are not available.'); @@ -26,12 +28,12 @@ class PHP64OpenSSLTest extends TestCase } } - public function getInstance($x = 0, $base = 10) + public function getInstance($x = 0, $base = 10): PHP64 { return new PHP64($x, $base); } - public function testInternalRepresentation() + public function testInternalRepresentation(): void { $x = new PHP64('FFFFFFFFFFFFFFFFC90FDA', 16); $y = new PHP64("$x"); @@ -39,7 +41,7 @@ class PHP64OpenSSLTest extends TestCase $this->assertSame(self::getVar($x, 'value'), self::getVar($y, 'value')); } - public static function getStaticClass() + public static function getStaticClass(): string { return 'phpseclib3\Math\BigInteger\Engines\PHP64'; } diff --git a/tests/Unit/Math/BigInteger/PHP64Test.php b/tests/Unit/Math/BigInteger/PHP64Test.php index 95165e68..f7d510bb 100644 --- a/tests/Unit/Math/BigInteger/PHP64Test.php +++ b/tests/Unit/Math/BigInteger/PHP64Test.php @@ -6,13 +6,15 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Math\BigInteger; use phpseclib3\Math\BigInteger\Engines\PHP64; class PHP64Test extends TestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!PHP64::isValidEngine()) { self::markTestSkipped('64-bit integers are not available.'); @@ -20,12 +22,12 @@ class PHP64Test extends TestCase PHP64::setModExpEngine('DefaultEngine'); } - public function getInstance($x = 0, $base = 10) + public function getInstance($x = 0, $base = 10): PHP64 { return new PHP64($x, $base); } - public function testInternalRepresentation() + public function testInternalRepresentation(): void { $x = new PHP64('FFFFFFFFFFFFFFFFC90FDA', 16); $y = new PHP64("$x"); @@ -33,7 +35,7 @@ class PHP64Test extends TestCase $this->assertSame(self::getVar($x, 'value'), self::getVar($y, 'value')); } - public static function getStaticClass() + public static function getStaticClass(): string { return 'phpseclib3\Math\BigInteger\Engines\PHP64'; } diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index 48d71fbf..2a39ec4c 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -6,24 +6,26 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Math\BigInteger; use phpseclib3\Tests\PhpseclibTestCase; abstract class TestCase extends PhpseclibTestCase { - public function testConstructorBase2() + public function testConstructorBase2(): void { // 2**65 = 36893488147419103232 $this->assertSame('36893488147419103232', (string) $this->getInstance('1' . str_repeat('0', 65), 2)); } - public function testConstructorBase10() + public function testConstructorBase10(): void { $this->assertSame('18446744073709551616', (string) $this->getInstance('18446744073709551616')); } - public function testConstructorBase16() + public function testConstructorBase16(): void { $this->assertSame('50', (string) $this->getInstance('0x32', 16)); $this->assertSame('12345678910', (string) $this->getInstance('0x2DFDC1C3E', 16)); @@ -31,34 +33,34 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('18446744073709551616', (string) $this->getInstance('0x10000000000000000', 16)); } - public function testConstructorBase256() + public function testConstructorBase256(): void { $this->assertSame('-128', (string) $this->getInstance("\x80", -256)); } - public function testToBytes() + public function testToBytes(): void { $this->assertSame(chr(65), $this->getInstance('65')->toBytes()); } - public function testToBytesTwosCompliment() + public function testToBytesTwosCompliment(): void { $this->assertSame(chr(126), $this->getInstance('01111110', 2)->toBytes(true)); } - public function testToHex() + public function testToHex(): void { $this->assertSame('41', $this->getInstance('65')->toHex()); } - public function testToBits() + public function testToBits(): void { $this->assertSame('1000001', $this->getInstance('65')->toBits()); $this->assertSame('10', $this->getInstance('-2')->toBits()); $this->assertSame('11111110', $this->getInstance('-2')->toBits(true)); } - public function testAdd() + public function testAdd(): void { $x = $this->getInstance('18446744073709551615'); $y = $this->getInstance('100000000000'); @@ -73,14 +75,14 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('18446744173709551615', (string) $b); } - public function testSubtract() + public function testSubtract(): void { $x = $this->getInstance('18446744073709551618'); $y = $this->getInstance('4000000000000'); $this->assertSame('18446740073709551618', (string) $x->subtract($y)); } - public function testMultiply() + public function testMultiply(): void { $x = $this->getInstance('8589934592'); // 2**33 $y = $this->getInstance('36893488147419103232'); // 2**65 @@ -95,7 +97,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('316912650057057350374175801344', (string) $b); } - public function testDivide() + public function testDivide(): void { $x = $this->getInstance('1180591620717411303425'); // 2**70 + 1 $y = $this->getInstance('12345678910'); @@ -122,7 +124,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('1', (string) $r); } - public function testModPow() + public function testModPow(): void { $a = $this->getInstance('10'); $b = $this->getInstance('20'); @@ -132,7 +134,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('10', (string) $d); } - public function testModInverse() + public function testModInverse(): void { $a = $this->getInstance(30); $b = $this->getInstance(17); @@ -145,7 +147,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('1', (string) $r); } - public function testExtendedGCD() + public function testExtendedGCD(): void { $a = $this->getInstance(693); $b = $this->getInstance(609); @@ -156,14 +158,14 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame(21, $a->toString() * $arr['x']->toString() + $b->toString() * $arr['y']->toString()); } - public function testGCD() + public function testGCD(): void { $x = $this->getInstance(693); $y = $this->getInstance(609); $this->assertSame('21', (string) $x->gcd($y)); } - public function testAbs() + public function testAbs(): void { $x = $this->getInstance('-18446744073709551617'); $y = $x->abs(); @@ -172,7 +174,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('18446744073709551617', (string) $y); } - public function testEquals() + public function testEquals(): void { $x = $this->getInstance('18446744073709551616'); $y = $this->getInstance('18446744073709551616'); @@ -181,7 +183,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertTrue($y->equals($x)); } - public function testCompare() + public function testCompare(): void { $a = $this->getInstance('-18446744073709551616'); $b = $this->getInstance('36893488147419103232'); @@ -204,7 +206,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame(1, $this->getInstance(999)->compare($this->getInstance(-700))); } - public function testBitwiseAND() + public function testBitwiseAND(): void { $x = $this->getInstance('66666666666666666666666', 16); $y = $this->getInstance('33333333333333333333333', 16); @@ -213,7 +215,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($z->toHex(), $x->bitwise_AND($y)->toHex()); } - public function testBitwiseOR() + public function testBitwiseOR(): void { $x = $this->getInstance('11111111111111111111111', 16); $y = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16); @@ -233,7 +235,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($z->toString(), $y->bitwise_OR($x)->toString()); } - public function testBitwiseXOR() + public function testBitwiseXOR(): void { $x = $this->getInstance('AFAFAFAFAFAFAFAFAFAFAFAF', 16); $y = $this->getInstance('133713371337133713371337', 16); @@ -254,7 +256,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame("$c", '-6725760161961546967'); } - public function testBitwiseNOT() + public function testBitwiseNOT(): void { $x = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16); $z = $this->getInstance('11111111111111111111111', 16); @@ -267,7 +269,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($a->toString(), '0'); } - public function testBitwiseLeftShift() + public function testBitwiseLeftShift(): void { $x = $this->getInstance('0x0000000FF0000000', 16); $y = $this->getInstance('0x000FF00000000000', 16); @@ -275,7 +277,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($y->toHex(), $x->bitwise_LeftShift(16)->toHex()); } - public function testBitwiseRightShift() + public function testBitwiseRightShift(): void { $x = $this->getInstance('0x0000000FF0000000', 16); $y = $this->getInstance('0x00000000000FF000', 16); @@ -287,7 +289,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($n->toHex(), $x->bitwise_RightShift(36)->toHex()); } - public function testSerializable() + public function testSerializable(): void { $x = $this->getInstance('18446744073709551616'); $y = unserialize(serialize($x)); @@ -299,7 +301,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('18446744073709551616', (string) $y); } - public function testClone() + public function testClone(): void { $x = $this->getInstance('18446744073709551616'); $y = clone $x; @@ -311,7 +313,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('18446744073709551616', (string) $y); } - public function testRandomTwoArgument() + public function testRandomTwoArgument(): void { $min = $this->getInstance(0); $max = $this->getInstance('18446744073709551616'); @@ -327,7 +329,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @group github279 */ - public function testDiffieHellmanKeyAgreement() + public function testDiffieHellmanKeyAgreement(): void { // "Oakley Group 14" 2048-bit modular exponentiation group as used in // SSH2 diffie-hellman-group14-sha1 @@ -385,14 +387,14 @@ abstract class TestCase extends PhpseclibTestCase /** * @requires PHP 5.6 */ - public function testDebugInfo() + public function testDebugInfo(): void { $num = $this->getInstance(50); $str = print_r($num, true); $this->assertStringContainsString('[value] => 0x32', $str); } - public function testPrecision() + public function testPrecision(): void { $a = $this->getInstance(51); $this->assertSame($a->getPrecision(), -1); @@ -410,7 +412,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @group github954 */ - public function testSlidingWindow() + public function testSlidingWindow(): void { $e = $this->getInstance(str_repeat('1', 1794), 2); $x = $this->getInstance(1); @@ -418,7 +420,7 @@ abstract class TestCase extends PhpseclibTestCase self::assertSame('1', $x->powMod($e, $n)->toString()); } - public function testRoot() + public function testRoot(): void { $bigInteger = $this->getInstance('64000000'); // (20^2)^3 $bigInteger = $bigInteger->root(); @@ -427,7 +429,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('20', (string) $bigInteger); } - public function testPow() + public function testPow(): void { $bigInteger = $this->getInstance('20'); $two = $this->getInstance('2'); @@ -438,7 +440,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame('64000000', (string) $bigInteger); // (20^2)^3 } - public function testMax() + public function testMax(): void { $class = static::getStaticClass(); $min = $this->getInstance('20'); @@ -447,7 +449,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame((string) $max, (string) $class::max($max, $min)); } - public function testMin() + public function testMin(): void { $class = static::getStaticClass(); $min = $this->getInstance('20'); @@ -456,7 +458,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame((string) $min, (string) $class::min($max, $min)); } - public function testRandomPrime() + public function testRandomPrime(): void { $class = static::getStaticClass(); $prime = $class::randomPrime(128); @@ -466,7 +468,7 @@ abstract class TestCase extends PhpseclibTestCase /** * @group github1260 */ - public function testZeros() + public function testZeros(): void { $a = $this->getInstance(); $b = $this->getInstance('00', 16); @@ -476,13 +478,13 @@ abstract class TestCase extends PhpseclibTestCase /** * @group github1264 */ - public function test48ToHex() + public function test48ToHex(): void { $temp = $this->getInstance(48); $this->assertSame($temp->toHex(true), '30'); } - public function testZeroBase10() + public function testZeroBase10(): void { $temp = $this->getInstance('00'); $this->assertSame($temp->toString(), '0'); @@ -491,7 +493,7 @@ abstract class TestCase extends PhpseclibTestCase $this->assertSame($temp->toString(), '0'); } - public function testNegativePrecision() + public function testNegativePrecision(): void { $vals = [ '-9223372036854775808', // eg. 8000 0000 0000 0000 diff --git a/tests/Unit/Math/BigIntegerTest.php b/tests/Unit/Math/BigIntegerTest.php index 68eb0768..42d2deaa 100644 --- a/tests/Unit/Math/BigIntegerTest.php +++ b/tests/Unit/Math/BigIntegerTest.php @@ -1,5 +1,7 @@ assertTrue(Stream::register()); $this->assertContains('sftp', stream_get_wrappers()); $this->assertTrue(stream_wrapper_unregister('sftp')); } - public function testRegisterWithArgument() + public function testRegisterWithArgument(): void { $protocol = 'sftptest'; $this->assertTrue(Stream::register($protocol)); diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 21e22be7..e94a2f0d 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -6,13 +6,15 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +declare(strict_types=1); + namespace phpseclib3\Tests\Unit\Net; use phpseclib3\Tests\PhpseclibTestCase; class SSH2UnitTest extends PhpseclibTestCase { - public function formatLogDataProvider() + public function formatLogDataProvider(): array { return [ [ @@ -32,7 +34,7 @@ class SSH2UnitTest extends PhpseclibTestCase /** * @dataProvider formatLogDataProvider */ - public function testFormatLog(array $message_log, array $message_number_log, $expected) + public function testFormatLog(array $message_log, array $message_number_log, $expected): void { $ssh = $this->createSSHMock(); @@ -40,7 +42,7 @@ class SSH2UnitTest extends PhpseclibTestCase $this->assertEquals($expected, $result); } - public function testGenerateIdentifier() + public function testGenerateIdentifier(): void { $identifier = self::callFunc($this->createSSHMock(), 'generate_identifier'); $this->assertStringStartsWith('SSH-2.0-phpseclib_3.0', $identifier); @@ -72,20 +74,20 @@ class SSH2UnitTest extends PhpseclibTestCase } } - public function testGetExitStatusIfNotConnected() + public function testGetExitStatusIfNotConnected(): void { $ssh = $this->createSSHMock(); $this->assertFalse($ssh->getExitStatus()); } - public function testPTYIDefaultValue() + public function testPTYIDefaultValue(): void { $ssh = $this->createSSHMock(); $this->assertFalse($ssh->isPTYEnabled()); } - public function testEnablePTY() + public function testEnablePTY(): void { $ssh = $this->createSSHMock(); @@ -96,14 +98,14 @@ class SSH2UnitTest extends PhpseclibTestCase $this->assertFalse($ssh->isPTYEnabled()); } - public function testQuietModeDefaultValue() + public function testQuietModeDefaultValue(): void { $ssh = $this->createSSHMock(); $this->assertFalse($ssh->isQuietModeEnabled()); } - public function testEnableQuietMode() + public function testEnableQuietMode(): void { $ssh = $this->createSSHMock(); @@ -114,22 +116,21 @@ class SSH2UnitTest extends PhpseclibTestCase $this->assertFalse($ssh->isQuietModeEnabled()); } - public function testGetConnectionByResourceId() + public function testGetConnectionByResourceId(): void { $ssh = new \phpseclib3\Net\SSH2('localhost'); $this->assertSame($ssh, \phpseclib3\Net\SSH2::getConnectionByResourceId($ssh->getResourceId())); } - public function testGetResourceId() + public function testGetResourceId(): void { $ssh = new \phpseclib3\Net\SSH2('localhost'); $this->assertSame('{' . spl_object_hash($ssh) . '}', $ssh->getResourceId()); } /** - * @return \phpseclib3\Net\SSH2 */ - protected function createSSHMock() + protected function createSSHMock(): \phpseclib3\Net\SSH2 { return $this->getMockBuilder('phpseclib3\Net\SSH2') ->disableOriginalConstructor() diff --git a/tests/make_compatible_with_new_phpunit_versions.php b/tests/make_compatible_with_new_phpunit_versions.php deleted file mode 100755 index e9448b6c..00000000 --- a/tests/make_compatible_with_new_phpunit_versions.php +++ /dev/null @@ -1,32 +0,0 @@ - $files */ -$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__)); -foreach ($files as $file) { - if ($file->getExtension() === 'php' && $file->getPathname() !== __FILE__) { - $fileContents = file_get_contents($file->getPathname()); - if ($fileContents === false) { - throw new \RuntimeException('file_get_contents() failed: ' . $file->getPathname()); - } - $patternToReplacementMap = [ - '~ function setUpBeforeClass\(\)~' => ' function setUpBeforeClass(): void', - '~ function setUp\(\)~' => ' function setUp(): void', - '~ function tearDown\(\)~' => ' function tearDown(): void', - '~ function assertIsArray\(\$actual, \$message = \'\'\)~' => ' function assertIsArray($actual, string $message = \'\'): void', - '~ function assertIsResource\(\$actual, \$message = \'\'\)~' => ' function assertIsResource($actual, string $message = \'\'): void', - '~ function assertIsObject\(\$actual, \$message = \'\'\)~' => ' function assertIsObject($actual, string $message = \'\'): void', - '~ function assertIsString\(\$actual, \$message = \'\'\)~' => ' function assertIsString($actual, string $message = \'\'): void', - '~ function assertStringContainsString\(\$needle, \$haystack, \$message = \'\'\)~' => ' function assertStringContainsString(string $needle, string $haystack, string $message = \'\'): void', - '~ function assertStringNotContainsString\(\$needle, \$haystack, \$message = \'\'\)~' => ' function assertStringNotContainsString(string $needle, string $haystack, string $message = \'\'): void', - '~ function assertMatchesRegularExpression\(\$pattern, \$string, \$message = \'\'\)~' => ' function assertMatchesRegularExpression(string $pattern, string $string, string $message = \'\'): void', - ]; - $updatedFileContents = preg_replace( - array_keys($patternToReplacementMap), - array_values($patternToReplacementMap), - $fileContents - ); - if (file_put_contents($file->getPathname(), $updatedFileContents) === false) { - throw new \RuntimeException('file_put_contents() failed: ' . $file->getPathname()); - } - } -}