mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:15:13 +00:00
downgrade phpseclib - version 3 requires too much futzing to autoload
This commit is contained in:
parent
67ec3332a3
commit
6a31034591
359 changed files with 15841 additions and 42573 deletions
|
@ -44,7 +44,7 @@
|
|||
"masterminds/html5": "^2.6",
|
||||
"forkawesome/fork-awesome": "^1.1",
|
||||
"p3k/emoji-detector": "^0.2.1",
|
||||
"phpseclib/phpseclib": "^3.0"
|
||||
"phpseclib/phpseclib": "^2.0"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "@stable",
|
||||
|
|
132
composer.lock
generated
132
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "84603c6c075970aa8f54ca25d037530f",
|
||||
"content-hash": "1b4fe49efccb9f54f198566c249c7e76",
|
||||
"packages": [
|
||||
{
|
||||
"name": "blueimp/jquery-file-upload",
|
||||
|
@ -673,68 +673,6 @@
|
|||
"homepage": "https://github.com/aaronpk/emoji-detector-php",
|
||||
"time": "2017-11-30T21:02:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/constant_time_encoding",
|
||||
"version": "v2.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paragonie/constant_time_encoding.git",
|
||||
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
|
||||
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7|^8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6|^7|^8|^9",
|
||||
"vimeo/psalm": "^1|^2|^3|^4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ParagonIE\\ConstantTime\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Steve 'Sc00bz' Thomas",
|
||||
"email": "steve@tobtu.com",
|
||||
"homepage": "https://www.tobtu.com",
|
||||
"role": "Original Developer"
|
||||
}
|
||||
],
|
||||
"description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)",
|
||||
"keywords": [
|
||||
"base16",
|
||||
"base32",
|
||||
"base32_decode",
|
||||
"base32_encode",
|
||||
"base64",
|
||||
"base64_decode",
|
||||
"base64_encode",
|
||||
"bin2hex",
|
||||
"encoding",
|
||||
"hex",
|
||||
"hex2bin",
|
||||
"rfc4648"
|
||||
],
|
||||
"time": "2020-12-06T15:14:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v9.99.99",
|
||||
|
@ -782,26 +720,24 @@
|
|||
},
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "3.0.6",
|
||||
"version": "2.0.30",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||
"reference": "906a5fafabe5e6ba51ef3dc65b2722a677908837"
|
||||
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/906a5fafabe5e6ba51ef3dc65b2722a677908837",
|
||||
"reference": "906a5fafabe5e6ba51ef3dc65b2722a677908837",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/136b9ca7eebef78be14abf90d65c5e57b6bc5d36",
|
||||
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"paragonie/constant_time_encoding": "^1|^2",
|
||||
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
|
||||
"php": ">=5.6.1"
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "~2.7",
|
||||
"phpunit/phpunit": "^5.7|^6.0|^9.4",
|
||||
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
|
||||
"squizlabs/php_codesniffer": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -816,7 +752,7 @@
|
|||
"phpseclib/bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"phpseclib3\\": "phpseclib/"
|
||||
"phpseclib\\": "phpseclib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -885,7 +821,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-10T13:58:31+00:00"
|
||||
"time": "2020-12-17T05:42:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
|
@ -5127,16 +5063,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v5.2.5",
|
||||
"version": "v5.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "938ebbadae1b0a9c9d1ec313f87f9708609f1b79"
|
||||
"reference": "35f039df40a3b335ebf310f244cb242b3a83ac8d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/938ebbadae1b0a9c9d1ec313f87f9708609f1b79",
|
||||
"reference": "938ebbadae1b0a9c9d1ec313f87f9708609f1b79",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/35f039df40a3b335ebf310f244cb242b3a83ac8d",
|
||||
"reference": "35f039df40a3b335ebf310f244cb242b3a83ac8d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5217,7 +5153,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-06T13:42:15+00:00"
|
||||
"time": "2021-03-28T09:42:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/css-selector",
|
||||
|
@ -5283,16 +5219,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/dependency-injection",
|
||||
"version": "v4.4.20",
|
||||
"version": "v4.4.21",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/dependency-injection.git",
|
||||
"reference": "4b3e341ce4436df9a9abc2914cb120b4d41796d7"
|
||||
"reference": "b5f97557faa48ead4671bc311cfca423d476e93e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/4b3e341ce4436df9a9abc2914cb120b4d41796d7",
|
||||
"reference": "4b3e341ce4436df9a9abc2914cb120b4d41796d7",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/b5f97557faa48ead4671bc311cfca423d476e93e",
|
||||
"reference": "b5f97557faa48ead4671bc311cfca423d476e93e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5361,7 +5297,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-03-03T12:11:09+00:00"
|
||||
"time": "2021-03-05T18:16:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/dom-crawler",
|
||||
|
@ -5593,16 +5529,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v5.2.4",
|
||||
"version": "v5.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/filesystem.git",
|
||||
"reference": "710d364200997a5afde34d9fe57bd52f3cc1e108"
|
||||
"reference": "8c86a82f51658188119e62cff0a050a12d09836f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/710d364200997a5afde34d9fe57bd52f3cc1e108",
|
||||
"reference": "710d364200997a5afde34d9fe57bd52f3cc1e108",
|
||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/8c86a82f51658188119e62cff0a050a12d09836f",
|
||||
"reference": "8c86a82f51658188119e62cff0a050a12d09836f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5648,7 +5584,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-02-12T10:38:38+00:00"
|
||||
"time": "2021-03-28T14:30:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-grapheme",
|
||||
|
@ -6121,16 +6057,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/string",
|
||||
"version": "v5.2.4",
|
||||
"version": "v5.2.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/string.git",
|
||||
"reference": "4e78d7d47061fa183639927ec40d607973699609"
|
||||
"reference": "ad0bd91bce2054103f5eaa18ebeba8d3bc2a0572"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609",
|
||||
"reference": "4e78d7d47061fa183639927ec40d607973699609",
|
||||
"url": "https://api.github.com/repos/symfony/string/zipball/ad0bd91bce2054103f5eaa18ebeba8d3bc2a0572",
|
||||
"reference": "ad0bd91bce2054103f5eaa18ebeba8d3bc2a0572",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -6197,20 +6133,20 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-02-16T10:20:28+00:00"
|
||||
"time": "2021-03-17T17:12:15+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v4.4.20",
|
||||
"version": "v4.4.21",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/translation.git",
|
||||
"reference": "2271b6d577018a7dea75a9162a08ac84f8234deb"
|
||||
"reference": "eb8f5428cc3b40d6dffe303b195b084f1c5fbd14"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/2271b6d577018a7dea75a9162a08ac84f8234deb",
|
||||
"reference": "2271b6d577018a7dea75a9162a08ac84f8234deb",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/eb8f5428cc3b40d6dffe303b195b084f1c5fbd14",
|
||||
"reference": "eb8f5428cc3b40d6dffe303b195b084f1c5fbd14",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -6282,7 +6218,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-02-26T13:53:48+00:00"
|
||||
"time": "2021-03-23T16:25:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation-contracts",
|
||||
|
|
364
vendor/composer/autoload_classmap.php
vendored
364
vendor/composer/autoload_classmap.php
vendored
|
@ -429,17 +429,6 @@ return array(
|
|||
'PHPGit\\Command\\TreeCommand' => $vendorDir . '/kzykhys/git/src/PHPGit/Command/TreeCommand.php',
|
||||
'PHPGit\\Exception\\GitException' => $vendorDir . '/kzykhys/git/src/PHPGit/Exception/GitException.php',
|
||||
'PHPGit\\Git' => $vendorDir . '/kzykhys/git/src/PHPGit/Git.php',
|
||||
'ParagonIE\\ConstantTime\\Base32' => $vendorDir . '/paragonie/constant_time_encoding/src/Base32.php',
|
||||
'ParagonIE\\ConstantTime\\Base32Hex' => $vendorDir . '/paragonie/constant_time_encoding/src/Base32Hex.php',
|
||||
'ParagonIE\\ConstantTime\\Base64' => $vendorDir . '/paragonie/constant_time_encoding/src/Base64.php',
|
||||
'ParagonIE\\ConstantTime\\Base64DotSlash' => $vendorDir . '/paragonie/constant_time_encoding/src/Base64DotSlash.php',
|
||||
'ParagonIE\\ConstantTime\\Base64DotSlashOrdered' => $vendorDir . '/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php',
|
||||
'ParagonIE\\ConstantTime\\Base64UrlSafe' => $vendorDir . '/paragonie/constant_time_encoding/src/Base64UrlSafe.php',
|
||||
'ParagonIE\\ConstantTime\\Binary' => $vendorDir . '/paragonie/constant_time_encoding/src/Binary.php',
|
||||
'ParagonIE\\ConstantTime\\EncoderInterface' => $vendorDir . '/paragonie/constant_time_encoding/src/EncoderInterface.php',
|
||||
'ParagonIE\\ConstantTime\\Encoding' => $vendorDir . '/paragonie/constant_time_encoding/src/Encoding.php',
|
||||
'ParagonIE\\ConstantTime\\Hex' => $vendorDir . '/paragonie/constant_time_encoding/src/Hex.php',
|
||||
'ParagonIE\\ConstantTime\\RFC4648' => $vendorDir . '/paragonie/constant_time_encoding/src/RFC4648.php',
|
||||
'Psr\\Log\\AbstractLogger' => $vendorDir . '/psr/log/Psr/Log/AbstractLogger.php',
|
||||
'Psr\\Log\\InvalidArgumentException' => $vendorDir . '/psr/log/Psr/Log/InvalidArgumentException.php',
|
||||
'Psr\\Log\\LogLevel' => $vendorDir . '/psr/log/Psr/Log/LogLevel.php',
|
||||
|
@ -1715,335 +1704,30 @@ return array(
|
|||
'Zotlabs\\Zot6\\IHandler' => $baseDir . '/Zotlabs/Zot6/IHandler.php',
|
||||
'Zotlabs\\Zot6\\Receiver' => $baseDir . '/Zotlabs/Zot6/Receiver.php',
|
||||
'Zotlabs\\Zot6\\Zot6Handler' => $baseDir . '/Zotlabs/Zot6/Zot6Handler.php',
|
||||
'phpseclib3\\Common\\Functions\\Strings' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php',
|
||||
'phpseclib3\\Crypt\\AES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/AES.php',
|
||||
'phpseclib3\\Crypt\\Blowfish' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php',
|
||||
'phpseclib3\\Crypt\\ChaCha20' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/ChaCha20.php',
|
||||
'phpseclib3\\Crypt\\Common\\AsymmetricKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/AsymmetricKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\BlockCipher' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/BlockCipher.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\OpenSSH' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PKCS' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PKCS1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PKCS8' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PuTTY' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Signature\\Raw' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Signature/Raw.php',
|
||||
'phpseclib3\\Crypt\\Common\\PrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\PublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\StreamCipher' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/StreamCipher.php',
|
||||
'phpseclib3\\Crypt\\Common\\SymmetricKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/SymmetricKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\Traits\\Fingerprint' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/Fingerprint.php',
|
||||
'phpseclib3\\Crypt\\Common\\Traits\\PasswordProtected' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/PasswordProtected.php',
|
||||
'phpseclib3\\Crypt\\DES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DES.php',
|
||||
'phpseclib3\\Crypt\\DH' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DH.php',
|
||||
'phpseclib3\\Crypt\\DH\\Formats\\Keys\\PKCS1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\DH\\Formats\\Keys\\PKCS8' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\DH\\Parameters' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DH/Parameters.php',
|
||||
'phpseclib3\\Crypt\\DH\\PrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DH/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\DH\\PublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DH/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\DSA' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\OpenSSH' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\PKCS1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\PKCS8' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\PuTTY' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\Raw' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/Raw.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\XML' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/XML.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Signature\\ASN1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Signature\\Raw' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/Raw.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Signature\\SSH2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Parameters' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Parameters.php',
|
||||
'phpseclib3\\Crypt\\DSA\\PrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\DSA\\PublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\EC' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Base' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Base.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Binary' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Binary.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\KoblitzPrime' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Montgomery' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Prime' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\TwistedEdwards' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Curve25519' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve25519.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Curve448' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve448.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Ed25519' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed25519.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Ed448' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed448.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP160r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP160t1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP192r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP192t1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP224r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP224t1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP256r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP256t1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP256t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP320r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP320t1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP384r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP384t1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP512r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP512t1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistb233' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb233.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistb409' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb409.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk163' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk163.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk233' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk233.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk283' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk283.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk409' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk409.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp192' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp192.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp224' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp224.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp256' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp256.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp384' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp384.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp521' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp521.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistt571' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistt571.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime192v1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime192v2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime192v3' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v3.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime239v1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime239v2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime239v3' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v3.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime256v1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime256v1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp112r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp112r2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp128r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp128r2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp160k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp160r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp160r2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp192k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp192r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp224k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp224k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp224r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp224r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp256k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp256k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp256r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp256r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp384r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp384r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp521r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp521r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect113r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect113r2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect131r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect131r2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect163k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect163r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect163r2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect193r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect193r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect193r2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect193r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect233k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect233k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect233r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect233r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect239k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect239k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect283k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect283k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect283r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect283r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect409k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect409r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect571k1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect571r1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\Common' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/Common.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\MontgomeryPrivate' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\MontgomeryPublic' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\OpenSSH' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\PKCS1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\PKCS8' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\PuTTY' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\XML' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\libsodium' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/libsodium.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Signature\\ASN1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/ASN1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Signature\\Raw' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/Raw.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Signature\\SSH2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/SSH2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Parameters' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Parameters.php',
|
||||
'phpseclib3\\Crypt\\EC\\PrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\EC\\PublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\Hash' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Hash.php',
|
||||
'phpseclib3\\Crypt\\PublicKeyLoader' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php',
|
||||
'phpseclib3\\Crypt\\RC2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RC2.php',
|
||||
'phpseclib3\\Crypt\\RC4' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RC4.php',
|
||||
'phpseclib3\\Crypt\\RSA' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\MSBLOB' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\OpenSSH' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PKCS1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PKCS8' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PSS' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PuTTY' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\Raw' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/Raw.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\XML' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/XML.php',
|
||||
'phpseclib3\\Crypt\\RSA\\PrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\RSA\\PublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\Random' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
|
||||
'phpseclib3\\Crypt\\Rijndael' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php',
|
||||
'phpseclib3\\Crypt\\Salsa20' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Salsa20.php',
|
||||
'phpseclib3\\Crypt\\TripleDES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php',
|
||||
'phpseclib3\\Crypt\\Twofish' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php',
|
||||
'phpseclib3\\Exception\\BadConfigurationException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/BadConfigurationException.php',
|
||||
'phpseclib3\\Exception\\BadDecryptionException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/BadDecryptionException.php',
|
||||
'phpseclib3\\Exception\\BadModeException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/BadModeException.php',
|
||||
'phpseclib3\\Exception\\ConnectionClosedException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/ConnectionClosedException.php',
|
||||
'phpseclib3\\Exception\\FileNotFoundException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/FileNotFoundException.php',
|
||||
'phpseclib3\\Exception\\InconsistentSetupException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/InconsistentSetupException.php',
|
||||
'phpseclib3\\Exception\\InsufficientSetupException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/InsufficientSetupException.php',
|
||||
'phpseclib3\\Exception\\NoKeyLoadedException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/NoKeyLoadedException.php',
|
||||
'phpseclib3\\Exception\\NoSupportedAlgorithmsException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/NoSupportedAlgorithmsException.php',
|
||||
'phpseclib3\\Exception\\UnableToConnectException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/UnableToConnectException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedAlgorithmException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedAlgorithmException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedCurveException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedCurveException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedFormatException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedFormatException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedOperationException' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedOperationException.php',
|
||||
'phpseclib3\\File\\ANSI' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ANSI.php',
|
||||
'phpseclib3\\File\\ASN1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1.php',
|
||||
'phpseclib3\\File\\ASN1\\Element' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AccessDescription' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AccessDescription.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AdministrationDomainName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AdministrationDomainName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AlgorithmIdentifier' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AnotherName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AnotherName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Attribute' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attribute.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AttributeType' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeType.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AttributeTypeAndValue' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AttributeValue' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Attributes' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AuthorityInfoAccessSyntax' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AuthorityKeyIdentifier' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BaseDistance' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BaseDistance.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BasicConstraints' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BasicConstraints.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BuiltInDomainDefinedAttribute' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BuiltInDomainDefinedAttributes' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BuiltInStandardAttributes' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CPSuri' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CPSuri.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CRLDistributionPoints' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CRLNumber' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLNumber.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CRLReason' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLReason.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertPolicyId' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertPolicyId.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Certificate' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Certificate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificateIssuer' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateIssuer.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificateList' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateList.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificatePolicies' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificatePolicies.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificateSerialNumber' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificationRequest' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequest.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificationRequestInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Characteristic_two' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Characteristic_two.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CountryName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CountryName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Curve' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Curve.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DHParameter' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DHParameter.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DSAParams' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAParams.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DSAPrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DSAPublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPublicKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DigestInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DigestInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DirectoryString' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DirectoryString.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DisplayText' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DisplayText.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DistributionPoint' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPoint.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DistributionPointName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPointName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DssSigValue' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DssSigValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ECParameters' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECParameters.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ECPoint' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPoint.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ECPrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EDIPartyName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EDIPartyName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EcdsaSigValue' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EcdsaSigValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EncryptedData' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedData.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EncryptedPrivateKeyInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ExtKeyUsageSyntax' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Extension' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extension.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ExtensionAttribute' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttribute.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ExtensionAttributes' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Extensions' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extensions.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\FieldElement' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldElement.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\FieldID' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldID.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralNames' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralNames.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralSubtree' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtree.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralSubtrees' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtrees.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\HashAlgorithm' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HashAlgorithm.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\HoldInstructionCode' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HoldInstructionCode.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\InvalidityDate' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/InvalidityDate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\IssuerAltName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuerAltName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\IssuingDistributionPoint' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\KeyIdentifier' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\KeyPurposeId' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyPurposeId.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\KeyUsage' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyUsage.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\MaskGenAlgorithm' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Name' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Name.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NameConstraints' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NameConstraints.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NetworkAddress' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NetworkAddress.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NoticeReference' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NoticeReference.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NumericUserIdentifier' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ORAddress' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ORAddress.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OneAsymmetricKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OrganizationName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OrganizationalUnitNames' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OtherPrimeInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OtherPrimeInfos' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBEParameter' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBEParameter.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBES2params' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBES2params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBKDF2params' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBKDF2params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBMAC1params' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBMAC1params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PKCS9String' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PKCS9String.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Pentanomial' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Pentanomial.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PersonalName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PersonalName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyInformation' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyInformation.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyMappings' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyMappings.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyQualifierId' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierId.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyQualifierInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PostalAddress' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PostalAddress.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Prime_p' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Prime_p.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateDomainName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateDomainName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateKeyInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateKeyUsagePeriod' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PublicKeyAndChallenge' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PublicKeyInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RC2CBCParameter' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RC2CBCParameter.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RDNSequence' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RDNSequence.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RSAPrivateKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RSAPublicKey' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPublicKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RSASSA_PSS_params' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ReasonFlags' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ReasonFlags.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RelativeDistinguishedName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RevokedCertificate' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RevokedCertificate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SignedPublicKeyAndChallenge' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SpecifiedECDomain' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectAltName' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectAltName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectDirectoryAttributes' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectInfoAccessSyntax' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectPublicKeyInfo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\TBSCertList' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertList.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\TBSCertificate' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertificate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\TerminalIdentifier' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TerminalIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Time' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Time.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Trinomial' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Trinomial.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\UniqueIdentifier' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UniqueIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\UserNotice' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UserNotice.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Validity' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Validity.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\netscape_ca_policy_url' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\netscape_cert_type' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_cert_type.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\netscape_comment' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_comment.php',
|
||||
'phpseclib3\\File\\X509' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/X509.php',
|
||||
'phpseclib3\\Math\\BigInteger' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\Base' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\BuiltIn' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\DefaultEngine' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\OpenSSL' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\Reductions\\Barrett' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\Reductions\\EvalBarrett' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\Engine' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\GMP' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\GMP\\DefaultEngine' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\OpenSSL' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/OpenSSL.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP32' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP32.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP64' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP64.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Base' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Base.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\DefaultEngine' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Montgomery' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\OpenSSL' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\Barrett' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\Classic' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\EvalBarrett' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\Montgomery' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\MontgomeryMult' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\PowerOfTwo' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php',
|
||||
'phpseclib3\\Math\\BinaryField' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BinaryField.php',
|
||||
'phpseclib3\\Math\\BinaryField\\Integer' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BinaryField/Integer.php',
|
||||
'phpseclib3\\Math\\Common\\FiniteField' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/Common/FiniteField.php',
|
||||
'phpseclib3\\Math\\Common\\FiniteField\\Integer' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/Common/FiniteField/Integer.php',
|
||||
'phpseclib3\\Math\\PrimeField' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/PrimeField.php',
|
||||
'phpseclib3\\Math\\PrimeField\\Integer' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/PrimeField/Integer.php',
|
||||
'phpseclib3\\Net\\SFTP' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SFTP.php',
|
||||
'phpseclib3\\Net\\SFTP\\Stream' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php',
|
||||
'phpseclib3\\Net\\SSH2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SSH2.php',
|
||||
'phpseclib3\\System\\SSH\\Agent' => $vendorDir . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent.php',
|
||||
'phpseclib3\\System\\SSH\\Agent\\Identity' => $vendorDir . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent/Identity.php',
|
||||
'phpseclib3\\System\\SSH\\Common\\Traits\\ReadBytes' => $vendorDir . '/phpseclib/phpseclib/phpseclib/System/SSH/Common/Traits/ReadBytes.php',
|
||||
'phpseclib\\Crypt\\AES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/AES.php',
|
||||
'phpseclib\\Crypt\\Base' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Base.php',
|
||||
'phpseclib\\Crypt\\Blowfish' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php',
|
||||
'phpseclib\\Crypt\\DES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DES.php',
|
||||
'phpseclib\\Crypt\\Hash' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Hash.php',
|
||||
'phpseclib\\Crypt\\RC2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RC2.php',
|
||||
'phpseclib\\Crypt\\RC4' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RC4.php',
|
||||
'phpseclib\\Crypt\\RSA' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA.php',
|
||||
'phpseclib\\Crypt\\Random' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
|
||||
'phpseclib\\Crypt\\Rijndael' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php',
|
||||
'phpseclib\\Crypt\\TripleDES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php',
|
||||
'phpseclib\\Crypt\\Twofish' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php',
|
||||
'phpseclib\\File\\ANSI' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ANSI.php',
|
||||
'phpseclib\\File\\ASN1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1.php',
|
||||
'phpseclib\\File\\ASN1\\Element' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php',
|
||||
'phpseclib\\File\\X509' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/X509.php',
|
||||
'phpseclib\\Math\\BigInteger' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger.php',
|
||||
'phpseclib\\Net\\SCP' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SCP.php',
|
||||
'phpseclib\\Net\\SFTP' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SFTP.php',
|
||||
'phpseclib\\Net\\SFTP\\Stream' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php',
|
||||
'phpseclib\\Net\\SSH1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SSH1.php',
|
||||
'phpseclib\\Net\\SSH2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SSH2.php',
|
||||
'phpseclib\\System\\SSH\\Agent' => $vendorDir . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent.php',
|
||||
'phpseclib\\System\\SSH\\Agent\\Identity' => $vendorDir . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent/Identity.php',
|
||||
'voku\\helper\\ASCII' => $vendorDir . '/voku/portable-ascii/src/voku/helper/ASCII.php',
|
||||
'voku\\helper\\StopWords' => $vendorDir . '/voku/stop-words/src/voku/helper/StopWords.php',
|
||||
'voku\\helper\\StopWordsLanguageNotExists' => $vendorDir . '/voku/stop-words/src/voku/helper/StopWordsLanguageNotExists.php',
|
||||
|
|
3
vendor/composer/autoload_psr4.php
vendored
3
vendor/composer/autoload_psr4.php
vendored
|
@ -7,7 +7,7 @@ $baseDir = dirname($vendorDir);
|
|||
|
||||
return array(
|
||||
'voku\\' => array($vendorDir . '/voku/portable-ascii/src/voku', $vendorDir . '/voku/stop-words/src/voku'),
|
||||
'phpseclib3\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
|
||||
'phpseclib\\' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
|
||||
'Zotlabs\\' => array($baseDir . '/Zotlabs'),
|
||||
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
|
||||
'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'),
|
||||
|
@ -26,7 +26,6 @@ return array(
|
|||
'Recurr\\' => array($vendorDir . '/simshaun/recurr/src/Recurr'),
|
||||
'Ramsey\\Uuid\\' => array($vendorDir . '/ramsey/uuid/src'),
|
||||
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
|
||||
'ParagonIE\\ConstantTime\\' => array($vendorDir . '/paragonie/constant_time_encoding/src'),
|
||||
'Michelf\\' => array($vendorDir . '/michelf/php-markdown/Michelf'),
|
||||
'Masterminds\\' => array($vendorDir . '/masterminds/html5/src'),
|
||||
'League\\HTMLToMarkdown\\' => array($vendorDir . '/league/html-to-markdown/src'),
|
||||
|
|
373
vendor/composer/autoload_static.php
vendored
373
vendor/composer/autoload_static.php
vendored
|
@ -31,7 +31,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
|||
),
|
||||
'p' =>
|
||||
array (
|
||||
'phpseclib3\\' => 11,
|
||||
'phpseclib\\' => 10,
|
||||
),
|
||||
'Z' =>
|
||||
array (
|
||||
|
@ -62,7 +62,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
|||
'P' =>
|
||||
array (
|
||||
'Psr\\Log\\' => 8,
|
||||
'ParagonIE\\ConstantTime\\' => 23,
|
||||
),
|
||||
'M' =>
|
||||
array (
|
||||
|
@ -93,7 +92,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
|||
0 => __DIR__ . '/..' . '/voku/portable-ascii/src/voku',
|
||||
1 => __DIR__ . '/..' . '/voku/stop-words/src/voku',
|
||||
),
|
||||
'phpseclib3\\' =>
|
||||
'phpseclib\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
|
||||
),
|
||||
|
@ -169,10 +168,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
|||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
|
||||
),
|
||||
'ParagonIE\\ConstantTime\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src',
|
||||
),
|
||||
'Michelf\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/michelf/php-markdown/Michelf',
|
||||
|
@ -651,17 +646,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
|||
'PHPGit\\Command\\TreeCommand' => __DIR__ . '/..' . '/kzykhys/git/src/PHPGit/Command/TreeCommand.php',
|
||||
'PHPGit\\Exception\\GitException' => __DIR__ . '/..' . '/kzykhys/git/src/PHPGit/Exception/GitException.php',
|
||||
'PHPGit\\Git' => __DIR__ . '/..' . '/kzykhys/git/src/PHPGit/Git.php',
|
||||
'ParagonIE\\ConstantTime\\Base32' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Base32.php',
|
||||
'ParagonIE\\ConstantTime\\Base32Hex' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Base32Hex.php',
|
||||
'ParagonIE\\ConstantTime\\Base64' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Base64.php',
|
||||
'ParagonIE\\ConstantTime\\Base64DotSlash' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Base64DotSlash.php',
|
||||
'ParagonIE\\ConstantTime\\Base64DotSlashOrdered' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Base64DotSlashOrdered.php',
|
||||
'ParagonIE\\ConstantTime\\Base64UrlSafe' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Base64UrlSafe.php',
|
||||
'ParagonIE\\ConstantTime\\Binary' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Binary.php',
|
||||
'ParagonIE\\ConstantTime\\EncoderInterface' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/EncoderInterface.php',
|
||||
'ParagonIE\\ConstantTime\\Encoding' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Encoding.php',
|
||||
'ParagonIE\\ConstantTime\\Hex' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/Hex.php',
|
||||
'ParagonIE\\ConstantTime\\RFC4648' => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src/RFC4648.php',
|
||||
'Psr\\Log\\AbstractLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/AbstractLogger.php',
|
||||
'Psr\\Log\\InvalidArgumentException' => __DIR__ . '/..' . '/psr/log/Psr/Log/InvalidArgumentException.php',
|
||||
'Psr\\Log\\LogLevel' => __DIR__ . '/..' . '/psr/log/Psr/Log/LogLevel.php',
|
||||
|
@ -1937,335 +1921,30 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
|||
'Zotlabs\\Zot6\\IHandler' => __DIR__ . '/../..' . '/Zotlabs/Zot6/IHandler.php',
|
||||
'Zotlabs\\Zot6\\Receiver' => __DIR__ . '/../..' . '/Zotlabs/Zot6/Receiver.php',
|
||||
'Zotlabs\\Zot6\\Zot6Handler' => __DIR__ . '/../..' . '/Zotlabs/Zot6/Zot6Handler.php',
|
||||
'phpseclib3\\Common\\Functions\\Strings' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php',
|
||||
'phpseclib3\\Crypt\\AES' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/AES.php',
|
||||
'phpseclib3\\Crypt\\Blowfish' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php',
|
||||
'phpseclib3\\Crypt\\ChaCha20' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/ChaCha20.php',
|
||||
'phpseclib3\\Crypt\\Common\\AsymmetricKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/AsymmetricKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\BlockCipher' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/BlockCipher.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\OpenSSH' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PKCS' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PKCS1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PKCS8' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Keys\\PuTTY' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\Common\\Formats\\Signature\\Raw' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Signature/Raw.php',
|
||||
'phpseclib3\\Crypt\\Common\\PrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\PublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\StreamCipher' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/StreamCipher.php',
|
||||
'phpseclib3\\Crypt\\Common\\SymmetricKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/SymmetricKey.php',
|
||||
'phpseclib3\\Crypt\\Common\\Traits\\Fingerprint' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/Fingerprint.php',
|
||||
'phpseclib3\\Crypt\\Common\\Traits\\PasswordProtected' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/PasswordProtected.php',
|
||||
'phpseclib3\\Crypt\\DES' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DES.php',
|
||||
'phpseclib3\\Crypt\\DH' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DH.php',
|
||||
'phpseclib3\\Crypt\\DH\\Formats\\Keys\\PKCS1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\DH\\Formats\\Keys\\PKCS8' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\DH\\Parameters' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DH/Parameters.php',
|
||||
'phpseclib3\\Crypt\\DH\\PrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DH/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\DH\\PublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DH/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\DSA' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\OpenSSH' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\PKCS1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\PKCS8' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\PuTTY' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\Raw' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/Raw.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Keys\\XML' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/XML.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Signature\\ASN1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Signature\\Raw' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/Raw.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Formats\\Signature\\SSH2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php',
|
||||
'phpseclib3\\Crypt\\DSA\\Parameters' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/Parameters.php',
|
||||
'phpseclib3\\Crypt\\DSA\\PrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\DSA\\PublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\EC' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Base' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Base.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Binary' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Binary.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\KoblitzPrime' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Montgomery' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\Prime' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php',
|
||||
'phpseclib3\\Crypt\\EC\\BaseCurves\\TwistedEdwards' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Curve25519' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve25519.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Curve448' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve448.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Ed25519' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed25519.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\Ed448' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed448.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP160r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP160t1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP192r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP192t1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP224r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP224t1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP256r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP256t1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP256t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP320r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP320t1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP384r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP384t1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP512r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\brainpoolP512t1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistb233' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb233.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistb409' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb409.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk163' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk163.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk233' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk233.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk283' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk283.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistk409' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk409.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp192' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp192.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp224' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp224.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp256' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp256.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp384' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp384.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistp521' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp521.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\nistt571' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistt571.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime192v1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime192v2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime192v3' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v3.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime239v1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime239v2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime239v3' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v3.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\prime256v1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime256v1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp112r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp112r2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp128r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp128r2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp160k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp160r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp160r2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp192k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp192r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp224k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp224k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp224r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp224r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp256k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp256k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp256r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp256r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp384r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp384r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\secp521r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp521r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect113r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect113r2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect131r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect131r2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect163k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect163r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect163r2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect193r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect193r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect193r2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect193r2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect233k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect233k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect233r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect233r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect239k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect239k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect283k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect283k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect283r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect283r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect409k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect409r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect571k1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571k1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Curves\\sect571r1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571r1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\Common' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/Common.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\MontgomeryPrivate' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\MontgomeryPublic' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\OpenSSH' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\PKCS1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\PKCS8' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\PuTTY' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\XML' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Keys\\libsodium' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/libsodium.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Signature\\ASN1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/ASN1.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Signature\\Raw' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/Raw.php',
|
||||
'phpseclib3\\Crypt\\EC\\Formats\\Signature\\SSH2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/SSH2.php',
|
||||
'phpseclib3\\Crypt\\EC\\Parameters' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/Parameters.php',
|
||||
'phpseclib3\\Crypt\\EC\\PrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\EC\\PublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\Hash' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Hash.php',
|
||||
'phpseclib3\\Crypt\\PublicKeyLoader' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php',
|
||||
'phpseclib3\\Crypt\\RC2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RC2.php',
|
||||
'phpseclib3\\Crypt\\RC4' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RC4.php',
|
||||
'phpseclib3\\Crypt\\RSA' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\MSBLOB' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\OpenSSH' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PKCS1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PKCS8' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PSS' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\PuTTY' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\Raw' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/Raw.php',
|
||||
'phpseclib3\\Crypt\\RSA\\Formats\\Keys\\XML' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/XML.php',
|
||||
'phpseclib3\\Crypt\\RSA\\PrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/PrivateKey.php',
|
||||
'phpseclib3\\Crypt\\RSA\\PublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA/PublicKey.php',
|
||||
'phpseclib3\\Crypt\\Random' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
|
||||
'phpseclib3\\Crypt\\Rijndael' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php',
|
||||
'phpseclib3\\Crypt\\Salsa20' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Salsa20.php',
|
||||
'phpseclib3\\Crypt\\TripleDES' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php',
|
||||
'phpseclib3\\Crypt\\Twofish' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php',
|
||||
'phpseclib3\\Exception\\BadConfigurationException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/BadConfigurationException.php',
|
||||
'phpseclib3\\Exception\\BadDecryptionException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/BadDecryptionException.php',
|
||||
'phpseclib3\\Exception\\BadModeException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/BadModeException.php',
|
||||
'phpseclib3\\Exception\\ConnectionClosedException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/ConnectionClosedException.php',
|
||||
'phpseclib3\\Exception\\FileNotFoundException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/FileNotFoundException.php',
|
||||
'phpseclib3\\Exception\\InconsistentSetupException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/InconsistentSetupException.php',
|
||||
'phpseclib3\\Exception\\InsufficientSetupException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/InsufficientSetupException.php',
|
||||
'phpseclib3\\Exception\\NoKeyLoadedException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/NoKeyLoadedException.php',
|
||||
'phpseclib3\\Exception\\NoSupportedAlgorithmsException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/NoSupportedAlgorithmsException.php',
|
||||
'phpseclib3\\Exception\\UnableToConnectException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/UnableToConnectException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedAlgorithmException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedAlgorithmException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedCurveException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedCurveException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedFormatException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedFormatException.php',
|
||||
'phpseclib3\\Exception\\UnsupportedOperationException' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Exception/UnsupportedOperationException.php',
|
||||
'phpseclib3\\File\\ANSI' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ANSI.php',
|
||||
'phpseclib3\\File\\ASN1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1.php',
|
||||
'phpseclib3\\File\\ASN1\\Element' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AccessDescription' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AccessDescription.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AdministrationDomainName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AdministrationDomainName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AlgorithmIdentifier' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AnotherName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AnotherName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Attribute' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attribute.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AttributeType' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeType.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AttributeTypeAndValue' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AttributeValue' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Attributes' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AuthorityInfoAccessSyntax' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\AuthorityKeyIdentifier' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BaseDistance' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BaseDistance.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BasicConstraints' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BasicConstraints.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BuiltInDomainDefinedAttribute' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BuiltInDomainDefinedAttributes' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\BuiltInStandardAttributes' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CPSuri' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CPSuri.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CRLDistributionPoints' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CRLNumber' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLNumber.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CRLReason' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLReason.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertPolicyId' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertPolicyId.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Certificate' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Certificate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificateIssuer' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateIssuer.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificateList' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateList.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificatePolicies' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificatePolicies.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificateSerialNumber' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateSerialNumber.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificationRequest' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequest.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CertificationRequestInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Characteristic_two' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Characteristic_two.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\CountryName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CountryName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Curve' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Curve.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DHParameter' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DHParameter.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DSAParams' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAParams.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DSAPrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DSAPublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPublicKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DigestInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DigestInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DirectoryString' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DirectoryString.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DisplayText' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DisplayText.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DistributionPoint' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPoint.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DistributionPointName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPointName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\DssSigValue' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DssSigValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ECParameters' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECParameters.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ECPoint' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPoint.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ECPrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECPrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EDIPartyName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EDIPartyName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EcdsaSigValue' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EcdsaSigValue.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EncryptedData' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedData.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\EncryptedPrivateKeyInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ExtKeyUsageSyntax' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Extension' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extension.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ExtensionAttribute' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttribute.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ExtensionAttributes' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Extensions' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extensions.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\FieldElement' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldElement.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\FieldID' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldID.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralNames' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralNames.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralSubtree' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtree.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\GeneralSubtrees' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtrees.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\HashAlgorithm' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HashAlgorithm.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\HoldInstructionCode' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HoldInstructionCode.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\InvalidityDate' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/InvalidityDate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\IssuerAltName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuerAltName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\IssuingDistributionPoint' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\KeyIdentifier' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\KeyPurposeId' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyPurposeId.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\KeyUsage' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyUsage.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\MaskGenAlgorithm' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Name' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Name.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NameConstraints' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NameConstraints.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NetworkAddress' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NetworkAddress.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NoticeReference' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NoticeReference.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\NumericUserIdentifier' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NumericUserIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ORAddress' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ORAddress.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OneAsymmetricKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OrganizationName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OrganizationalUnitNames' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OtherPrimeInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\OtherPrimeInfos' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfos.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBEParameter' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBEParameter.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBES2params' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBES2params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBKDF2params' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBKDF2params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PBMAC1params' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBMAC1params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PKCS9String' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PKCS9String.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Pentanomial' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Pentanomial.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PersonalName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PersonalName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyInformation' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyInformation.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyMappings' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyMappings.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyQualifierId' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierId.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PolicyQualifierInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PostalAddress' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PostalAddress.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Prime_p' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Prime_p.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateDomainName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateDomainName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateKeyInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PrivateKeyUsagePeriod' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PublicKeyAndChallenge' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\PublicKeyInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RC2CBCParameter' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RC2CBCParameter.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RDNSequence' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RDNSequence.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RSAPrivateKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPrivateKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RSAPublicKey' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPublicKey.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RSASSA_PSS_params' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\ReasonFlags' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ReasonFlags.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RelativeDistinguishedName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\RevokedCertificate' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RevokedCertificate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SignedPublicKeyAndChallenge' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SpecifiedECDomain' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectAltName' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectAltName.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectDirectoryAttributes' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectInfoAccessSyntax' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\SubjectPublicKeyInfo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\TBSCertList' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertList.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\TBSCertificate' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertificate.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\TerminalIdentifier' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TerminalIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Time' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Time.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Trinomial' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Trinomial.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\UniqueIdentifier' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UniqueIdentifier.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\UserNotice' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UserNotice.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\Validity' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Validity.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\netscape_ca_policy_url' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_ca_policy_url.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\netscape_cert_type' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_cert_type.php',
|
||||
'phpseclib3\\File\\ASN1\\Maps\\netscape_comment' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_comment.php',
|
||||
'phpseclib3\\File\\X509' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/X509.php',
|
||||
'phpseclib3\\Math\\BigInteger' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\Base' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\BuiltIn' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\DefaultEngine' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\OpenSSL' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\Reductions\\Barrett' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\BCMath\\Reductions\\EvalBarrett' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\Engine' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\GMP' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\GMP\\DefaultEngine' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/GMP/DefaultEngine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\OpenSSL' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/OpenSSL.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP32' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP32.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP64' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP64.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Base' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Base.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\DefaultEngine' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/DefaultEngine.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Montgomery' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Montgomery.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\OpenSSL' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/OpenSSL.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\Barrett' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Barrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\Classic' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Classic.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\EvalBarrett' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/EvalBarrett.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\Montgomery' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/Montgomery.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\MontgomeryMult' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/MontgomeryMult.php',
|
||||
'phpseclib3\\Math\\BigInteger\\Engines\\PHP\\Reductions\\PowerOfTwo' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/PHP/Reductions/PowerOfTwo.php',
|
||||
'phpseclib3\\Math\\BinaryField' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BinaryField.php',
|
||||
'phpseclib3\\Math\\BinaryField\\Integer' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BinaryField/Integer.php',
|
||||
'phpseclib3\\Math\\Common\\FiniteField' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/Common/FiniteField.php',
|
||||
'phpseclib3\\Math\\Common\\FiniteField\\Integer' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/Common/FiniteField/Integer.php',
|
||||
'phpseclib3\\Math\\PrimeField' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/PrimeField.php',
|
||||
'phpseclib3\\Math\\PrimeField\\Integer' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/PrimeField/Integer.php',
|
||||
'phpseclib3\\Net\\SFTP' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SFTP.php',
|
||||
'phpseclib3\\Net\\SFTP\\Stream' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php',
|
||||
'phpseclib3\\Net\\SSH2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SSH2.php',
|
||||
'phpseclib3\\System\\SSH\\Agent' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent.php',
|
||||
'phpseclib3\\System\\SSH\\Agent\\Identity' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent/Identity.php',
|
||||
'phpseclib3\\System\\SSH\\Common\\Traits\\ReadBytes' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/System/SSH/Common/Traits/ReadBytes.php',
|
||||
'phpseclib\\Crypt\\AES' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/AES.php',
|
||||
'phpseclib\\Crypt\\Base' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Base.php',
|
||||
'phpseclib\\Crypt\\Blowfish' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php',
|
||||
'phpseclib\\Crypt\\DES' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/DES.php',
|
||||
'phpseclib\\Crypt\\Hash' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Hash.php',
|
||||
'phpseclib\\Crypt\\RC2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RC2.php',
|
||||
'phpseclib\\Crypt\\RC4' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RC4.php',
|
||||
'phpseclib\\Crypt\\RSA' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/RSA.php',
|
||||
'phpseclib\\Crypt\\Random' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
|
||||
'phpseclib\\Crypt\\Rijndael' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php',
|
||||
'phpseclib\\Crypt\\TripleDES' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php',
|
||||
'phpseclib\\Crypt\\Twofish' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php',
|
||||
'phpseclib\\File\\ANSI' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ANSI.php',
|
||||
'phpseclib\\File\\ASN1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1.php',
|
||||
'phpseclib\\File\\ASN1\\Element' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/ASN1/Element.php',
|
||||
'phpseclib\\File\\X509' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/File/X509.php',
|
||||
'phpseclib\\Math\\BigInteger' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Math/BigInteger.php',
|
||||
'phpseclib\\Net\\SCP' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SCP.php',
|
||||
'phpseclib\\Net\\SFTP' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SFTP.php',
|
||||
'phpseclib\\Net\\SFTP\\Stream' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php',
|
||||
'phpseclib\\Net\\SSH1' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SSH1.php',
|
||||
'phpseclib\\Net\\SSH2' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Net/SSH2.php',
|
||||
'phpseclib\\System\\SSH\\Agent' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent.php',
|
||||
'phpseclib\\System\\SSH\\Agent\\Identity' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/System/SSH/Agent/Identity.php',
|
||||
'voku\\helper\\ASCII' => __DIR__ . '/..' . '/voku/portable-ascii/src/voku/helper/ASCII.php',
|
||||
'voku\\helper\\StopWords' => __DIR__ . '/..' . '/voku/stop-words/src/voku/helper/StopWords.php',
|
||||
'voku\\helper\\StopWordsLanguageNotExists' => __DIR__ . '/..' . '/voku/stop-words/src/voku/helper/StopWordsLanguageNotExists.php',
|
||||
|
|
84
vendor/composer/installed.json
vendored
84
vendor/composer/installed.json
vendored
|
@ -690,70 +690,6 @@
|
|||
"description": "Detect and return all emoji found in a string",
|
||||
"homepage": "https://github.com/aaronpk/emoji-detector-php"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/constant_time_encoding",
|
||||
"version": "v2.4.0",
|
||||
"version_normalized": "2.4.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paragonie/constant_time_encoding.git",
|
||||
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
|
||||
"reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7|^8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6|^7|^8|^9",
|
||||
"vimeo/psalm": "^1|^2|^3|^4"
|
||||
},
|
||||
"time": "2020-12-06T15:14:20+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ParagonIE\\ConstantTime\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Steve 'Sc00bz' Thomas",
|
||||
"email": "steve@tobtu.com",
|
||||
"homepage": "https://www.tobtu.com",
|
||||
"role": "Original Developer"
|
||||
}
|
||||
],
|
||||
"description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)",
|
||||
"keywords": [
|
||||
"base16",
|
||||
"base32",
|
||||
"base32_decode",
|
||||
"base32_encode",
|
||||
"base64",
|
||||
"base64_decode",
|
||||
"base64_encode",
|
||||
"bin2hex",
|
||||
"encoding",
|
||||
"hex",
|
||||
"hex2bin",
|
||||
"rfc4648"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v9.99.99",
|
||||
|
@ -803,27 +739,25 @@
|
|||
},
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "3.0.6",
|
||||
"version_normalized": "3.0.6.0",
|
||||
"version": "2.0.30",
|
||||
"version_normalized": "2.0.30.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||
"reference": "906a5fafabe5e6ba51ef3dc65b2722a677908837"
|
||||
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/906a5fafabe5e6ba51ef3dc65b2722a677908837",
|
||||
"reference": "906a5fafabe5e6ba51ef3dc65b2722a677908837",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/136b9ca7eebef78be14abf90d65c5e57b6bc5d36",
|
||||
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"paragonie/constant_time_encoding": "^1|^2",
|
||||
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
|
||||
"php": ">=5.6.1"
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "~2.7",
|
||||
"phpunit/phpunit": "^5.7|^6.0|^9.4",
|
||||
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
|
||||
"squizlabs/php_codesniffer": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -832,7 +766,7 @@
|
|||
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
|
||||
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
|
||||
},
|
||||
"time": "2021-03-10T13:58:31+00:00",
|
||||
"time": "2020-12-17T05:42:04+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -840,7 +774,7 @@
|
|||
"phpseclib/bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"phpseclib3\\": "phpseclib/"
|
||||
"phpseclib\\": "phpseclib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
.idea/
|
||||
vendor/
|
|
@ -1,24 +0,0 @@
|
|||
language: php
|
||||
sudo: false
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: "7.1"
|
||||
- php: "7.2"
|
||||
- php: "7.3"
|
||||
- php: "7.4"
|
||||
- php: "8.0"
|
||||
- php: "nightly"
|
||||
allow_failures:
|
||||
- php: "nightly"
|
||||
- php: "7.4"
|
||||
- php: "8.0"
|
||||
|
||||
install:
|
||||
- composer self-update
|
||||
- composer update
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit
|
||||
- vendor/bin/psalm
|
|
@ -1,48 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 - 2020 Paragon Initiative Enterprises
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This library was based on the work of Steve "Sc00bz" Thomas.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Steve Thomas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
# Constant-Time Encoding
|
||||
|
||||
[![Build Status](https://travis-ci.org/paragonie/constant_time_encoding.svg?branch=master)](https://travis-ci.org/paragonie/constant_time_encoding)
|
||||
[![Latest Stable Version](https://poser.pugx.org/paragonie/constant_time_encoding/v/stable)](https://packagist.org/packages/paragonie/constant_time_encoding)
|
||||
[![Latest Unstable Version](https://poser.pugx.org/paragonie/constant_time_encoding/v/unstable)](https://packagist.org/packages/paragonie/constant_time_encoding)
|
||||
[![License](https://poser.pugx.org/paragonie/constant_time_encoding/license)](https://packagist.org/packages/paragonie/constant_time_encoding)
|
||||
[![Downloads](https://img.shields.io/packagist/dt/paragonie/constant_time_encoding.svg)](https://packagist.org/packages/paragonie/constant_time_encoding)
|
||||
|
||||
Based on the [constant-time base64 implementation made by Steve "Sc00bz" Thomas](https://github.com/Sc00bz/ConstTimeEncoding),
|
||||
this library aims to offer character encoding functions that do not leak
|
||||
information about what you are encoding/decoding via processor cache
|
||||
misses. Further reading on [cache-timing attacks](http://blog.ircmaxell.com/2014/11/its-all-about-time.html).
|
||||
|
||||
Our fork offers the following enchancements:
|
||||
|
||||
* `mbstring.func_overload` resistance
|
||||
* Unit tests
|
||||
* Composer- and Packagist-ready
|
||||
* Base16 encoding
|
||||
* Base32 encoding
|
||||
* Uses `pack()` and `unpack()` instead of `chr()` and `ord()`
|
||||
|
||||
## PHP Version Requirements
|
||||
|
||||
Version 2 of this library should work on **PHP 7** or newer. For PHP 5
|
||||
support, see [the v1.x branch](https://github.com/paragonie/constant_time_encoding/tree/v1.x).
|
||||
|
||||
If you are adding this as a dependency to a project intended to work on both PHP 5 and PHP 7, please set the required version to `^1|^2` instead of just `^1` or `^2`.
|
||||
|
||||
## How to Install
|
||||
|
||||
```sh
|
||||
composer require paragonie/constant_time_encoding
|
||||
```
|
||||
|
||||
## How to Use
|
||||
|
||||
```php
|
||||
use \ParagonIE\ConstantTime\Encoding;
|
||||
|
||||
// possibly (if applicable):
|
||||
// require 'vendor/autoload.php';
|
||||
|
||||
$data = random_bytes(32);
|
||||
echo Encoding::base64Encode($data), "\n";
|
||||
echo Encoding::base32EncodeUpper($data), "\n";
|
||||
echo Encoding::base32Encode($data), "\n";
|
||||
echo Encoding::hexEncode($data), "\n";
|
||||
echo Encoding::hexEncodeUpper($data), "\n";
|
||||
```
|
||||
|
||||
Example output:
|
||||
|
||||
```
|
||||
1VilPkeVqirlPifk5scbzcTTbMT2clp+Zkyv9VFFasE=
|
||||
2VMKKPSHSWVCVZJ6E7SONRY3ZXCNG3GE6ZZFU7TGJSX7KUKFNLAQ====
|
||||
2vmkkpshswvcvzj6e7sonry3zxcng3ge6zzfu7tgjsx7kukfnlaq====
|
||||
d558a53e4795aa2ae53e27e4e6c71bcdc4d36cc4f6725a7e664caff551456ac1
|
||||
D558A53E4795AA2AE53E27E4E6C71BDCC4D36CC4F6725A7E664CAFF551456AC1
|
||||
```
|
||||
|
||||
If you only need a particular variant, you can just reference the
|
||||
required class like so:
|
||||
|
||||
```php
|
||||
use \ParagonIE\ConstantTime\Base64;
|
||||
use \ParagonIE\ConstantTime\Base32;
|
||||
|
||||
$data = random_bytes(32);
|
||||
echo Base64::encode($data), "\n";
|
||||
echo Base32::encode($data), "\n";
|
||||
```
|
||||
|
||||
Example output:
|
||||
|
||||
```
|
||||
1VilPkeVqirlPifk5scbzcTTbMT2clp+Zkyv9VFFasE=
|
||||
2vmkkpshswvcvzj6e7sonry3zxcng3ge6zzfu7tgjsx7kukfnlaq====
|
||||
```
|
||||
|
||||
## Support Contracts
|
||||
|
||||
If your company uses this library in their products or services, you may be
|
||||
interested in [purchasing a support contract from Paragon Initiative Enterprises](https://paragonie.com/enterprise).
|
|
@ -1,51 +0,0 @@
|
|||
{
|
||||
"name": "paragonie/constant_time_encoding",
|
||||
"description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)",
|
||||
"keywords": [
|
||||
"base64",
|
||||
"encoding",
|
||||
"rfc4648",
|
||||
"base32",
|
||||
"base16",
|
||||
"hex",
|
||||
"bin2hex",
|
||||
"hex2bin",
|
||||
"base64_encode",
|
||||
"base64_decode",
|
||||
"base32_encode",
|
||||
"base32_decode"
|
||||
],
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Steve 'Sc00bz' Thomas",
|
||||
"email": "steve@tobtu.com",
|
||||
"homepage": "https://www.tobtu.com",
|
||||
"role": "Original Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/paragonie/constant_time_encoding/issues",
|
||||
"email": "info@paragonie.com",
|
||||
"source": "https://github.com/paragonie/constant_time_encoding"
|
||||
},
|
||||
"require": {
|
||||
"php": "^7|^8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6|^7|^8|^9",
|
||||
"vimeo/psalm": "^1|^2|^3|^4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ParagonIE\\ConstantTime\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="Constant Time Encoding Test Suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
useDocblockTypes="true"
|
||||
totallyTyped="true"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
</projectFiles>
|
||||
</psalm>
|
|
@ -1,471 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Base32
|
||||
* [A-Z][2-7]
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Base32 implements EncoderInterface
|
||||
{
|
||||
/**
|
||||
* Decode a Base32-encoded string into raw binary
|
||||
*
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
*/
|
||||
public static function decode(string $encodedString, bool $strictPadding = false): string
|
||||
{
|
||||
return static::doDecode($encodedString, false, $strictPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode an uppercase Base32-encoded string into raw binary
|
||||
*
|
||||
* @param string $src
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
*/
|
||||
public static function decodeUpper(string $src, bool $strictPadding = false): string
|
||||
{
|
||||
return static::doDecode($src, true, $strictPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode into Base32 (RFC 4648)
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encode(string $src): string
|
||||
{
|
||||
return static::doEncode($src, false, true);
|
||||
}
|
||||
/**
|
||||
* Encode into Base32 (RFC 4648)
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encodeUnpadded(string $src): string
|
||||
{
|
||||
return static::doEncode($src, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode into uppercase Base32 (RFC 4648)
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encodeUpper(string $src): string
|
||||
{
|
||||
return static::doEncode($src, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode into uppercase Base32 (RFC 4648)
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encodeUpperUnpadded(string $src): string
|
||||
{
|
||||
return static::doEncode($src, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 5-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5Bits(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 96 && $src < 123) $ret += $src - 97 + 1; // -64
|
||||
$ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 96);
|
||||
|
||||
// if ($src > 0x31 && $src < 0x38) $ret += $src - 24 + 1; // -23
|
||||
$ret += (((0x31 - $src) & ($src - 0x38)) >> 8) & ($src - 23);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 5-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* Uppercase variant.
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5BitsUpper(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 64 && $src < 91) $ret += $src - 65 + 1; // -64
|
||||
$ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 64);
|
||||
|
||||
// if ($src > 0x31 && $src < 0x38) $ret += $src - 24 + 1; // -23
|
||||
$ret += (((0x31 - $src) & ($src - 0x38)) >> 8) & ($src - 23);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 5-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5Bits(int $src): string
|
||||
{
|
||||
$diff = 0x61;
|
||||
|
||||
// if ($src > 25) $ret -= 72;
|
||||
$diff -= ((25 - $src) >> 8) & 73;
|
||||
|
||||
return \pack('C', $src + $diff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 5-bit integers.
|
||||
*
|
||||
* Uppercase variant.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5BitsUpper(int $src): string
|
||||
{
|
||||
$diff = 0x41;
|
||||
|
||||
// if ($src > 25) $ret -= 40;
|
||||
$diff -= ((25 - $src) >> 8) & 41;
|
||||
|
||||
return \pack('C', $src + $diff);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Base32 decoding
|
||||
*
|
||||
* @param string $src
|
||||
* @param bool $upper
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
* @psalm-suppress RedundantCondition
|
||||
*/
|
||||
protected static function doDecode(string $src, bool $upper = false, bool $strictPadding = false): string
|
||||
{
|
||||
// We do this to reduce code duplication:
|
||||
$method = $upper
|
||||
? 'decode5BitsUpper'
|
||||
: 'decode5Bits';
|
||||
|
||||
// Remove padding
|
||||
$srcLen = Binary::safeStrlen($src);
|
||||
if ($srcLen === 0) {
|
||||
return '';
|
||||
}
|
||||
if ($strictPadding) {
|
||||
if (($srcLen & 7) === 0) {
|
||||
for ($j = 0; $j < 7; ++$j) {
|
||||
if ($src[$srcLen - 1] === '=') {
|
||||
$srcLen--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($srcLen & 7) === 1) {
|
||||
throw new \RangeException(
|
||||
'Incorrect padding'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$src = \rtrim($src, '=');
|
||||
$srcLen = Binary::safeStrlen($src);
|
||||
}
|
||||
|
||||
$err = 0;
|
||||
$dest = '';
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 8 <= $srcLen; $i += 8) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, 8));
|
||||
/** @var int $c0 */
|
||||
$c0 = static::$method($chunk[1]);
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
/** @var int $c5 */
|
||||
$c5 = static::$method($chunk[6]);
|
||||
/** @var int $c6 */
|
||||
$c6 = static::$method($chunk[7]);
|
||||
/** @var int $c7 */
|
||||
$c7 = static::$method($chunk[8]);
|
||||
|
||||
$dest .= \pack(
|
||||
'CCCCC',
|
||||
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
|
||||
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
|
||||
(($c3 << 4) | ($c4 >> 1) ) & 0xff,
|
||||
(($c4 << 7) | ($c5 << 2) | ($c6 >> 3)) & 0xff,
|
||||
(($c6 << 5) | ($c7 ) ) & 0xff
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6 | $c7) >> 8;
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
|
||||
/** @var int $c0 */
|
||||
$c0 = static::$method($chunk[1]);
|
||||
|
||||
if ($i + 6 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
/** @var int $c5 */
|
||||
$c5 = static::$method($chunk[6]);
|
||||
/** @var int $c6 */
|
||||
$c6 = static::$method($chunk[7]);
|
||||
|
||||
$dest .= \pack(
|
||||
'CCCC',
|
||||
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
|
||||
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
|
||||
(($c3 << 4) | ($c4 >> 1) ) & 0xff,
|
||||
(($c4 << 7) | ($c5 << 2) | ($c6 >> 3)) & 0xff
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5 | $c6) >> 8;
|
||||
} elseif ($i + 5 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
/** @var int $c5 */
|
||||
$c5 = static::$method($chunk[6]);
|
||||
|
||||
$dest .= \pack(
|
||||
'CCCC',
|
||||
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
|
||||
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
|
||||
(($c3 << 4) | ($c4 >> 1) ) & 0xff,
|
||||
(($c4 << 7) | ($c5 << 2) ) & 0xff
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4 | $c5) >> 8;
|
||||
} elseif ($i + 4 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
/** @var int $c4 */
|
||||
$c4 = static::$method($chunk[5]);
|
||||
|
||||
$dest .= \pack(
|
||||
'CCC',
|
||||
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
|
||||
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff,
|
||||
(($c3 << 4) | ($c4 >> 1) ) & 0xff
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3 | $c4) >> 8;
|
||||
} elseif ($i + 3 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
/** @var int $c3 */
|
||||
$c3 = static::$method($chunk[4]);
|
||||
|
||||
$dest .= \pack(
|
||||
'CC',
|
||||
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
|
||||
(($c1 << 6) | ($c2 << 1) | ($c3 >> 4)) & 0xff
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3) >> 8;
|
||||
} elseif ($i + 2 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
/** @var int $c2 */
|
||||
$c2 = static::$method($chunk[3]);
|
||||
|
||||
$dest .= \pack(
|
||||
'CC',
|
||||
(($c0 << 3) | ($c1 >> 2) ) & 0xff,
|
||||
(($c1 << 6) | ($c2 << 1) ) & 0xff
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2) >> 8;
|
||||
} elseif ($i + 1 < $srcLen) {
|
||||
/** @var int $c1 */
|
||||
$c1 = static::$method($chunk[2]);
|
||||
|
||||
$dest .= \pack(
|
||||
'C',
|
||||
(($c0 << 3) | ($c1 >> 2) ) & 0xff
|
||||
);
|
||||
$err |= ($c0 | $c1) >> 8;
|
||||
} else {
|
||||
$dest .= \pack(
|
||||
'C',
|
||||
(($c0 << 3) ) & 0xff
|
||||
);
|
||||
$err |= ($c0) >> 8;
|
||||
}
|
||||
}
|
||||
/** @var bool $check */
|
||||
$check = ($err === 0);
|
||||
if (!$check) {
|
||||
throw new \RangeException(
|
||||
'Base32::doDecode() only expects characters in the correct base32 alphabet'
|
||||
);
|
||||
}
|
||||
return $dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base32 Encoding
|
||||
*
|
||||
* @param string $src
|
||||
* @param bool $upper
|
||||
* @param bool $pad
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
protected static function doEncode(string $src, bool $upper = false, $pad = true): string
|
||||
{
|
||||
// We do this to reduce code duplication:
|
||||
$method = $upper
|
||||
? 'encode5BitsUpper'
|
||||
: 'encode5Bits';
|
||||
|
||||
$dest = '';
|
||||
$srcLen = Binary::safeStrlen($src);
|
||||
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 5 <= $srcLen; $i += 5) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, 5));
|
||||
$b0 = $chunk[1];
|
||||
$b1 = $chunk[2];
|
||||
$b2 = $chunk[3];
|
||||
$b3 = $chunk[4];
|
||||
$b4 = $chunk[5];
|
||||
$dest .=
|
||||
static::$method( ($b0 >> 3) & 31) .
|
||||
static::$method((($b0 << 2) | ($b1 >> 6)) & 31) .
|
||||
static::$method((($b1 >> 1) ) & 31) .
|
||||
static::$method((($b1 << 4) | ($b2 >> 4)) & 31) .
|
||||
static::$method((($b2 << 1) | ($b3 >> 7)) & 31) .
|
||||
static::$method((($b3 >> 2) ) & 31) .
|
||||
static::$method((($b3 << 3) | ($b4 >> 5)) & 31) .
|
||||
static::$method( $b4 & 31);
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
|
||||
$b0 = $chunk[1];
|
||||
if ($i + 3 < $srcLen) {
|
||||
$b1 = $chunk[2];
|
||||
$b2 = $chunk[3];
|
||||
$b3 = $chunk[4];
|
||||
$dest .=
|
||||
static::$method( ($b0 >> 3) & 31) .
|
||||
static::$method((($b0 << 2) | ($b1 >> 6)) & 31) .
|
||||
static::$method((($b1 >> 1) ) & 31) .
|
||||
static::$method((($b1 << 4) | ($b2 >> 4)) & 31) .
|
||||
static::$method((($b2 << 1) | ($b3 >> 7)) & 31) .
|
||||
static::$method((($b3 >> 2) ) & 31) .
|
||||
static::$method((($b3 << 3) ) & 31);
|
||||
if ($pad) {
|
||||
$dest .= '=';
|
||||
}
|
||||
} elseif ($i + 2 < $srcLen) {
|
||||
$b1 = $chunk[2];
|
||||
$b2 = $chunk[3];
|
||||
$dest .=
|
||||
static::$method( ($b0 >> 3) & 31) .
|
||||
static::$method((($b0 << 2) | ($b1 >> 6)) & 31) .
|
||||
static::$method((($b1 >> 1) ) & 31) .
|
||||
static::$method((($b1 << 4) | ($b2 >> 4)) & 31) .
|
||||
static::$method((($b2 << 1) ) & 31);
|
||||
if ($pad) {
|
||||
$dest .= '===';
|
||||
}
|
||||
} elseif ($i + 1 < $srcLen) {
|
||||
$b1 = $chunk[2];
|
||||
$dest .=
|
||||
static::$method( ($b0 >> 3) & 31) .
|
||||
static::$method((($b0 << 2) | ($b1 >> 6)) & 31) .
|
||||
static::$method((($b1 >> 1) ) & 31) .
|
||||
static::$method((($b1 << 4) ) & 31);
|
||||
if ($pad) {
|
||||
$dest .= '====';
|
||||
}
|
||||
} else {
|
||||
$dest .=
|
||||
static::$method( ($b0 >> 3) & 31) .
|
||||
static::$method( ($b0 << 2) & 31);
|
||||
if ($pad) {
|
||||
$dest .= '======';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dest;
|
||||
}
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Base32Hex
|
||||
* [0-9][A-V]
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Base32Hex extends Base32
|
||||
{
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 5-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5Bits(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 0x30 && $src < 0x3a) ret += $src - 0x2e + 1; // -47
|
||||
$ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src - 47);
|
||||
|
||||
// if ($src > 0x60 && $src < 0x77) ret += $src - 0x61 + 10 + 1; // -86
|
||||
$ret += (((0x60 - $src) & ($src - 0x77)) >> 8) & ($src - 86);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 5-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode5BitsUpper(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 0x30 && $src < 0x3a) ret += $src - 0x2e + 1; // -47
|
||||
$ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src - 47);
|
||||
|
||||
// if ($src > 0x40 && $src < 0x57) ret += $src - 0x41 + 10 + 1; // -54
|
||||
$ret += (((0x40 - $src) & ($src - 0x57)) >> 8) & ($src - 54);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 5-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5Bits(int $src): string
|
||||
{
|
||||
$src += 0x30;
|
||||
|
||||
// if ($src > 0x39) $src += 0x61 - 0x3a; // 39
|
||||
$src += ((0x39 - $src) >> 8) & 39;
|
||||
|
||||
return \pack('C', $src);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 5-bit integers.
|
||||
*
|
||||
* Uppercase variant.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode5BitsUpper(int $src): string
|
||||
{
|
||||
$src += 0x30;
|
||||
|
||||
// if ($src > 0x39) $src += 0x41 - 0x3a; // 7
|
||||
$src += ((0x39 - $src) >> 8) & 7;
|
||||
|
||||
return \pack('C', $src);
|
||||
}
|
||||
}
|
|
@ -1,271 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Base64
|
||||
* [A-Z][a-z][0-9]+/
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Base64 implements EncoderInterface
|
||||
{
|
||||
/**
|
||||
* Encode into Base64
|
||||
*
|
||||
* Base64 character set "[A-Z][a-z][0-9]+/"
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encode(string $src): string
|
||||
{
|
||||
return static::doEncode($src, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode into Base64, no = padding
|
||||
*
|
||||
* Base64 character set "[A-Z][a-z][0-9]+/"
|
||||
*
|
||||
* @param string $src
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encodeUnpadded(string $src): string
|
||||
{
|
||||
return static::doEncode($src, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $src
|
||||
* @param bool $pad Include = padding?
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
protected static function doEncode(string $src, bool $pad = true): string
|
||||
{
|
||||
$dest = '';
|
||||
$srcLen = Binary::safeStrlen($src);
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 3 <= $srcLen; $i += 3) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, 3));
|
||||
$b0 = $chunk[1];
|
||||
$b1 = $chunk[2];
|
||||
$b2 = $chunk[3];
|
||||
|
||||
$dest .=
|
||||
static::encode6Bits( $b0 >> 2 ) .
|
||||
static::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) .
|
||||
static::encode6Bits((($b1 << 2) | ($b2 >> 6)) & 63) .
|
||||
static::encode6Bits( $b2 & 63);
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i));
|
||||
$b0 = $chunk[1];
|
||||
if ($i + 1 < $srcLen) {
|
||||
$b1 = $chunk[2];
|
||||
$dest .=
|
||||
static::encode6Bits($b0 >> 2) .
|
||||
static::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) .
|
||||
static::encode6Bits(($b1 << 2) & 63);
|
||||
if ($pad) {
|
||||
$dest .= '=';
|
||||
}
|
||||
} else {
|
||||
$dest .=
|
||||
static::encode6Bits( $b0 >> 2) .
|
||||
static::encode6Bits(($b0 << 4) & 63);
|
||||
if ($pad) {
|
||||
$dest .= '==';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* decode from base64 into binary
|
||||
*
|
||||
* Base64 character set "./[A-Z][a-z][0-9]"
|
||||
*
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding
|
||||
* @return string
|
||||
* @throws \RangeException
|
||||
* @throws \TypeError
|
||||
* @psalm-suppress RedundantCondition
|
||||
*/
|
||||
public static function decode(string $encodedString, bool $strictPadding = false): string
|
||||
{
|
||||
// Remove padding
|
||||
$srcLen = Binary::safeStrlen($encodedString);
|
||||
if ($srcLen === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($strictPadding) {
|
||||
if (($srcLen & 3) === 0) {
|
||||
if ($encodedString[$srcLen - 1] === '=') {
|
||||
$srcLen--;
|
||||
if ($encodedString[$srcLen - 1] === '=') {
|
||||
$srcLen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (($srcLen & 3) === 1) {
|
||||
throw new \RangeException(
|
||||
'Incorrect padding'
|
||||
);
|
||||
}
|
||||
if ($encodedString[$srcLen - 1] === '=') {
|
||||
throw new \RangeException(
|
||||
'Incorrect padding'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$encodedString = \rtrim($encodedString, '=');
|
||||
$srcLen = Binary::safeStrlen($encodedString);
|
||||
}
|
||||
|
||||
$err = 0;
|
||||
$dest = '';
|
||||
// Main loop (no padding):
|
||||
for ($i = 0; $i + 4 <= $srcLen; $i += 4) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, 4));
|
||||
$c0 = static::decode6Bits($chunk[1]);
|
||||
$c1 = static::decode6Bits($chunk[2]);
|
||||
$c2 = static::decode6Bits($chunk[3]);
|
||||
$c3 = static::decode6Bits($chunk[4]);
|
||||
|
||||
$dest .= \pack(
|
||||
'CCC',
|
||||
((($c0 << 2) | ($c1 >> 4)) & 0xff),
|
||||
((($c1 << 4) | ($c2 >> 2)) & 0xff),
|
||||
((($c2 << 6) | $c3 ) & 0xff)
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2 | $c3) >> 8;
|
||||
}
|
||||
// The last chunk, which may have padding:
|
||||
if ($i < $srcLen) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, $srcLen - $i));
|
||||
$c0 = static::decode6Bits($chunk[1]);
|
||||
|
||||
if ($i + 2 < $srcLen) {
|
||||
$c1 = static::decode6Bits($chunk[2]);
|
||||
$c2 = static::decode6Bits($chunk[3]);
|
||||
$dest .= \pack(
|
||||
'CC',
|
||||
((($c0 << 2) | ($c1 >> 4)) & 0xff),
|
||||
((($c1 << 4) | ($c2 >> 2)) & 0xff)
|
||||
);
|
||||
$err |= ($c0 | $c1 | $c2) >> 8;
|
||||
} elseif ($i + 1 < $srcLen) {
|
||||
$c1 = static::decode6Bits($chunk[2]);
|
||||
$dest .= \pack(
|
||||
'C',
|
||||
((($c0 << 2) | ($c1 >> 4)) & 0xff)
|
||||
);
|
||||
$err |= ($c0 | $c1) >> 8;
|
||||
} elseif ($i < $srcLen && $strictPadding) {
|
||||
$err |= 1;
|
||||
}
|
||||
}
|
||||
/** @var bool $check */
|
||||
$check = ($err === 0);
|
||||
if (!$check) {
|
||||
throw new \RangeException(
|
||||
'Base64::decode() only expects characters in the correct base64 alphabet'
|
||||
);
|
||||
}
|
||||
return $dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 6-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* Base64 character set:
|
||||
* [A-Z] [a-z] [0-9] + /
|
||||
* 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2b, 0x2f
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 0x40 && $src < 0x5b) $ret += $src - 0x41 + 1; // -64
|
||||
$ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 64);
|
||||
|
||||
// if ($src > 0x60 && $src < 0x7b) $ret += $src - 0x61 + 26 + 1; // -70
|
||||
$ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 70);
|
||||
|
||||
// if ($src > 0x2f && $src < 0x3a) $ret += $src - 0x30 + 52 + 1; // 5
|
||||
$ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src + 5);
|
||||
|
||||
// if ($src == 0x2b) $ret += 62 + 1;
|
||||
$ret += (((0x2a - $src) & ($src - 0x2c)) >> 8) & 63;
|
||||
|
||||
// if ($src == 0x2f) ret += 63 + 1;
|
||||
$ret += (((0x2e - $src) & ($src - 0x30)) >> 8) & 64;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 6-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits(int $src): string
|
||||
{
|
||||
$diff = 0x41;
|
||||
|
||||
// if ($src > 25) $diff += 0x61 - 0x41 - 26; // 6
|
||||
$diff += ((25 - $src) >> 8) & 6;
|
||||
|
||||
// if ($src > 51) $diff += 0x30 - 0x61 - 26; // -75
|
||||
$diff -= ((51 - $src) >> 8) & 75;
|
||||
|
||||
// if ($src > 61) $diff += 0x2b - 0x30 - 10; // -15
|
||||
$diff -= ((61 - $src) >> 8) & 15;
|
||||
|
||||
// if ($src > 62) $diff += 0x2f - 0x2b - 1; // 3
|
||||
$diff += ((62 - $src) >> 8) & 3;
|
||||
|
||||
return \pack('C', $src + $diff);
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Base64DotSlash
|
||||
* ./[A-Z][a-z][0-9]
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Base64DotSlash extends Base64
|
||||
{
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 6-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* Base64 character set:
|
||||
* ./ [A-Z] [a-z] [0-9]
|
||||
* 0x2e-0x2f, 0x41-0x5a, 0x61-0x7a, 0x30-0x39
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 0x2d && $src < 0x30) ret += $src - 0x2e + 1; // -45
|
||||
$ret += (((0x2d - $src) & ($src - 0x30)) >> 8) & ($src - 45);
|
||||
|
||||
// if ($src > 0x40 && $src < 0x5b) ret += $src - 0x41 + 2 + 1; // -62
|
||||
$ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 62);
|
||||
|
||||
// if ($src > 0x60 && $src < 0x7b) ret += $src - 0x61 + 28 + 1; // -68
|
||||
$ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 68);
|
||||
|
||||
// if ($src > 0x2f && $src < 0x3a) ret += $src - 0x30 + 54 + 1; // 7
|
||||
$ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src + 7);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 6-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits(int $src): string
|
||||
{
|
||||
$src += 0x2e;
|
||||
|
||||
// if ($src > 0x2f) $src += 0x41 - 0x30; // 17
|
||||
$src += ((0x2f - $src) >> 8) & 17;
|
||||
|
||||
// if ($src > 0x5a) $src += 0x61 - 0x5b; // 6
|
||||
$src += ((0x5a - $src) >> 8) & 6;
|
||||
|
||||
// if ($src > 0x7a) $src += 0x30 - 0x7b; // -75
|
||||
$src -= ((0x7a - $src) >> 8) & 75;
|
||||
|
||||
return \pack('C', $src);
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Base64DotSlashOrdered
|
||||
* ./[0-9][A-Z][a-z]
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Base64DotSlashOrdered extends Base64
|
||||
{
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 6-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* Base64 character set:
|
||||
* [.-9] [A-Z] [a-z]
|
||||
* 0x2e-0x39, 0x41-0x5a, 0x61-0x7a
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 0x2d && $src < 0x3a) ret += $src - 0x2e + 1; // -45
|
||||
$ret += (((0x2d - $src) & ($src - 0x3a)) >> 8) & ($src - 45);
|
||||
|
||||
// if ($src > 0x40 && $src < 0x5b) ret += $src - 0x41 + 12 + 1; // -52
|
||||
$ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 52);
|
||||
|
||||
// if ($src > 0x60 && $src < 0x7b) ret += $src - 0x61 + 38 + 1; // -58
|
||||
$ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 58);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 6-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits(int $src): string
|
||||
{
|
||||
$src += 0x2e;
|
||||
|
||||
// if ($src > 0x39) $src += 0x41 - 0x3a; // 7
|
||||
$src += ((0x39 - $src) >> 8) & 7;
|
||||
|
||||
// if ($src > 0x5a) $src += 0x61 - 0x5b; // 6
|
||||
$src += ((0x5a - $src) >> 8) & 6;
|
||||
|
||||
return \pack('C', $src);
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Base64UrlSafe
|
||||
* [A-Z][a-z][0-9]\-_
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Base64UrlSafe extends Base64
|
||||
{
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 6-bit integers
|
||||
* into 8-bit integers.
|
||||
*
|
||||
* Base64 character set:
|
||||
* [A-Z] [a-z] [0-9] - _
|
||||
* 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2d, 0x5f
|
||||
*
|
||||
* @param int $src
|
||||
* @return int
|
||||
*/
|
||||
protected static function decode6Bits(int $src): int
|
||||
{
|
||||
$ret = -1;
|
||||
|
||||
// if ($src > 0x40 && $src < 0x5b) $ret += $src - 0x41 + 1; // -64
|
||||
$ret += (((0x40 - $src) & ($src - 0x5b)) >> 8) & ($src - 64);
|
||||
|
||||
// if ($src > 0x60 && $src < 0x7b) $ret += $src - 0x61 + 26 + 1; // -70
|
||||
$ret += (((0x60 - $src) & ($src - 0x7b)) >> 8) & ($src - 70);
|
||||
|
||||
// if ($src > 0x2f && $src < 0x3a) $ret += $src - 0x30 + 52 + 1; // 5
|
||||
$ret += (((0x2f - $src) & ($src - 0x3a)) >> 8) & ($src + 5);
|
||||
|
||||
// if ($src == 0x2c) $ret += 62 + 1;
|
||||
$ret += (((0x2c - $src) & ($src - 0x2e)) >> 8) & 63;
|
||||
|
||||
// if ($src == 0x5f) ret += 63 + 1;
|
||||
$ret += (((0x5e - $src) & ($src - 0x60)) >> 8) & 64;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
|
||||
* into 6-bit integers.
|
||||
*
|
||||
* @param int $src
|
||||
* @return string
|
||||
*/
|
||||
protected static function encode6Bits(int $src): string
|
||||
{
|
||||
$diff = 0x41;
|
||||
|
||||
// if ($src > 25) $diff += 0x61 - 0x41 - 26; // 6
|
||||
$diff += ((25 - $src) >> 8) & 6;
|
||||
|
||||
// if ($src > 51) $diff += 0x30 - 0x61 - 26; // -75
|
||||
$diff -= ((51 - $src) >> 8) & 75;
|
||||
|
||||
// if ($src > 61) $diff += 0x2d - 0x30 - 10; // -13
|
||||
$diff -= ((61 - $src) >> 8) & 13;
|
||||
|
||||
// if ($src > 62) $diff += 0x5f - 0x2b - 1; // 3
|
||||
$diff += ((62 - $src) >> 8) & 49;
|
||||
|
||||
return \pack('C', $src + $diff);
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Binary
|
||||
*
|
||||
* Binary string operators that don't choke on
|
||||
* mbstring.func_overload
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Binary
|
||||
{
|
||||
/**
|
||||
* Safe string length
|
||||
*
|
||||
* @ref mbstring.func_overload
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
public static function safeStrlen(string $str): int
|
||||
{
|
||||
if (\function_exists('mb_strlen')) {
|
||||
return (int) \mb_strlen($str, '8bit');
|
||||
} else {
|
||||
return \strlen($str);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe substring
|
||||
*
|
||||
* @ref mbstring.func_overload
|
||||
*
|
||||
* @staticvar boolean $exists
|
||||
* @param string $str
|
||||
* @param int $start
|
||||
* @param int $length
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function safeSubstr(
|
||||
string $str,
|
||||
int $start = 0,
|
||||
$length = null
|
||||
): string {
|
||||
if ($length === 0) {
|
||||
return '';
|
||||
}
|
||||
if (\function_exists('mb_substr')) {
|
||||
return \mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
// Unlike mb_substr(), substr() doesn't accept NULL for length
|
||||
if ($length !== null) {
|
||||
return \substr($str, $start, $length);
|
||||
} else {
|
||||
return \substr($str, $start);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface EncoderInterface
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
interface EncoderInterface
|
||||
{
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $binString (raw binary)
|
||||
* @return string
|
||||
*/
|
||||
public static function encode(string $binString): string;
|
||||
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding Error on invalid padding
|
||||
* @return string (raw binary)
|
||||
*/
|
||||
public static function decode(string $encodedString, bool $strictPadding = false): string;
|
||||
}
|
|
@ -1,260 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Encoding
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Encoding
|
||||
{
|
||||
/**
|
||||
* RFC 4648 Base32 encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32Encode(string $str): string
|
||||
{
|
||||
return Base32::encode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32 encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32EncodeUpper(string $str): string
|
||||
{
|
||||
return Base32::encodeUpper($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32 decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32Decode(string $str): string
|
||||
{
|
||||
return Base32::decode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32 decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32DecodeUpper(string $str): string
|
||||
{
|
||||
return Base32::decodeUpper($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32 encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32HexEncode(string $str): string
|
||||
{
|
||||
return Base32Hex::encode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32Hex encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32HexEncodeUpper(string $str): string
|
||||
{
|
||||
return Base32Hex::encodeUpper($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32Hex decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32HexDecode(string $str): string
|
||||
{
|
||||
return Base32Hex::decode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32Hex decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32HexDecodeUpper(string $str): string
|
||||
{
|
||||
return Base32Hex::decodeUpper($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base64 encoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64Encode(string $str): string
|
||||
{
|
||||
return Base64::encode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base64 decoding
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64Decode(string $str): string
|
||||
{
|
||||
return Base64::decode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode into Base64
|
||||
*
|
||||
* Base64 character set "./[A-Z][a-z][0-9]"
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64EncodeDotSlash(string $str): string
|
||||
{
|
||||
return Base64DotSlash::encode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode from base64 to raw binary
|
||||
*
|
||||
* Base64 character set "./[A-Z][a-z][0-9]"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \RangeException
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64DecodeDotSlash(string $str): string
|
||||
{
|
||||
return Base64DotSlash::decode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode into Base64
|
||||
*
|
||||
* Base64 character set "[.-9][A-Z][a-z]" or "./[0-9][A-Z][a-z]"
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64EncodeDotSlashOrdered(string $str): string
|
||||
{
|
||||
return Base64DotSlashOrdered::encode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode from base64 to raw binary
|
||||
*
|
||||
* Base64 character set "[.-9][A-Z][a-z]" or "./[0-9][A-Z][a-z]"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \RangeException
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64DecodeDotSlashOrdered(string $str): string
|
||||
{
|
||||
return Base64DotSlashOrdered::decode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function hexEncode(string $bin_string): string
|
||||
{
|
||||
return Hex::encode($bin_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a hexadecimal string into a binary string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $hex_string
|
||||
* @return string (raw binary)
|
||||
* @throws \RangeException
|
||||
*/
|
||||
public static function hexDecode(string $hex_string): string
|
||||
{
|
||||
return Hex::decode($hex_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function hexEncodeUpper(string $bin_string): string
|
||||
{
|
||||
return Hex::encodeUpper($bin_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $bin_string (raw binary)
|
||||
* @return string
|
||||
*/
|
||||
public static function hexDecodeUpper(string $bin_string): string
|
||||
{
|
||||
return Hex::decode($bin_string);
|
||||
}
|
||||
}
|
159
vendor/paragonie/constant_time_encoding/src/Hex.php
vendored
159
vendor/paragonie/constant_time_encoding/src/Hex.php
vendored
|
@ -1,159 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Hex
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class Hex implements EncoderInterface
|
||||
{
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $binString (raw binary)
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encode(string $binString): string
|
||||
{
|
||||
/** @var string $hex */
|
||||
$hex = '';
|
||||
$len = Binary::safeStrlen($binString);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C', Binary::safeSubstr($binString, $i, 1));
|
||||
/** @var int $c */
|
||||
$c = $chunk[1] & 0xf;
|
||||
/** @var int $b */
|
||||
$b = $chunk[1] >> 4;
|
||||
|
||||
$hex .= pack(
|
||||
'CC',
|
||||
(87 + $b + ((($b - 10) >> 8) & ~38)),
|
||||
(87 + $c + ((($c - 10) >> 8) & ~38))
|
||||
);
|
||||
}
|
||||
return $hex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a binary string into a hexadecimal string without cache-timing
|
||||
* leaks, returning uppercase letters (as per RFC 4648)
|
||||
*
|
||||
* @param string $binString (raw binary)
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function encodeUpper(string $binString): string
|
||||
{
|
||||
/** @var string $hex */
|
||||
$hex = '';
|
||||
/** @var int $len */
|
||||
$len = Binary::safeStrlen($binString);
|
||||
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C', Binary::safeSubstr($binString, $i, 2));
|
||||
/** @var int $c */
|
||||
$c = $chunk[1] & 0xf;
|
||||
/** @var int $b */
|
||||
$b = $chunk[1] >> 4;
|
||||
|
||||
$hex .= pack(
|
||||
'CC',
|
||||
(55 + $b + ((($b - 10) >> 8) & ~6)),
|
||||
(55 + $c + ((($c - 10) >> 8) & ~6))
|
||||
);
|
||||
}
|
||||
return $hex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a hexadecimal string into a binary string without cache-timing
|
||||
* leaks
|
||||
*
|
||||
* @param string $encodedString
|
||||
* @param bool $strictPadding
|
||||
* @return string (raw binary)
|
||||
* @throws \RangeException
|
||||
*/
|
||||
public static function decode(string $encodedString, bool $strictPadding = false): string
|
||||
{
|
||||
/** @var int $hex_pos */
|
||||
$hex_pos = 0;
|
||||
/** @var string $bin */
|
||||
$bin = '';
|
||||
/** @var int $c_acc */
|
||||
$c_acc = 0;
|
||||
/** @var int $hex_len */
|
||||
$hex_len = Binary::safeStrlen($encodedString);
|
||||
/** @var int $state */
|
||||
$state = 0;
|
||||
if (($hex_len & 1) !== 0) {
|
||||
if ($strictPadding) {
|
||||
throw new \RangeException(
|
||||
'Expected an even number of hexadecimal characters'
|
||||
);
|
||||
} else {
|
||||
$encodedString = '0' . $encodedString;
|
||||
++$hex_len;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var array<int, int> $chunk */
|
||||
$chunk = \unpack('C*', $encodedString);
|
||||
while ($hex_pos < $hex_len) {
|
||||
++$hex_pos;
|
||||
/** @var int $c */
|
||||
$c = $chunk[$hex_pos];
|
||||
/** @var int $c_num */
|
||||
$c_num = $c ^ 48;
|
||||
/** @var int $c_num0 */
|
||||
$c_num0 = ($c_num - 10) >> 8;
|
||||
/** @var int $c_alpha */
|
||||
$c_alpha = ($c & ~32) - 55;
|
||||
/** @var int $c_alpha0 */
|
||||
$c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8;
|
||||
|
||||
if (($c_num0 | $c_alpha0) === 0) {
|
||||
throw new \RangeException(
|
||||
'Expected hexadecimal character'
|
||||
);
|
||||
}
|
||||
/** @var int $c_val */
|
||||
$c_val = ($c_num0 & $c_num) | ($c_alpha & $c_alpha0);
|
||||
if ($state === 0) {
|
||||
$c_acc = $c_val * 16;
|
||||
} else {
|
||||
$bin .= \pack('C', $c_acc | $c_val);
|
||||
}
|
||||
$state ^= 1;
|
||||
}
|
||||
return $bin;
|
||||
}
|
||||
}
|
|
@ -1,175 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ParagonIE\ConstantTime;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
|
||||
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class RFC4648
|
||||
*
|
||||
* This class conforms strictly to the RFC
|
||||
*
|
||||
* @package ParagonIE\ConstantTime
|
||||
*/
|
||||
abstract class RFC4648
|
||||
{
|
||||
/**
|
||||
* RFC 4648 Base64 encoding
|
||||
*
|
||||
* "foo" -> "Zm9v"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64Encode(string $str): string
|
||||
{
|
||||
return Base64::encode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base64 decoding
|
||||
*
|
||||
* "Zm9v" -> "foo"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64Decode(string $str): string
|
||||
{
|
||||
return Base64::decode($str, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base64 (URL Safe) encoding
|
||||
*
|
||||
* "foo" -> "Zm9v"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64UrlSafeEncode(string $str): string
|
||||
{
|
||||
return Base64UrlSafe::encode($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base64 (URL Safe) decoding
|
||||
*
|
||||
* "Zm9v" -> "foo"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base64UrlSafeDecode(string $str): string
|
||||
{
|
||||
return Base64UrlSafe::decode($str, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32 encoding
|
||||
*
|
||||
* "foo" -> "MZXW6==="
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32Encode(string $str): string
|
||||
{
|
||||
return Base32::encodeUpper($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32 encoding
|
||||
*
|
||||
* "MZXW6===" -> "foo"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32Decode(string $str): string
|
||||
{
|
||||
return Base32::decodeUpper($str, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32-Hex encoding
|
||||
*
|
||||
* "foo" -> "CPNMU==="
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32HexEncode(string $str): string
|
||||
{
|
||||
return Base32::encodeUpper($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base32-Hex decoding
|
||||
*
|
||||
* "CPNMU===" -> "foo"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base32HexDecode(string $str): string
|
||||
{
|
||||
return Base32::decodeUpper($str, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base16 decoding
|
||||
*
|
||||
* "foo" -> "666F6F"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public static function base16Encode(string $str): string
|
||||
{
|
||||
return Hex::encodeUpper($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 4648 Base16 decoding
|
||||
*
|
||||
* "666F6F" -> "foo"
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
public static function base16Decode(string $str): string
|
||||
{
|
||||
return Hex::decode($str, true);
|
||||
}
|
||||
}
|
12
vendor/phpseclib/phpseclib/.github/FUNDING.yml
vendored
12
vendor/phpseclib/phpseclib/.github/FUNDING.yml
vendored
|
@ -1,12 +0,0 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: terrafrost
|
||||
patreon: phpseclib
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: "packagist/phpseclib/phpseclib"
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
4
vendor/phpseclib/phpseclib/README.md
vendored
4
vendor/phpseclib/phpseclib/README.md
vendored
|
@ -1,6 +1,6 @@
|
|||
# phpseclib - PHP Secure Communications Library
|
||||
|
||||
[![Build Status](https://travis-ci.com/phpseclib/phpseclib.svg?branch=3.0)](https://travis-ci.com/phpseclib/phpseclib)
|
||||
[![Build Status](https://travis-ci.com/phpseclib/phpseclib.svg?branch=2.0)](https://travis-ci.com/phpseclib/phpseclib)
|
||||
|
||||
## Supporting phpseclib
|
||||
|
||||
|
@ -19,7 +19,7 @@ SSH-2, SFTP, X.509, an arbitrary-precision integer arithmetic library, Ed25519 /
|
|||
## Documentation
|
||||
|
||||
* [Documentation / Manual](https://phpseclib.com/)
|
||||
* [API Documentation](https://api.phpseclib.com/3.0/) (generated by Doctum)
|
||||
* [API Documentation](https://api.phpseclib.com/2.0/) (generated by Doctum)
|
||||
|
||||
## Branches
|
||||
|
||||
|
|
8
vendor/phpseclib/phpseclib/composer.json
vendored
8
vendor/phpseclib/phpseclib/composer.json
vendored
|
@ -51,13 +51,11 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"paragonie/constant_time_encoding": "^1|^2",
|
||||
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
|
||||
"php": ">=5.6.1"
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "~2.7",
|
||||
"phpunit/phpunit": "^5.7|^6.0|^9.4",
|
||||
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
|
||||
"squizlabs/php_codesniffer": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -71,7 +69,7 @@
|
|||
"phpseclib/bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"phpseclib3\\": "phpseclib/"
|
||||
"phpseclib\\": "phpseclib/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,387 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Common String Functions
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Common
|
||||
* @package Functions\Strings
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Common\Functions;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Math\Common\FiniteField;
|
||||
|
||||
/**
|
||||
* Common String Functions
|
||||
*
|
||||
* @package Functions\Strings
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
abstract class Strings
|
||||
{
|
||||
/**
|
||||
* String Shift
|
||||
*
|
||||
* Inspired by array_shift
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $index
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function shift(&$string, $index = 1)
|
||||
{
|
||||
$substr = substr($string, 0, $index);
|
||||
$string = substr($string, $index);
|
||||
return $substr;
|
||||
}
|
||||
|
||||
/**
|
||||
* String Pop
|
||||
*
|
||||
* Inspired by array_pop
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $index
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function pop(&$string, $index = 1)
|
||||
{
|
||||
$substr = substr($string, -$index);
|
||||
$string = substr($string, 0, -$index);
|
||||
return $substr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse SSH2-style string
|
||||
*
|
||||
* Returns either an array or a boolean if $data is malformed.
|
||||
*
|
||||
* Valid characters for $format are as follows:
|
||||
*
|
||||
* C = byte
|
||||
* b = boolean (true/false)
|
||||
* N = uint32
|
||||
* s = string
|
||||
* i = mpint
|
||||
* L = name-list
|
||||
*
|
||||
* uint64 is not supported.
|
||||
*
|
||||
* @param string $format
|
||||
* @param string $data
|
||||
* @return mixed
|
||||
*/
|
||||
public static function unpackSSH2($format, &$data)
|
||||
{
|
||||
$format = self::formatPack($format);
|
||||
$result = [];
|
||||
for ($i = 0; $i < strlen($format); $i++) {
|
||||
switch ($format[$i]) {
|
||||
case 'C':
|
||||
case 'b':
|
||||
if (!strlen($data)) {
|
||||
throw new \LengthException('At least one byte needs to be present for successful C / b decodes');
|
||||
}
|
||||
break;
|
||||
case 'N':
|
||||
case 'i':
|
||||
case 's':
|
||||
case 'L':
|
||||
if (strlen($data) < 4) {
|
||||
throw new \LengthException('At least four byte needs to be present for successful N / i / s / L decodes');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException('$format contains an invalid character');
|
||||
}
|
||||
switch ($format[$i]) {
|
||||
case 'C':
|
||||
$result[] = ord(self::shift($data));
|
||||
continue 2;
|
||||
case 'b':
|
||||
$result[] = ord(self::shift($data)) != 0;
|
||||
continue 2;
|
||||
case 'N':
|
||||
list(, $temp) = unpack('N', self::shift($data, 4));
|
||||
$result[] = $temp;
|
||||
continue 2;
|
||||
}
|
||||
list(, $length) = unpack('N', self::shift($data, 4));
|
||||
if (strlen($data) < $length) {
|
||||
throw new \LengthException("$length bytes needed; " . strlen($data) . ' bytes available');
|
||||
}
|
||||
$temp = self::shift($data, $length);
|
||||
switch ($format[$i]) {
|
||||
case 'i':
|
||||
$result[] = new BigInteger($temp, -256);
|
||||
break;
|
||||
case 's':
|
||||
$result[] = $temp;
|
||||
break;
|
||||
case 'L':
|
||||
$result[] = explode(',', $temp);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create SSH2-style string
|
||||
*
|
||||
* @param string[] ...$elements
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public static function packSSH2(...$elements)
|
||||
{
|
||||
$format = self::formatPack($elements[0]);
|
||||
array_shift($elements);
|
||||
if (strlen($format) != count($elements)) {
|
||||
throw new \InvalidArgumentException('There must be as many arguments as there are characters in the $format string');
|
||||
}
|
||||
$result = '';
|
||||
for ($i = 0; $i < strlen($format); $i++) {
|
||||
$element = $elements[$i];
|
||||
switch ($format[$i]) {
|
||||
case 'C':
|
||||
if (!is_int($element)) {
|
||||
throw new \InvalidArgumentException('Bytes must be represented as an integer between 0 and 255, inclusive.');
|
||||
}
|
||||
$result.= pack('C', $element);
|
||||
break;
|
||||
case 'b':
|
||||
if (!is_bool($element)) {
|
||||
throw new \InvalidArgumentException('A boolean parameter was expected.');
|
||||
}
|
||||
$result.= $element ? "\1" : "\0";
|
||||
break;
|
||||
case 'N':
|
||||
if (is_float($element)) {
|
||||
$element = (int) $element;
|
||||
}
|
||||
if (!is_int($element)) {
|
||||
throw new \InvalidArgumentException('An integer was expected.');
|
||||
}
|
||||
$result.= pack('N', $element);
|
||||
break;
|
||||
case 's':
|
||||
if (!self::is_stringable($element)) {
|
||||
throw new \InvalidArgumentException('A string was expected.');
|
||||
}
|
||||
$result.= pack('Na*', strlen($element), $element);
|
||||
break;
|
||||
case 'i':
|
||||
if (!$element instanceof BigInteger && !$element instanceof FiniteField\Integer) {
|
||||
throw new \InvalidArgumentException('A phpseclib3\Math\BigInteger or phpseclib3\Math\Common\FiniteField\Integer object was expected.');
|
||||
}
|
||||
$element = $element->toBytes(true);
|
||||
$result.= pack('Na*', strlen($element), $element);
|
||||
break;
|
||||
case 'L':
|
||||
if (!is_array($element)) {
|
||||
throw new \InvalidArgumentException('An array was expected.');
|
||||
}
|
||||
$element = implode(',', $element);
|
||||
$result.= pack('Na*', strlen($element), $element);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException('$format contains an invalid character');
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand a pack string
|
||||
*
|
||||
* Converts C5 to CCCCC, for example.
|
||||
*
|
||||
* @access private
|
||||
* @param string $format
|
||||
* @return string
|
||||
*/
|
||||
private static function formatPack($format)
|
||||
{
|
||||
$parts = preg_split('#(\d+)#', $format, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$format = '';
|
||||
for ($i = 1; $i < count($parts); $i+=2) {
|
||||
$format.= substr($parts[$i - 1], 0, -1) . str_repeat(substr($parts[$i - 1], -1), $parts[$i]);
|
||||
}
|
||||
$format.= $parts[$i - 1];
|
||||
|
||||
return $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert binary data into bits
|
||||
*
|
||||
* bin2hex / hex2bin refer to base-256 encoded data as binary, whilst
|
||||
* decbin / bindec refer to base-2 encoded data as binary. For the purposes
|
||||
* of this function, bin refers to base-256 encoded data whilst bits refers
|
||||
* to base-2 encoded data
|
||||
*
|
||||
* @access public
|
||||
* @param string $x
|
||||
* @return string
|
||||
*/
|
||||
public static function bits2bin($x)
|
||||
{
|
||||
/*
|
||||
// the pure-PHP approach is faster than the GMP approach
|
||||
if (function_exists('gmp_export')) {
|
||||
return strlen($x) ? gmp_export(gmp_init($x, 2)) : gmp_init(0);
|
||||
}
|
||||
*/
|
||||
|
||||
if (preg_match('#[^01]#', $x)) {
|
||||
throw new \RuntimeException('The only valid characters are 0 and 1');
|
||||
}
|
||||
|
||||
if (!defined('PHP_INT_MIN')) {
|
||||
define('PHP_INT_MIN', ~PHP_INT_MAX);
|
||||
}
|
||||
|
||||
$length = strlen($x);
|
||||
if (!$length) {
|
||||
return '';
|
||||
}
|
||||
$block_size = PHP_INT_SIZE << 3;
|
||||
$pad = $block_size - ($length % $block_size);
|
||||
if ($pad != $block_size) {
|
||||
$x = str_repeat('0', $pad) . $x;
|
||||
}
|
||||
|
||||
$parts = str_split($x, $block_size);
|
||||
$str = '';
|
||||
foreach ($parts as $part) {
|
||||
$xor = $part[0] == '1' ? PHP_INT_MIN : 0;
|
||||
$part[0] = '0';
|
||||
$str.= pack(
|
||||
PHP_INT_SIZE == 4 ? 'N' : 'J',
|
||||
$xor ^ eval('return 0b' . $part . ';')
|
||||
);
|
||||
}
|
||||
return ltrim($str, "\0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert bits to binary data
|
||||
*
|
||||
* @access public
|
||||
* @param string $x
|
||||
* @return string
|
||||
*/
|
||||
public static function bin2bits($x)
|
||||
{
|
||||
/*
|
||||
// the pure-PHP approach is slower than the GMP approach BUT
|
||||
// i want to the pure-PHP version to be easily unit tested as well
|
||||
if (function_exists('gmp_import')) {
|
||||
return gmp_strval(gmp_import($x), 2);
|
||||
}
|
||||
*/
|
||||
|
||||
$len = strlen($x);
|
||||
$mod = $len % PHP_INT_SIZE;
|
||||
if ($mod) {
|
||||
$x = str_pad($x, $len + PHP_INT_SIZE - $mod, "\0", STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
$bits = '';
|
||||
if (PHP_INT_SIZE == 4) {
|
||||
$digits = unpack('N*', $x);
|
||||
foreach ($digits as $digit) {
|
||||
$bits.= sprintf('%032b', $digit);
|
||||
}
|
||||
} else {
|
||||
$digits = unpack('J*', $x);
|
||||
foreach ($digits as $digit) {
|
||||
$bits.= sprintf('%064b', $digit);
|
||||
}
|
||||
}
|
||||
|
||||
return ltrim($bits, '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch Endianness Bit Order
|
||||
*
|
||||
* @access public
|
||||
* @param string $x
|
||||
* @return string
|
||||
*/
|
||||
public static function switchEndianness($x)
|
||||
{
|
||||
$r = '';
|
||||
// from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
|
||||
for ($i = strlen($x) - 1; $i >= 0; $i--) {
|
||||
$b = ord($x[$i]);
|
||||
$p1 = ($b * 0x0802) & 0x22110;
|
||||
$p2 = ($b * 0x8020) & 0x88440;
|
||||
$r.= chr(
|
||||
(($p1 | $p2) * 0x10101) >> 16
|
||||
);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the current string
|
||||
*
|
||||
* @param string $var
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public static function increment_str(&$var)
|
||||
{
|
||||
for ($i = 4; $i <= strlen($var); $i+= 4) {
|
||||
$temp = substr($var, -$i, 4);
|
||||
switch ($temp) {
|
||||
case "\xFF\xFF\xFF\xFF":
|
||||
$var = substr_replace($var, "\x00\x00\x00\x00", -$i, 4);
|
||||
break;
|
||||
case "\x7F\xFF\xFF\xFF":
|
||||
$var = substr_replace($var, "\x80\x00\x00\x00", -$i, 4);
|
||||
return $var;
|
||||
default:
|
||||
$temp = unpack('Nnum', $temp);
|
||||
$var = substr_replace($var, pack('N', $temp['num'] + 1), -$i, 4);
|
||||
return $var;
|
||||
}
|
||||
}
|
||||
|
||||
$remainder = strlen($var) % 4;
|
||||
|
||||
if ($remainder == 0) {
|
||||
return $var;
|
||||
}
|
||||
|
||||
$temp = unpack('Nnum', str_pad(substr($var, 0, $remainder), 4, "\0", STR_PAD_LEFT));
|
||||
$temp = substr(pack('N', $temp['num'] + 1), -$remainder);
|
||||
$var = substr_replace($var, $temp, 0, $remainder);
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find whether the type of a variable is string (or could be converted to one)
|
||||
*
|
||||
* @param string|object $var
|
||||
* @return boolean
|
||||
* @access public
|
||||
*/
|
||||
public static function is_stringable($var)
|
||||
{
|
||||
return is_string($var) || (is_object($var) && method_exists($var, '__toString'));
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
* it'll be null-padded to 192-bits and 192 bits will be the key length until {@link self::setKey() setKey()}
|
||||
* is called, again, at which point, it'll be recalculated.
|
||||
*
|
||||
* Since \phpseclib3\Crypt\AES extends \phpseclib3\Crypt\Rijndael, some functions are available to be called that, in the context of AES, don't
|
||||
* Since \phpseclib\Crypt\AES extends \phpseclib\Crypt\Rijndael, some functions are available to be called that, in the context of AES, don't
|
||||
* make a whole lot of sense. {@link self::setBlockLength() setBlockLength()}, for instance. Calling that function,
|
||||
* however possible, won't do anything (AES has a fixed block length whereas Rijndael has a variable one).
|
||||
*
|
||||
|
@ -25,7 +25,7 @@
|
|||
* <?php
|
||||
* include 'vendor/autoload.php';
|
||||
*
|
||||
* $aes = new \phpseclib3\Crypt\AES('ctr');
|
||||
* $aes = new \phpseclib\Crypt\AES();
|
||||
*
|
||||
* $aes->setKey('abcdefghijklmnop');
|
||||
*
|
||||
|
@ -47,7 +47,7 @@
|
|||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt;
|
||||
namespace phpseclib\Crypt;
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of AES.
|
||||
|
@ -61,37 +61,35 @@ class AES extends Rijndael
|
|||
/**
|
||||
* Dummy function
|
||||
*
|
||||
* Since \phpseclib3\Crypt\AES extends \phpseclib3\Crypt\Rijndael, this function is, technically, available, but it doesn't do anything.
|
||||
* Since \phpseclib\Crypt\AES extends \phpseclib\Crypt\Rijndael, this function is, technically, available, but it doesn't do anything.
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Rijndael::setBlockLength()
|
||||
* @see \phpseclib\Crypt\Rijndael::setBlockLength()
|
||||
* @access public
|
||||
* @param int $length
|
||||
* @throws \BadMethodCallException anytime it's called
|
||||
*/
|
||||
public function setBlockLength($length)
|
||||
function setBlockLength($length)
|
||||
{
|
||||
throw new \BadMethodCallException('The block length cannot be set for AES.');
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key length
|
||||
*
|
||||
* Valid key lengths are 128, 192, and 256. Set the link to bool(false) to disable a fixed key length
|
||||
* Valid key lengths are 128, 192, and 256. If the length is less than 128, it will be rounded up to
|
||||
* 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Rijndael:setKeyLength()
|
||||
* @see \phpseclib\Crypt\Rijndael:setKeyLength()
|
||||
* @access public
|
||||
* @param int $length
|
||||
* @throws \LengthException if the key length isn't supported
|
||||
*/
|
||||
public function setKeyLength($length)
|
||||
function setKeyLength($length)
|
||||
{
|
||||
switch ($length) {
|
||||
case 128:
|
||||
case 192:
|
||||
case 256:
|
||||
case 160:
|
||||
$length = 192;
|
||||
break;
|
||||
default:
|
||||
throw new \LengthException('Key of size ' . $length . ' not supported by this algorithm. Only keys of sizes 128, 192 or 256 supported');
|
||||
case 224:
|
||||
$length = 256;
|
||||
}
|
||||
parent::setKeyLength($length);
|
||||
}
|
||||
|
@ -101,23 +99,28 @@ class AES extends Rijndael
|
|||
*
|
||||
* Rijndael supports five different key lengths, AES only supports three.
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Rijndael:setKey()
|
||||
* @see \phpseclib\Crypt\Rijndael:setKey()
|
||||
* @see setKeyLength()
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @throws \LengthException if the key length isn't supported
|
||||
*/
|
||||
public function setKey($key)
|
||||
function setKey($key)
|
||||
{
|
||||
switch (strlen($key)) {
|
||||
case 16:
|
||||
case 24:
|
||||
case 32:
|
||||
break;
|
||||
default:
|
||||
throw new \LengthException('Key of size ' . strlen($key) . ' not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported');
|
||||
}
|
||||
|
||||
parent::setKey($key);
|
||||
|
||||
if (!$this->explicit_key_length) {
|
||||
$length = strlen($key);
|
||||
switch (true) {
|
||||
case $length <= 16:
|
||||
$this->key_length = 16;
|
||||
break;
|
||||
case $length <= 24:
|
||||
$this->key_length = 24;
|
||||
break;
|
||||
default:
|
||||
$this->key_length = 32;
|
||||
}
|
||||
$this->_setEngine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@
|
|||
* <?php
|
||||
* include 'vendor/autoload.php';
|
||||
*
|
||||
* $blowfish = new \phpseclib3\Crypt\Blowfish('ctr');
|
||||
* $blowfish = new \phpseclib\Crypt\Blowfish();
|
||||
*
|
||||
* $blowfish->setKey('12345678901234567890123456789012');
|
||||
*
|
||||
|
@ -35,9 +35,7 @@
|
|||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt;
|
||||
|
||||
use phpseclib3\Crypt\Common\BlockCipher;
|
||||
namespace phpseclib\Crypt;
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of Blowfish.
|
||||
|
@ -47,34 +45,34 @@ use phpseclib3\Crypt\Common\BlockCipher;
|
|||
* @author Hans-Juergen Petrich <petrich@tronic-media.com>
|
||||
* @access public
|
||||
*/
|
||||
class Blowfish extends BlockCipher
|
||||
class Blowfish extends Base
|
||||
{
|
||||
/**
|
||||
* Block Length of the cipher
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::block_size
|
||||
* @see \phpseclib\Crypt\Base::block_size
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
protected $block_size = 8;
|
||||
var $block_size = 8;
|
||||
|
||||
/**
|
||||
* The mcrypt specific name of the cipher
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
|
||||
* @see \phpseclib\Crypt\Base::cipher_name_mcrypt
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $cipher_name_mcrypt = 'blowfish';
|
||||
var $cipher_name_mcrypt = 'blowfish';
|
||||
|
||||
/**
|
||||
* Optimizing value while CFB-encrypting
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
|
||||
* @see \phpseclib\Crypt\Base::cfb_init_len
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
protected $cfb_init_len = 500;
|
||||
var $cfb_init_len = 500;
|
||||
|
||||
/**
|
||||
* The fixed subkeys boxes ($sbox0 - $sbox3) with 256 entries each
|
||||
|
@ -84,7 +82,7 @@ class Blowfish extends BlockCipher
|
|||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private static $sbox0 = [
|
||||
var $sbox0 = array(
|
||||
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
||||
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
|
||||
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
|
||||
|
@ -117,7 +115,7 @@ class Blowfish extends BlockCipher
|
|||
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
|
||||
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
|
||||
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* S-Box 1
|
||||
|
@ -125,7 +123,7 @@ class Blowfish extends BlockCipher
|
|||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private static $sbox1 = [
|
||||
var $sbox1 = array(
|
||||
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
|
||||
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
|
||||
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
|
||||
|
@ -158,7 +156,7 @@ class Blowfish extends BlockCipher
|
|||
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
|
||||
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
|
||||
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* S-Box 2
|
||||
|
@ -166,7 +164,7 @@ class Blowfish extends BlockCipher
|
|||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private static $sbox2 = [
|
||||
var $sbox2 = array(
|
||||
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
|
||||
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
|
||||
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
|
||||
|
@ -199,7 +197,7 @@ class Blowfish extends BlockCipher
|
|||
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
|
||||
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
|
||||
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* S-Box 3
|
||||
|
@ -207,7 +205,7 @@ class Blowfish extends BlockCipher
|
|||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
private static $sbox3 = [
|
||||
var $sbox3 = array(
|
||||
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
|
||||
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
|
||||
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
|
||||
|
@ -240,7 +238,7 @@ class Blowfish extends BlockCipher
|
|||
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
|
||||
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
|
||||
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* P-Array consists of 18 32-bit subkeys
|
||||
|
@ -248,11 +246,11 @@ class Blowfish extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $parray = [
|
||||
var $parray = array(
|
||||
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
|
||||
0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
|
||||
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* The BCTX-working Array
|
||||
|
@ -262,7 +260,7 @@ class Blowfish extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $bctx;
|
||||
var $bctx;
|
||||
|
||||
/**
|
||||
* Holds the last used key
|
||||
|
@ -270,36 +268,20 @@ class Blowfish extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $kl;
|
||||
var $kl;
|
||||
|
||||
/**
|
||||
* The Key Length (in bytes)
|
||||
* {@internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk
|
||||
* because the encryption / decryption / key schedule creation requires this number and not $key_length. We could
|
||||
* derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
|
||||
* of that, we'll just precompute it once.}
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::setKeyLength()
|
||||
* @see \phpseclib\Crypt\Base::setKeyLength()
|
||||
* @var int
|
||||
* @access private
|
||||
* @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk
|
||||
* because the encryption / decryption / key schedule creation requires this number and not $key_length. We could
|
||||
* derive this from $key_length or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu
|
||||
* of that, we'll just precompute it once.
|
||||
*/
|
||||
protected $key_length = 16;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws \InvalidArgumentException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new \InvalidArgumentException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
var $key_length = 16;
|
||||
|
||||
/**
|
||||
* Sets the key length.
|
||||
|
@ -309,28 +291,30 @@ class Blowfish extends BlockCipher
|
|||
* @access public
|
||||
* @param int $length
|
||||
*/
|
||||
public function setKeyLength($length)
|
||||
function setKeyLength($length)
|
||||
{
|
||||
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');
|
||||
if ($length < 32) {
|
||||
$this->key_length = 4;
|
||||
} elseif ($length > 448) {
|
||||
$this->key_length = 56;
|
||||
} else {
|
||||
$this->key_length = $length >> 3;
|
||||
}
|
||||
|
||||
$this->key_length = $length >> 3;
|
||||
|
||||
parent::setKeyLength($length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for engine validity
|
||||
*
|
||||
* This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
|
||||
* This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine()
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
|
||||
* @see \phpseclib\Crypt\Base::isValidEngine()
|
||||
* @param int $engine
|
||||
* @access protected
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidEngineHelper($engine)
|
||||
function isValidEngine($engine)
|
||||
{
|
||||
if ($engine == self::ENGINE_OPENSSL) {
|
||||
if (version_compare(PHP_VERSION, '5.3.7') < 0 && $this->key_length != 16) {
|
||||
|
@ -339,37 +323,37 @@ class Blowfish extends BlockCipher
|
|||
if ($this->key_length < 16) {
|
||||
return false;
|
||||
}
|
||||
self::$cipher_name_openssl_ecb = 'bf-ecb';
|
||||
$this->cipher_name_openssl = 'bf-' . $this->openssl_translate_mode();
|
||||
$this->cipher_name_openssl_ecb = 'bf-ecb';
|
||||
$this->cipher_name_openssl = 'bf-' . $this->_openssl_translate_mode();
|
||||
}
|
||||
|
||||
return parent::isValidEngineHelper($engine);
|
||||
return parent::isValidEngine($engine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the key (expansion)
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::_setupKey()
|
||||
* @see \phpseclib\Crypt\Base::_setupKey()
|
||||
* @access private
|
||||
*/
|
||||
protected function setupKey()
|
||||
function _setupKey()
|
||||
{
|
||||
if (isset($this->kl['key']) && $this->key === $this->kl['key']) {
|
||||
// already expanded
|
||||
return;
|
||||
}
|
||||
$this->kl = ['key' => $this->key];
|
||||
$this->kl = array('key' => $this->key);
|
||||
|
||||
/* key-expanding p[] and S-Box building sb[] */
|
||||
$this->bctx = [
|
||||
'p' => [],
|
||||
'sb' => [
|
||||
self::$sbox0,
|
||||
self::$sbox1,
|
||||
self::$sbox2,
|
||||
self::$sbox3
|
||||
]
|
||||
];
|
||||
$this->bctx = array(
|
||||
'p' => array(),
|
||||
'sb' => array(
|
||||
$this->sbox0,
|
||||
$this->sbox1,
|
||||
$this->sbox2,
|
||||
$this->sbox3
|
||||
)
|
||||
);
|
||||
|
||||
// unpack binary string in unsigned chars
|
||||
$key = array_values(unpack('C*', $this->key));
|
||||
|
@ -382,20 +366,20 @@ class Blowfish extends BlockCipher
|
|||
$j = 0;
|
||||
}
|
||||
}
|
||||
$this->bctx['p'][] = self::$parray[$i] ^ $data;
|
||||
$this->bctx['p'][] = $this->parray[$i] ^ $data;
|
||||
}
|
||||
|
||||
// encrypt the zero-string, replace P1 and P2 with the encrypted data,
|
||||
// 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)));
|
||||
list($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)));
|
||||
list($l, $r) = array_values(unpack('N*', $data = $this->_encryptBlock($data)));
|
||||
$this->bctx['sb'][$i][$j ] = $l;
|
||||
$this->bctx['sb'][$i][$j + 1] = $r;
|
||||
}
|
||||
|
@ -409,31 +393,31 @@ class Blowfish extends BlockCipher
|
|||
* @param string $in
|
||||
* @return string
|
||||
*/
|
||||
protected function encryptBlock($in)
|
||||
function _encryptBlock($in)
|
||||
{
|
||||
$p = $this->bctx['p'];
|
||||
// extract($this->bctx['sb'], EXTR_PREFIX_ALL, 'sb'); // slower
|
||||
$sb_0 = $this->bctx['sb'][0];
|
||||
$sb_1 = $this->bctx['sb'][1];
|
||||
$sb_2 = $this->bctx['sb'][2];
|
||||
$sb_3 = $this->bctx['sb'][3];
|
||||
$p = $this->bctx["p"];
|
||||
// extract($this->bctx["sb"], EXTR_PREFIX_ALL, "sb"); // slower
|
||||
$sb_0 = $this->bctx["sb"][0];
|
||||
$sb_1 = $this->bctx["sb"][1];
|
||||
$sb_2 = $this->bctx["sb"][2];
|
||||
$sb_3 = $this->bctx["sb"][3];
|
||||
|
||||
$in = unpack('N*', $in);
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
|
||||
for ($i = 0; $i < 16; $i+= 2) {
|
||||
$l^= $p[$i];
|
||||
$r^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
|
||||
$r^= $this->safe_intval(($this->safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
|
||||
$sb_2[$l >> 8 & 0xff]) +
|
||||
$sb_3[$l & 0xff]);
|
||||
|
||||
$r^= $p[$i + 1];
|
||||
$l^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
|
||||
$l^= $this->safe_intval(($this->safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
|
||||
$sb_2[$r >> 8 & 0xff]) +
|
||||
$sb_3[$r & 0xff]);
|
||||
}
|
||||
return pack('N*', $r ^ $p[17], $l ^ $p[16]);
|
||||
return pack("N*", $r ^ $p[17], $l ^ $p[16]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,114 +427,145 @@ class Blowfish extends BlockCipher
|
|||
* @param string $in
|
||||
* @return string
|
||||
*/
|
||||
protected function decryptBlock($in)
|
||||
function _decryptBlock($in)
|
||||
{
|
||||
$p = $this->bctx['p'];
|
||||
$sb_0 = $this->bctx['sb'][0];
|
||||
$sb_1 = $this->bctx['sb'][1];
|
||||
$sb_2 = $this->bctx['sb'][2];
|
||||
$sb_3 = $this->bctx['sb'][3];
|
||||
$p = $this->bctx["p"];
|
||||
$sb_0 = $this->bctx["sb"][0];
|
||||
$sb_1 = $this->bctx["sb"][1];
|
||||
$sb_2 = $this->bctx["sb"][2];
|
||||
$sb_3 = $this->bctx["sb"][3];
|
||||
|
||||
$in = unpack('N*', $in);
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
|
||||
for ($i = 17; $i > 2; $i-= 2) {
|
||||
$l^= $p[$i];
|
||||
$r^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
|
||||
$r^= $this->safe_intval(($this->safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
|
||||
$sb_2[$l >> 8 & 0xff]) +
|
||||
$sb_3[$l & 0xff]);
|
||||
|
||||
$r^= $p[$i - 1];
|
||||
$l^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
|
||||
$l^= $this->safe_intval(($this->safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
|
||||
$sb_2[$r >> 8 & 0xff]) +
|
||||
$sb_3[$r & 0xff]);
|
||||
}
|
||||
return pack('N*', $r ^ $p[0], $l ^ $p[1]);
|
||||
return pack("N*", $r ^ $p[0], $l ^ $p[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the performance-optimized function for de/encrypt()
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::_setupInlineCrypt()
|
||||
* @see \phpseclib\Crypt\Base::_setupInlineCrypt()
|
||||
* @access private
|
||||
*/
|
||||
protected function setupInlineCrypt()
|
||||
function _setupInlineCrypt()
|
||||
{
|
||||
$p = $this->bctx['p'];
|
||||
$init_crypt = '
|
||||
static $sb_0, $sb_1, $sb_2, $sb_3;
|
||||
if (!$sb_0) {
|
||||
$sb_0 = $this->bctx["sb"][0];
|
||||
$sb_1 = $this->bctx["sb"][1];
|
||||
$sb_2 = $this->bctx["sb"][2];
|
||||
$sb_3 = $this->bctx["sb"][3];
|
||||
$lambda_functions =& self::_getLambdaFunctions();
|
||||
|
||||
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
|
||||
// (Currently, for Blowfish, one generated $lambda_function cost on php5.5@32bit ~100kb unfreeable mem and ~180kb on php5.5@64bit)
|
||||
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
|
||||
$gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
|
||||
|
||||
// Generation of a unique hash for our generated code
|
||||
$code_hash = "Crypt_Blowfish, {$this->mode}";
|
||||
if ($gen_hi_opt_code) {
|
||||
$code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key);
|
||||
}
|
||||
|
||||
$safeint = $this->safe_intval_inline();
|
||||
|
||||
if (!isset($lambda_functions[$code_hash])) {
|
||||
switch (true) {
|
||||
case $gen_hi_opt_code:
|
||||
$p = $this->bctx['p'];
|
||||
$init_crypt = '
|
||||
static $sb_0, $sb_1, $sb_2, $sb_3;
|
||||
if (!$sb_0) {
|
||||
$sb_0 = $self->bctx["sb"][0];
|
||||
$sb_1 = $self->bctx["sb"][1];
|
||||
$sb_2 = $self->bctx["sb"][2];
|
||||
$sb_3 = $self->bctx["sb"][3];
|
||||
}
|
||||
';
|
||||
break;
|
||||
default:
|
||||
$p = array();
|
||||
for ($i = 0; $i < 18; ++$i) {
|
||||
$p[] = '$p_' . $i;
|
||||
}
|
||||
$init_crypt = '
|
||||
list($sb_0, $sb_1, $sb_2, $sb_3) = $self->bctx["sb"];
|
||||
list(' . implode(',', $p) . ') = $self->bctx["p"];
|
||||
|
||||
';
|
||||
}
|
||||
';
|
||||
|
||||
$safeint = self::safe_intval_inline();
|
||||
// Generating encrypt code:
|
||||
$encrypt_block = '
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
';
|
||||
for ($i = 0; $i < 16; $i+= 2) {
|
||||
$encrypt_block.= '
|
||||
$l^= ' . $p[$i] . ';
|
||||
$r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$l >> 8 & 0xff]) +
|
||||
$sb_3[$l & 0xff]') . ';
|
||||
|
||||
// Generating encrypt code:
|
||||
$encrypt_block = '
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
';
|
||||
for ($i = 0; $i < 16; $i+= 2) {
|
||||
$r^= ' . $p[$i + 1] . ';
|
||||
$l^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$r >> 8 & 0xff]) +
|
||||
$sb_3[$r & 0xff]') . ';
|
||||
';
|
||||
}
|
||||
$encrypt_block.= '
|
||||
$l^= ' . $p[$i] . ';
|
||||
$r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$l >> 8 & 0xff]) +
|
||||
$sb_3[$l & 0xff]') . ';
|
||||
|
||||
$r^= ' . $p[$i + 1] . ';
|
||||
$l^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$r >> 8 & 0xff]) +
|
||||
$sb_3[$r & 0xff]') . ';
|
||||
$in = pack("N*",
|
||||
$r ^ ' . $p[17] . ',
|
||||
$l ^ ' . $p[16] . '
|
||||
);
|
||||
';
|
||||
}
|
||||
$encrypt_block.= '
|
||||
$in = pack("N*",
|
||||
$r ^ ' . $p[17] . ',
|
||||
$l ^ ' . $p[16] . '
|
||||
);
|
||||
';
|
||||
// Generating decrypt code:
|
||||
$decrypt_block = '
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
';
|
||||
|
||||
for ($i = 17; $i > 2; $i-= 2) {
|
||||
// Generating decrypt code:
|
||||
$decrypt_block = '
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
';
|
||||
|
||||
for ($i = 17; $i > 2; $i-= 2) {
|
||||
$decrypt_block.= '
|
||||
$l^= ' . $p[$i] . ';
|
||||
$r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$l >> 8 & 0xff]) +
|
||||
$sb_3[$l & 0xff]') . ';
|
||||
|
||||
$r^= ' . $p[$i - 1] . ';
|
||||
$l^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$r >> 8 & 0xff]) +
|
||||
$sb_3[$r & 0xff]') . ';
|
||||
';
|
||||
}
|
||||
|
||||
$decrypt_block.= '
|
||||
$l^= ' . $p[$i] . ';
|
||||
$r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$l >> 8 & 0xff]) +
|
||||
$sb_3[$l & 0xff]') . ';
|
||||
|
||||
$r^= ' . $p[$i - 1] . ';
|
||||
$l^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]') . ' ^
|
||||
$sb_2[$r >> 8 & 0xff]) +
|
||||
$sb_3[$r & 0xff]') . ';
|
||||
$in = pack("N*",
|
||||
$r ^ ' . $p[0] . ',
|
||||
$l ^ ' . $p[1] . '
|
||||
);
|
||||
';
|
||||
}
|
||||
|
||||
$decrypt_block.= '
|
||||
$in = pack("N*",
|
||||
$r ^ ' . $p[0] . ',
|
||||
$l ^ ' . $p[1] . '
|
||||
$lambda_functions[$code_hash] = $this->_createInlineCryptFunction(
|
||||
array(
|
||||
'init_crypt' => $init_crypt,
|
||||
'init_encrypt' => '',
|
||||
'init_decrypt' => '',
|
||||
'encrypt_block' => $encrypt_block,
|
||||
'decrypt_block' => $decrypt_block
|
||||
)
|
||||
);
|
||||
';
|
||||
|
||||
$this->inline_crypt = $this->createInlineCryptFunction(
|
||||
[
|
||||
'init_crypt' => $init_crypt,
|
||||
'init_encrypt' => '',
|
||||
'init_decrypt' => '',
|
||||
'encrypt_block' => $encrypt_block,
|
||||
'decrypt_block' => $decrypt_block
|
||||
]
|
||||
);
|
||||
}
|
||||
$this->inline_crypt = $lambda_functions[$code_hash];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,797 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of ChaCha20.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package ChaCha20
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2019 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt;
|
||||
|
||||
use phpseclib3\Exception\InsufficientSetupException;
|
||||
use phpseclib3\Exception\BadDecryptionException;
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of ChaCha20.
|
||||
*
|
||||
* @package ChaCha20
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class ChaCha20 extends Salsa20
|
||||
{
|
||||
/**
|
||||
* The OpenSSL specific name of the cipher
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cipher_name_openssl = 'chacha20';
|
||||
|
||||
/**
|
||||
* Test for engine validity
|
||||
*
|
||||
* 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
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidEngineHelper($engine)
|
||||
{
|
||||
switch ($engine) {
|
||||
case self::ENGINE_LIBSODIUM:
|
||||
// PHP 7.2.0 (30 Nov 2017) added support for libsodium
|
||||
|
||||
// we could probably make it so that if $this->counter == 0 then the first block would be done with either OpenSSL
|
||||
// or PHP and then subsequent blocks would then be done with libsodium but idk - it's not a high priority atm
|
||||
|
||||
// we could also make it so that if $this->counter == 0 and $this->continuousBuffer then do the first string
|
||||
// with libsodium and subsequent strings with openssl or pure-PHP but again not a high priority
|
||||
return function_exists('sodium_crypto_aead_chacha20poly1305_ietf_encrypt') &&
|
||||
$this->key_length == 32 &&
|
||||
(($this->usePoly1305 && !isset($this->poly1305Key) && $this->counter == 0) || $this->counter == 1) &&
|
||||
!$this->continuousBuffer;
|
||||
case self::ENGINE_OPENSSL:
|
||||
// OpenSSL 1.1.0 (released 25 Aug 2016) added support for chacha20.
|
||||
// PHP didn't support OpenSSL 1.1.0 until 7.0.19 (11 May 2017)
|
||||
|
||||
// if you attempt to provide openssl with a 128 bit key (as opposed to a 256 bit key) openssl will null
|
||||
// pad the key to 256 bits and still use the expansion constant for 256-bit keys. the fact that
|
||||
// openssl treats the IV as both the counter and nonce, however, let's us use openssl in continuous mode
|
||||
// whereas libsodium does not
|
||||
if ($this->key_length != 32) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::isValidEngineHelper($engine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a message.
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
|
||||
* @see self::crypt()
|
||||
* @param string $plaintext
|
||||
* @return string $ciphertext
|
||||
*/
|
||||
public function encrypt($plaintext)
|
||||
{
|
||||
$this->setup();
|
||||
|
||||
if ($this->engine == self::ENGINE_LIBSODIUM) {
|
||||
return $this->encrypt_with_libsodium($plaintext);
|
||||
}
|
||||
|
||||
return parent::encrypt($plaintext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a message.
|
||||
*
|
||||
* $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
|
||||
*/
|
||||
public function decrypt($ciphertext)
|
||||
{
|
||||
$this->setup();
|
||||
|
||||
if ($this->engine == self::ENGINE_LIBSODIUM) {
|
||||
return $this->decrypt_with_libsodium($ciphertext);
|
||||
}
|
||||
|
||||
return parent::decrypt($ciphertext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a message with libsodium
|
||||
*
|
||||
* @see self::encrypt()
|
||||
* @param string $plaintext
|
||||
* @return string $text
|
||||
*/
|
||||
private function encrypt_with_libsodium($plaintext)
|
||||
{
|
||||
$params = [$plaintext, $this->aad, $this->nonce, $this->key];
|
||||
$ciphertext = strlen($this->nonce) == 8 ?
|
||||
sodium_crypto_aead_chacha20poly1305_encrypt(...$params) :
|
||||
sodium_crypto_aead_chacha20poly1305_ietf_encrypt(...$params);
|
||||
if (!$this->usePoly1305) {
|
||||
return substr($ciphertext, 0, strlen($plaintext));
|
||||
}
|
||||
|
||||
$newciphertext = substr($ciphertext, 0, strlen($plaintext));
|
||||
|
||||
$this->newtag = $this->usingGeneratedPoly1305Key && strlen($this->nonce) == 12 ?
|
||||
substr($ciphertext, strlen($plaintext)) :
|
||||
$this->poly1305($newciphertext);
|
||||
|
||||
return $newciphertext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a message with libsodium
|
||||
*
|
||||
* @see self::decrypt()
|
||||
* @param string $ciphertext
|
||||
* @return string $text
|
||||
*/
|
||||
private function decrypt_with_libsodium($ciphertext)
|
||||
{
|
||||
$params = [$ciphertext, $this->aad, $this->nonce, $this->key];
|
||||
|
||||
if (isset($this->poly1305Key)) {
|
||||
if ($this->oldtag === false) {
|
||||
throw new InsufficientSetupException('Authentication Tag has not been set');
|
||||
}
|
||||
if ($this->usingGeneratedPoly1305Key && strlen($this->nonce) == 12) {
|
||||
$plaintext = sodium_crypto_aead_chacha20poly1305_ietf_decrypt(...$params);
|
||||
$this->oldtag = false;
|
||||
if ($plaintext === false) {
|
||||
throw new BadDecryptionException('Derived authentication tag and supplied authentication tag do not match');
|
||||
}
|
||||
return $plaintext;
|
||||
}
|
||||
$newtag = $this->poly1305($ciphertext);
|
||||
if ($this->oldtag != substr($newtag, 0, strlen($this->oldtag))) {
|
||||
$this->oldtag = false;
|
||||
throw new BadDecryptionException('Derived authentication tag and supplied authentication tag do not match');
|
||||
}
|
||||
$this->oldtag = false;
|
||||
}
|
||||
|
||||
$plaintext = strlen($this->nonce) == 8 ?
|
||||
sodium_crypto_aead_chacha20poly1305_encrypt(...$params) :
|
||||
sodium_crypto_aead_chacha20poly1305_ietf_encrypt(...$params);
|
||||
|
||||
return substr($plaintext, 0, strlen($ciphertext));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the nonce.
|
||||
*
|
||||
* @param string $nonce
|
||||
*/
|
||||
public function setNonce($nonce)
|
||||
{
|
||||
if (!is_string($nonce)) {
|
||||
throw new \UnexpectedValueException('The nonce should be a string');
|
||||
}
|
||||
|
||||
/*
|
||||
from https://tools.ietf.org/html/rfc7539#page-7
|
||||
|
||||
"Note also that the original ChaCha had a 64-bit nonce and 64-bit
|
||||
block count. We have modified this here to be more consistent with
|
||||
recommendations in Section 3.2 of [RFC5116]."
|
||||
*/
|
||||
switch (strlen($nonce)) {
|
||||
case 8: // 64 bits
|
||||
case 12: // 96 bits
|
||||
break;
|
||||
default:
|
||||
throw new \LengthException('Nonce of size ' . strlen($nonce) . ' not supported by this algorithm. Only 64-bit nonces or 96-bit nonces are supported');
|
||||
}
|
||||
|
||||
$this->nonce = $nonce;
|
||||
$this->changed = true;
|
||||
$this->setEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the self::ENGINE_INTERNAL $engine
|
||||
*
|
||||
* (re)init, if necessary, the internal cipher $engine
|
||||
*
|
||||
* _setup() will be called each time if $changed === true
|
||||
* typically this happens when using one or more of following public methods:
|
||||
*
|
||||
* - setKey()
|
||||
*
|
||||
* - setNonce()
|
||||
*
|
||||
* - First run of encrypt() / decrypt() with no init-settings
|
||||
*
|
||||
* @see self::setKey()
|
||||
* @see self::setNonce()
|
||||
* @see self::disableContinuousBuffer()
|
||||
*/
|
||||
protected function setup()
|
||||
{
|
||||
if (!$this->changed) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->enbuffer = $this->debuffer = ['ciphertext' => '', 'counter' => $this->counter];
|
||||
|
||||
$this->changed = $this->nonIVChanged = false;
|
||||
|
||||
if ($this->nonce === false) {
|
||||
throw new InsufficientSetupException('No nonce has been defined');
|
||||
}
|
||||
|
||||
if ($this->key === false) {
|
||||
throw new InsufficientSetupException('No key has been defined');
|
||||
}
|
||||
|
||||
if ($this->usePoly1305 && !isset($this->poly1305Key)) {
|
||||
$this->usingGeneratedPoly1305Key = true;
|
||||
if ($this->engine == self::ENGINE_LIBSODIUM) {
|
||||
return;
|
||||
}
|
||||
$this->createPoly1305Key();
|
||||
}
|
||||
|
||||
$key = $this->key;
|
||||
if (strlen($key) == 16) {
|
||||
$constant = 'expand 16-byte k';
|
||||
$key.= $key;
|
||||
} else {
|
||||
$constant = 'expand 32-byte k';
|
||||
}
|
||||
|
||||
$this->p1 = $constant . $key;
|
||||
$this->p2 = $this->nonce;
|
||||
if (strlen($this->nonce) == 8) {
|
||||
$this->p2 = "\0\0\0\0" . $this->p2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The quarterround function
|
||||
*
|
||||
* @param int $a
|
||||
* @param int $b
|
||||
* @param int $c
|
||||
* @param int $d
|
||||
*/
|
||||
protected static function quarterRound(&$a, &$b, &$c, &$d)
|
||||
{
|
||||
$a+= $b; $d = self::leftRotate($d ^ $a, 16);
|
||||
$c+= $d; $b = self::leftRotate($b ^ $c, 12);
|
||||
$a+= $b; $d = self::leftRotate($d ^ $a, 8);
|
||||
$c+= $d; $b = self::leftRotate($b ^ $c, 7);
|
||||
}
|
||||
|
||||
/**
|
||||
* The doubleround function
|
||||
*
|
||||
* @param int $x0 (by reference)
|
||||
* @param int $x1 (by reference)
|
||||
* @param int $x2 (by reference)
|
||||
* @param int $x3 (by reference)
|
||||
* @param int $x4 (by reference)
|
||||
* @param int $x5 (by reference)
|
||||
* @param int $x6 (by reference)
|
||||
* @param int $x7 (by reference)
|
||||
* @param int $x8 (by reference)
|
||||
* @param int $x9 (by reference)
|
||||
* @param int $x10 (by reference)
|
||||
* @param int $x11 (by reference)
|
||||
* @param int $x12 (by reference)
|
||||
* @param int $x13 (by reference)
|
||||
* @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)
|
||||
{
|
||||
// columnRound
|
||||
static::quarterRound($x0, $x4, $x8, $x12);
|
||||
static::quarterRound($x1, $x5, $x9, $x13);
|
||||
static::quarterRound($x2, $x6, $x10, $x14);
|
||||
static::quarterRound($x3, $x7, $x11, $x15);
|
||||
// rowRound
|
||||
static::quarterRound($x0, $x5, $x10, $x15);
|
||||
static::quarterRound($x1, $x6, $x11, $x12);
|
||||
static::quarterRound($x2, $x7, $x8, $x13);
|
||||
static::quarterRound($x3, $x4, $x9, $x14);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Salsa20 hash function function
|
||||
*
|
||||
* On my laptop this loop unrolled / function dereferenced version of parent::salsa20 encrypts 1mb of text in
|
||||
* 0.65s vs the 0.85s that it takes with the parent method.
|
||||
*
|
||||
* If we were free to assume that the host OS would always be 64-bits then the if condition in leftRotate could
|
||||
* be eliminated and we could knock this done to 0.60s.
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
list(, $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;
|
||||
$z3 = $x3;
|
||||
$z4 = $x4;
|
||||
$z5 = $x5;
|
||||
$z6 = $x6;
|
||||
$z7 = $x7;
|
||||
$z8 = $x8;
|
||||
$z9 = $x9;
|
||||
$z10 = $x10;
|
||||
$z11 = $x11;
|
||||
$z12 = $x12;
|
||||
$z13 = $x13;
|
||||
$z14 = $x14;
|
||||
$z15 = $x15;
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
// columnRound
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
|
||||
$x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 8);
|
||||
$x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 7);
|
||||
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 16);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 12);
|
||||
$x1+= $x5; $x13 = self::leftRotate($x13 ^ $x1, 8);
|
||||
$x9+= $x13; $x5 = self::leftRotate($x5 ^ $x9, 7);
|
||||
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 16);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 12);
|
||||
$x2+= $x6; $x14 = self::leftRotate($x14 ^ $x2, 8);
|
||||
$x10+= $x14; $x6 = self::leftRotate($x6 ^ $x10, 7);
|
||||
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 16);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 12);
|
||||
$x3+= $x7; $x15 = self::leftRotate($x15 ^ $x3, 8);
|
||||
$x11+= $x15; $x7 = self::leftRotate($x7 ^ $x11, 7);
|
||||
|
||||
// rowRound
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 16);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 12);
|
||||
$x0+= $x5; $x15 = self::leftRotate($x15 ^ $x0, 8);
|
||||
$x10+= $x15; $x5 = self::leftRotate($x5 ^ $x10, 7);
|
||||
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 16);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 12);
|
||||
$x1+= $x6; $x12 = self::leftRotate($x12 ^ $x1, 8);
|
||||
$x11+= $x12; $x6 = self::leftRotate($x6 ^ $x11, 7);
|
||||
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 16);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 12);
|
||||
$x2+= $x7; $x13 = self::leftRotate($x13 ^ $x2, 8);
|
||||
$x8+= $x13; $x7 = self::leftRotate($x7 ^ $x8, 7);
|
||||
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 16);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
|
||||
$x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
|
||||
$x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
|
||||
|
||||
$x0+= $z0;
|
||||
$x1+= $z1;
|
||||
$x2+= $z2;
|
||||
$x3+= $z3;
|
||||
$x4+= $z4;
|
||||
$x5+= $z5;
|
||||
$x6+= $z6;
|
||||
$x7+= $z7;
|
||||
$x8+= $z8;
|
||||
$x9+= $z9;
|
||||
$x10+= $z10;
|
||||
$x11+= $z11;
|
||||
$x12+= $z12;
|
||||
$x13+= $z13;
|
||||
$x14+= $z14;
|
||||
$x15+= $z15;
|
||||
|
||||
return pack('V*', $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15);
|
||||
}
|
||||
}
|
|
@ -1,593 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Base Class for all asymmetric key ciphers
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package AsymmetricKey
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common;
|
||||
|
||||
use phpseclib3\Exception\UnsupportedFormatException;
|
||||
use phpseclib3\Exception\NoKeyLoadedException;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Hash;
|
||||
use phpseclib3\Crypt\RSA;
|
||||
use phpseclib3\Crypt\DSA;
|
||||
use phpseclib3\Crypt\ECDSA;
|
||||
|
||||
/**
|
||||
* Base Class for all asymmetric cipher classes
|
||||
*
|
||||
* @package AsymmetricKey
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
abstract class AsymmetricKey
|
||||
{
|
||||
/**
|
||||
* Precomputed Zero
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected static $zero;
|
||||
|
||||
/**
|
||||
* Precomputed One
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected static $one;
|
||||
|
||||
/**
|
||||
* Format of the loaded key
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $format;
|
||||
|
||||
/**
|
||||
* Hash function
|
||||
*
|
||||
* @var \phpseclib3\Crypt\Hash
|
||||
* @access private
|
||||
*/
|
||||
protected $hash;
|
||||
|
||||
/**
|
||||
* HMAC function
|
||||
*
|
||||
* @var \phpseclib3\Crypt\Hash
|
||||
* @access private
|
||||
*/
|
||||
private $hmac;
|
||||
|
||||
/**
|
||||
* Supported plugins (lower case)
|
||||
*
|
||||
* @see self::initialize_static_variables()
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $plugins = [];
|
||||
|
||||
/**
|
||||
* Invisible plugins
|
||||
*
|
||||
* @see self::initialize_static_variables()
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $invisiblePlugins = [];
|
||||
|
||||
/**
|
||||
* Supported signature formats (lower case)
|
||||
*
|
||||
* @see self::initialize_static_variables()
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $signatureFormats = [];
|
||||
|
||||
/**
|
||||
* Supported signature formats (original case)
|
||||
*
|
||||
* @see self::initialize_static_variables()
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private static $signatureFileFormats = [];
|
||||
|
||||
/**
|
||||
* Available Engines
|
||||
*
|
||||
* @var boolean[]
|
||||
* @access private
|
||||
*/
|
||||
protected static $engines = [];
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
$this->hash = new Hash('sha256');
|
||||
$this->hmac = new Hash('sha256');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize static variables
|
||||
*/
|
||||
protected static function initialize_static_variables()
|
||||
{
|
||||
if (!isset(self::$zero)) {
|
||||
self::$zero= new BigInteger(0);
|
||||
self::$one = new BigInteger(1);
|
||||
}
|
||||
|
||||
self::loadPlugins('Keys');
|
||||
if (static::ALGORITHM != 'RSA' && static::ALGORITHM != 'DH') {
|
||||
self::loadPlugins('Signature');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the key
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return AsymmetricKey
|
||||
*/
|
||||
public static function load($key, $password = false)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
$components = false;
|
||||
foreach (self::$plugins[static::ALGORITHM]['Keys'] as $format) {
|
||||
if (isset(self::$invisiblePlugins[static::ALGORITHM]) && in_array($format, self::$invisiblePlugins[static::ALGORITHM])) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$components = $format::load($key, $password);
|
||||
} catch (\Exception $e) {
|
||||
$components = false;
|
||||
}
|
||||
if ($components !== false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($components === false) {
|
||||
throw new NoKeyLoadedException('Unable to read key');
|
||||
}
|
||||
|
||||
$components['format'] = $format;
|
||||
$new = static::onLoad($components);
|
||||
$new->format = $format;
|
||||
return $new instanceof PrivateKey ?
|
||||
$new->withPassword($password) :
|
||||
$new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a private key
|
||||
*
|
||||
* @return PrivateKey
|
||||
* @access public
|
||||
* @param string|array $key
|
||||
* @param string $password optional
|
||||
*/
|
||||
public function loadPrivateKey($key, $password = '')
|
||||
{
|
||||
$key = self::load($key, $password);
|
||||
if (!$key instanceof PrivateKey) {
|
||||
throw new NoKeyLoadedException('The key that was loaded was not a private key');
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a public key
|
||||
*
|
||||
* @return PublicKey
|
||||
* @access public
|
||||
* @param string|array $key
|
||||
*/
|
||||
public function loadPublicKey($key)
|
||||
{
|
||||
$key = self::load($key);
|
||||
if (!$key instanceof PublicKey) {
|
||||
throw new NoKeyLoadedException('The key that was loaded was not a public key');
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads parameters
|
||||
*
|
||||
* @return AsymmetricKey
|
||||
* @access public
|
||||
* @param string|array $key
|
||||
*/
|
||||
public function loadParameters($key)
|
||||
{
|
||||
$key = self::load($key);
|
||||
if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
|
||||
throw new NoKeyLoadedException('The key that was loaded was not a parameter');
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the key, assuming a specific format
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return AsymmetricKey
|
||||
*/
|
||||
public static function loadFormat($type, $key, $password = false)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
$components = false;
|
||||
$format = strtolower($type);
|
||||
if (isset(self::$plugins[static::ALGORITHM]['Keys'][$format])) {
|
||||
$format = self::$plugins[static::ALGORITHM]['Keys'][$format];
|
||||
$components = $format::load($key, $password);
|
||||
}
|
||||
|
||||
if ($components === false) {
|
||||
throw new NoKeyLoadedException('Unable to read key');
|
||||
}
|
||||
|
||||
$components['format'] = $format;
|
||||
|
||||
$new = static::onLoad($components);
|
||||
$new->format = $format;
|
||||
return $new instanceof PrivateKey ?
|
||||
$new->withPassword($password) :
|
||||
$new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a private key
|
||||
*
|
||||
* @return PrivateKey
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
*/
|
||||
public function loadPrivateKeyFormat($type, $key, $password = false)
|
||||
{
|
||||
$key = self::loadFormat($type, $key, $password);
|
||||
if (!$key instanceof PrivateKey) {
|
||||
throw new NoKeyLoadedException('The key that was loaded was not a private key');
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a public key
|
||||
*
|
||||
* @return PublicKey
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param string $key
|
||||
*/
|
||||
public function loadPublicKeyFormat($type, $key)
|
||||
{
|
||||
$key = self::loadFormat($type, $key);
|
||||
if (!$key instanceof PublicKey) {
|
||||
throw new NoKeyLoadedException('The key that was loaded was not a public key');
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads parameters
|
||||
*
|
||||
* @return AsymmetricKey
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param string|array $key
|
||||
*/
|
||||
public function loadParametersFormat($type, $key)
|
||||
{
|
||||
$key = self::loadFormat($type, $key);
|
||||
if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
|
||||
throw new NoKeyLoadedException('The key that was loaded was not a parameter');
|
||||
}
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Plugin
|
||||
*
|
||||
* @access private
|
||||
* @param string $format
|
||||
* @param string $type
|
||||
* @param string $method optional
|
||||
* @return mixed
|
||||
*/
|
||||
protected static function validatePlugin($format, $type, $method = NULL)
|
||||
{
|
||||
$type = strtolower($type);
|
||||
if (!isset(self::$plugins[static::ALGORITHM][$format][$type])) {
|
||||
throw new UnsupportedFormatException("$type is not a supported format");
|
||||
}
|
||||
$type = self::$plugins[static::ALGORITHM][$format][$type];
|
||||
if (isset($method) && !method_exists($type, $method)) {
|
||||
throw new UnsupportedFormatException("$type does not implement $method");
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Plugins
|
||||
*
|
||||
* @access private
|
||||
* @param string $format
|
||||
*/
|
||||
private static function loadPlugins($format)
|
||||
{
|
||||
if (!isset(self::$plugins[static::ALGORITHM][$format])) {
|
||||
self::$plugins[static::ALGORITHM][$format] = [];
|
||||
foreach (new \DirectoryIterator(__DIR__ . '/../' . static::ALGORITHM . '/Formats/' . $format . '/') as $file) {
|
||||
if ($file->getExtension() != 'php') {
|
||||
continue;
|
||||
}
|
||||
$name = $file->getBasename('.php');
|
||||
$type = 'phpseclib3\Crypt\\' . static::ALGORITHM . '\\Formats\\' . $format . '\\' . $name;
|
||||
$reflect = new \ReflectionClass($type);
|
||||
if ($reflect->isTrait()) {
|
||||
continue;
|
||||
}
|
||||
self::$plugins[static::ALGORITHM][$format][strtolower($name)] = $type;
|
||||
if ($reflect->hasConstant('IS_INVISIBLE')) {
|
||||
self::$invisiblePlugins[static::ALGORITHM][] = $type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of supported formats.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getSupportedKeyFormats()
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
return self::$plugins[static::ALGORITHM]['Keys'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a fileformat plugin
|
||||
*
|
||||
* 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
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public static function addFileFormat($fullname)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
if (class_exists($fullname)) {
|
||||
$meta = new \ReflectionClass($fullname);
|
||||
$shortname = $meta->getShortName();
|
||||
self::$plugins[static::ALGORITHM]['Keys'][strtolower($shortname)] = $fullname;
|
||||
if ($meta->hasConstant('IS_INVISIBLE')) {
|
||||
self::$invisiblePlugins[static::ALGORITHM] = strtolower($name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the format of the loaded key.
|
||||
*
|
||||
* If the key that was loaded wasn't in a valid or if the key was auto-generated
|
||||
* with RSA::createKey() then this will throw an exception.
|
||||
*
|
||||
* @see self::load()
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLoadedFormat()
|
||||
{
|
||||
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"');
|
||||
}
|
||||
|
||||
$meta = new \ReflectionClass($this->format);
|
||||
return $meta->getShortName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests engine validity
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public static function useBestEngine()
|
||||
{
|
||||
static::$engines = [
|
||||
'PHP' => true,
|
||||
'OpenSSL' => extension_loaded('openssl'),
|
||||
// this test can be satisfied by either of the following:
|
||||
// http://php.net/manual/en/book.sodium.php
|
||||
// https://github.com/paragonie/sodium_compat
|
||||
'libsodium' => function_exists('sodium_crypto_sign_keypair')
|
||||
];
|
||||
|
||||
return static::$engines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag to use internal engine only (useful for unit testing)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public static function useInternalEngine()
|
||||
{
|
||||
static::$engines = [
|
||||
'PHP' => true,
|
||||
'OpenSSL' => false,
|
||||
'libsodium' => false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* __toString() magic method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString('PKCS8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which hashing function should be used
|
||||
*
|
||||
* @access public
|
||||
* @param string $hash
|
||||
*/
|
||||
public function withHash($hash)
|
||||
{
|
||||
$new = clone $this;
|
||||
|
||||
$new->hash = new Hash($hash);
|
||||
$new->hmac = new Hash($hash);
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash algorithm currently being used
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getHash()
|
||||
{
|
||||
return clone $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the pseudorandom k for signature generation,
|
||||
* using the process specified for deterministic DSA.
|
||||
*
|
||||
* @access public
|
||||
* @param string $h1
|
||||
* @return string
|
||||
*/
|
||||
protected function computek($h1)
|
||||
{
|
||||
$v = str_repeat("\1", strlen($h1));
|
||||
|
||||
$k = str_repeat("\0", strlen($h1));
|
||||
|
||||
$x = $this->int2octets($this->x);
|
||||
$h1 = $this->bits2octets($h1);
|
||||
|
||||
$this->hmac->setKey($k);
|
||||
$k = $this->hmac->hash($v . "\0" . $x . $h1);
|
||||
$this->hmac->setKey($k);
|
||||
$v = $this->hmac->hash($v);
|
||||
$k = $this->hmac->hash($v . "\1" . $x . $h1);
|
||||
$this->hmac->setKey($k);
|
||||
$v = $this->hmac->hash($v);
|
||||
|
||||
$qlen = $this->q->getLengthInBytes();
|
||||
|
||||
while (true) {
|
||||
$t = '';
|
||||
while (strlen($t) < $qlen) {
|
||||
$v = $this->hmac->hash($v);
|
||||
$t = $t . $v;
|
||||
}
|
||||
$k = $this->bits2int($t);
|
||||
|
||||
if (!$k->equals(self::$zero) && $k->compare($this->q) < 0) {
|
||||
break;
|
||||
}
|
||||
$k = $this->hmac->hash($v . "\0");
|
||||
$this->hmac->setKey($k);
|
||||
$v = $this->hmac->hash($v);
|
||||
}
|
||||
|
||||
return $k;
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer to Octet String
|
||||
*
|
||||
* @access private
|
||||
* @param \phpseclib3\Math\BigInteger $v
|
||||
* @return string
|
||||
*/
|
||||
private function int2octets($v)
|
||||
{
|
||||
$out = $v->toBytes();
|
||||
$rolen = $this->q->getLengthInBytes();
|
||||
if (strlen($out) < $rolen) {
|
||||
return str_pad($out, $rolen, "\0", STR_PAD_LEFT);
|
||||
} else if (strlen($out) > $rolen) {
|
||||
return substr($out, -$rolen);
|
||||
} else {
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bit String to Integer
|
||||
*
|
||||
* @access private
|
||||
* @param string $in
|
||||
* @return \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
protected function bits2int($in)
|
||||
{
|
||||
$v = new BigInteger($in, 256);
|
||||
$vlen = strlen($in) << 3;
|
||||
$qlen = $this->q->getLength();
|
||||
if ($vlen > $qlen) {
|
||||
return $v->bitwise_rightShift($vlen - $qlen);
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bit String to Octet String
|
||||
*
|
||||
* @access private
|
||||
* @param string $in
|
||||
* @return string
|
||||
*/
|
||||
private function bits2octets($in)
|
||||
{
|
||||
$z1 = $this->bits2int($in);
|
||||
$z2 = $z1->subtract($this->q);
|
||||
return $z2->compare(self::$zero) < 0 ?
|
||||
$this->int2octets($z1) :
|
||||
$this->int2octets($z2);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Base Class for all block ciphers
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package BlockCipher
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @author Hans-Juergen Petrich <petrich@tronic-media.com>
|
||||
* @copyright 2007 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* Base Class for all block cipher classes
|
||||
*
|
||||
* @package BlockCipher
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
abstract class BlockCipher extends SymmetricKey
|
||||
{
|
||||
}
|
|
@ -1,234 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* OpenSSH Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Place in $HOME/.ssh/authorized_keys
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Formats\Keys;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Crypt\Random;
|
||||
use phpseclib3\Exception\UnsupportedFormatException;
|
||||
|
||||
/**
|
||||
* OpenSSH Formatted RSA Key Handler
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class OpenSSH
|
||||
{
|
||||
/**
|
||||
* Default comment
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected static $comment = 'phpseclib-generated-key';
|
||||
|
||||
/**
|
||||
* Binary key flag
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
protected static $binary = false;
|
||||
|
||||
/**
|
||||
* Sets the default comment
|
||||
*
|
||||
* @access public
|
||||
* @param string $comment
|
||||
*/
|
||||
public static function setComment($comment)
|
||||
{
|
||||
self::$comment = str_replace(["\r", "\n"], '', $comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* $type can be either ssh-dss or ssh-rsa
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
// key format is described here:
|
||||
// https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.key?annotate=HEAD
|
||||
|
||||
if (strpos($key, 'BEGIN OPENSSH PRIVATE KEY') !== false) {
|
||||
$key = preg_replace('#(?:^-.*?-[\r\n]*$)|\s#ms', '', $key);
|
||||
$key = Base64::decode($key);
|
||||
$magic = Strings::shift($key, 15);
|
||||
if ($magic != "openssh-key-v1\0") {
|
||||
throw new \RuntimeException('Expected openssh-key-v1');
|
||||
}
|
||||
list($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
|
||||
// that to the appropriate key loading parser $numKey times or something
|
||||
throw new \RuntimeException('Although the OpenSSH private key format supports multiple keys phpseclib does not');
|
||||
}
|
||||
if (strlen($kdfoptions) || $kdfname != 'none' || $ciphername != 'none') {
|
||||
/*
|
||||
OpenSSH private keys use a customized version of bcrypt. specifically, instead of encrypting
|
||||
OrpheanBeholderScryDoubt 64 times OpenSSH's bcrypt variant encrypts
|
||||
OxychromaticBlowfishSwatDynamite 64 times. so we can't use crypt().
|
||||
|
||||
bcrypt is basically Blowfish with an altered key expansion. whereas Blowfish just runs the
|
||||
key through the key expansion bcrypt interleaves the key expansion with the salt and
|
||||
password. this renders openssl / mcrypt unusuable. this forces us to use a pure-PHP implementation
|
||||
of bcrypt. the problem with that is that pure-PHP is too slow to be practically useful.
|
||||
|
||||
in addition to encrypting a different string 64 times the OpenSSH implementation also performs bcrypt
|
||||
from scratch $rounds times. calling crypt() 64x with bcrypt takes 0.7s. PHP is going to be naturally
|
||||
slower. pure-PHP is 215x slower than OpenSSL for AES and pure-PHP is 43x slower for bcrypt.
|
||||
43 * 0.7 = 30s. no one wants to wait 30s to load a private key.
|
||||
|
||||
another way to think about this.. according to wikipedia's article on Blowfish,
|
||||
"Each new key requires pre-processing equivalent to encrypting about 4 kilobytes of text".
|
||||
key expansion is done (9+64*2)*160 times. multiply that by 4 and it turns out that Blowfish,
|
||||
OpenSSH style, is the equivalent of encrypting ~80mb of text.
|
||||
|
||||
more supporting evidence: sodium_compat does not implement Argon2 (another password hashing
|
||||
algorithm) because "It's not feasible to polyfill scrypt or Argon2 into PHP and get reasonable
|
||||
performance. Users would feel motivated to select parameters that downgrade security to avoid
|
||||
denial of service (DoS) attacks. The only winning move is not to play"
|
||||
-- https://github.com/paragonie/sodium_compat/blob/master/README.md
|
||||
*/
|
||||
throw new \RuntimeException('Encrypted OpenSSH private keys are not supported');
|
||||
//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);
|
||||
// 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');
|
||||
}
|
||||
self::checkType($type);
|
||||
|
||||
return compact('type', 'publicKey', 'paddedKey');
|
||||
}
|
||||
|
||||
$parts = explode(' ', $key, 3);
|
||||
|
||||
if (!isset($parts[1])) {
|
||||
$key = base64_decode($parts[0]);
|
||||
$comment = isset($parts[1]) ? $parts[1] : false;
|
||||
} else {
|
||||
$asciiType = $parts[0];
|
||||
self::checkType($parts[0]);
|
||||
$key = base64_decode($parts[1]);
|
||||
$comment = isset($parts[2]) ? $parts[2] : false;
|
||||
}
|
||||
if ($key === false) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
list($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);
|
||||
}
|
||||
if (strlen($key) <= 4) {
|
||||
throw new \UnexpectedValueException('Key appears to be malformed');
|
||||
}
|
||||
|
||||
$publicKey = $key;
|
||||
|
||||
return compact('type', 'publicKey', 'comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle between binary and printable keys
|
||||
*
|
||||
* Printable keys are what are generated by default. These are the ones that go in
|
||||
* $HOME/.ssh/authorized_key.
|
||||
*
|
||||
* @access public
|
||||
* @param bool $enabled
|
||||
*/
|
||||
public static function setBinaryOutput($enabled)
|
||||
{
|
||||
self::$binary = $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the type is valid
|
||||
*
|
||||
* @access private
|
||||
* @param string $candidate
|
||||
*/
|
||||
private static function checkType($candidate)
|
||||
{
|
||||
if (!in_array($candidate, static::$types)) {
|
||||
throw new \RuntimeException("The key type ($candidate) is not equal to: " . implode(',', static::$types));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a private key appropriately
|
||||
*
|
||||
* @access public
|
||||
* @param string $publicKey
|
||||
* @param string $privateKey
|
||||
* @param string $password
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPrivateKey($publicKey, $privateKey, $password, $options)
|
||||
{
|
||||
if (!empty($password) && is_string($password)) {
|
||||
throw new UnsupportedFormatException('Encrypted OpenSSH private keys are not supported');
|
||||
}
|
||||
|
||||
list(, $checkint) = unpack('N', Random::string(4));
|
||||
|
||||
$comment = isset($options['comment']) ? $options['comment'] : self::$comment;
|
||||
$paddedKey = Strings::packSSH2('NN', $checkint, $checkint) .
|
||||
$privateKey .
|
||||
Strings::packSSH2('s', $comment);
|
||||
|
||||
/*
|
||||
from http://tools.ietf.org/html/rfc4253#section-6 :
|
||||
|
||||
Note that the length of the concatenation of 'packet_length',
|
||||
'padding_length', 'payload', and 'random padding' MUST be a multiple
|
||||
of the cipher block size or 8, whichever is larger.
|
||||
*/
|
||||
$paddingLength = (7 * strlen($paddedKey)) % 8;
|
||||
for ($i = 1; $i <= $paddingLength; $i++) {
|
||||
$paddedKey.= chr($i);
|
||||
}
|
||||
$key = Strings::packSSH2('sssNss', 'none', 'none', '', 1, $publicKey, $paddedKey);
|
||||
$key = "openssh-key-v1\0$key";
|
||||
|
||||
return "-----BEGIN OPENSSH PRIVATE KEY-----\r\n" .
|
||||
chunk_split(Base64::encode($key), 70) .
|
||||
"-----END OPENSSH PRIVATE KEY-----";
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PKCS Formatted Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Formats\Keys;
|
||||
|
||||
/**
|
||||
* PKCS1 Formatted Key Handler
|
||||
*
|
||||
* @package RSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PKCS
|
||||
{
|
||||
/**
|
||||
* Auto-detect the format
|
||||
*/
|
||||
const MODE_ANY = 0;
|
||||
/**
|
||||
* Require base64-encoded PEM's be supplied
|
||||
*/
|
||||
const MODE_PEM = 1;
|
||||
/**
|
||||
* Require raw DER's be supplied
|
||||
*/
|
||||
const MODE_DER = 2;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Is the key a base-64 encoded PEM, DER or should it be auto-detected?
|
||||
*
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
protected static $format = self::MODE_ANY;
|
||||
|
||||
/**
|
||||
* Require base64-encoded PEM's be supplied
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public static function requirePEM()
|
||||
{
|
||||
self::$format = self::MODE_PEM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require raw DER's be supplied
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public static function requireDER()
|
||||
{
|
||||
self::$format = self::MODE_DER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept any format and auto detect the format
|
||||
*
|
||||
* This is the default setting
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public static function requireAny()
|
||||
{
|
||||
self::$format = self::MODE_ANY;
|
||||
}
|
||||
}
|
|
@ -1,223 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PKCS1 Formatted Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Formats\Keys;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use ParagonIE\ConstantTime\Hex;
|
||||
use phpseclib3\Crypt\Random;
|
||||
use phpseclib3\Crypt\AES;
|
||||
use phpseclib3\Crypt\DES;
|
||||
use phpseclib3\Crypt\TripleDES;
|
||||
use phpseclib3\File\ASN1;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Exception\UnsupportedAlgorithmException;
|
||||
|
||||
/**
|
||||
* PKCS1 Formatted Key Handler
|
||||
*
|
||||
* @package RSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PKCS1 extends PKCS
|
||||
{
|
||||
/**
|
||||
* Default encryption algorithm
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private static $defaultEncryptionAlgorithm = 'AES-128-CBC';
|
||||
|
||||
/**
|
||||
* Sets the default encryption algorithm
|
||||
*
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
public static function setEncryptionAlgorithm($algo)
|
||||
{
|
||||
self::$defaultEncryptionAlgorithm = $algo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mode constant corresponding to the mode string
|
||||
*
|
||||
* @access public
|
||||
* @param string $mode
|
||||
* @return int
|
||||
* @throws \UnexpectedValueException if the block cipher mode is unsupported
|
||||
*/
|
||||
private static function getEncryptionMode($mode)
|
||||
{
|
||||
switch ($mode) {
|
||||
case 'CBC':
|
||||
case 'ECB':
|
||||
case 'CFB':
|
||||
case 'OFB':
|
||||
case 'CTR':
|
||||
return $mode;
|
||||
}
|
||||
throw new \UnexpectedValueException('Unsupported block cipher mode of operation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cipher object corresponding to a string
|
||||
*
|
||||
* @access public
|
||||
* @param string $algo
|
||||
* @return string
|
||||
* @throws \UnexpectedValueException if the encryption algorithm is unsupported
|
||||
*/
|
||||
private static function getEncryptionObject($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]);
|
||||
return $cipher;
|
||||
case preg_match("#^DES-EDE3-$modes$#", $algo, $matches):
|
||||
return new TripleDES(self::getEncryptionMode($matches[1]));
|
||||
case preg_match("#^DES-$modes$#", $algo, $matches):
|
||||
return new DES(self::getEncryptionMode($matches[1]));
|
||||
default:
|
||||
throw new UnsupportedAlgorithmException($algo . ' is not a supported algorithm');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a symmetric key for PKCS#1 keys
|
||||
*
|
||||
* @access private
|
||||
* @param string $password
|
||||
* @param string $iv
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
private static function generateSymmetricKey($password, $iv, $length)
|
||||
{
|
||||
$symkey = '';
|
||||
$iv = substr($iv, 0, 8);
|
||||
while (strlen($symkey) < $length) {
|
||||
$symkey.= md5($symkey . $password . $iv, true);
|
||||
}
|
||||
return substr($symkey, 0, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
protected static function load($key, $password)
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
/* Although PKCS#1 proposes a format that public and private keys can use, encrypting them is
|
||||
"outside the scope" of PKCS#1. PKCS#1 then refers you to PKCS#12 and PKCS#15 if you're wanting to
|
||||
protect private keys, however, that's not what OpenSSL* does. OpenSSL protects private keys by adding
|
||||
two new "fields" to the key - DEK-Info and Proc-Type. These fields are discussed here:
|
||||
|
||||
http://tools.ietf.org/html/rfc1421#section-4.6.1.1
|
||||
http://tools.ietf.org/html/rfc1421#section-4.6.1.3
|
||||
|
||||
DES-EDE3-CBC as an algorithm, however, is not discussed anywhere, near as I can tell.
|
||||
DES-CBC and DES-EDE are discussed in RFC1423, however, DES-EDE3-CBC isn't, nor is its key derivation
|
||||
function. As is, the definitive authority on this encoding scheme isn't the IETF but rather OpenSSL's
|
||||
own implementation. ie. the implementation *is* the standard and any bugs that may exist in that
|
||||
implementation are part of the standard, as well.
|
||||
|
||||
* OpenSSL is the de facto standard. It's utilized by OpenSSH and other projects */
|
||||
if (preg_match('#DEK-Info: (.+),(.+)#', $key, $matches)) {
|
||||
$iv = Hex::decode(trim($matches[2]));
|
||||
// remove the Proc-Type / DEK-Info sections as they're no longer needed
|
||||
$key = preg_replace('#^(?:Proc-Type|DEK-Info): .*#m', '', $key);
|
||||
$ciphertext = ASN1::extractBER($key);
|
||||
if ($ciphertext === false) {
|
||||
$ciphertext = $key;
|
||||
}
|
||||
$crypto = self::getEncryptionObject($matches[1]);
|
||||
$crypto->setKey(self::generateSymmetricKey($password, $iv, $crypto->getKeyLength() >> 3));
|
||||
$crypto->setIV($iv);
|
||||
$key = $crypto->decrypt($ciphertext);
|
||||
} else {
|
||||
if (self::$format != self::MODE_DER) {
|
||||
$decoded = ASN1::extractBER($key);
|
||||
if ($decoded !== false) {
|
||||
$key = $decoded;
|
||||
} elseif (self::$format == self::MODE_PEM) {
|
||||
throw new \UnexpectedValueException('Expected base64-encoded PEM format but was unable to decode base64 text');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a private key appropriately
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $type
|
||||
* @param string $password
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPrivateKey($key, $type, $password, array $options = [])
|
||||
{
|
||||
if (empty($password) || !is_string($password)) {
|
||||
return "-----BEGIN $type PRIVATE KEY-----\r\n" .
|
||||
chunk_split(Base64::encode($key), 64) .
|
||||
"-----END $type PRIVATE KEY-----";
|
||||
}
|
||||
|
||||
$encryptionAlgorithm = isset($options['encryptionAlgorithm']) ? $options['encryptionAlgorithm'] : self::$defaultEncryptionAlgorithm;
|
||||
|
||||
$cipher = self::getEncryptionObject($encryptionAlgorithm);
|
||||
$iv = Random::string($cipher->getBlockLength() >> 3);
|
||||
$cipher->setKey(self::generateSymmetricKey($password, $iv, $cipher->getKeyLength() >> 3));
|
||||
$cipher->setIV($iv);
|
||||
$iv = strtoupper(Hex::encode($iv));
|
||||
return "-----BEGIN $type PRIVATE KEY-----\r\n" .
|
||||
"Proc-Type: 4,ENCRYPTED\r\n" .
|
||||
"DEK-Info: " . $encryptionAlgorithm. ",$iv\r\n" .
|
||||
"\r\n" .
|
||||
chunk_split(Base64::encode($cipher->encrypt($key)), 64) .
|
||||
"-----END $type PRIVATE KEY-----";
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a public key appropriately
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPublicKey($key, $type)
|
||||
{
|
||||
return "-----BEGIN $type PUBLIC KEY-----\r\n" .
|
||||
chunk_split(Base64::encode($key), 64) .
|
||||
"-----END $type PUBLIC KEY-----";
|
||||
}
|
||||
}
|
|
@ -1,702 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PKCS#8 Formatted Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Used by PHP's openssl_public_encrypt() and openssl's rsautl (when -pubin is set)
|
||||
*
|
||||
* Processes keys with the following headers:
|
||||
*
|
||||
* -----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
* -----BEGIN PRIVATE KEY-----
|
||||
* -----BEGIN PUBLIC KEY-----
|
||||
*
|
||||
* Analogous to ssh-keygen's pkcs8 format (as specified by -m). Although PKCS8
|
||||
* is specific to private keys it's basically creating a DER-encoded wrapper
|
||||
* for keys. This just extends that same concept to public keys (much like ssh-keygen)
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Formats\Keys;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use phpseclib3\Crypt\DES;
|
||||
use phpseclib3\Crypt\RC2;
|
||||
use phpseclib3\Crypt\RC4;
|
||||
use phpseclib3\Crypt\AES;
|
||||
use phpseclib3\Crypt\TripleDES;
|
||||
use phpseclib3\Crypt\Random;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\File\ASN1;
|
||||
use phpseclib3\File\ASN1\Maps;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Exception\UnsupportedAlgorithmException;
|
||||
|
||||
/**
|
||||
* PKCS#8 Formatted Key Handler
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PKCS8 extends PKCS
|
||||
{
|
||||
/**
|
||||
* Default encryption algorithm
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private static $defaultEncryptionAlgorithm = 'id-PBES2';
|
||||
|
||||
/**
|
||||
* Default encryption scheme
|
||||
*
|
||||
* Only used when defaultEncryptionAlgorithm is id-PBES2
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private static $defaultEncryptionScheme = 'aes128-CBC-PAD';
|
||||
|
||||
/**
|
||||
* Default PRF
|
||||
*
|
||||
* Only used when defaultEncryptionAlgorithm is id-PBES2
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private static $defaultPRF = 'id-hmacWithSHA256';
|
||||
|
||||
/**
|
||||
* Default Iteration Count
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private static $defaultIterationCount = 2048;
|
||||
|
||||
/**
|
||||
* OIDs loaded
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
private static $oidsLoaded = false;
|
||||
|
||||
/**
|
||||
* Sets the default encryption algorithm
|
||||
*
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
public static function setEncryptionAlgorithm($algo)
|
||||
{
|
||||
self::$defaultEncryptionAlgorithm = $algo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default encryption algorithm for PBES2
|
||||
*
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
public static function setEncryptionScheme($algo)
|
||||
{
|
||||
self::$defaultEncryptionScheme = $algo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the iteration count
|
||||
*
|
||||
* @access public
|
||||
* @param int $count
|
||||
*/
|
||||
public static function setIterationCount($count)
|
||||
{
|
||||
self::$defaultIterationCount = $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PRF for PBES2
|
||||
*
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
public static function setPRF($algo)
|
||||
{
|
||||
self::$defaultPRF = $algo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SymmetricKey object based on a PBES1 $algo
|
||||
*
|
||||
* @return \phpseclib3\Crypt\Common\SymmetricKey
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
private static function getPBES1EncryptionObject($algo)
|
||||
{
|
||||
$algo = preg_match('#^pbeWith(?:MD2|MD5|SHA1|SHA)And(.*?)-CBC$#', $algo, $matches) ?
|
||||
$matches[1] :
|
||||
substr($algo, 13); // strlen('pbeWithSHAAnd') == 13
|
||||
|
||||
switch ($algo) {
|
||||
case 'DES':
|
||||
$cipher = new DES('cbc');
|
||||
break;
|
||||
case 'RC2':
|
||||
$cipher = new RC2('cbc');
|
||||
break;
|
||||
case '3-KeyTripleDES':
|
||||
$cipher = new TripleDES('cbc');
|
||||
break;
|
||||
case '2-KeyTripleDES':
|
||||
$cipher = new TripleDES('cbc');
|
||||
$cipher->setKeyLength(128);
|
||||
break;
|
||||
case '128BitRC2':
|
||||
$cipher = new RC2('cbc');
|
||||
$cipher->setKeyLength(128);
|
||||
break;
|
||||
case '40BitRC2':
|
||||
$cipher = new RC2('cbc');
|
||||
$cipher->setKeyLength(40);
|
||||
break;
|
||||
case '128BitRC4':
|
||||
$cipher = new RC4();
|
||||
$cipher->setKeyLength(128);
|
||||
break;
|
||||
case '40BitRC4':
|
||||
$cipher = new RC4();
|
||||
$cipher->setKeyLength(40);
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedAlgorithmException("$algo is not a supported algorithm");
|
||||
}
|
||||
|
||||
return $cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash based on a PBES1 $algo
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
private static function getPBES1Hash($algo)
|
||||
{
|
||||
if (preg_match('#^pbeWith(MD2|MD5|SHA1|SHA)And.*?-CBC$#', $algo, $matches)) {
|
||||
return $matches[1] == 'SHA' ? 'sha1' : $matches[1];
|
||||
}
|
||||
|
||||
return 'sha1';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a KDF baesd on a PBES1 $algo
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
private static function getPBES1KDF($algo)
|
||||
{
|
||||
switch ($algo) {
|
||||
case 'pbeWithMD2AndDES-CBC':
|
||||
case 'pbeWithMD2AndRC2-CBC':
|
||||
case 'pbeWithMD5AndDES-CBC':
|
||||
case 'pbeWithMD5AndRC2-CBC':
|
||||
case 'pbeWithSHA1AndDES-CBC':
|
||||
case 'pbeWithSHA1AndRC2-CBC':
|
||||
return 'pbkdf1';
|
||||
}
|
||||
|
||||
return 'pkcs12';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a SymmetricKey object baesd on a PBES2 $algo
|
||||
*
|
||||
* @return SymmetricKey
|
||||
* @access public
|
||||
* @param string $algo
|
||||
*/
|
||||
private static function getPBES2EncryptionObject($algo)
|
||||
{
|
||||
switch ($algo) {
|
||||
case 'desCBC':
|
||||
$cipher = new TripleDES('cbc');
|
||||
break;
|
||||
case 'des-EDE3-CBC':
|
||||
$cipher = new TripleDES('cbc');
|
||||
break;
|
||||
case 'rc2CBC':
|
||||
$cipher = new RC2('cbc');
|
||||
// in theory this can be changed
|
||||
$cipher->setKeyLength(128);
|
||||
break;
|
||||
case 'rc5-CBC-PAD':
|
||||
throw new UnsupportedAlgorithmException('rc5-CBC-PAD is not supported for PBES2 PKCS#8 keys');
|
||||
case 'aes128-CBC-PAD':
|
||||
case 'aes192-CBC-PAD':
|
||||
case 'aes256-CBC-PAD':
|
||||
$cipher = new AES('cbc');
|
||||
$cipher->setKeyLength(substr($algo, 3, 3));
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedAlgorithmException("$algo is not supported");
|
||||
}
|
||||
|
||||
return $cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize static variables
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private static function initialize_static_variables()
|
||||
{
|
||||
if (!static::$childOIDsLoaded) {
|
||||
ASN1::loadOIDs(is_array(static::OID_NAME) ?
|
||||
array_combine(static::OID_NAME, static::OID_VALUE) :
|
||||
[static::OID_NAME => static::OID_VALUE]
|
||||
);
|
||||
static::$childOIDsLoaded = true;
|
||||
}
|
||||
if (!self::$oidsLoaded) {
|
||||
// from https://tools.ietf.org/html/rfc2898
|
||||
ASN1::loadOIDs([
|
||||
// PBES1 encryption schemes
|
||||
'pbeWithMD2AndDES-CBC' => '1.2.840.113549.1.5.1',
|
||||
'pbeWithMD2AndRC2-CBC' => '1.2.840.113549.1.5.4',
|
||||
'pbeWithMD5AndDES-CBC' => '1.2.840.113549.1.5.3',
|
||||
'pbeWithMD5AndRC2-CBC' => '1.2.840.113549.1.5.6',
|
||||
'pbeWithSHA1AndDES-CBC'=> '1.2.840.113549.1.5.10',
|
||||
'pbeWithSHA1AndRC2-CBC'=> '1.2.840.113549.1.5.11',
|
||||
|
||||
// from PKCS#12:
|
||||
// https://tools.ietf.org/html/rfc7292
|
||||
'pbeWithSHAAnd128BitRC4' => '1.2.840.113549.1.12.1.1',
|
||||
'pbeWithSHAAnd40BitRC4' => '1.2.840.113549.1.12.1.2',
|
||||
'pbeWithSHAAnd3-KeyTripleDES-CBC' => '1.2.840.113549.1.12.1.3',
|
||||
'pbeWithSHAAnd2-KeyTripleDES-CBC' => '1.2.840.113549.1.12.1.4',
|
||||
'pbeWithSHAAnd128BitRC2-CBC' => '1.2.840.113549.1.12.1.5',
|
||||
'pbeWithSHAAnd40BitRC2-CBC' => '1.2.840.113549.1.12.1.6',
|
||||
|
||||
'id-PBKDF2' => '1.2.840.113549.1.5.12',
|
||||
'id-PBES2' => '1.2.840.113549.1.5.13',
|
||||
'id-PBMAC1' => '1.2.840.113549.1.5.14',
|
||||
|
||||
// from PKCS#5 v2.1:
|
||||
// http://www.rsa.com/rsalabs/pkcs/files/h11302-wp-pkcs5v2-1-password-based-cryptography-standard.pdf
|
||||
'id-hmacWithSHA1' => '1.2.840.113549.2.7',
|
||||
'id-hmacWithSHA224' => '1.2.840.113549.2.8',
|
||||
'id-hmacWithSHA256' => '1.2.840.113549.2.9',
|
||||
'id-hmacWithSHA384'=> '1.2.840.113549.2.10',
|
||||
'id-hmacWithSHA512'=> '1.2.840.113549.2.11',
|
||||
'id-hmacWithSHA512-224'=> '1.2.840.113549.2.12',
|
||||
'id-hmacWithSHA512-256'=> '1.2.840.113549.2.13',
|
||||
|
||||
'desCBC' => '1.3.14.3.2.7',
|
||||
'des-EDE3-CBC' => '1.2.840.113549.3.7',
|
||||
'rc2CBC' => '1.2.840.113549.3.2',
|
||||
'rc5-CBC-PAD' => '1.2.840.113549.3.9',
|
||||
|
||||
'aes128-CBC-PAD' => '2.16.840.1.101.3.4.1.2',
|
||||
'aes192-CBC-PAD'=> '2.16.840.1.101.3.4.1.22',
|
||||
'aes256-CBC-PAD'=> '2.16.840.1.101.3.4.1.42'
|
||||
]);
|
||||
self::$oidsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
protected static function load($key, $password = '')
|
||||
{
|
||||
$decoded = self::preParse($key);
|
||||
|
||||
$meta = [];
|
||||
|
||||
$decrypted = ASN1::asn1map($decoded[0], Maps\EncryptedPrivateKeyInfo::MAP);
|
||||
if (strlen($password) && is_array($decrypted)) {
|
||||
$algorithm = $decrypted['encryptionAlgorithm']['algorithm'];
|
||||
switch ($algorithm) {
|
||||
// PBES1
|
||||
case 'pbeWithMD2AndDES-CBC':
|
||||
case 'pbeWithMD2AndRC2-CBC':
|
||||
case 'pbeWithMD5AndDES-CBC':
|
||||
case 'pbeWithMD5AndRC2-CBC':
|
||||
case 'pbeWithSHA1AndDES-CBC':
|
||||
case 'pbeWithSHA1AndRC2-CBC':
|
||||
case 'pbeWithSHAAnd3-KeyTripleDES-CBC':
|
||||
case 'pbeWithSHAAnd2-KeyTripleDES-CBC':
|
||||
case 'pbeWithSHAAnd128BitRC2-CBC':
|
||||
case 'pbeWithSHAAnd40BitRC2-CBC':
|
||||
case 'pbeWithSHAAnd128BitRC4':
|
||||
case 'pbeWithSHAAnd40BitRC4':
|
||||
$cipher = self::getPBES1EncryptionObject($algorithm);
|
||||
$hash = self::getPBES1Hash($algorithm);
|
||||
$kdf = self::getPBES1KDF($algorithm);
|
||||
|
||||
$meta['meta']['algorithm'] = $algorithm;
|
||||
|
||||
$temp = ASN1::decodeBER($decrypted['encryptionAlgorithm']['parameters']);
|
||||
extract(ASN1::asn1map($temp[0], Maps\PBEParameter::MAP));
|
||||
$iterationCount = (int) $iterationCount->toString();
|
||||
$cipher->setPassword($password, $kdf, $hash, $salt, $iterationCount);
|
||||
$key = $cipher->decrypt($decrypted['encryptedData']);
|
||||
$decoded = ASN1::decodeBER($key);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER 2');
|
||||
}
|
||||
|
||||
break;
|
||||
case 'id-PBES2':
|
||||
$meta['meta']['algorithm'] = $algorithm;
|
||||
|
||||
$temp = ASN1::decodeBER($decrypted['encryptionAlgorithm']['parameters']);
|
||||
$temp = ASN1::asn1map($temp[0], Maps\PBES2params::MAP);
|
||||
extract($temp);
|
||||
|
||||
$cipher = self::getPBES2EncryptionObject($encryptionScheme['algorithm']);
|
||||
$meta['meta']['cipher'] = $encryptionScheme['algorithm'];
|
||||
|
||||
$temp = ASN1::decodeBER($decrypted['encryptionAlgorithm']['parameters']);
|
||||
$temp = ASN1::asn1map($temp[0], Maps\PBES2params::MAP);
|
||||
extract($temp);
|
||||
|
||||
if (!$cipher instanceof RC2) {
|
||||
$cipher->setIV($encryptionScheme['parameters']['octetString']);
|
||||
} else {
|
||||
$temp = ASN1::decodeBER($encryptionScheme['parameters']);
|
||||
extract(ASN1::asn1map($temp[0], Maps\RC2CBCParameter::MAP));
|
||||
$effectiveKeyLength = (int) $rc2ParametersVersion->toString();
|
||||
switch ($effectiveKeyLength) {
|
||||
case 160:
|
||||
$effectiveKeyLength = 40;
|
||||
break;
|
||||
case 120:
|
||||
$effectiveKeyLength = 64;
|
||||
break;
|
||||
case 58:
|
||||
$effectiveKeyLength = 128;
|
||||
break;
|
||||
//default: // should be >= 256
|
||||
}
|
||||
$cipher->setIV($iv);
|
||||
$cipher->setKeyLength($effectiveKeyLength);
|
||||
}
|
||||
|
||||
$meta['meta']['keyDerivationFunc'] = $keyDerivationFunc['algorithm'];
|
||||
switch ($keyDerivationFunc['algorithm']) {
|
||||
case 'id-PBKDF2':
|
||||
$temp = ASN1::decodeBER($keyDerivationFunc['parameters']);
|
||||
$prf = ['algorithm' => 'id-hmacWithSHA1'];
|
||||
$params = ASN1::asn1map($temp[0], Maps\PBKDF2params::MAP);
|
||||
extract($params);
|
||||
$meta['meta']['prf'] = $prf['algorithm'];
|
||||
$hash = str_replace('-', '/', substr($prf['algorithm'], 11));
|
||||
$params = [
|
||||
$password,
|
||||
'pbkdf2',
|
||||
$hash,
|
||||
$salt,
|
||||
(int) $iterationCount->toString()
|
||||
];
|
||||
if (isset($keyLength)) {
|
||||
$params[] = (int) $keyLength->toString();
|
||||
}
|
||||
$cipher->setPassword(...$params);
|
||||
$key = $cipher->decrypt($decrypted['encryptedData']);
|
||||
$decoded = ASN1::decodeBER($key);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER 3');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedAlgorithmException('Only PBKDF2 is supported for PBES2 PKCS#8 keys');
|
||||
}
|
||||
break;
|
||||
case 'id-PBMAC1':
|
||||
//$temp = ASN1::decodeBER($decrypted['encryptionAlgorithm']['parameters']);
|
||||
//$value = ASN1::asn1map($temp[0], Maps\PBMAC1params::MAP);
|
||||
// since i can't find any implementation that does PBMAC1 it is unsupported
|
||||
throw new UnsupportedAlgorithmException('Only PBES1 and PBES2 PKCS#8 keys are supported.');
|
||||
// at this point we'll assume that the key conforms to PublicKeyInfo
|
||||
}
|
||||
}
|
||||
|
||||
$private = ASN1::asn1map($decoded[0], Maps\OneAsymmetricKey::MAP);
|
||||
if (is_array($private)) {
|
||||
if (isset($private['privateKeyAlgorithm']['parameters']) && !$private['privateKeyAlgorithm']['parameters'] instanceof ASN1\Element && isset($decoded[0]['content'][1]['content'][1])) {
|
||||
$temp = $decoded[0]['content'][1]['content'][1];
|
||||
$private['privateKeyAlgorithm']['parameters'] = new ASN1\Element(substr($key, $temp['start'], $temp['length']));
|
||||
}
|
||||
if (is_array(static::OID_NAME)) {
|
||||
if (!in_array($private['privateKeyAlgorithm']['algorithm'], static::OID_NAME)) {
|
||||
throw new UnsupportedAlgorithmException($private['privateKeyAlgorithm']['algorithm'] . ' is not a supported key type');
|
||||
}
|
||||
} else {
|
||||
if ($private['privateKeyAlgorithm']['algorithm'] != static::OID_NAME) {
|
||||
throw new UnsupportedAlgorithmException('Only ' . static::OID_NAME . ' keys are supported; this is a ' . $private['privateKeyAlgorithm']['algorithm'] . ' key');
|
||||
}
|
||||
}
|
||||
if (isset($private['publicKey'])) {
|
||||
if ($private['publicKey'][0] != "\0") {
|
||||
throw new \UnexpectedValueException('The first byte of the public key should be null - not ' . bin2hex($private['publicKey'][0]));
|
||||
}
|
||||
$private['publicKey'] = substr($private['publicKey'], 1);
|
||||
}
|
||||
return $private + $meta;
|
||||
}
|
||||
|
||||
// EncryptedPrivateKeyInfo and PublicKeyInfo have largely identical "signatures". the only difference
|
||||
// is that the former has an octet string and the later has a bit string. the first byte of a bit
|
||||
// string represents the number of bits in the last byte that are to be ignored but, currently,
|
||||
// bit strings wanting a non-zero amount of bits trimmed are not supported
|
||||
$public = ASN1::asn1map($decoded[0], Maps\PublicKeyInfo::MAP);
|
||||
|
||||
if (is_array($public)) {
|
||||
if ($public['publicKey'][0] != "\0") {
|
||||
throw new \UnexpectedValueException('The first byte of the public key should be null - not ' . bin2hex($public['publicKey'][0]));
|
||||
}
|
||||
if (is_array(static::OID_NAME)) {
|
||||
if (!in_array($public['publicKeyAlgorithm']['algorithm'], static::OID_NAME)) {
|
||||
throw new UnsupportedAlgorithmException($public['publicKeyAlgorithm']['algorithm'] . ' is not a supported key type');
|
||||
}
|
||||
} else {
|
||||
if ($public['publicKeyAlgorithm']['algorithm'] != static::OID_NAME) {
|
||||
throw new UnsupportedAlgorithmException('Only ' . static::OID_NAME . ' keys are supported; this is a ' . $public['publicKeyAlgorithm']['algorithm'] . ' key');
|
||||
}
|
||||
}
|
||||
if (isset($public['publicKeyAlgorithm']['parameters']) && !$public['publicKeyAlgorithm']['parameters'] instanceof ASN1\Element && isset($decoded[0]['content'][0]['content'][1])) {
|
||||
$temp = $decoded[0]['content'][0]['content'][1];
|
||||
$public['publicKeyAlgorithm']['parameters'] = new ASN1\Element(substr($key, $temp['start'], $temp['length']));
|
||||
}
|
||||
$public['publicKey'] = substr($public['publicKey'], 1);
|
||||
return $public;
|
||||
}
|
||||
|
||||
throw new \RuntimeException('Unable to parse using either OneAsymmetricKey or PublicKeyInfo ASN1 maps');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a private key appropriately
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $attr
|
||||
* @param mixed $params
|
||||
* @param string $password
|
||||
* @param string $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 = [])
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
$key = [
|
||||
'version' => 'v1',
|
||||
'privateKeyAlgorithm' => [
|
||||
'algorithm' => is_string(static::OID_NAME) ? static::OID_NAME : $oid,
|
||||
'parameters' => $params
|
||||
],
|
||||
'privateKey' => $key
|
||||
];
|
||||
if (!empty($attr)) {
|
||||
$key['attributes'] = $attr;
|
||||
}
|
||||
if (!empty($publicKey)) {
|
||||
$key['version'] = 'v2';
|
||||
$key['publicKey'] = $publicKey;
|
||||
}
|
||||
$key = ASN1::encodeDER($key, Maps\OneAsymmetricKey::MAP);
|
||||
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;
|
||||
|
||||
if ($encryptionAlgorithm == 'id-PBES2') {
|
||||
$crypto = self::getPBES2EncryptionObject($encryptionScheme);
|
||||
$hash = str_replace('-', '/', substr($prf, 11));
|
||||
$kdf = 'pbkdf2';
|
||||
$iv = Random::string($crypto->getBlockLength() >> 3);
|
||||
|
||||
$PBKDF2params = [
|
||||
'salt' => $salt,
|
||||
'iterationCount' => $iterationCount,
|
||||
'prf' => ['algorithm' => $prf, 'parameters' => null]
|
||||
];
|
||||
$PBKDF2params = ASN1::encodeDER($PBKDF2params, Maps\PBKDF2params::MAP);
|
||||
|
||||
if (!$crypto instanceof RC2) {
|
||||
$params = ['octetString' => $iv];
|
||||
} else {
|
||||
$params = [
|
||||
'rc2ParametersVersion' => 58,
|
||||
'iv' => $iv
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\RC2CBCParameter::MAP);
|
||||
$params = new ASN1\Element($params);
|
||||
}
|
||||
|
||||
$params = [
|
||||
'keyDerivationFunc' => [
|
||||
'algorithm' => 'id-PBKDF2',
|
||||
'parameters' => new ASN1\Element($PBKDF2params)
|
||||
],
|
||||
'encryptionScheme' => [
|
||||
'algorithm' => $encryptionScheme,
|
||||
'parameters' => $params
|
||||
]
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\PBES2params::MAP);
|
||||
|
||||
$crypto->setIV($iv);
|
||||
} else {
|
||||
$crypto = self::getPBES1EncryptionObject($encryptionAlgorithm);
|
||||
$hash = self::getPBES1Hash($encryptionAlgorithm);
|
||||
$kdf = self::getPBES1KDF($encryptionAlgorithm);
|
||||
|
||||
$params = [
|
||||
'salt' => $salt,
|
||||
'iterationCount' => $iterationCount
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\PBEParameter::MAP);
|
||||
}
|
||||
$crypto->setPassword($password, $kdf, $hash, $salt, $iterationCount);
|
||||
$key = $crypto->encrypt($key);
|
||||
|
||||
$key = [
|
||||
'encryptionAlgorithm' => [
|
||||
'algorithm' => $encryptionAlgorithm,
|
||||
'parameters' => new ASN1\Element($params)
|
||||
],
|
||||
'encryptedData' => $key
|
||||
];
|
||||
|
||||
$key = ASN1::encodeDER($key, Maps\EncryptedPrivateKeyInfo::MAP);
|
||||
|
||||
return "-----BEGIN ENCRYPTED PRIVATE KEY-----\r\n" .
|
||||
chunk_split(Base64::encode($key), 64) .
|
||||
"-----END ENCRYPTED PRIVATE KEY-----";
|
||||
}
|
||||
|
||||
return "-----BEGIN PRIVATE KEY-----\r\n" .
|
||||
chunk_split(Base64::encode($key), 64) .
|
||||
"-----END PRIVATE KEY-----";
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a public key appropriately
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param mixed $params
|
||||
* @param string $oid
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPublicKey($key, $params, $oid = null)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
$key = [
|
||||
'publicKeyAlgorithm' => [
|
||||
'algorithm' => is_string(static::OID_NAME) ? static::OID_NAME : $oid,
|
||||
'parameters' => $params
|
||||
],
|
||||
'publicKey' => "\0" . $key
|
||||
];
|
||||
|
||||
$key = ASN1::encodeDER($key, Maps\PublicKeyInfo::MAP);
|
||||
|
||||
return "-----BEGIN PUBLIC KEY-----\r\n" .
|
||||
chunk_split(Base64::encode($key), 64) .
|
||||
"-----END PUBLIC KEY-----";
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform some preliminary parsing of the key
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
private static function preParse(&$key)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
if (self::$format != self::MODE_DER) {
|
||||
$decoded = ASN1::extractBER($key);
|
||||
if ($decoded !== false) {
|
||||
$key = $decoded;
|
||||
} elseif (self::$format == self::MODE_PEM) {
|
||||
throw new \UnexpectedValueException('Expected base64-encoded PEM format but was unable to decode base64 text');
|
||||
}
|
||||
}
|
||||
|
||||
$decoded = ASN1::decodeBER($key);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER');
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the encryption parameters used by the key
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
public static function extractEncryptionAlgorithm($key)
|
||||
{
|
||||
$decoded = self::preParse($key);
|
||||
|
||||
$r = ASN1::asn1map($decoded[0], ASN1\Maps\EncryptedPrivateKeyInfo::MAP);
|
||||
if (!is_array($r)) {
|
||||
throw new \RuntimeException('Unable to parse using EncryptedPrivateKeyInfo map');
|
||||
}
|
||||
|
||||
if ($r['encryptionAlgorithm']['algorithm'] == 'id-PBES2') {
|
||||
$decoded = ASN1::decodeBER($r['encryptionAlgorithm']['parameters']->element);
|
||||
$r['encryptionAlgorithm']['parameters'] = ASN1::asn1map($decoded[0], ASN1\Maps\PBES2params::MAP);
|
||||
|
||||
$kdf = &$r['encryptionAlgorithm']['parameters']['keyDerivationFunc'];
|
||||
switch ($kdf['algorithm']) {
|
||||
case 'id-PBKDF2':
|
||||
$decoded = ASN1::decodeBER($kdf['parameters']->element);
|
||||
$kdf['parameters'] = ASN1::asn1map($decoded[0], Maps\PBKDF2params::MAP);
|
||||
}
|
||||
}
|
||||
|
||||
return $r['encryptionAlgorithm'];
|
||||
}
|
||||
}
|
|
@ -1,261 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PuTTY Formatted Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Formats\Keys;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use ParagonIE\ConstantTime\Hex;
|
||||
use phpseclib3\Crypt\AES;
|
||||
use phpseclib3\Crypt\Hash;
|
||||
use phpseclib3\Crypt\Random;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Exception\UnsupportedAlgorithmException;
|
||||
|
||||
/**
|
||||
* PuTTY Formatted Key Handler
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PuTTY
|
||||
{
|
||||
/**
|
||||
* Default comment
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private static $comment = 'phpseclib-generated-key';
|
||||
|
||||
/**
|
||||
* Sets the default comment
|
||||
*
|
||||
* @access public
|
||||
* @param string $comment
|
||||
*/
|
||||
public static function setComment($comment)
|
||||
{
|
||||
self::$comment = str_replace(["\r", "\n"], '', $comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a symmetric key for PuTTY keys
|
||||
*
|
||||
* @access public
|
||||
* @param string $password
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
private static function generateSymmetricKey($password, $length)
|
||||
{
|
||||
$symkey = '';
|
||||
$sequence = 0;
|
||||
while (strlen($symkey) < $length) {
|
||||
$temp = pack('Na*', $sequence++, $password);
|
||||
$symkey.= Hex::decode(sha1($temp));
|
||||
}
|
||||
return substr($symkey, 0, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password)
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
if (strpos($key, 'BEGIN SSH2 PUBLIC KEY') !== false) {
|
||||
$lines = preg_split('#[\r\n]+#', $key);
|
||||
switch (true) {
|
||||
case $lines[0] != '---- BEGIN SSH2 PUBLIC KEY ----':
|
||||
throw new \UnexpectedValueException('Key doesn\'t start with ---- BEGIN SSH2 PUBLIC KEY ----');
|
||||
case $lines[count($lines) - 1] != '---- END SSH2 PUBLIC KEY ----':
|
||||
throw new \UnexpectedValueException('Key doesn\'t end with ---- END SSH2 PUBLIC KEY ----');
|
||||
}
|
||||
$lines = array_splice($lines, 1, -1);
|
||||
$lines = array_map(function ($line) {
|
||||
return rtrim($line, "\r\n");
|
||||
}, $lines);
|
||||
$data = $current = '';
|
||||
$values = [];
|
||||
$in_value = false;
|
||||
foreach ($lines as $line) {
|
||||
switch (true) {
|
||||
case preg_match('#^(.*?): (.*)#', $line, $match):
|
||||
$in_value = $line[strlen($line) - 1] == '\\';
|
||||
$current = strtolower($match[1]);
|
||||
$values[$current] = $in_value ? substr($match[2], 0, -1) : $match[2];
|
||||
break;
|
||||
case $in_value:
|
||||
$in_value = $line[strlen($line) - 1] == '\\';
|
||||
$values[$current].= $in_value ? substr($line, 0, -1) : $line;
|
||||
break;
|
||||
default:
|
||||
$data.= $line;
|
||||
}
|
||||
}
|
||||
|
||||
$components = call_user_func([static::PUBLIC_HANDLER, 'load'], $data);
|
||||
if ($components === false) {
|
||||
throw new \UnexpectedValueException('Unable to decode public key');
|
||||
}
|
||||
$components+= $values;
|
||||
$components['comment'] = str_replace(['\\\\', '\"'], ['\\', '"'], $values['comment']);
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
$components = [];
|
||||
|
||||
$key = preg_split('#\r\n|\r|\n#', trim($key));
|
||||
$type = trim(preg_replace('#PuTTY-User-Key-File-2: (.+)#', '$1', $key[0]));
|
||||
$components['type'] = $type;
|
||||
if (!in_array($type, static::$types)) {
|
||||
$error = count(static::$types) == 1 ?
|
||||
'Only ' . static::$types[0] . ' keys are supported. ' :
|
||||
'';
|
||||
throw new UnsupportedAlgorithmException($error . 'This is an unsupported ' . $type . ' key');
|
||||
}
|
||||
$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]));
|
||||
$public = Base64::decode(implode('', array_map('trim', array_slice($key, 4, $publicLength))));
|
||||
|
||||
$source = Strings::packSSH2('ssss', $type, $encryption, $components['comment'], $public);
|
||||
|
||||
extract(unpack('Nlength', Strings::shift($public, 4)));
|
||||
$newtype = Strings::shift($public, $length);
|
||||
if ($newtype != $type) {
|
||||
throw new \RuntimeException('The binary type does not match the human readable type field');
|
||||
}
|
||||
|
||||
$components['public'] = $public;
|
||||
|
||||
$privateLength = trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$publicLength + 4]));
|
||||
$private = Base64::decode(implode('', array_map('trim', array_slice($key, $publicLength + 5, $privateLength))));
|
||||
|
||||
switch ($encryption) {
|
||||
case 'aes256-cbc':
|
||||
$symkey = self::generateSymmetricKey($password, 32);
|
||||
$crypto = new AES('cbc');
|
||||
}
|
||||
|
||||
$hashkey = 'putty-private-key-file-mac-key';
|
||||
|
||||
if ($encryption != 'none') {
|
||||
$hashkey.= $password;
|
||||
$crypto->setKey($symkey);
|
||||
$crypto->setIV(str_repeat("\0", $crypto->getBlockLength() >> 3));
|
||||
$crypto->disablePadding();
|
||||
$private = $crypto->decrypt($private);
|
||||
}
|
||||
|
||||
$source.= Strings::packSSH2('s', $private);
|
||||
|
||||
$hash = new Hash('sha1');
|
||||
$hash->setKey(sha1($hashkey, true));
|
||||
$hmac = trim(preg_replace('#Private-MAC: (.+)#', '$1', $key[$publicLength + $privateLength + 5]));
|
||||
$hmac = Hex::decode($hmac);
|
||||
|
||||
if (!hash_equals($hash->hash($source), $hmac)) {
|
||||
throw new \UnexpectedValueException('MAC validation error');
|
||||
}
|
||||
|
||||
$components['private'] = $private;
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a private key appropriately
|
||||
*
|
||||
* @access private
|
||||
* @param string $public
|
||||
* @param string $private
|
||||
* @param string $type
|
||||
* @param string $password
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPrivateKey($public, $private, $type, $password, array $options = [])
|
||||
{
|
||||
$encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none';
|
||||
$comment = isset($options['comment']) ? $options['comment'] : self::$comment;
|
||||
|
||||
$key = "PuTTY-User-Key-File-2: " . $type . "\r\nEncryption: "; $key.= $encryption;
|
||||
$key.= "\r\nComment: " . $comment . "\r\n";
|
||||
|
||||
$public = Strings::packSSH2('s', $type) . $public;
|
||||
|
||||
$source = Strings::packSSH2('ssss', $type, $encryption, $comment, $public);
|
||||
|
||||
$public = Base64::encode($public);
|
||||
$key.= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n";
|
||||
$key.= chunk_split($public, 64);
|
||||
|
||||
if (empty($password) && !is_string($password)) {
|
||||
$source.= Strings::packSSH2('s', $private);
|
||||
$hashkey = 'putty-private-key-file-mac-key';
|
||||
} else {
|
||||
$private.= Random::string(16 - (strlen($private) & 15));
|
||||
$source.= Strings::packSSH2('s', $private);
|
||||
$crypto = new AES('cbc');
|
||||
|
||||
$crypto->setKey(self::generateSymmetricKey($password, 32));
|
||||
$crypto->setIV(str_repeat("\0", $crypto->getBlockLength() >> 3));
|
||||
$crypto->disablePadding();
|
||||
$private = $crypto->encrypt($private);
|
||||
$hashkey = 'putty-private-key-file-mac-key' . $password;
|
||||
}
|
||||
|
||||
$private = Base64::encode($private);
|
||||
$key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n";
|
||||
$key.= chunk_split($private, 64);
|
||||
$hash = new Hash('sha1');
|
||||
$hash->setKey(sha1($hashkey, true));
|
||||
$key.= 'Private-MAC: ' . Hex::encode($hash->hash($source)) . "\r\n";
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a public key appropriately
|
||||
*
|
||||
* This is basically the format described in RFC 4716 (https://tools.ietf.org/html/rfc4716)
|
||||
*
|
||||
* @access private
|
||||
* @param string $key
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPublicKey($key, $type)
|
||||
{
|
||||
$key = pack('Na*a*', strlen($type), $type, $key);
|
||||
$key = "---- BEGIN SSH2 PUBLIC KEY ----\r\n" .
|
||||
'Comment: "' . str_replace(['\\', '"'], ['\\\\', '\"'], self::$comment) . "\"\r\n" .
|
||||
chunk_split(Base64::encode($key), 64) .
|
||||
'---- END SSH2 PUBLIC KEY ----';
|
||||
return $key;
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Raw Signature Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Handles signatures as arrays
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Formats\Signature;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
/**
|
||||
* Raw Signature Handler
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class Raw
|
||||
{
|
||||
/**
|
||||
* Loads a signature
|
||||
*
|
||||
* @access public
|
||||
* @param array $sig
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function load($sig)
|
||||
{
|
||||
switch (true) {
|
||||
case !is_array($sig):
|
||||
case !isset($sig['r']) || !isset($sig['s']):
|
||||
case !$sig['r'] instanceof BigInteger:
|
||||
case !$sig['s'] instanceof BigInteger:
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'r' => $sig['r'],
|
||||
's' => $sig['s']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a signature in the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @param \phpseclib3\Math\BigInteger $r
|
||||
* @param \phpseclib3\Math\BigInteger $s
|
||||
* @return string
|
||||
*/
|
||||
public static function save(BigInteger $r, BigInteger $s)
|
||||
{
|
||||
return compact('r', 's');
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PrivateKey interface
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2009 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* PrivateKey interface
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
interface PrivateKey
|
||||
{
|
||||
public function sign($message);
|
||||
//public function decrypt($ciphertext);
|
||||
public function getPublicKey();
|
||||
public function toString($type, array $options = []);
|
||||
public function withPassword($string);
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PublicKey interface
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2009 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* PublicKey interface
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
interface PublicKey
|
||||
{
|
||||
public function verify($message, $signature);
|
||||
//public function encrypt($plaintext);
|
||||
public function toString($type, array $options = []);
|
||||
public function getFingerprint($algorithm);
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Base Class for all stream ciphers
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package StreamCipher
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @author Hans-Juergen Petrich <petrich@tronic-media.com>
|
||||
* @copyright 2007 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* Base Class for all stream cipher classes
|
||||
*
|
||||
* @package StreamCipher
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
*/
|
||||
abstract class StreamCipher extends SymmetricKey
|
||||
{
|
||||
/**
|
||||
* Block Length of the cipher
|
||||
*
|
||||
* Stream ciphers do not have a block size
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::block_size
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
protected $block_size = 0;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::__construct()
|
||||
* @return \phpseclib3\Crypt\Common\StreamCipher
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('stream');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream ciphers not use an IV
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function usesIV()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Fingerprint Trait for Public Keys
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Traits;
|
||||
|
||||
use phpseclib3\Crypt\Hash;
|
||||
|
||||
/**
|
||||
* Fingerprint Trait for Private Keys
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
trait Fingerprint
|
||||
{
|
||||
/**
|
||||
* Returns the public key's fingerprint
|
||||
*
|
||||
* The public key's fingerprint is returned, which is equivalent to running `ssh-keygen -lf rsa.pub`. If there is
|
||||
* no public key currently loaded, false is returned.
|
||||
* Example output (md5): "c1:b1:30:29:d7:b8:de:6c:97:77:10:d7:46:41:63:87" (as specified by RFC 4716)
|
||||
*
|
||||
* @access public
|
||||
* @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')
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'OpenSSH', 'savePublicKey');
|
||||
if ($type === false) {
|
||||
return false;
|
||||
}
|
||||
$key = $this->toString('OpenSSH', ['binary' => true]);
|
||||
if ($key === false) {
|
||||
return false;
|
||||
}
|
||||
switch ($algorithm) {
|
||||
case 'sha256':
|
||||
$hash = new Hash('sha256');
|
||||
$base = base64_encode($hash->hash($key));
|
||||
return substr($base, 0, strlen($base) - 1);
|
||||
case 'md5':
|
||||
return substr(chunk_split(md5($key), 2, ':'), 0, -1);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Password Protected Trait for Private Keys
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\Common\Traits;
|
||||
|
||||
/**
|
||||
* Password Protected Trait for Private Keys
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
trait PasswordProtected
|
||||
{
|
||||
/**
|
||||
* Password
|
||||
*
|
||||
* @var string|bool
|
||||
*/
|
||||
private $password = false;
|
||||
|
||||
/**
|
||||
* Sets the password
|
||||
*
|
||||
* Private keys can be encrypted with a password. To unset the password, pass in the empty string or false.
|
||||
* Or rather, pass in $password such that empty($password) && !is_string($password) is true.
|
||||
*
|
||||
* @see self::createKey()
|
||||
* @see self::load()
|
||||
* @access public
|
||||
* @param string|boolean $password
|
||||
*/
|
||||
public function withPassword($password = false)
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->password = $password;
|
||||
return $new;
|
||||
}
|
||||
}
|
518
vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php
vendored
518
vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php
vendored
|
@ -18,7 +18,7 @@
|
|||
* <?php
|
||||
* include 'vendor/autoload.php';
|
||||
*
|
||||
* $des = new \phpseclib3\Crypt\DES('ctr');
|
||||
* $des = new \phpseclib\Crypt\DES();
|
||||
*
|
||||
* $des->setKey('abcdefgh');
|
||||
*
|
||||
|
@ -40,10 +40,7 @@
|
|||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt;
|
||||
|
||||
use phpseclib3\Crypt\Common\BlockCipher;
|
||||
use phpseclib3\Exception\BadModeException;
|
||||
namespace phpseclib\Crypt;
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of DES.
|
||||
|
@ -52,87 +49,85 @@ use phpseclib3\Exception\BadModeException;
|
|||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class DES extends BlockCipher
|
||||
class DES extends Base
|
||||
{
|
||||
/**#@+
|
||||
* @access private
|
||||
* @see \phpseclib\Crypt\DES::_setupKey()
|
||||
* @see \phpseclib\Crypt\DES::_processBlock()
|
||||
*/
|
||||
/**
|
||||
* Contains $keys[self::ENCRYPT]
|
||||
*
|
||||
* @access private
|
||||
* @see \phpseclib3\Crypt\DES::setupKey()
|
||||
* @see \phpseclib3\Crypt\DES::processBlock()
|
||||
*/
|
||||
const ENCRYPT = 0;
|
||||
/**
|
||||
* Contains $keys[self::DECRYPT]
|
||||
*
|
||||
* @access private
|
||||
* @see \phpseclib3\Crypt\DES::setupKey()
|
||||
* @see \phpseclib3\Crypt\DES::processBlock()
|
||||
*/
|
||||
const DECRYPT = 1;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Block Length of the cipher
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::block_size
|
||||
* @see \phpseclib\Crypt\Base::block_size
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
protected $block_size = 8;
|
||||
var $block_size = 8;
|
||||
|
||||
/**
|
||||
* Key Length (in bytes)
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::setKeyLength()
|
||||
* @see \phpseclib\Crypt\Base::setKeyLength()
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
protected $key_length = 8;
|
||||
var $key_length = 8;
|
||||
|
||||
/**
|
||||
* The mcrypt specific name of the cipher
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::cipher_name_mcrypt
|
||||
* @see \phpseclib\Crypt\Base::cipher_name_mcrypt
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $cipher_name_mcrypt = 'des';
|
||||
var $cipher_name_mcrypt = 'des';
|
||||
|
||||
/**
|
||||
* The OpenSSL names of the cipher / modes
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::openssl_mode_names
|
||||
* @see \phpseclib\Crypt\Base::openssl_mode_names
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected $openssl_mode_names = [
|
||||
var $openssl_mode_names = array(
|
||||
self::MODE_ECB => 'des-ecb',
|
||||
self::MODE_CBC => 'des-cbc',
|
||||
self::MODE_CFB => 'des-cfb',
|
||||
self::MODE_OFB => 'des-ofb'
|
||||
// self::MODE_CTR is undefined for DES
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Optimizing value while CFB-encrypting
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::cfb_init_len
|
||||
* @see \phpseclib\Crypt\Base::cfb_init_len
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
protected $cfb_init_len = 500;
|
||||
var $cfb_init_len = 500;
|
||||
|
||||
/**
|
||||
* Switch for DES/3DES encryption
|
||||
*
|
||||
* Used only if $engine == self::ENGINE_INTERNAL
|
||||
*
|
||||
* @see self::setupKey()
|
||||
* @see self::processBlock()
|
||||
* @see self::_setupKey()
|
||||
* @see self::_processBlock()
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
protected $des_rounds = 1;
|
||||
var $des_rounds = 1;
|
||||
|
||||
/**
|
||||
* max possible size of $key
|
||||
|
@ -141,16 +136,16 @@ class DES extends BlockCipher
|
|||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $key_length_max = 8;
|
||||
var $key_length_max = 8;
|
||||
|
||||
/**
|
||||
* The Key Schedule
|
||||
*
|
||||
* @see self::setupKey()
|
||||
* @see self::_setupKey()
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $keys;
|
||||
var $keys;
|
||||
|
||||
/**
|
||||
* Shuffle table.
|
||||
|
@ -159,12 +154,12 @@ class DES extends BlockCipher
|
|||
* with each byte containing all bits in the same state as the
|
||||
* corresponding bit in the index value.
|
||||
*
|
||||
* @see self::processBlock()
|
||||
* @see self::setupKey()
|
||||
* @see self::_processBlock()
|
||||
* @see self::_setupKey()
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $shuffle = [
|
||||
var $shuffle = array(
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00", "\x00\x00\x00\x00\x00\x00\x00\xFF",
|
||||
"\x00\x00\x00\x00\x00\x00\xFF\x00", "\x00\x00\x00\x00\x00\x00\xFF\xFF",
|
||||
"\x00\x00\x00\x00\x00\xFF\x00\x00", "\x00\x00\x00\x00\x00\xFF\x00\xFF",
|
||||
|
@ -293,7 +288,7 @@ class DES extends BlockCipher
|
|||
"\xFF\xFF\xFF\xFF\xFF\x00\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF",
|
||||
"\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF",
|
||||
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* IP mapping helper table.
|
||||
|
@ -303,7 +298,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $ipmap = [
|
||||
var $ipmap = array(
|
||||
0x00, 0x10, 0x01, 0x11, 0x20, 0x30, 0x21, 0x31,
|
||||
0x02, 0x12, 0x03, 0x13, 0x22, 0x32, 0x23, 0x33,
|
||||
0x40, 0x50, 0x41, 0x51, 0x60, 0x70, 0x61, 0x71,
|
||||
|
@ -336,7 +331,7 @@ class DES extends BlockCipher
|
|||
0x8E, 0x9E, 0x8F, 0x9F, 0xAE, 0xBE, 0xAF, 0xBF,
|
||||
0xCC, 0xDC, 0xCD, 0xDD, 0xEC, 0xFC, 0xED, 0xFD,
|
||||
0xCE, 0xDE, 0xCF, 0xDF, 0xEE, 0xFE, 0xEF, 0xFF
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Inverse IP mapping helper table.
|
||||
|
@ -345,7 +340,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $invipmap = [
|
||||
var $invipmap = array(
|
||||
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
|
||||
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
||||
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
|
||||
|
@ -378,7 +373,7 @@ class DES extends BlockCipher
|
|||
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
||||
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
|
||||
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box1
|
||||
|
@ -389,7 +384,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox1 = [
|
||||
var $sbox1 = array(
|
||||
0x00808200, 0x00000000, 0x00008000, 0x00808202,
|
||||
0x00808002, 0x00008202, 0x00000002, 0x00008000,
|
||||
0x00000200, 0x00808200, 0x00808202, 0x00000200,
|
||||
|
@ -406,7 +401,7 @@ class DES extends BlockCipher
|
|||
0x00800002, 0x00000202, 0x00008202, 0x00808200,
|
||||
0x00000202, 0x00800200, 0x00800200, 0x00000000,
|
||||
0x00008002, 0x00008200, 0x00000000, 0x00808002
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box2
|
||||
|
@ -414,7 +409,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox2 = [
|
||||
var $sbox2 = array(
|
||||
0x40084010, 0x40004000, 0x00004000, 0x00084010,
|
||||
0x00080000, 0x00000010, 0x40080010, 0x40004010,
|
||||
0x40000010, 0x40084010, 0x40084000, 0x40000000,
|
||||
|
@ -431,7 +426,7 @@ class DES extends BlockCipher
|
|||
0x00080010, 0x40004010, 0x40000010, 0x00080010,
|
||||
0x00084000, 0x00000000, 0x40004000, 0x00004010,
|
||||
0x40000000, 0x40080010, 0x40084010, 0x00084000
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box3
|
||||
|
@ -439,7 +434,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox3 = [
|
||||
var $sbox3 = array(
|
||||
0x00000104, 0x04010100, 0x00000000, 0x04010004,
|
||||
0x04000100, 0x00000000, 0x00010104, 0x04000100,
|
||||
0x00010004, 0x04000004, 0x04000004, 0x00010000,
|
||||
|
@ -456,7 +451,7 @@ class DES extends BlockCipher
|
|||
0x00000004, 0x00010104, 0x00010100, 0x04000004,
|
||||
0x04010000, 0x04000104, 0x00000104, 0x04010000,
|
||||
0x00010104, 0x00000004, 0x04010004, 0x00010100
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box4
|
||||
|
@ -464,7 +459,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox4 = [
|
||||
var $sbox4 = array(
|
||||
0x80401000, 0x80001040, 0x80001040, 0x00000040,
|
||||
0x00401040, 0x80400040, 0x80400000, 0x80001000,
|
||||
0x00000000, 0x00401000, 0x00401000, 0x80401040,
|
||||
|
@ -481,7 +476,7 @@ class DES extends BlockCipher
|
|||
0x80400000, 0x80001000, 0x00401040, 0x80400040,
|
||||
0x80001000, 0x00001040, 0x00400000, 0x80401000,
|
||||
0x00000040, 0x00400000, 0x00001000, 0x00401040
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box5
|
||||
|
@ -489,7 +484,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox5 = [
|
||||
var $sbox5 = array(
|
||||
0x00000080, 0x01040080, 0x01040000, 0x21000080,
|
||||
0x00040000, 0x00000080, 0x20000000, 0x01040000,
|
||||
0x20040080, 0x00040000, 0x01000080, 0x20040080,
|
||||
|
@ -506,7 +501,7 @@ class DES extends BlockCipher
|
|||
0x01040000, 0x00000000, 0x20040000, 0x21000000,
|
||||
0x00040080, 0x01000080, 0x20000080, 0x00040000,
|
||||
0x00000000, 0x20040000, 0x01040080, 0x20000080
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box6
|
||||
|
@ -514,7 +509,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox6 = [
|
||||
var $sbox6 = array(
|
||||
0x10000008, 0x10200000, 0x00002000, 0x10202008,
|
||||
0x10200000, 0x00000008, 0x10202008, 0x00200000,
|
||||
0x10002000, 0x00202008, 0x00200000, 0x10000008,
|
||||
|
@ -531,7 +526,7 @@ class DES extends BlockCipher
|
|||
0x00000008, 0x00002000, 0x10200000, 0x00202008,
|
||||
0x00002000, 0x00200008, 0x10002008, 0x00000000,
|
||||
0x10202000, 0x10000000, 0x00200008, 0x10002008
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box7
|
||||
|
@ -539,7 +534,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox7 = [
|
||||
var $sbox7 = array(
|
||||
0x00100000, 0x02100001, 0x02000401, 0x00000000,
|
||||
0x00000400, 0x02000401, 0x00100401, 0x02100400,
|
||||
0x02100401, 0x00100000, 0x00000000, 0x02000001,
|
||||
|
@ -556,7 +551,7 @@ class DES extends BlockCipher
|
|||
0x00100400, 0x00000000, 0x00000001, 0x02100401,
|
||||
0x00000000, 0x00100401, 0x02100000, 0x00000400,
|
||||
0x02000001, 0x02000400, 0x00000400, 0x00100001
|
||||
];
|
||||
);
|
||||
|
||||
/**
|
||||
* Pre-permuted S-box8
|
||||
|
@ -564,7 +559,7 @@ class DES extends BlockCipher
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $sbox8 = [
|
||||
var $sbox8 = array(
|
||||
0x08000820, 0x00000800, 0x00020000, 0x08020820,
|
||||
0x08000000, 0x08000820, 0x00000020, 0x08000000,
|
||||
0x00020020, 0x08020000, 0x08020820, 0x00020800,
|
||||
|
@ -581,61 +576,51 @@ class DES extends BlockCipher
|
|||
0x08020000, 0x08000800, 0x08000820, 0x00000000,
|
||||
0x08020820, 0x00020800, 0x00020800, 0x00000820,
|
||||
0x00000820, 0x00020020, 0x08000000, 0x08020800
|
||||
];
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
* @param string $mode
|
||||
* @access public
|
||||
* @throws BadModeException if an invalid / unsupported mode is provided
|
||||
*/
|
||||
public function __construct($mode)
|
||||
{
|
||||
parent::__construct($mode);
|
||||
|
||||
if ($this->mode == self::MODE_STREAM) {
|
||||
throw new BadModeException('Block ciphers cannot be ran in stream mode');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test for engine validity
|
||||
*
|
||||
* This is mainly just a wrapper to set things up for \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
|
||||
* This is mainly just a wrapper to set things up for \phpseclib\Crypt\Base::isValidEngine()
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::isValidEngine()
|
||||
* @see \phpseclib\Crypt\Base::isValidEngine()
|
||||
* @param int $engine
|
||||
* @access protected
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidEngineHelper($engine)
|
||||
function isValidEngine($engine)
|
||||
{
|
||||
if ($this->key_length_max == 8) {
|
||||
if ($engine == self::ENGINE_OPENSSL) {
|
||||
self::$cipher_name_openssl_ecb = 'des-ecb';
|
||||
$this->cipher_name_openssl = 'des-' . $this->openssl_translate_mode();
|
||||
$this->cipher_name_openssl_ecb = 'des-ecb';
|
||||
$this->cipher_name_openssl = 'des-' . $this->_openssl_translate_mode();
|
||||
}
|
||||
}
|
||||
|
||||
return parent::isValidEngineHelper($engine);
|
||||
return parent::isValidEngine($engine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the key.
|
||||
*
|
||||
* Keys must be 64-bits long or 8 bytes long.
|
||||
* Keys can be of any length. DES, itself, uses 64-bit keys (eg. strlen($key) == 8), however, we
|
||||
* only use the first eight, if $key has more then eight characters in it, and pad $key with the
|
||||
* null byte if it is less then eight characters long.
|
||||
*
|
||||
* DES also requires that every eighth bit be a parity bit, however, we'll ignore that.
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::setKey()
|
||||
* If the key is not explicitly set, it'll be assumed to be all zero's.
|
||||
*
|
||||
* @see \phpseclib\Crypt\Base::setKey()
|
||||
* @access public
|
||||
* @param string $key
|
||||
*/
|
||||
public function setKey($key)
|
||||
function setKey($key)
|
||||
{
|
||||
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');
|
||||
// We check/cut here only up to max length of the key.
|
||||
// Key padding to the proper length will be done in _setupKey()
|
||||
if (strlen($key) > $this->key_length_max) {
|
||||
$key = substr($key, 0, $this->key_length_max);
|
||||
}
|
||||
|
||||
// Sets the key
|
||||
|
@ -645,31 +630,31 @@ class DES extends BlockCipher
|
|||
/**
|
||||
* Encrypts a block
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::encryptBlock()
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
|
||||
* @see \phpseclib\Crypt\Base::_encryptBlock()
|
||||
* @see \phpseclib\Crypt\Base::encrypt()
|
||||
* @see self::encrypt()
|
||||
* @access private
|
||||
* @param string $in
|
||||
* @return string
|
||||
*/
|
||||
protected function encryptBlock($in)
|
||||
function _encryptBlock($in)
|
||||
{
|
||||
return $this->processBlock($in, self::ENCRYPT);
|
||||
return $this->_processBlock($in, self::ENCRYPT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a block
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::decryptBlock()
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
|
||||
* @see \phpseclib\Crypt\Base::_decryptBlock()
|
||||
* @see \phpseclib\Crypt\Base::decrypt()
|
||||
* @see self::decrypt()
|
||||
* @access private
|
||||
* @param string $in
|
||||
* @return string
|
||||
*/
|
||||
protected function decryptBlock($in)
|
||||
function _decryptBlock($in)
|
||||
{
|
||||
return $this->processBlock($in, self::DECRYPT);
|
||||
return $this->_processBlock($in, self::DECRYPT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -679,29 +664,29 @@ 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()
|
||||
* @see self::_encryptBlock()
|
||||
* @see self::_decryptBlock()
|
||||
* @access private
|
||||
* @param string $block
|
||||
* @param int $mode
|
||||
* @return string
|
||||
*/
|
||||
private function processBlock($block, $mode)
|
||||
function _processBlock($block, $mode)
|
||||
{
|
||||
static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip;
|
||||
if (!$sbox1) {
|
||||
$sbox1 = array_map('intval', self::$sbox1);
|
||||
$sbox2 = array_map('intval', self::$sbox2);
|
||||
$sbox3 = array_map('intval', self::$sbox3);
|
||||
$sbox4 = array_map('intval', self::$sbox4);
|
||||
$sbox5 = array_map('intval', self::$sbox5);
|
||||
$sbox6 = array_map('intval', self::$sbox6);
|
||||
$sbox7 = array_map('intval', self::$sbox7);
|
||||
$sbox8 = array_map('intval', self::$sbox8);
|
||||
$sbox1 = array_map("intval", $this->sbox1);
|
||||
$sbox2 = array_map("intval", $this->sbox2);
|
||||
$sbox3 = array_map("intval", $this->sbox3);
|
||||
$sbox4 = array_map("intval", $this->sbox4);
|
||||
$sbox5 = array_map("intval", $this->sbox5);
|
||||
$sbox6 = array_map("intval", $this->sbox6);
|
||||
$sbox7 = array_map("intval", $this->sbox7);
|
||||
$sbox8 = array_map("intval", $this->sbox8);
|
||||
/* Merge $shuffle with $[inv]ipmap */
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
$shuffleip[] = self::$shuffle[self::$ipmap[$i]];
|
||||
$shuffleinvip[] = self::$shuffle[self::$invipmap[$i]];
|
||||
$shuffleip[] = $this->shuffle[$this->ipmap[$i]];
|
||||
$shuffleinvip[] = $this->shuffle[$this->invipmap[$i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -710,7 +695,7 @@ class DES extends BlockCipher
|
|||
|
||||
// Do the initial IP permutation.
|
||||
$t = unpack('Nl/Nr', $block);
|
||||
list($l, $r) = [$t['l'], $t['r']];
|
||||
list($l, $r) = array($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") |
|
||||
|
@ -722,7 +707,7 @@ class DES extends BlockCipher
|
|||
|
||||
// Extract L0 and R0.
|
||||
$t = unpack('Nl/Nr', $block);
|
||||
list($l, $r) = [$t['l'], $t['r']];
|
||||
list($l, $r) = array($t['l'], $t['r']);
|
||||
|
||||
for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) {
|
||||
// Perform the 16 steps.
|
||||
|
@ -764,22 +749,22 @@ class DES extends BlockCipher
|
|||
/**
|
||||
* Creates the key schedule
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::setupKey()
|
||||
* @see \phpseclib\Crypt\Base::_setupKey()
|
||||
* @access private
|
||||
*/
|
||||
protected function setupKey()
|
||||
function _setupKey()
|
||||
{
|
||||
if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->des_rounds === $this->kl['des_rounds']) {
|
||||
// already expanded
|
||||
return;
|
||||
}
|
||||
$this->kl = ['key' => $this->key, 'des_rounds' => $this->des_rounds];
|
||||
$this->kl = array('key' => $this->key, 'des_rounds' => $this->des_rounds);
|
||||
|
||||
static $shifts = [ // number of key bits shifted per round
|
||||
static $shifts = array( // number of key bits shifted per round
|
||||
1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
|
||||
];
|
||||
);
|
||||
|
||||
static $pc1map = [
|
||||
static $pc1map = array(
|
||||
0x00, 0x00, 0x08, 0x08, 0x04, 0x04, 0x0C, 0x0C,
|
||||
0x02, 0x02, 0x0A, 0x0A, 0x06, 0x06, 0x0E, 0x0E,
|
||||
0x10, 0x10, 0x18, 0x18, 0x14, 0x14, 0x1C, 0x1C,
|
||||
|
@ -812,16 +797,16 @@ class DES extends BlockCipher
|
|||
0xE2, 0xE2, 0xEA, 0xEA, 0xE6, 0xE6, 0xEE, 0xEE,
|
||||
0xF0, 0xF0, 0xF8, 0xF8, 0xF4, 0xF4, 0xFC, 0xFC,
|
||||
0xF2, 0xF2, 0xFA, 0xFA, 0xF6, 0xF6, 0xFE, 0xFE
|
||||
];
|
||||
);
|
||||
|
||||
// Mapping tables for the PC-2 transformation.
|
||||
static $pc2mapc1 = [
|
||||
static $pc2mapc1 = array(
|
||||
0x00000000, 0x00000400, 0x00200000, 0x00200400,
|
||||
0x00000001, 0x00000401, 0x00200001, 0x00200401,
|
||||
0x02000000, 0x02000400, 0x02200000, 0x02200400,
|
||||
0x02000001, 0x02000401, 0x02200001, 0x02200401
|
||||
];
|
||||
static $pc2mapc2 = [
|
||||
);
|
||||
static $pc2mapc2 = array(
|
||||
0x00000000, 0x00000800, 0x08000000, 0x08000800,
|
||||
0x00010000, 0x00010800, 0x08010000, 0x08010800,
|
||||
0x00000000, 0x00000800, 0x08000000, 0x08000800,
|
||||
|
@ -886,8 +871,8 @@ class DES extends BlockCipher
|
|||
0x01050110, 0x01050910, 0x09050110, 0x09050910,
|
||||
0x01040110, 0x01040910, 0x09040110, 0x09040910,
|
||||
0x01050110, 0x01050910, 0x09050110, 0x09050910
|
||||
];
|
||||
static $pc2mapc3 = [
|
||||
);
|
||||
static $pc2mapc3 = array(
|
||||
0x00000000, 0x00000004, 0x00001000, 0x00001004,
|
||||
0x00000000, 0x00000004, 0x00001000, 0x00001004,
|
||||
0x10000000, 0x10000004, 0x10001000, 0x10001004,
|
||||
|
@ -952,8 +937,8 @@ class DES extends BlockCipher
|
|||
0x20080022, 0x20080026, 0x20081022, 0x20081026,
|
||||
0x30080022, 0x30080026, 0x30081022, 0x30081026,
|
||||
0x30080022, 0x30080026, 0x30081022, 0x30081026
|
||||
];
|
||||
static $pc2mapc4 = [
|
||||
);
|
||||
static $pc2mapc4 = array(
|
||||
0x00000000, 0x00100000, 0x00000008, 0x00100008,
|
||||
0x00000200, 0x00100200, 0x00000208, 0x00100208,
|
||||
0x00000000, 0x00100000, 0x00000008, 0x00100008,
|
||||
|
@ -1018,14 +1003,14 @@ class DES extends BlockCipher
|
|||
0x04022200, 0x04122200, 0x04022208, 0x04122208,
|
||||
0x04022000, 0x04122000, 0x04022008, 0x04122008,
|
||||
0x04022200, 0x04122200, 0x04022208, 0x04122208
|
||||
];
|
||||
static $pc2mapd1 = [
|
||||
);
|
||||
static $pc2mapd1 = array(
|
||||
0x00000000, 0x00000001, 0x08000000, 0x08000001,
|
||||
0x00200000, 0x00200001, 0x08200000, 0x08200001,
|
||||
0x00000002, 0x00000003, 0x08000002, 0x08000003,
|
||||
0x00200002, 0x00200003, 0x08200002, 0x08200003
|
||||
];
|
||||
static $pc2mapd2 = [
|
||||
);
|
||||
static $pc2mapd2 = array(
|
||||
0x00000000, 0x00100000, 0x00000800, 0x00100800,
|
||||
0x00000000, 0x00100000, 0x00000800, 0x00100800,
|
||||
0x04000000, 0x04100000, 0x04000800, 0x04100800,
|
||||
|
@ -1090,8 +1075,8 @@ class DES extends BlockCipher
|
|||
0x00020204, 0x00120204, 0x00020A04, 0x00120A04,
|
||||
0x04020204, 0x04120204, 0x04020A04, 0x04120A04,
|
||||
0x04020204, 0x04120204, 0x04020A04, 0x04120A04
|
||||
];
|
||||
static $pc2mapd3 = [
|
||||
);
|
||||
static $pc2mapd3 = array(
|
||||
0x00000000, 0x00010000, 0x02000000, 0x02010000,
|
||||
0x00000020, 0x00010020, 0x02000020, 0x02010020,
|
||||
0x00040000, 0x00050000, 0x02040000, 0x02050000,
|
||||
|
@ -1156,8 +1141,8 @@ class DES extends BlockCipher
|
|||
0x20002030, 0x20012030, 0x22002030, 0x22012030,
|
||||
0x20042010, 0x20052010, 0x22042010, 0x22052010,
|
||||
0x20042030, 0x20052030, 0x22042030, 0x22052030
|
||||
];
|
||||
static $pc2mapd4 = [
|
||||
);
|
||||
static $pc2mapd4 = array(
|
||||
0x00000000, 0x00000400, 0x01000000, 0x01000400,
|
||||
0x00000000, 0x00000400, 0x01000000, 0x01000400,
|
||||
0x00000100, 0x00000500, 0x01000100, 0x01000500,
|
||||
|
@ -1222,32 +1207,32 @@ class DES extends BlockCipher
|
|||
0x10081008, 0x10081408, 0x11081008, 0x11081408,
|
||||
0x10081108, 0x10081508, 0x11081108, 0x11081508,
|
||||
0x10081108, 0x10081508, 0x11081108, 0x11081508
|
||||
];
|
||||
);
|
||||
|
||||
$keys = [];
|
||||
$keys = array();
|
||||
for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) {
|
||||
// pad the key and remove extra characters as appropriate.
|
||||
$key = str_pad(substr($this->key, $des_round * 8, 8), 8, "\0");
|
||||
|
||||
// Perform the PC/1 transformation and compute C and D.
|
||||
$t = unpack('Nl/Nr', $key);
|
||||
list($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") |
|
||||
(self::$shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") |
|
||||
(self::$shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") |
|
||||
(self::$shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") |
|
||||
(self::$shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") |
|
||||
(self::$shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00");
|
||||
list($l, $r) = array($t['l'], $t['r']);
|
||||
$key = ($this->shuffle[$pc1map[ $r & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") |
|
||||
($this->shuffle[$pc1map[($r >> 8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") |
|
||||
($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") |
|
||||
($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") |
|
||||
($this->shuffle[$pc1map[ $l & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") |
|
||||
($this->shuffle[$pc1map[($l >> 8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") |
|
||||
($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") |
|
||||
($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00");
|
||||
$key = unpack('Nc/Nd', $key);
|
||||
$c = ( $key['c'] >> 4) & 0x0FFFFFFF;
|
||||
$d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F);
|
||||
|
||||
$keys[$des_round] = [
|
||||
self::ENCRYPT => [],
|
||||
$keys[$des_round] = array(
|
||||
self::ENCRYPT => array(),
|
||||
self::DECRYPT => array_fill(0, 32, 0)
|
||||
];
|
||||
);
|
||||
for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) {
|
||||
$c <<= $shifts[$i];
|
||||
$c = ($c | ($c >> 28)) & 0x0FFFFFFF;
|
||||
|
@ -1274,7 +1259,7 @@ class DES extends BlockCipher
|
|||
|
||||
switch ($this->des_rounds) {
|
||||
case 3: // 3DES keys
|
||||
$this->keys = [
|
||||
$this->keys = array(
|
||||
self::ENCRYPT => array_merge(
|
||||
$keys[0][self::ENCRYPT],
|
||||
$keys[1][self::DECRYPT],
|
||||
|
@ -1285,127 +1270,174 @@ class DES extends BlockCipher
|
|||
$keys[1][self::ENCRYPT],
|
||||
$keys[0][self::DECRYPT]
|
||||
)
|
||||
];
|
||||
);
|
||||
break;
|
||||
// case 1: // DES keys
|
||||
default:
|
||||
$this->keys = [
|
||||
$this->keys = array(
|
||||
self::ENCRYPT => $keys[0][self::ENCRYPT],
|
||||
self::DECRYPT => $keys[0][self::DECRYPT]
|
||||
];
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the performance-optimized function for de/encrypt()
|
||||
*
|
||||
* @see \phpseclib3\Crypt\Common\SymmetricKey::setupInlineCrypt()
|
||||
* @see \phpseclib\Crypt\Base::_setupInlineCrypt()
|
||||
* @access private
|
||||
*/
|
||||
protected function setupInlineCrypt()
|
||||
function _setupInlineCrypt()
|
||||
{
|
||||
$lambda_functions =& self::_getLambdaFunctions();
|
||||
|
||||
// Engine configuration for:
|
||||
// - DES ($des_rounds == 1) or
|
||||
// - 3DES ($des_rounds == 3)
|
||||
$des_rounds = $this->des_rounds;
|
||||
|
||||
$init_crypt = 'static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip;
|
||||
if (!$sbox1) {
|
||||
$sbox1 = array_map("intval", self::$sbox1);
|
||||
$sbox2 = array_map("intval", self::$sbox2);
|
||||
$sbox3 = array_map("intval", self::$sbox3);
|
||||
$sbox4 = array_map("intval", self::$sbox4);
|
||||
$sbox5 = array_map("intval", self::$sbox5);
|
||||
$sbox6 = array_map("intval", self::$sbox6);
|
||||
$sbox7 = array_map("intval", self::$sbox7);
|
||||
$sbox8 = array_map("intval", self::$sbox8);'
|
||||
/* Merge $shuffle with $[inv]ipmap */ . '
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
$shuffleip[] = self::$shuffle[self::$ipmap[$i]];
|
||||
$shuffleinvip[] = self::$shuffle[self::$invipmap[$i]];
|
||||
}
|
||||
}
|
||||
';
|
||||
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
|
||||
// (Currently, for DES, one generated $lambda_function cost on php5.5@32bit ~135kb unfreeable mem and ~230kb on php5.5@64bit)
|
||||
// (Currently, for TripleDES, one generated $lambda_function cost on php5.5@32bit ~240kb unfreeable mem and ~340kb on php5.5@64bit)
|
||||
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one
|
||||
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 );
|
||||
|
||||
$k = [
|
||||
self::ENCRYPT => $this->keys[self::ENCRYPT],
|
||||
self::DECRYPT => $this->keys[self::DECRYPT]
|
||||
];
|
||||
$init_encrypt = '';
|
||||
$init_decrypt = '';
|
||||
|
||||
// Creating code for en- and decryption.
|
||||
$crypt_block = [];
|
||||
foreach ([self::ENCRYPT, self::DECRYPT] as $c) {
|
||||
/* Do the initial IP permutation. */
|
||||
$crypt_block[$c] = '
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
$in = unpack("N*",
|
||||
($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") |
|
||||
($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
|
||||
($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
|
||||
($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
|
||||
($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
|
||||
($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01")
|
||||
);
|
||||
' . /* Extract L0 and R0 */ '
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
';
|
||||
|
||||
$l = '$l';
|
||||
$r = '$r';
|
||||
|
||||
// Perform DES or 3DES.
|
||||
for ($ki = -1, $des_round = 0; $des_round < $des_rounds; ++$des_round) {
|
||||
// Perform the 16 steps.
|
||||
for ($i = 0; $i < 16; ++$i) {
|
||||
// start of "the Feistel (F) function" - see the following URL:
|
||||
// http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png
|
||||
// Merge key schedule.
|
||||
$crypt_block[$c].= '
|
||||
$b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . ';
|
||||
$b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' .
|
||||
/* S-box indexing. */
|
||||
$l . ' = $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] ^ ' . $l . ';
|
||||
';
|
||||
// end of "the Feistel (F) function"
|
||||
|
||||
// swap L & R
|
||||
list($l, $r) = [$r, $l];
|
||||
}
|
||||
list($l, $r) = [$r, $l];
|
||||
}
|
||||
|
||||
// Perform the inverse IP permutation.
|
||||
$crypt_block[$c].= '$in =
|
||||
($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
|
||||
($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
|
||||
($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
|
||||
($shuffleinvip[($r >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
|
||||
($shuffleinvip[($l >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
|
||||
($shuffleinvip[($r >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
|
||||
($shuffleinvip[ $l & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
|
||||
($shuffleinvip[ $r & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01");
|
||||
';
|
||||
// Generation of a unique hash for our generated code
|
||||
$code_hash = "Crypt_DES, $des_rounds, {$this->mode}";
|
||||
if ($gen_hi_opt_code) {
|
||||
// For hi-optimized code, we create for each combination of
|
||||
// $mode, $des_rounds and $this->key its own encrypt/decrypt function.
|
||||
// After max 10 hi-optimized functions, we create generic
|
||||
// (still very fast.. but not ultra) functions for each $mode/$des_rounds
|
||||
// Currently 2 * 5 generic functions will be then max. possible.
|
||||
$code_hash = str_pad($code_hash, 32) . $this->_hashInlineCryptFunction($this->key);
|
||||
}
|
||||
|
||||
// Creates the inline-crypt function
|
||||
$this->inline_crypt = $this->createInlineCryptFunction(
|
||||
[
|
||||
'init_crypt' => $init_crypt,
|
||||
'init_encrypt' => $init_encrypt,
|
||||
'init_decrypt' => $init_decrypt,
|
||||
'encrypt_block' => $crypt_block[self::ENCRYPT],
|
||||
'decrypt_block' => $crypt_block[self::DECRYPT]
|
||||
]
|
||||
);
|
||||
// Is there a re-usable $lambda_functions in there? If not, we have to create it.
|
||||
if (!isset($lambda_functions[$code_hash])) {
|
||||
// Init code for both, encrypt and decrypt.
|
||||
$init_crypt = 'static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip;
|
||||
if (!$sbox1) {
|
||||
$sbox1 = array_map("intval", $self->sbox1);
|
||||
$sbox2 = array_map("intval", $self->sbox2);
|
||||
$sbox3 = array_map("intval", $self->sbox3);
|
||||
$sbox4 = array_map("intval", $self->sbox4);
|
||||
$sbox5 = array_map("intval", $self->sbox5);
|
||||
$sbox6 = array_map("intval", $self->sbox6);
|
||||
$sbox7 = array_map("intval", $self->sbox7);
|
||||
$sbox8 = array_map("intval", $self->sbox8);'
|
||||
/* Merge $shuffle with $[inv]ipmap */ . '
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
$shuffleip[] = $self->shuffle[$self->ipmap[$i]];
|
||||
$shuffleinvip[] = $self->shuffle[$self->invipmap[$i]];
|
||||
}
|
||||
}
|
||||
';
|
||||
|
||||
switch (true) {
|
||||
case $gen_hi_opt_code:
|
||||
// In Hi-optimized code mode, we use our [3]DES key schedule as hardcoded integers.
|
||||
// No futher initialisation of the $keys schedule is necessary.
|
||||
// That is the extra performance boost.
|
||||
$k = array(
|
||||
self::ENCRYPT => $this->keys[self::ENCRYPT],
|
||||
self::DECRYPT => $this->keys[self::DECRYPT]
|
||||
);
|
||||
$init_encrypt = '';
|
||||
$init_decrypt = '';
|
||||
break;
|
||||
default:
|
||||
// In generic optimized code mode, we have to use, as the best compromise [currently],
|
||||
// our key schedule as $ke/$kd arrays. (with hardcoded indexes...)
|
||||
$k = array(
|
||||
self::ENCRYPT => array(),
|
||||
self::DECRYPT => array()
|
||||
);
|
||||
for ($i = 0, $c = count($this->keys[self::ENCRYPT]); $i < $c; ++$i) {
|
||||
$k[self::ENCRYPT][$i] = '$ke[' . $i . ']';
|
||||
$k[self::DECRYPT][$i] = '$kd[' . $i . ']';
|
||||
}
|
||||
$init_encrypt = '$ke = $self->keys[$self::ENCRYPT];';
|
||||
$init_decrypt = '$kd = $self->keys[$self::DECRYPT];';
|
||||
break;
|
||||
}
|
||||
|
||||
// Creating code for en- and decryption.
|
||||
$crypt_block = array();
|
||||
foreach (array(self::ENCRYPT, self::DECRYPT) as $c) {
|
||||
/* Do the initial IP permutation. */
|
||||
$crypt_block[$c] = '
|
||||
$in = unpack("N*", $in);
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
$in = unpack("N*",
|
||||
($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") |
|
||||
($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
|
||||
($shuffleip[ $l & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
|
||||
($shuffleip[($l >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
|
||||
($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
|
||||
($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01")
|
||||
);
|
||||
' . /* Extract L0 and R0 */ '
|
||||
$l = $in[1];
|
||||
$r = $in[2];
|
||||
';
|
||||
|
||||
$l = '$l';
|
||||
$r = '$r';
|
||||
|
||||
// Perform DES or 3DES.
|
||||
for ($ki = -1, $des_round = 0; $des_round < $des_rounds; ++$des_round) {
|
||||
// Perform the 16 steps.
|
||||
for ($i = 0; $i < 16; ++$i) {
|
||||
// start of "the Feistel (F) function" - see the following URL:
|
||||
// http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png
|
||||
// Merge key schedule.
|
||||
$crypt_block[$c].= '
|
||||
$b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . ';
|
||||
$b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' .
|
||||
/* S-box indexing. */
|
||||
$l . ' = $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] ^ ' . $l . ';
|
||||
';
|
||||
// end of "the Feistel (F) function"
|
||||
|
||||
// swap L & R
|
||||
list($l, $r) = array($r, $l);
|
||||
}
|
||||
list($l, $r) = array($r, $l);
|
||||
}
|
||||
|
||||
// Perform the inverse IP permutation.
|
||||
$crypt_block[$c].= '$in =
|
||||
($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
|
||||
($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
|
||||
($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
|
||||
($shuffleinvip[($r >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
|
||||
($shuffleinvip[($l >> 8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
|
||||
($shuffleinvip[($r >> 8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
|
||||
($shuffleinvip[ $l & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
|
||||
($shuffleinvip[ $r & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01");
|
||||
';
|
||||
}
|
||||
|
||||
// Creates the inline-crypt function
|
||||
$lambda_functions[$code_hash] = $this->_createInlineCryptFunction(
|
||||
array(
|
||||
'init_crypt' => $init_crypt,
|
||||
'init_encrypt' => $init_encrypt,
|
||||
'init_decrypt' => $init_decrypt,
|
||||
'encrypt_block' => $crypt_block[self::ENCRYPT],
|
||||
'decrypt_block' => $crypt_block[self::DECRYPT]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Set the inline-crypt function as callback in: $this->inline_crypt
|
||||
$this->inline_crypt = $lambda_functions[$code_hash];
|
||||
}
|
||||
}
|
||||
|
|
400
vendor/phpseclib/phpseclib/phpseclib/Crypt/DH.php
vendored
400
vendor/phpseclib/phpseclib/phpseclib/Crypt/DH.php
vendored
|
@ -1,400 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pure-PHP (EC)DH implementation
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Here's an example of how to compute a shared secret with this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include 'vendor/autoload.php';
|
||||
*
|
||||
* $ourPrivate = \phpseclib3\Crypt\DH::createKey();
|
||||
* $secret = DH::computeSecret($ourPrivate, $theirPublic);
|
||||
*
|
||||
* ?>
|
||||
* </code>
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt;
|
||||
|
||||
use phpseclib3\Exception\NoKeyLoadedException;
|
||||
use phpseclib3\Exception\UnsupportedOperationException;
|
||||
use phpseclib3\Crypt\Common\AsymmetricKey;
|
||||
use phpseclib3\Crypt\DH\PrivateKey;
|
||||
use phpseclib3\Crypt\DH\PublicKey;
|
||||
use phpseclib3\Crypt\DH\Parameters;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
/**
|
||||
* Pure-PHP (EC)DH implementation
|
||||
*
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class DH extends AsymmetricKey
|
||||
{
|
||||
/**
|
||||
* Algorithm Name
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const ALGORITHM = 'DH';
|
||||
|
||||
/**
|
||||
* DH prime
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $prime;
|
||||
|
||||
/**
|
||||
* DH Base
|
||||
*
|
||||
* Prime divisor of p-1
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $base;
|
||||
|
||||
/**
|
||||
* Create DH parameters
|
||||
*
|
||||
* This method is a bit polymorphic. It can take any of the following:
|
||||
* - 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)
|
||||
*
|
||||
* @access public
|
||||
* @return \phpseclib3\Crypt\DH|bool
|
||||
*/
|
||||
public static function createParameters(...$args)
|
||||
{
|
||||
$params = new Parameters;
|
||||
if (count($args) == 2 && $args[0] instanceof BigInteger && $args[1] instanceof BigInteger) {
|
||||
//if (!$args[0]->isPrime()) {
|
||||
// throw new \InvalidArgumentException('The first parameter should be a prime number');
|
||||
//}
|
||||
$params->prime = $args[0];
|
||||
$params->base = $args[1];
|
||||
return $params;
|
||||
} elseif (count($args) == 1 && is_numeric($args[0])) {
|
||||
$params->prime = BigInteger::randomPrime($args[0]);
|
||||
$params->base = new BigInteger(2);
|
||||
return $params;
|
||||
} elseif (count($args) != 1 || !is_string($args[0])) {
|
||||
throw new \InvalidArgumentException('Valid parameters are either: two BigInteger\'s (prime and base), a single integer (the length of the prime; base is assumed to be 2) or a string');
|
||||
}
|
||||
switch ($args[0]) {
|
||||
// see http://tools.ietf.org/html/rfc2409#section-6.2 and
|
||||
// http://tools.ietf.org/html/rfc2412, appendex E
|
||||
case 'diffie-hellman-group1-sha1':
|
||||
$prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' .
|
||||
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' .
|
||||
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' .
|
||||
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF';
|
||||
break;
|
||||
// see http://tools.ietf.org/html/rfc3526#section-3
|
||||
case 'diffie-hellman-group14-sha1': // 2048-bit MODP Group
|
||||
case 'diffie-hellman-group14-sha256':
|
||||
$prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' .
|
||||
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' .
|
||||
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' .
|
||||
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' .
|
||||
'98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' .
|
||||
'9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' .
|
||||
'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' .
|
||||
'3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF';
|
||||
break;
|
||||
// see https://tools.ietf.org/html/rfc3526#section-4
|
||||
case 'diffie-hellman-group15-sha512': // 3072-bit MODP Group
|
||||
$prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' .
|
||||
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' .
|
||||
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' .
|
||||
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' .
|
||||
'98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' .
|
||||
'9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' .
|
||||
'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' .
|
||||
'3995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33' .
|
||||
'A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7' .
|
||||
'ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864' .
|
||||
'D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E2' .
|
||||
'08E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF';
|
||||
break;
|
||||
// see https://tools.ietf.org/html/rfc3526#section-5
|
||||
case 'diffie-hellman-group16-sha512': // 4096-bit MODP Group
|
||||
$prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' .
|
||||
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' .
|
||||
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' .
|
||||
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' .
|
||||
'98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' .
|
||||
'9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' .
|
||||
'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' .
|
||||
'3995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33' .
|
||||
'A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7' .
|
||||
'ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864' .
|
||||
'D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E2' .
|
||||
'08E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7' .
|
||||
'88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8' .
|
||||
'DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2' .
|
||||
'233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9' .
|
||||
'93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199FFFFFFFFFFFFFFFF';
|
||||
break;
|
||||
// see https://tools.ietf.org/html/rfc3526#section-6
|
||||
case 'diffie-hellman-group17-sha512': // 6144-bit MODP Group
|
||||
$prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' .
|
||||
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' .
|
||||
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' .
|
||||
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' .
|
||||
'98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' .
|
||||
'9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' .
|
||||
'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' .
|
||||
'3995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33' .
|
||||
'A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7' .
|
||||
'ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864' .
|
||||
'D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E2' .
|
||||
'08E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7' .
|
||||
'88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8' .
|
||||
'DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2' .
|
||||
'233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9' .
|
||||
'93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C93402849236C3FAB4D27C7026' .
|
||||
'C1D4DCB2602646DEC9751E763DBA37BDF8FF9406AD9E530EE5DB382F413001AE' .
|
||||
'B06A53ED9027D831179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B' .
|
||||
'DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF5983CA01C64B92EC' .
|
||||
'F032EA15D1721D03F482D7CE6E74FEF6D55E702F46980C82B5A84031900B1C9E' .
|
||||
'59E7C97FBEC7E8F323A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA' .
|
||||
'CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE32806A1D58BB7C5DA76' .
|
||||
'F550AA3D8A1FBFF0EB19CCB1A313D55CDA56C9EC2EF29632387FE8D76E3C0468' .
|
||||
'043E8F663F4860EE12BF2D5B0B7474D6E694F91E6DCC4024FFFFFFFFFFFFFFFF';
|
||||
break;
|
||||
// see https://tools.ietf.org/html/rfc3526#section-7
|
||||
case 'diffie-hellman-group18-sha512': // 8192-bit MODP Group
|
||||
$prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' .
|
||||
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' .
|
||||
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' .
|
||||
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' .
|
||||
'98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' .
|
||||
'9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' .
|
||||
'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' .
|
||||
'3995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33' .
|
||||
'A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7' .
|
||||
'ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864' .
|
||||
'D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E2' .
|
||||
'08E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7' .
|
||||
'88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8' .
|
||||
'DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2' .
|
||||
'233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9' .
|
||||
'93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C93402849236C3FAB4D27C7026' .
|
||||
'C1D4DCB2602646DEC9751E763DBA37BDF8FF9406AD9E530EE5DB382F413001AE' .
|
||||
'B06A53ED9027D831179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B' .
|
||||
'DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF5983CA01C64B92EC' .
|
||||
'F032EA15D1721D03F482D7CE6E74FEF6D55E702F46980C82B5A84031900B1C9E' .
|
||||
'59E7C97FBEC7E8F323A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA' .
|
||||
'CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE32806A1D58BB7C5DA76' .
|
||||
'F550AA3D8A1FBFF0EB19CCB1A313D55CDA56C9EC2EF29632387FE8D76E3C0468' .
|
||||
'043E8F663F4860EE12BF2D5B0B7474D6E694F91E6DBE115974A3926F12FEE5E4' .
|
||||
'38777CB6A932DF8CD8BEC4D073B931BA3BC832B68D9DD300741FA7BF8AFC47ED' .
|
||||
'2576F6936BA424663AAB639C5AE4F5683423B4742BF1C978238F16CBE39D652D' .
|
||||
'E3FDB8BEFC848AD922222E04A4037C0713EB57A81A23F0C73473FC646CEA306B' .
|
||||
'4BCBC8862F8385DDFA9D4B7FA2C087E879683303ED5BDD3A062B3CF5B3A278A6' .
|
||||
'6D2A13F83F44F82DDF310EE074AB6A364597E899A0255DC164F31CC50846851D' .
|
||||
'F9AB48195DED7EA1B1D510BD7EE74D73FAF36BC31ECFA268359046F4EB879F92' .
|
||||
'4009438B481C6CD7889A002ED5EE382BC9190DA6FC026E479558E4475677E9AA' .
|
||||
'9E3050E2765694DFC81F56E880B96E7160C980DD98EDD3DFFFFFFFFFFFFFFFFF';
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid named prime provided');
|
||||
}
|
||||
|
||||
$params->prime = new BigInteger($prime, 16);
|
||||
$params->base = new BigInteger(2);
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create public / private key pair.
|
||||
*
|
||||
* The rationale for the second parameter is described in http://tools.ietf.org/html/rfc4419#section-6.2 :
|
||||
*
|
||||
* "To increase the speed of the key exchange, both client and server may
|
||||
* reduce the size of their private exponents. It should be at least
|
||||
* twice as long as the key material that is generated from the shared
|
||||
* secret. For more details, see the paper by van Oorschot and Wiener
|
||||
* [VAN-OORSCHOT]."
|
||||
*
|
||||
* $length is in bits
|
||||
*
|
||||
* @param Parameters $params
|
||||
* @param int $length optional
|
||||
* @access public
|
||||
* @return DH\PrivateKey
|
||||
*/
|
||||
public static function createKey(Parameters $params, $length = 0)
|
||||
{
|
||||
$one = new BigInteger(1);
|
||||
if ($length) {
|
||||
$max = $one->bitwise_leftShift($length);
|
||||
$max = $max->subtract($one);
|
||||
} else {
|
||||
$max = $params->prime->subtract($one);
|
||||
}
|
||||
|
||||
$key = new PrivateKey;
|
||||
$key->prime = $params->prime;
|
||||
$key->base = $params->base;
|
||||
$key->privateKey = BigInteger::randomRange($one, $max);
|
||||
$key->publicKey = $key->base->powMod($key->privateKey, $key->prime);
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute Shared Secret
|
||||
*
|
||||
* @param PrivateKey|EC $private
|
||||
* @param PublicKey|BigInteger|string $public
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public static function computeSecret($private, $public)
|
||||
{
|
||||
if ($private instanceof PrivateKey) { // DH\PrivateKey
|
||||
switch (true) {
|
||||
case $public instanceof PublicKey:
|
||||
if (!$private->prime->equals($public->prime) || !$private->base->equals($public->base)) {
|
||||
throw new \InvalidArgumentException('The public and private key do not share the same prime and / or base numbers');
|
||||
}
|
||||
return $public->publicKey->powMod($private->privateKey, $private->prime)->toBytes(true);
|
||||
case is_string($public):
|
||||
$public = new BigInteger($public, -256);
|
||||
case $public instanceof BigInteger:
|
||||
return $public->powMod($private->privateKey, $private->prime)->toBytes(true);
|
||||
default:
|
||||
throw new \InvalidArgumentException('$public needs to be an instance of DH\PublicKey, a BigInteger or a string');
|
||||
}
|
||||
}
|
||||
|
||||
if ($private instanceof EC\PrivateKey) {
|
||||
switch (true) {
|
||||
case $public instanceof EC\PublicKey:
|
||||
$public = $public->getEncodedCoordinates();
|
||||
case is_string($public):
|
||||
$point = $private->multiply($public);
|
||||
switch ($private->getCurve()) {
|
||||
case 'Curve25519':
|
||||
case 'Curve448':
|
||||
$secret = $point;
|
||||
break;
|
||||
default:
|
||||
// according to https://www.secg.org/sec1-v2.pdf#page=33 only X is returned
|
||||
$secret = substr($point, 1, (strlen($point) - 1) >> 1);
|
||||
}
|
||||
/*
|
||||
if (($secret[0] & "\x80") === "\x80") {
|
||||
$secret = "\0$secret";
|
||||
}
|
||||
*/
|
||||
return $secret;
|
||||
default:
|
||||
throw new \InvalidArgumentException('$public needs to be an instance of EC\PublicKey or a string (an encoded coordinate)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the key
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return AsymmetricKey
|
||||
*/
|
||||
public static function load($key, $password = false)
|
||||
{
|
||||
try {
|
||||
return EC::load($key, $password);
|
||||
} catch (NoKeyLoadedException $e) {}
|
||||
|
||||
return parent::load($key, $password);
|
||||
}
|
||||
|
||||
/**
|
||||
* OnLoad Handler
|
||||
*
|
||||
* @return bool
|
||||
* @access protected
|
||||
* @param array $components
|
||||
*/
|
||||
protected static function onLoad($components)
|
||||
{
|
||||
if (!isset($components['privateKey']) && !isset($components['publicKey'])) {
|
||||
$new = new Parameters;
|
||||
} else {
|
||||
$new = isset($components['privateKey']) ?
|
||||
new PrivateKey :
|
||||
new PublicKey;
|
||||
}
|
||||
|
||||
$new->prime = $components['prime'];
|
||||
$new->base = $components['base'];
|
||||
|
||||
if (isset($components['privateKey'])) {
|
||||
$new->privateKey = $components['privateKey'];
|
||||
}
|
||||
if (isset($components['publicKey'])) {
|
||||
$new->publicKey = $components['publicKey'];
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which hashing function should be used
|
||||
*
|
||||
* @access public
|
||||
* @param string $hash
|
||||
*/
|
||||
public function withHash($hash)
|
||||
{
|
||||
throw new UnsupportedOperationException('DH does not use a hash algorithm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash algorithm currently being used
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getHash()
|
||||
{
|
||||
throw new UnsupportedOperationException('DH does not use a hash algorithm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters
|
||||
*
|
||||
* A public / private key is only returned if the currently loaded "key" contains an x or y
|
||||
* value.
|
||||
*
|
||||
* @see self::getPublicKey()
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters');
|
||||
|
||||
$key = $type::saveParameters($this->prime, $this->base);
|
||||
return self::load($key, 'PKCS1');
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* "PKCS1" Formatted EC Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Processes keys with the following headers:
|
||||
*
|
||||
* -----BEGIN DH PARAMETERS-----
|
||||
*
|
||||
* Technically, PKCS1 is for RSA keys, only, but we're using PKCS1 to describe
|
||||
* DSA, whose format isn't really formally described anywhere, so might as well
|
||||
* use it to describe this, too.
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DH\Formats\Keys;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
|
||||
use phpseclib3\File\ASN1;
|
||||
use phpseclib3\File\ASN1\Maps;
|
||||
|
||||
/**
|
||||
* "PKCS1" Formatted DH Key Handler
|
||||
*
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PKCS1 extends Progenitor
|
||||
{
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
$key = parent::load($key, $password);
|
||||
|
||||
$decoded = ASN1::decodeBER($key);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER');
|
||||
}
|
||||
|
||||
$components = ASN1::asn1map($decoded[0], Maps\DHParameter::MAP);
|
||||
if (!is_array($components)) {
|
||||
throw new \RuntimeException('Unable to perform ASN1 mapping on parameters');
|
||||
}
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert EC parameters to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function saveParameters(BigInteger $prime, BigInteger $base, array $options = [])
|
||||
{
|
||||
$params = [
|
||||
'prime' => $prime,
|
||||
'base' => $base
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\DHParameter::MAP);
|
||||
|
||||
return "-----BEGIN DH PARAMETERS-----\r\n" .
|
||||
chunk_split(base64_encode($params), 64) .
|
||||
"-----END DH PARAMETERS-----\r\n";
|
||||
}
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PKCS#8 Formatted DH Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Processes keys with the following headers:
|
||||
*
|
||||
* -----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
* -----BEGIN PRIVATE KEY-----
|
||||
* -----BEGIN PUBLIC KEY-----
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DH\Formats\Keys;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
|
||||
use phpseclib3\File\ASN1;
|
||||
use phpseclib3\File\ASN1\Maps;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
|
||||
/**
|
||||
* PKCS#8 Formatted DH Key Handler
|
||||
*
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PKCS8 extends Progenitor
|
||||
{
|
||||
/**
|
||||
* OID Name
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const OID_NAME = 'dhKeyAgreement';
|
||||
|
||||
/**
|
||||
* OID Value
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const OID_VALUE = '1.2.840.113549.1.3.1';
|
||||
|
||||
/**
|
||||
* Child OIDs loaded
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
protected static $childOIDsLoaded = false;
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
$isPublic = strpos($key, 'PUBLIC') !== false;
|
||||
|
||||
$key = parent::load($key, $password);
|
||||
|
||||
$type = isset($key['privateKey']) ? 'privateKey' : 'publicKey';
|
||||
|
||||
switch (true) {
|
||||
case !$isPublic && $type == 'publicKey':
|
||||
throw new \UnexpectedValueException('Human readable string claims non-public key but DER encoded string claims public key');
|
||||
case $isPublic && $type == 'privateKey':
|
||||
throw new \UnexpectedValueException('Human readable string claims public key but DER encoded string claims private key');
|
||||
}
|
||||
|
||||
$decoded = ASN1::decodeBER($key[$type . 'Algorithm']['parameters']->element);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER of parameters');
|
||||
}
|
||||
$components = ASN1::asn1map($decoded[0], Maps\DHParameter::MAP);
|
||||
if (!is_array($components)) {
|
||||
throw new \RuntimeException('Unable to perform ASN1 mapping on parameters');
|
||||
}
|
||||
|
||||
$decoded = ASN1::decodeBER($key[$type]);
|
||||
switch (true) {
|
||||
case empty($decoded):
|
||||
case !is_array($decoded):
|
||||
case !isset($decoded[0]['content']):
|
||||
case !$decoded[0]['content'] instanceof BigInteger:
|
||||
throw new \RuntimeException('Unable to decode BER of parameters');
|
||||
}
|
||||
$components[$type] = $decoded[0]['content'];
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @access public
|
||||
* @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 array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $prime, BigInteger $base, BigInteger $privateKey, BigInteger $publicKey, $password = '', array $options = [])
|
||||
{
|
||||
$params = [
|
||||
'prime' => $prime,
|
||||
'base' => $base
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\DHParameter::MAP);
|
||||
$params = new ASN1\Element($params);
|
||||
$key = ASN1::encodeDER($privateKey, ['type' => ASN1::TYPE_INTEGER]);
|
||||
return self::wrapPrivateKey($key, [], $params, $password, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a public key to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @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 = [])
|
||||
{
|
||||
$params = [
|
||||
'prime' => $prime,
|
||||
'base' => $base
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\DHParameter::MAP);
|
||||
$params = new ASN1\Element($params);
|
||||
$key = ASN1::encodeDER($publicKey, ['type' => ASN1::TYPE_INTEGER]);
|
||||
return self::wrapPublicKey($key, $params);
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DH Parameters
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DH;
|
||||
|
||||
use phpseclib3\Crypt\DH;
|
||||
|
||||
/**
|
||||
* DH Parameters
|
||||
*
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class Parameters extends DH
|
||||
{
|
||||
/**
|
||||
* Returns the parameters
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type = 'PKCS1', array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters');
|
||||
|
||||
return $type::saveParameters($this->prime, $this->base, $options);
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DH Private Key
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DH;
|
||||
|
||||
use phpseclib3\Crypt\DH;
|
||||
use phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* DH Private Key
|
||||
*
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class PrivateKey extends DH
|
||||
{
|
||||
use Common\Traits\PasswordProtected;
|
||||
|
||||
/**
|
||||
* Private Key
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $privateKey;
|
||||
|
||||
/**
|
||||
* Public Key
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $publicKey;
|
||||
|
||||
/**
|
||||
* Returns the public key
|
||||
*
|
||||
* @access public
|
||||
* @return DH
|
||||
*/
|
||||
public function getPublicKey()
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS8', 'savePublicKey');
|
||||
|
||||
if (!isset($this->publicKey)) {
|
||||
$this->publicKey = $this->base->powMod($this->privateKey, $this->prime);
|
||||
}
|
||||
|
||||
$key = $type::savePublicKey($this->prime, $this->base, $this->publicKey);
|
||||
|
||||
return DH::loadFormat('PKCS8', $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the private key
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePrivateKey');
|
||||
|
||||
if (!isset($this->publicKey)) {
|
||||
$this->publicKey = $this->base->powMod($this->privateKey, $this->prime);
|
||||
}
|
||||
|
||||
return $type::savePrivateKey($this->prime, $this->base, $this->privateKey, $this->publicKey, $this->password, $options);
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DH Public Key
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DH;
|
||||
|
||||
use phpseclib3\Crypt\DH;
|
||||
use phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* DH Public Key
|
||||
*
|
||||
* @package DH
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class PublicKey extends DH
|
||||
{
|
||||
use Common\Traits\Fingerprint;
|
||||
|
||||
/**
|
||||
* Returns the public key
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePublicKey');
|
||||
|
||||
return $type::savePublicKey($this->prime, $this->base, $this->publicKey, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public key as a BigInteger
|
||||
*
|
||||
* @return \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
public function toBigInteger()
|
||||
{
|
||||
return $this->publicKey;
|
||||
}
|
||||
}
|
344
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA.php
vendored
344
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA.php
vendored
|
@ -1,344 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pure-PHP FIPS 186-4 compliant implementation of DSA.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Here's an example of how to create signatures and verify signatures with this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include 'vendor/autoload.php';
|
||||
*
|
||||
* $private = \phpseclib3\Crypt\DSA::createKey();
|
||||
* $public = $private->getPublicKey();
|
||||
*
|
||||
* $plaintext = 'terrafrost';
|
||||
*
|
||||
* $signature = $private->sign($plaintext);
|
||||
*
|
||||
* echo $public->verify($plaintext, $signature) ? 'verified' : 'unverified';
|
||||
* ?>
|
||||
* </code>
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt;
|
||||
|
||||
use phpseclib3\Crypt\Common\AsymmetricKey;
|
||||
use phpseclib3\Crypt\DSA\PrivateKey;
|
||||
use phpseclib3\Crypt\DSA\PublicKey;
|
||||
use phpseclib3\Crypt\DSA\Parameters;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Exception\InsufficientSetupException;
|
||||
|
||||
/**
|
||||
* Pure-PHP FIPS 186-4 compliant implementation of DSA.
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class DSA extends AsymmetricKey
|
||||
{
|
||||
/**
|
||||
* Algorithm Name
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const ALGORITHM = 'DSA';
|
||||
|
||||
/**
|
||||
* DSA Prime P
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $p;
|
||||
|
||||
/**
|
||||
* DSA Group Order q
|
||||
*
|
||||
* Prime divisor of p-1
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $q;
|
||||
|
||||
/**
|
||||
* DSA Group Generator G
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $g;
|
||||
|
||||
/**
|
||||
* DSA public key value y
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $y;
|
||||
|
||||
/**
|
||||
* Signature Format
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $sigFormat;
|
||||
|
||||
/**
|
||||
* Signature Format (Short)
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $shortFormat;
|
||||
|
||||
/**
|
||||
* Create DSA parameters
|
||||
*
|
||||
* @access public
|
||||
* @param int $L
|
||||
* @param int $N
|
||||
* @return \phpseclib3\Crypt\DSA|bool
|
||||
*/
|
||||
public static function createParameters($L = 2048, $N = 224)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
if (!isset(self::$engines['PHP'])) {
|
||||
self::useBestEngine();
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case $N == 160:
|
||||
/*
|
||||
in FIPS 186-1 and 186-2 N was fixed at 160 whereas K had an upper bound of 1024.
|
||||
RFC 4253 (SSH Transport Layer Protocol) references FIPS 186-2 and as such most
|
||||
SSH DSA implementations only support keys with an N of 160.
|
||||
puttygen let's you set the size of L (but not the size of N) and uses 2048 as the
|
||||
default L value. that's not really compliant with any of the FIPS standards, however,
|
||||
for the purposes of maintaining compatibility with puttygen, we'll support it
|
||||
*/
|
||||
//case ($L >= 512 || $L <= 1024) && (($L & 0x3F) == 0) && $N == 160:
|
||||
// FIPS 186-3 changed this as follows:
|
||||
//case $L == 1024 && $N == 160:
|
||||
case $L == 2048 && $N == 224:
|
||||
case $L == 2048 && $N == 256:
|
||||
case $L == 3072 && $N == 256:
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid values for N and L');
|
||||
}
|
||||
|
||||
$two = new BigInteger(2);
|
||||
|
||||
$q = BigInteger::randomPrime($N);
|
||||
$divisor = $q->multiply($two);
|
||||
|
||||
do {
|
||||
$x = BigInteger::random($L);
|
||||
list(, $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);
|
||||
|
||||
// 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
|
||||
// changes after each use". PuTTY (sshdssg.c) starts h off at 1 and increments
|
||||
// it on each loop. wikipedia says "commonly h = 2 is used" so we'll just do that
|
||||
$h = clone $two;
|
||||
while (true) {
|
||||
$g = $h->powMod($e, $p);
|
||||
if (!$g->equals(self::$one)) {
|
||||
break;
|
||||
}
|
||||
$h = $h->add(self::$one);
|
||||
}
|
||||
|
||||
$dsa = new Parameters;
|
||||
$dsa->p = $p;
|
||||
$dsa->q = $q;
|
||||
$dsa->g = $g;
|
||||
|
||||
return $dsa;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create public / private key pair.
|
||||
*
|
||||
* This method is a bit polymorphic. It can take a DSA/Parameters object, L / N as two distinct parameters or
|
||||
* no parameters (at which point L and N will be generated with this method)
|
||||
*
|
||||
* Returns the private key, from which the publickey can be extracted
|
||||
*
|
||||
* @param int[] ...$args
|
||||
* @access public
|
||||
* @return DSA\PrivateKey
|
||||
*/
|
||||
public static function createKey(...$args)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
if (!isset(self::$engines['PHP'])) {
|
||||
self::useBestEngine();
|
||||
}
|
||||
|
||||
if (count($args) == 2 && is_int($args[0]) && is_int($args[1])) {
|
||||
$params = self::createParameters($args[0], $args[1]);
|
||||
} else if (count($args) == 1 && $args[0] instanceof Parameters) {
|
||||
$params = $args[0];
|
||||
} else if (!count($args)) {
|
||||
$params = self::createParameters();
|
||||
} else {
|
||||
throw new InsufficientSetupException('Valid parameters are either two integers (L and N), a single DSA object or no parameters at all.');
|
||||
}
|
||||
|
||||
$private = new PrivateKey;
|
||||
$private->p = $params->p;
|
||||
$private->q = $params->q;
|
||||
$private->g = $params->g;
|
||||
|
||||
$private->x = BigInteger::randomRange(self::$one, $private->q->subtract(self::$one));
|
||||
$private->y = $private->g->powMod($private->x, $private->p);
|
||||
|
||||
//$public = clone $private;
|
||||
//unset($public->x);
|
||||
|
||||
return $private
|
||||
->withHash($params->hash->getHash())
|
||||
->withSignatureFormat($params->shortFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* OnLoad Handler
|
||||
*
|
||||
* @return bool
|
||||
* @access protected
|
||||
* @param array $components
|
||||
*/
|
||||
protected static function onLoad($components)
|
||||
{
|
||||
if (!isset(self::$engines['PHP'])) {
|
||||
self::useBestEngine();
|
||||
}
|
||||
|
||||
if (!isset($components['x']) && !isset($components['y'])) {
|
||||
$new = new Parameters;
|
||||
} else if (isset($components['x'])) {
|
||||
$new = new PrivateKey;
|
||||
$new->x = $components['x'];
|
||||
} else {
|
||||
$new = new PublicKey;
|
||||
}
|
||||
|
||||
$new->p = $components['p'];
|
||||
$new->q = $components['q'];
|
||||
$new->g = $components['g'];
|
||||
|
||||
if (isset($components['y'])) {
|
||||
$new->y = $components['y'];
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* PublicKey and PrivateKey objects can only be created from abstract RSA class
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
$this->sigFormat = self::validatePlugin('Signature', 'ASN1');
|
||||
$this->shortFormat = 'ASN1';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key size
|
||||
*
|
||||
* More specifically, this L (the length of DSA Prime P) and N (the length of DSA Group Order q)
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
return ['L' => $this->p->getLength(), 'N' => $this->q->getLength()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current engine being used
|
||||
*
|
||||
* @see self::useInternalEngine()
|
||||
* @see self::useBestEngine()
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getEngine()
|
||||
{
|
||||
return self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods()) ?
|
||||
'OpenSSL' : 'PHP';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters
|
||||
*
|
||||
* A public / private key is only returned if the currently loaded "key" contains an x or y
|
||||
* value.
|
||||
*
|
||||
* @see self::getPublicKey()
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters');
|
||||
|
||||
$key = $type::saveParameters($this->p, $this->q, $this->g);
|
||||
return DSA::load($key, 'PKCS1')
|
||||
->withHash($this->hash->getHash())
|
||||
->withSignatureFormat($this->shortFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the signature padding mode
|
||||
*
|
||||
* Valid values are: ASN1, SSH2, Raw
|
||||
*
|
||||
* @access public
|
||||
* @param string $format
|
||||
*/
|
||||
public function withSignatureFormat($format)
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->shortFormat = $format;
|
||||
$new->sigFormat = self::validatePlugin('Signature', $format);
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signature format currently being used
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getSignatureFormat()
|
||||
{
|
||||
return $this->shortFormat;
|
||||
}
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* OpenSSH Formatted DSA Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Place in $HOME/.ssh/authorized_keys
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Keys;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor;
|
||||
|
||||
/**
|
||||
* OpenSSH Formatted DSA Key Handler
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class OpenSSH extends Progenitor
|
||||
{
|
||||
/**
|
||||
* Supported Key Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $types = ['ssh-dss'];
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
$parsed = parent::load($key, $password);
|
||||
|
||||
if (isset($parsed['paddedKey'])) {
|
||||
list($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']);
|
||||
|
||||
return compact('p', 'q', 'g', 'y', 'x', 'comment');
|
||||
}
|
||||
|
||||
list($p, $q, $g, $y) = Strings::unpackSSH2('iiii', $parsed['publicKey']);
|
||||
|
||||
$comment = $parsed['comment'];
|
||||
|
||||
return compact('p', 'q', 'g', 'y', 'comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a public key to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @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 = [])
|
||||
{
|
||||
if ($q->getLength() != 160) {
|
||||
throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160');
|
||||
}
|
||||
|
||||
// from <http://tools.ietf.org/html/rfc4253#page-15>:
|
||||
// string "ssh-dss"
|
||||
// mpint p
|
||||
// mpint q
|
||||
// mpint g
|
||||
// mpint y
|
||||
$DSAPublicKey = Strings::packSSH2('siiii', 'ssh-dss', $p, $q, $g, $y);
|
||||
|
||||
if (isset($options['binary']) ? $options['binary'] : self::$binary) {
|
||||
return $DSAPublicKey;
|
||||
}
|
||||
|
||||
$comment = isset($options['comment']) ? $options['comment'] : self::$comment;
|
||||
$DSAPublicKey = 'ssh-dss ' . base64_encode($DSAPublicKey) . ' ' . $comment;
|
||||
|
||||
return $DSAPublicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @access public
|
||||
* @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 = [])
|
||||
{
|
||||
$publicKey = self::savePublicKey($p, $q, $g, $y, ['binary' => true]);
|
||||
$privateKey = Strings::packSSH2('si5', 'ssh-dss', $p, $q, $g, $y, $x);
|
||||
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $password, $options);
|
||||
}
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PKCS#1 Formatted DSA Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Used by File/X509.php
|
||||
*
|
||||
* Processes keys with the following headers:
|
||||
*
|
||||
* -----BEGIN DSA PRIVATE KEY-----
|
||||
* -----BEGIN DSA PUBLIC KEY-----
|
||||
* -----BEGIN DSA PARAMETERS-----
|
||||
*
|
||||
* Analogous to ssh-keygen's pem format (as specified by -m)
|
||||
*
|
||||
* Also, technically, PKCS1 decribes RSA but I am not aware of a formal specification for DSA.
|
||||
* The DSA private key format seems to have been adapted from the RSA private key format so
|
||||
* we're just re-using that as the name.
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Keys;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
|
||||
use phpseclib3\File\ASN1;
|
||||
use phpseclib3\File\ASN1\Maps;
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
|
||||
/**
|
||||
* PKCS#1 Formatted DSA Key Handler
|
||||
*
|
||||
* @package RSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PKCS1 extends Progenitor
|
||||
{
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
$key = parent::load($key, $password);
|
||||
|
||||
$decoded = ASN1::decodeBER($key);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER');
|
||||
}
|
||||
|
||||
$key = ASN1::asn1map($decoded[0], Maps\DSAParams::MAP);
|
||||
if (is_array($key)) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
$key = ASN1::asn1map($decoded[0], Maps\DSAPrivateKey::MAP);
|
||||
if (is_array($key)) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
$key = ASN1::asn1map($decoded[0], Maps\DSAPublicKey::MAP);
|
||||
if (is_array($key)) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
throw new \RuntimeException('Unable to perform ASN1 mapping');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert DSA parameters to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @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)
|
||||
{
|
||||
$key = [
|
||||
'p' => $p,
|
||||
'q' => $q,
|
||||
'g' => $g
|
||||
];
|
||||
|
||||
$key = ASN1::encodeDER($key, Maps\DSAParams::MAP);
|
||||
|
||||
return "-----BEGIN DSA PARAMETERS-----\r\n" .
|
||||
chunk_split(Base64::encode($key), 64) .
|
||||
"-----END DSA PARAMETERS-----\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @access public
|
||||
* @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 = [])
|
||||
{
|
||||
$key = [
|
||||
'version' => 0,
|
||||
'p' => $p,
|
||||
'q' => $q,
|
||||
'g' => $g,
|
||||
'y' => $y,
|
||||
'x' => $x
|
||||
];
|
||||
|
||||
$key = ASN1::encodeDER($key, Maps\DSAPrivateKey::MAP);
|
||||
|
||||
return self::wrapPrivateKey($key, 'DSA', $password, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a public key to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @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)
|
||||
{
|
||||
$key = ASN1::encodeDER($y, Maps\DSAPublicKey::MAP);
|
||||
|
||||
return self::wrapPublicKey($key, 'DSA');
|
||||
}
|
||||
}
|
|
@ -1,170 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PKCS#8 Formatted DSA Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Processes keys with the following headers:
|
||||
*
|
||||
* -----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
* -----BEGIN PRIVATE KEY-----
|
||||
* -----BEGIN PUBLIC KEY-----
|
||||
*
|
||||
* Analogous to ssh-keygen's pkcs8 format (as specified by -m). Although PKCS8
|
||||
* is specific to private keys it's basically creating a DER-encoded wrapper
|
||||
* for keys. This just extends that same concept to public keys (much like ssh-keygen)
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Keys;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
|
||||
use phpseclib3\File\ASN1;
|
||||
use phpseclib3\File\ASN1\Maps;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
|
||||
/**
|
||||
* PKCS#8 Formatted DSA Key Handler
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PKCS8 extends Progenitor
|
||||
{
|
||||
/**
|
||||
* OID Name
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const OID_NAME = 'id-dsa';
|
||||
|
||||
/**
|
||||
* OID Value
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const OID_VALUE = '1.2.840.10040.4.1';
|
||||
|
||||
/**
|
||||
* Child OIDs loaded
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
protected static $childOIDsLoaded = false;
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
$isPublic = strpos($key, 'PUBLIC') !== false;
|
||||
|
||||
$key = parent::load($key, $password);
|
||||
|
||||
$type = isset($key['privateKey']) ? 'privateKey' : 'publicKey';
|
||||
|
||||
switch (true) {
|
||||
case !$isPublic && $type == 'publicKey':
|
||||
throw new \UnexpectedValueException('Human readable string claims non-public key but DER encoded string claims public key');
|
||||
case $isPublic && $type == 'privateKey':
|
||||
throw new \UnexpectedValueException('Human readable string claims public key but DER encoded string claims private key');
|
||||
}
|
||||
|
||||
$decoded = ASN1::decodeBER($key[$type . 'Algorithm']['parameters']->element);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER of parameters');
|
||||
}
|
||||
$components = ASN1::asn1map($decoded[0], Maps\DSAParams::MAP);
|
||||
if (!is_array($components)) {
|
||||
throw new \RuntimeException('Unable to perform ASN1 mapping on parameters');
|
||||
}
|
||||
|
||||
$decoded = ASN1::decodeBER($key[$type]);
|
||||
if (empty($decoded)) {
|
||||
throw new \RuntimeException('Unable to decode BER');
|
||||
}
|
||||
|
||||
$var = $type == 'privateKey' ? 'x' : 'y';
|
||||
$components[$var] = ASN1::asn1map($decoded[0], Maps\DSAPublicKey::MAP);
|
||||
if (!$components[$var] instanceof BigInteger) {
|
||||
throw new \RuntimeException('Unable to perform ASN1 mapping');
|
||||
}
|
||||
|
||||
if (isset($key['meta'])) {
|
||||
$components['meta'] = $key['meta'];
|
||||
}
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @access public
|
||||
* @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 = [])
|
||||
{
|
||||
$params = [
|
||||
'p' => $p,
|
||||
'q' => $q,
|
||||
'g' => $g
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\DSAParams::MAP);
|
||||
$params = new ASN1\Element($params);
|
||||
$key = ASN1::encodeDER($x, Maps\DSAPublicKey::MAP);
|
||||
return self::wrapPrivateKey($key, [], $params, $password, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a public key to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @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 = [])
|
||||
{
|
||||
$params = [
|
||||
'p' => $p,
|
||||
'q' => $q,
|
||||
'g' => $g
|
||||
];
|
||||
$params = ASN1::encodeDER($params, Maps\DSAParams::MAP);
|
||||
$params = new ASN1\Element($params);
|
||||
$key = ASN1::encodeDER($y, Maps\DSAPublicKey::MAP);
|
||||
return self::wrapPublicKey($key, $params);
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PuTTY Formatted DSA Key Handler
|
||||
*
|
||||
* puttygen does not generate DSA keys with an N of anything other than 160, however,
|
||||
* it can still load them and convert them. PuTTY will load them, too, but SSH servers
|
||||
* won't accept them. Since PuTTY formatted keys are primarily used with SSH this makes
|
||||
* keys with N > 160 kinda useless, hence this handlers not supporting such keys.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Keys;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor;
|
||||
|
||||
/**
|
||||
* PuTTY Formatted DSA Key Handler
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class PuTTY extends Progenitor
|
||||
{
|
||||
/**
|
||||
* Public Handler
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const PUBLIC_HANDLER = 'phpseclib3\Crypt\DSA\Formats\Keys\OpenSSH';
|
||||
|
||||
/**
|
||||
* Algorithm Identifier
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
protected static $types = ['ssh-dss'];
|
||||
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
$components = parent::load($key, $password);
|
||||
if (!isset($components['private'])) {
|
||||
return $components;
|
||||
}
|
||||
extract($components);
|
||||
unset($components['public'], $components['private']);
|
||||
|
||||
list($p, $q, $g, $y) = Strings::unpackSSH2('iiii', $public);
|
||||
list($x) = Strings::unpackSSH2('i', $private);
|
||||
|
||||
return compact('p', 'q', 'g', 'y', 'x', 'comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @access public
|
||||
* @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 = [])
|
||||
{
|
||||
if ($q->getLength() != 160) {
|
||||
throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160');
|
||||
}
|
||||
|
||||
$public = Strings::packSSH2('iiii', $p, $q, $g, $y);
|
||||
$private = Strings::packSSH2('i', $x);
|
||||
|
||||
return self::wrapPrivateKey($public, $private, 'ssh-dsa', $password, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a public key to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @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)
|
||||
{
|
||||
if ($q->getLength() != 160) {
|
||||
throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160');
|
||||
}
|
||||
|
||||
return self::wrapPublicKey(Strings::packSSH2('iiii', $p, $q, $g, $y), 'ssh-dsa');
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Raw DSA Key Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Reads and creates arrays as DSA keys
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Keys;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
/**
|
||||
* Raw DSA Key Handler
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class Raw
|
||||
{
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param array $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
if (!is_array($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a array - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case !isset($key['p']) || !isset($key['q']) || !isset($key['g']):
|
||||
case !$key['p'] instanceof BigInteger:
|
||||
case !$key['q'] instanceof BigInteger:
|
||||
case !$key['g'] instanceof BigInteger:
|
||||
case !isset($key['x']) && !isset($key['y']):
|
||||
case isset($key['x']) && !$key['x'] instanceof BigInteger:
|
||||
case isset($key['y']) && !$key['y'] instanceof BigInteger:
|
||||
throw new \UnexpectedValueException('Key appears to be malformed');
|
||||
}
|
||||
|
||||
$options = ['p' => 1, 'q' => 1, 'g' => 1, 'x' => 1, 'y' => 1];
|
||||
|
||||
return array_intersect_key($key, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a private key to the appropriate format.
|
||||
*
|
||||
* @access public
|
||||
* @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 = '')
|
||||
{
|
||||
return compact('p', 'q', 'g', 'y', 'x');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a public key to the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @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)
|
||||
{
|
||||
return compact('p', 'q', 'g', 'y');
|
||||
}
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* XML Formatted DSA Key Handler
|
||||
*
|
||||
* While XKMS defines a private key format for RSA it does not do so for DSA. Quoting that standard:
|
||||
*
|
||||
* "[XKMS] does not specify private key parameters for the DSA signature algorithm since the algorithm only
|
||||
* supports signature modes and so the application of server generated keys and key recovery is of limited
|
||||
* value"
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Keys;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
|
||||
/**
|
||||
* XML Formatted DSA Key Handler
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class XML
|
||||
{
|
||||
/**
|
||||
* Break a public or private key down into its constituent components
|
||||
*
|
||||
* @access public
|
||||
* @param string $key
|
||||
* @param string $password optional
|
||||
* @return array
|
||||
*/
|
||||
public static function load($key, $password = '')
|
||||
{
|
||||
if (!Strings::is_stringable($key)) {
|
||||
throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
||||
}
|
||||
|
||||
$use_errors = libxml_use_internal_errors(true);
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
if (substr($key, 0, 5) != '<?xml') {
|
||||
$key = '<xml>' . $key . '</xml>';
|
||||
}
|
||||
if (!$dom->loadXML($key)) {
|
||||
throw new \UnexpectedValueException('Key does not appear to contain XML');
|
||||
}
|
||||
$xpath = new \DOMXPath($dom);
|
||||
$keys = ['p', 'q', 'g', 'y', 'j', 'seed', 'pgencounter'];
|
||||
foreach ($keys as $key) {
|
||||
// $dom->getElementsByTagName($key) is case-sensitive
|
||||
$temp = $xpath->query("//*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='$key']");
|
||||
if (!$temp->length) {
|
||||
continue;
|
||||
}
|
||||
$value = new BigInteger(Base64::decode($temp->item(0)->nodeValue), 256);
|
||||
switch ($key) {
|
||||
case 'p': // a prime modulus meeting the [DSS] requirements
|
||||
// Parameters P, Q, and G can be public and common to a group of users. They might be known
|
||||
// from application context. As such, they are optional but P and Q must either both appear
|
||||
// or both be absent
|
||||
$components['p'] = $value;
|
||||
break;
|
||||
case 'q': // an integer in the range 2**159 < Q < 2**160 which is a prime divisor of P-1
|
||||
$components['q'] = $value;
|
||||
break;
|
||||
case 'g': // an integer with certain properties with respect to P and Q
|
||||
$components['g'] = $value;
|
||||
break;
|
||||
case 'y': // G**X mod P (where X is part of the private key and not made public)
|
||||
$components['y'] = $value;
|
||||
// the remaining options do not do anything
|
||||
case 'j': // (P - 1) / Q
|
||||
// Parameter J is available for inclusion solely for efficiency as it is calculatable from
|
||||
// P and Q
|
||||
case 'seed': // a DSA prime generation seed
|
||||
// Parameters seed and pgenCounter are used in the DSA prime number generation algorithm
|
||||
// specified in [DSS]. As such, they are optional but must either both be present or both
|
||||
// be absent
|
||||
case 'pgencounter': // a DSA prime generation counter
|
||||
}
|
||||
}
|
||||
|
||||
libxml_use_internal_errors($use_errors);
|
||||
|
||||
if (!isset($components['y'])) {
|
||||
throw new \UnexpectedValueException('Key is missing y component');
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case !isset($components['p']):
|
||||
case !isset($components['q']):
|
||||
case !isset($components['g']):
|
||||
return ['y' => $components['y']];
|
||||
}
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a public key to the appropriate format
|
||||
*
|
||||
* See https://www.w3.org/TR/xmldsig-core/#sec-DSAKeyValue
|
||||
*
|
||||
* @access public
|
||||
* @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)
|
||||
{
|
||||
return "<DSAKeyValue>\r\n" .
|
||||
' <P>' . Base64::encode($p->toBytes()) . "</P>\r\n" .
|
||||
' <Q>' . Base64::encode($q->toBytes()) . "</Q>\r\n" .
|
||||
' <G>' . Base64::encode($g->toBytes()) . "</G>\r\n" .
|
||||
' <Y>' . Base64::encode($y->toBytes()) . "</Y>\r\n" .
|
||||
'</DSAKeyValue>';
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ASN1 Signature Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Handles signatures in the format described in
|
||||
* https://tools.ietf.org/html/rfc3279#section-2.2.2
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Signature;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\File\ASN1 as Encoder;
|
||||
use phpseclib3\File\ASN1\Maps;
|
||||
|
||||
/**
|
||||
* ASN1 Signature Handler
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class ASN1
|
||||
{
|
||||
/**
|
||||
* Loads a signature
|
||||
*
|
||||
* @access public
|
||||
* @param string $sig
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function load($sig)
|
||||
{
|
||||
if (!is_string($sig)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$decoded = Encoder::decodeBER($sig);
|
||||
if (empty($decoded)) {
|
||||
return false;
|
||||
}
|
||||
$components = Encoder::asn1map($decoded[0], Maps\DssSigValue::MAP);
|
||||
|
||||
return $components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a signature in the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @param \phpseclib3\Math\BigInteger $r
|
||||
* @param \phpseclib3\Math\BigInteger $s
|
||||
* @return string
|
||||
*/
|
||||
public static function save(BigInteger $r, BigInteger $s)
|
||||
{
|
||||
return Encoder::encodeDER(compact('r', 's'), Maps\DssSigValue::MAP);
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Raw DSA Signature Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Signature;
|
||||
|
||||
use phpseclib3\Crypt\Common\Formats\Signature\Raw as Progenitor;
|
||||
|
||||
/**
|
||||
* Raw DSA Signature Handler
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class Raw extends Progenitor
|
||||
{
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SSH2 Signature Handler
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Handles signatures in the format used by SSH2
|
||||
*
|
||||
* @category Crypt
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA\Formats\Signature;
|
||||
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
|
||||
/**
|
||||
* SSH2 Signature Handler
|
||||
*
|
||||
* @package Common
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class SSH2
|
||||
{
|
||||
/**
|
||||
* Loads a signature
|
||||
*
|
||||
* @access public
|
||||
* @param string $sig
|
||||
* @return mixed
|
||||
*/
|
||||
public static function load($sig)
|
||||
{
|
||||
if (!is_string($sig)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = Strings::unpackSSH2('ss', $sig);
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
list($type, $blob) = $result;
|
||||
if ($type != 'ssh-dss' || strlen($blob) != 40) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'r' => new BigInteger(substr($blob, 0, 20), 256),
|
||||
's' => new BigInteger(substr($blob, 20), 256)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a signature in the appropriate format
|
||||
*
|
||||
* @access public
|
||||
* @param \phpseclib3\Math\BigInteger $r
|
||||
* @param \phpseclib3\Math\BigInteger $s
|
||||
* @return string
|
||||
*/
|
||||
public static function save(BigInteger $r, BigInteger $s)
|
||||
{
|
||||
if ($r->getLength() > 160 || $s->getLength() > 160) {
|
||||
return false;
|
||||
}
|
||||
return Strings::packSSH2('ss', 'ssh-dss',
|
||||
str_pad($r->toBytes(), 20, "\0", STR_PAD_LEFT) .
|
||||
str_pad($s->toBytes(), 20, "\0", STR_PAD_LEFT)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DSA Parameters
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA;
|
||||
|
||||
use phpseclib3\Crypt\DSA;
|
||||
|
||||
/**
|
||||
* DSA Parameters
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class Parameters extends DSA
|
||||
{
|
||||
/**
|
||||
* Returns the parameters
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type = 'PKCS1', array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters');
|
||||
|
||||
return $type::saveParameters($this->p, $this->q, $this->g, $options);
|
||||
}
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DSA Private Key
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA;
|
||||
|
||||
use phpseclib3\Crypt\DSA;
|
||||
use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* DSA Private Key
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class PrivateKey extends DSA implements Common\PrivateKey
|
||||
{
|
||||
use Common\Traits\PasswordProtected;
|
||||
|
||||
/**
|
||||
* DSA secret exponent x
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
* @access private
|
||||
*/
|
||||
protected $x;
|
||||
|
||||
/**
|
||||
* Returns the public key
|
||||
*
|
||||
* If you do "openssl rsa -in private.rsa -pubout -outform PEM" you get a PKCS8 formatted key
|
||||
* that contains a publicKeyAlgorithm AlgorithmIdentifier and a publicKey BIT STRING.
|
||||
* An AlgorithmIdentifier contains an OID and a parameters field. With RSA public keys this
|
||||
* parameters field is NULL. With DSA PKCS8 public keys it is not - it contains the p, q and g
|
||||
* variables. The publicKey BIT STRING contains, simply, the y variable. This can be verified
|
||||
* by getting a DSA PKCS8 public key:
|
||||
*
|
||||
* "openssl dsa -in private.dsa -pubout -outform PEM"
|
||||
*
|
||||
* ie. just swap out rsa with dsa in the rsa command above.
|
||||
*
|
||||
* A PKCS1 public key corresponds to the publicKey portion of the PKCS8 key. In the case of RSA
|
||||
* the publicKey portion /is/ the key. In the case of DSA it is not. You cannot verify a signature
|
||||
* without the parameters and the PKCS1 DSA public key format does not include the parameters.
|
||||
*
|
||||
* @see self::getPrivateKey()
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPublicKey()
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS8', 'savePublicKey');
|
||||
|
||||
if (!isset($this->y)) {
|
||||
$this->y = $this->g->powMod($this->x, $this->p);
|
||||
}
|
||||
|
||||
$key = $type::savePublicKey($this->p, $this->q, $this->g, $this->y);
|
||||
|
||||
return DSA::loadFormat('PKCS8', $key)
|
||||
->withHash($this->hash->getHash())
|
||||
->withSignatureFormat($this->shortFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a signature
|
||||
*
|
||||
* @see self::verify()
|
||||
* @access public
|
||||
* @param string $message
|
||||
* @return mixed
|
||||
*/
|
||||
public function sign($message)
|
||||
{
|
||||
$format = $this->sigFormat;
|
||||
|
||||
if (self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods())) {
|
||||
$signature = '';
|
||||
$result = openssl_sign($message, $signature, $this->toString('PKCS8'), $this->hash->getHash());
|
||||
|
||||
if ($result) {
|
||||
if ($this->shortFormat == 'ASN1') {
|
||||
return $signature;
|
||||
}
|
||||
|
||||
extract(ASN1Signature::load($signature));
|
||||
|
||||
return $format::save($r, $s);
|
||||
}
|
||||
}
|
||||
|
||||
$h = $this->hash->hash($message);
|
||||
$h = $this->bits2int($h);
|
||||
|
||||
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);
|
||||
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);
|
||||
if (!$s->equals(self::$zero)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the following is an RFC6979 compliant implementation of deterministic DSA
|
||||
// it's unused because it's mainly intended for use when a good CSPRNG isn't
|
||||
// available. if phpseclib's CSPRNG isn't good then even key generation is
|
||||
// suspect
|
||||
/*
|
||||
$h1 = $this->hash->hash($message);
|
||||
$k = $this->computek($h1);
|
||||
$r = $this->g->powMod($k, $this->p);
|
||||
list(, $r) = $r->divide($this->q);
|
||||
$kinv = $k->modInverse($this->q);
|
||||
$h1 = $this->bits2int($h1);
|
||||
$temp = $h1->add($this->x->multiply($r));
|
||||
$temp = $kinv->multiply($temp);
|
||||
list(, $s) = $temp->divide($this->q);
|
||||
*/
|
||||
|
||||
return $format::save($r, $s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the private key
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePrivateKey');
|
||||
|
||||
if (!isset($this->y)) {
|
||||
$this->y = $this->g->powMod($this->x, $this->p);
|
||||
}
|
||||
|
||||
return $type::savePrivateKey($this->p, $this->q, $this->g, $this->y, $this->x, $this->password, $options);
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* DSA Public Key
|
||||
*
|
||||
* @category Crypt
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2015 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\DSA;
|
||||
|
||||
use phpseclib3\Crypt\DSA;
|
||||
use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature;
|
||||
use phpseclib3\Crypt\Common;
|
||||
|
||||
/**
|
||||
* DSA Public Key
|
||||
*
|
||||
* @package DSA
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class PublicKey extends DSA implements Common\PublicKey
|
||||
{
|
||||
use Common\Traits\Fingerprint;
|
||||
|
||||
/**
|
||||
* Verify a signature
|
||||
*
|
||||
* @see self::verify()
|
||||
* @access public
|
||||
* @param string $message
|
||||
* @param string $signature
|
||||
* @return mixed
|
||||
*/
|
||||
public function verify($message, $signature)
|
||||
{
|
||||
$format = $this->sigFormat;
|
||||
|
||||
$params = $format::load($signature);
|
||||
if ($params === false || count($params) != 2) {
|
||||
return false;
|
||||
}
|
||||
extract($params);
|
||||
|
||||
if (self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods())) {
|
||||
$sig = $format != 'ASN1' ? ASN1Signature::save($r, $s) : $signature;
|
||||
|
||||
$result = openssl_verify($message, $sig, $this->toString('PKCS8'), $this->hash->getHash());
|
||||
|
||||
if ($result != -1) {
|
||||
return (bool) $result;
|
||||
}
|
||||
}
|
||||
|
||||
$q_1 = $this->q->subtract(self::$one);
|
||||
if (!$r->between(self::$one, $q_1) || !$s->between(self::$one, $q_1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$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);
|
||||
$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);
|
||||
|
||||
return $v->equals($r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public key
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePublicKey');
|
||||
|
||||
return $type::savePublicKey($this->p, $this->q, $this->g, $this->y, $options);
|
||||
}
|
||||
}
|
477
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC.php
vendored
477
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC.php
vendored
|
@ -1,477 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of EC.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* Here's an example of how to create signatures and verify signatures with this library:
|
||||
* <code>
|
||||
* <?php
|
||||
* include 'vendor/autoload.php';
|
||||
*
|
||||
* $private = \phpseclib3\Crypt\EC::createKey('secp256k1');
|
||||
* $public = $private->getPublicKey();
|
||||
*
|
||||
* $plaintext = 'terrafrost';
|
||||
*
|
||||
* $signature = $private->sign($plaintext);
|
||||
*
|
||||
* echo $public->verify($plaintext, $signature) ? 'verified' : 'unverified';
|
||||
* ?>
|
||||
* </code>
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2016 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt;
|
||||
|
||||
use phpseclib3\Crypt\Common\AsymmetricKey;
|
||||
use phpseclib3\Crypt\EC\PrivateKey;
|
||||
use phpseclib3\Crypt\EC\PublicKey;
|
||||
use phpseclib3\Crypt\EC\Parameters;
|
||||
use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
|
||||
use phpseclib3\Crypt\EC\Curves\Curve25519;
|
||||
use phpseclib3\Crypt\EC\Curves\Ed25519;
|
||||
use phpseclib3\Crypt\EC\Curves\Ed448;
|
||||
use phpseclib3\Crypt\EC\Formats\Keys\PKCS1;
|
||||
use phpseclib3\File\ASN1\Maps\ECParameters;
|
||||
use phpseclib3\File\ASN1;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Exception\UnsupportedCurveException;
|
||||
use phpseclib3\Exception\UnsupportedAlgorithmException;
|
||||
use phpseclib3\Exception\UnsupportedOperationException;
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of EC.
|
||||
*
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class EC extends AsymmetricKey
|
||||
{
|
||||
/**
|
||||
* Algorithm Name
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
const ALGORITHM = 'EC';
|
||||
|
||||
/**
|
||||
* Public Key QA
|
||||
*
|
||||
* @var object[]
|
||||
*/
|
||||
protected $QA;
|
||||
|
||||
/**
|
||||
* Curve
|
||||
*
|
||||
* @var \phpseclib3\Crypt\EC\BaseCurves\Base
|
||||
*/
|
||||
protected $curve;
|
||||
|
||||
/**
|
||||
* Signature Format
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $format;
|
||||
|
||||
/**
|
||||
* Signature Format (Short)
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $shortFormat;
|
||||
|
||||
/**
|
||||
* Curve Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $curveName;
|
||||
|
||||
/**
|
||||
* Curve Order
|
||||
*
|
||||
* Used for deterministic ECDSA
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
protected $q;
|
||||
|
||||
/**
|
||||
* Alias for the private key
|
||||
*
|
||||
* Used for deterministic ECDSA. AsymmetricKey expects $x. I don't like x because
|
||||
* with x you have x * the base point yielding an (x, y)-coordinate that is the
|
||||
* public key. But the x is different depending on which side of the equal sign
|
||||
* you're on. It's less ambiguous if you do dA * base point = (x, y)-coordinate.
|
||||
*
|
||||
* @var \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
protected $x;
|
||||
|
||||
/**
|
||||
* Context
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* Create public / private key pair.
|
||||
*
|
||||
* @access public
|
||||
* @param string $curve
|
||||
* @return \phpseclib3\Crypt\EC\PrivateKey
|
||||
*/
|
||||
public static function createKey($curve)
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
if (!isset(self::$engines['PHP'])) {
|
||||
self::useBestEngine();
|
||||
}
|
||||
|
||||
$curve = strtolower($curve);
|
||||
if (self::$engines['libsodium'] && $curve == 'ed25519' && function_exists('sodium_crypto_sign_keypair')) {
|
||||
$kp = sodium_crypto_sign_keypair();
|
||||
|
||||
$privatekey = EC::loadFormat('libsodium', sodium_crypto_sign_secretkey($kp));
|
||||
//$publickey = EC::loadFormat('libsodium', sodium_crypto_sign_publickey($kp));
|
||||
|
||||
$privatekey->curveName = 'Ed25519';
|
||||
//$publickey->curveName = $curve;
|
||||
|
||||
return $privatekey;
|
||||
}
|
||||
|
||||
$privatekey = new PrivateKey;
|
||||
|
||||
$curveName = $curve;
|
||||
if (preg_match('#(?:^curve|^ed)\d+$#', $curveName)) {
|
||||
$curveName = ucfirst($curveName);
|
||||
} elseif (substr($curveName, 0, 10) == 'brainpoolp') {
|
||||
$curveName = 'brainpoolP' . substr($curveName, 10);
|
||||
}
|
||||
$curve = '\phpseclib3\Crypt\EC\Curves\\' . $curveName;
|
||||
|
||||
if (!class_exists($curve)) {
|
||||
throw new UnsupportedCurveException('Named Curve of ' . $curveName . ' is not supported');
|
||||
}
|
||||
|
||||
$reflect = new \ReflectionClass($curve);
|
||||
$curveName = $reflect->isFinal() ?
|
||||
$reflect->getParentClass()->getShortName() :
|
||||
$reflect->getShortName();
|
||||
|
||||
$curve = new $curve();
|
||||
$privatekey->dA = $dA = $curve->createRandomMultiplier();
|
||||
if ($curve instanceof Curve25519 && self::$engines['libsodium']) {
|
||||
//$r = pack('H*', '0900000000000000000000000000000000000000000000000000000000000000');
|
||||
//$QA = sodium_crypto_scalarmult($dA->toBytes(), $r);
|
||||
$QA = sodium_crypto_box_publickey_from_secretkey($dA->toBytes());
|
||||
$privatekey->QA = [$curve->convertInteger(new BigInteger(strrev($QA), 256))];
|
||||
} else {
|
||||
$privatekey->QA = $curve->multiplyPoint($curve->getBasePoint(), $dA);
|
||||
}
|
||||
$privatekey->curve = $curve;
|
||||
|
||||
//$publickey = clone $privatekey;
|
||||
//unset($publickey->dA);
|
||||
//unset($publickey->x);
|
||||
|
||||
$privatekey->curveName = $curveName;
|
||||
//$publickey->curveName = $curveName;
|
||||
|
||||
if ($privatekey->curve instanceof TwistedEdwardsCurve) {
|
||||
return $privatekey->withHash($curve::HASH);
|
||||
}
|
||||
|
||||
return $privatekey;
|
||||
}
|
||||
|
||||
/**
|
||||
* OnLoad Handler
|
||||
*
|
||||
* @return bool
|
||||
* @access protected
|
||||
* @param array $components
|
||||
*/
|
||||
protected static function onLoad($components)
|
||||
{
|
||||
if (!isset(self::$engines['PHP'])) {
|
||||
self::useBestEngine();
|
||||
}
|
||||
|
||||
if (!isset($components['dA']) && !isset($components['QA'])) {
|
||||
$new = new Parameters;
|
||||
$new->curve = $components['curve'];
|
||||
return $new;
|
||||
}
|
||||
|
||||
$new = isset($components['dA']) ?
|
||||
new PrivateKey :
|
||||
new PublicKey;
|
||||
$new->curve = $components['curve'];
|
||||
$new->QA = $components['QA'];
|
||||
|
||||
if (isset($components['dA'])) {
|
||||
$new->dA = $components['dA'];
|
||||
}
|
||||
|
||||
if ($new->curve instanceof TwistedEdwardsCurve) {
|
||||
return $new->withHash($components['curve']::HASH);
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* PublicKey and PrivateKey objects can only be created from abstract RSA class
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
$this->sigFormat = self::validatePlugin('Signature', 'ASN1');
|
||||
$this->shortFormat = 'ASN1';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the curve
|
||||
*
|
||||
* Returns a string if it's a named curve, an array if not
|
||||
*
|
||||
* @access public
|
||||
* @return string|array
|
||||
*/
|
||||
public function getCurve()
|
||||
{
|
||||
if ($this->curveName) {
|
||||
return $this->curveName;
|
||||
}
|
||||
|
||||
if ($this->curve instanceof MontgomeryCurve) {
|
||||
$this->curveName = $this->curve instanceof Curve25519 ? 'Curve25519' : 'Curve448';
|
||||
return $this->curveName;
|
||||
}
|
||||
|
||||
if ($this->curve instanceof TwistedEdwardsCurve) {
|
||||
$this->curveName = $this->curve instanceof Ed25519 ? 'Ed25519' : 'Ed448';
|
||||
return $this->curveName;
|
||||
}
|
||||
|
||||
$params = $this->getParameters()->toString('PKCS8', ['namedCurve' => true]);
|
||||
$decoded = ASN1::extractBER($params);
|
||||
$decoded = ASN1::decodeBER($decoded);
|
||||
$decoded = ASN1::asn1map($decoded[0], ECParameters::MAP);
|
||||
if (isset($decoded['namedCurve'])) {
|
||||
$this->curveName = $decoded['namedCurve'];
|
||||
return $decoded['namedCurve'];
|
||||
}
|
||||
|
||||
if (!$namedCurves) {
|
||||
PKCS1::useSpecifiedCurve();
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key size
|
||||
*
|
||||
* Quoting https://tools.ietf.org/html/rfc5656#section-2,
|
||||
*
|
||||
* "The size of a set of elliptic curve domain parameters on a prime
|
||||
* curve is defined as the number of bits in the binary representation
|
||||
* of the field order, commonly denoted by p. Size on a
|
||||
* characteristic-2 curve is defined as the number of bits in the binary
|
||||
* 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"
|
||||
*
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
return $this->curve->getLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current engine being used
|
||||
*
|
||||
* @see self::useInternalEngine()
|
||||
* @see self::useBestEngine()
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getEngine()
|
||||
{
|
||||
if ($this->curve instanceof TwistedEdwardsCurve) {
|
||||
return $this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context) ?
|
||||
'libsodium' : 'PHP';
|
||||
}
|
||||
|
||||
return self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods()) ?
|
||||
'OpenSSL' : 'PHP';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the public key coordinates as a string
|
||||
*
|
||||
* Used by ECDH
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncodedCoordinates()
|
||||
{
|
||||
if ($this->curve instanceof MontgomeryCurve) {
|
||||
return strrev($this->QA[0]->toBytes(true));
|
||||
}
|
||||
if ($this->curve instanceof TwistedEdwardsCurve) {
|
||||
return $this->curve->encodePoint($this->QA);
|
||||
}
|
||||
return "\4" . $this->QA[0]->toBytes(true) . $this->QA[1]->toBytes(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters
|
||||
*
|
||||
* @see self::getPublicKey()
|
||||
* @access public
|
||||
* @param string $type optional
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParameters($type = 'PKCS1')
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'saveParameters');
|
||||
|
||||
$key = $type::saveParameters($this->curve);
|
||||
|
||||
return EC::load($key, 'PKCS1')
|
||||
->withHash($this->hash->getHash())
|
||||
->withSignatureFormat($this->shortFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the signature padding mode
|
||||
*
|
||||
* Valid values are: ASN1, SSH2, Raw
|
||||
*
|
||||
* @access public
|
||||
* @param string $format
|
||||
*/
|
||||
public function withSignatureFormat($format)
|
||||
{
|
||||
if ($this->curve instanceof MontgomeryCurve) {
|
||||
throw new UnsupportedOperationException('Montgomery Curves cannot be used to create signatures');
|
||||
}
|
||||
|
||||
$new = clone $this;
|
||||
$new->shortFormat = $format;
|
||||
$new->sigFormat = self::validatePlugin('Signature', $format);
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signature format currently being used
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getSignatureFormat()
|
||||
{
|
||||
return $this->shortFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context
|
||||
*
|
||||
* Used by Ed25519 / Ed448.
|
||||
*
|
||||
* @see self::sign()
|
||||
* @see self::verify()
|
||||
* @access public
|
||||
* @param string $context optional
|
||||
*/
|
||||
public function withContext($context = null)
|
||||
{
|
||||
if (!$this->curve instanceof TwistedEdwardsCurve) {
|
||||
throw new UnsupportedCurveException('Only Ed25519 and Ed448 support contexts');
|
||||
}
|
||||
|
||||
$new = clone $this;
|
||||
if (!isset($context)) {
|
||||
$new->context = null;
|
||||
return $new;
|
||||
}
|
||||
if (!is_string($context)) {
|
||||
throw new \InvalidArgumentException('setContext expects a string');
|
||||
}
|
||||
if (strlen($context) > 255) {
|
||||
throw new \LengthException('The context is supposed to be, at most, 255 bytes long');
|
||||
}
|
||||
$new->context = $context;
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the signature format currently being used
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which hashing function should be used
|
||||
*
|
||||
* @access public
|
||||
* @param string $hash
|
||||
*/
|
||||
public function withHash($hash)
|
||||
{
|
||||
if ($this->curve instanceof MontgomeryCurve) {
|
||||
throw new UnsupportedOperationException('Montgomery Curves cannot be used to create signatures');
|
||||
}
|
||||
if ($this->curve instanceof Ed25519 && $hash != 'sha512') {
|
||||
throw new UnsupportedAlgorithmException('Ed25519 only supports sha512 as a hash');
|
||||
}
|
||||
if ($this->curve instanceof Ed448 && $hash != 'shake256-912') {
|
||||
throw new UnsupportedAlgorithmException('Ed448 only supports shake256 with a length of 114 bytes');
|
||||
}
|
||||
|
||||
return parent::withHash($hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* __toString() magic method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if ($this->curve instanceof MontgomeryCurve) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return parent::__toString();
|
||||
}
|
||||
}
|
|
@ -1,220 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Curve methods common to all curves
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\BaseCurves;
|
||||
|
||||
use phpseclib3\Math\Common\FiniteField;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
/**
|
||||
* Base
|
||||
*
|
||||
* @package Prime
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
abstract class Base
|
||||
{
|
||||
/**
|
||||
* Doubles
|
||||
*
|
||||
* @var object[]
|
||||
*/
|
||||
protected $doubles;
|
||||
|
||||
/**
|
||||
* NAF Points
|
||||
*
|
||||
* @var int[]
|
||||
*/
|
||||
private $naf;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Finite Field Integer factory
|
||||
*
|
||||
* @var \phpseclib3\Math\FiniteField\Integer
|
||||
*/
|
||||
protected $factory;
|
||||
|
||||
/**
|
||||
* Returns a random integer
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function randomInteger()
|
||||
{
|
||||
return $this->factory->randomInteger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a BigInteger to a FiniteField integer
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function convertInteger(BigInteger $x)
|
||||
{
|
||||
return $this->factory->newInteger($x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length, in bytes, of the modulo
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getLengthInBytes()
|
||||
{
|
||||
return $this->factory->getLengthInBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length, in bits, of the modulo
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
return $this->factory->getLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply a point on the curve by a scalar
|
||||
*
|
||||
* Uses the montgomery ladder technique as described here:
|
||||
*
|
||||
* 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, FiniteField\Integer $d)
|
||||
{
|
||||
$alreadyInternal = isset($p[2]);
|
||||
$r = $alreadyInternal ?
|
||||
[[], $p] :
|
||||
[[], $this->convertToInternal($p)];
|
||||
|
||||
$d = $d->toBits();
|
||||
for ($i = 0; $i < strlen($d); $i++) {
|
||||
$d_i = (int) $d[$i];
|
||||
$r[1 - $d_i] = $this->addPoint($r[0], $r[1]);
|
||||
$r[$d_i] = $this->doublePoint($r[$d_i]);
|
||||
}
|
||||
|
||||
return $alreadyInternal ? $r[0] : $this->convertToAffine($r[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a random scalar multiplier
|
||||
*
|
||||
* @return FiniteField
|
||||
*/
|
||||
public function createRandomMultiplier()
|
||||
{
|
||||
static $one;
|
||||
if (!isset($one)) {
|
||||
$one = new BigInteger(1);
|
||||
}
|
||||
|
||||
$dA = BigInteger::randomRange($one, $this->order->subtract($one));
|
||||
return $this->factory->newInteger($dA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Order
|
||||
*/
|
||||
public function setOrder(BigInteger $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Order
|
||||
*
|
||||
* @return \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a custom defined modular reduction function
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function setReduction(callable $func)
|
||||
{
|
||||
$this->factory->setReduction($func);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the affine point
|
||||
*
|
||||
* @return object[]
|
||||
*/
|
||||
public function convertToAffine(array $p)
|
||||
{
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an affine point to a jacobian coordinate
|
||||
*
|
||||
* @return object[]
|
||||
*/
|
||||
public function convertToInternal(array $p)
|
||||
{
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Negates a point
|
||||
*
|
||||
* @return object[]
|
||||
*/
|
||||
public function negatePoint(array $p)
|
||||
{
|
||||
$temp = [
|
||||
$p[0],
|
||||
$p[1]->negate()
|
||||
];
|
||||
if (isset($p[2])) {
|
||||
$temp[] = $p[2];
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply and Add Points
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function multiplyAddPoints(array $points, array $scalars)
|
||||
{
|
||||
$p1 = $this->convertToInternal($points[0]);
|
||||
$p2 = $this->convertToInternal($points[1]);
|
||||
$p1 = $this->multiplyPoint($p1, $scalars[0]);
|
||||
$p2 = $this->multiplyPoint($p2, $scalars[1]);
|
||||
$r = $this->addPoint($p1, $p2);
|
||||
return $this->convertToAffine($r);
|
||||
}
|
||||
}
|
|
@ -1,378 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Curves over y^2 + x*y = x^3 + a*x^2 + b
|
||||
*
|
||||
* These are curves used in SEC 2 over prime fields: http://www.secg.org/SEC2-Ver-1.0.pdf
|
||||
* The curve is a weierstrass curve with a[3] and a[2] set to 0.
|
||||
*
|
||||
* Uses Jacobian Coordinates for speed if able:
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Jacobian_curve
|
||||
* https://en.wikibooks.org/wiki/Cryptography/Prime_Curve/Jacobian_Coordinates
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\BaseCurves;
|
||||
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Math\BinaryField;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Math\BinaryField\Integer as BinaryInteger;
|
||||
|
||||
/**
|
||||
* Curves over y^2 + x*y = x^3 + a*x^2 + b
|
||||
*
|
||||
* @package Binary
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class Binary extends Base
|
||||
{
|
||||
/**
|
||||
* Binary Field Integer factory
|
||||
*
|
||||
* @var \phpseclib3\Math\BinaryField
|
||||
*/
|
||||
protected $factory;
|
||||
|
||||
/**
|
||||
* Cofficient for x^1
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $a;
|
||||
|
||||
/**
|
||||
* Cofficient for x^0
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $b;
|
||||
|
||||
/**
|
||||
* Base Point
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $p;
|
||||
|
||||
/**
|
||||
* The number one over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $one;
|
||||
|
||||
/**
|
||||
* The modulo
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $modulo;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Sets the modulo
|
||||
*/
|
||||
public function setModulo(...$modulo)
|
||||
{
|
||||
$this->modulo = $modulo;
|
||||
$this->factory = new BinaryField(...$modulo);
|
||||
|
||||
$this->one = $this->factory->newInteger("\1");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set coefficients a and b
|
||||
*
|
||||
* @param string $a
|
||||
* @param string $b
|
||||
*/
|
||||
public function setCoefficients($a, $b)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->a = $this->factory->newInteger(pack('H*', $a));
|
||||
$this->b = $this->factory->newInteger(pack('H*', $b));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set x and y coordinates for the base point
|
||||
*
|
||||
* @param string|BinaryInteger $x
|
||||
* @param string|BinaryInteger $y
|
||||
*/
|
||||
public function setBasePoint($x, $y)
|
||||
{
|
||||
switch (true) {
|
||||
case !is_string($x) && !$x instanceof BinaryInteger:
|
||||
throw new \UnexpectedValueException('Argument 1 passed to Binary::setBasePoint() must be a string or an instance of BinaryField\Integer');
|
||||
case !is_string($y) && !$y instanceof BinaryInteger:
|
||||
throw new \UnexpectedValueException('Argument 2 passed to Binary::setBasePoint() must be a string or an instance of BinaryField\Integer');
|
||||
}
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->p = [
|
||||
is_string($x) ? $this->factory->newInteger(pack('H*', $x)) : $x,
|
||||
is_string($y) ? $this->factory->newInteger(pack('H*', $y)) : $y
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the base point as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBasePoint()
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
/*
|
||||
if (!isset($this->p)) {
|
||||
throw new \RuntimeException('setBasePoint needs to be called before this method');
|
||||
}
|
||||
*/
|
||||
return $this->p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two points on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function addPoint(array $p, array $q)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p) || !count($q)) {
|
||||
if (count($q)) {
|
||||
return $q;
|
||||
}
|
||||
if (count($p)) {
|
||||
return $p;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!isset($p[2]) || !isset($q[2])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa');
|
||||
}
|
||||
|
||||
if ($p[0]->equals($q[0])) {
|
||||
return !$p[1]->equals($q[1]) ? [] : $this->doublePoint($p);
|
||||
}
|
||||
|
||||
// formulas from http://hyperelliptic.org/EFD/g12o/auto-shortw-jacobian.html
|
||||
|
||||
list($x1, $y1, $z1) = $p;
|
||||
list($x2, $y2, $z2) = $q;
|
||||
|
||||
$o1 = $z1->multiply($z1);
|
||||
$b = $x2->multiply($o1);
|
||||
|
||||
if ($z2->equals($this->one)) {
|
||||
$d = $y2->multiply($o1)->multiply($z1);
|
||||
$e = $x1->add($b);
|
||||
$f = $y1->add($d);
|
||||
$z3 = $e->multiply($z1);
|
||||
$h = $f->multiply($x2)->add($z3->multiply($y2));
|
||||
$i = $f->add($z3);
|
||||
$g = $z3->multiply($z3);
|
||||
$p1 = $this->a->multiply($g);
|
||||
$p2 = $f->multiply($i);
|
||||
$p3 = $e->multiply($e)->multiply($e);
|
||||
$x3 = $p1->add($p2)->add($p3);
|
||||
$y3 = $i->multiply($x3)->add($g->multiply($h));
|
||||
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
$o2 = $z2->multiply($z2);
|
||||
$a = $x1->multiply($o2);
|
||||
$c = $y1->multiply($o2)->multiply($z2);
|
||||
$d = $y2->multiply($o1)->multiply($z1);
|
||||
$e = $a->add($b);
|
||||
$f = $c->add($d);
|
||||
$g = $e->multiply($z1);
|
||||
$h = $f->multiply($x2)->add($g->multiply($y2));
|
||||
$z3 = $g->multiply($z2);
|
||||
$i = $f->add($z3);
|
||||
$p1 = $this->a->multiply($z3->multiply($z3));
|
||||
$p2 = $f->multiply($i);
|
||||
$p3 = $e->multiply($e)->multiply($e);
|
||||
$x3 = $p1->add($p2)->add($p3);
|
||||
$y3 = $i->multiply($x3)->add($g->multiply($g)->multiply($h));
|
||||
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a point on a curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function doublePoint(array $p)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!isset($p[2])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa');
|
||||
}
|
||||
|
||||
// formulas from http://hyperelliptic.org/EFD/g12o/auto-shortw-jacobian.html
|
||||
|
||||
list($x1, $y1, $z1) = $p;
|
||||
|
||||
$a = $x1->multiply($x1);
|
||||
$b = $a->multiply($a);
|
||||
|
||||
if ($z1->equals($this->one)) {
|
||||
$x3 = $b->add($this->b);
|
||||
$z3 = clone $x1;
|
||||
$p1 = $a->add($y1)->add($z3)->multiply($this->b);
|
||||
$p2 = $a->add($y1)->multiply($b);
|
||||
$y3 = $p1->add($p2);
|
||||
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
$c = $z1->multiply($z1);
|
||||
$d = $c->multiply($c);
|
||||
$x3 = $b->add($this->b->multiply($d->multiply($d)));
|
||||
$z3 = $x1->multiply($c);
|
||||
$p1 = $b->multiply($z3);
|
||||
$p2 = $a->add($y1->multiply($z1))->add($z3)->multiply($x3);
|
||||
$y3 = $p1->add($p2);
|
||||
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the X coordinate and the derived Y coordinate
|
||||
*
|
||||
* Not supported because it is covered by patents.
|
||||
* Quoting https://www.openssl.org/docs/man1.1.0/apps/ecparam.html ,
|
||||
*
|
||||
* "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)
|
||||
{
|
||||
throw new \RuntimeException('Point compression on binary finite field elliptic curves is not supported');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not the x / y values satisfy the equation
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function verifyPoint(array $p)
|
||||
{
|
||||
list($x, $y) = $p;
|
||||
$lhs = $y->multiply($y);
|
||||
$lhs = $lhs->add($x->multiply($y));
|
||||
$x2 = $x->multiply($x);
|
||||
$x3 = $x2->multiply($x);
|
||||
$rhs = $x3->add($this->a->multiply($x2))->add($this->b);
|
||||
|
||||
return $lhs->equals($rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the modulo
|
||||
*
|
||||
* @return \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
public function getModulo()
|
||||
{
|
||||
return $this->modulo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the a coefficient
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function getA()
|
||||
{
|
||||
return $this->a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the a coefficient
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function getB()
|
||||
{
|
||||
return $this->b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the affine point
|
||||
*
|
||||
* A Jacobian Coordinate is of the form (x, y, z).
|
||||
* To convert a Jacobian Coordinate to an Affine Point
|
||||
* you do (x / z^2, y / z^3)
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToAffine(array $p)
|
||||
{
|
||||
if (!isset($p[2])) {
|
||||
return $p;
|
||||
}
|
||||
list($x, $y, $z) = $p;
|
||||
$z = $this->one->divide($z);
|
||||
$z2 = $z->multiply($z);
|
||||
return [
|
||||
$x->multiply($z2),
|
||||
$y->multiply($z2)->multiply($z)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an affine point to a jacobian coordinate
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToInternal(array $p)
|
||||
{
|
||||
if (isset($p[2])) {
|
||||
return $p;
|
||||
}
|
||||
|
||||
$p[2] = clone $this->one;
|
||||
$p['fresh'] = true;
|
||||
return $p;
|
||||
}
|
||||
}
|
|
@ -1,325 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Generalized Koblitz Curves over y^2 = x^3 + b.
|
||||
*
|
||||
* According to http://www.secg.org/SEC2-Ver-1.0.pdf Koblitz curves are over the GF(2**m)
|
||||
* finite field. Both the $a$ and $b$ coefficients are either 0 or 1. However, SEC2
|
||||
* generalizes the definition to include curves over GF(P) "which possess an efficiently
|
||||
* computable endomorphism".
|
||||
*
|
||||
* For these generalized Koblitz curves $b$ doesn't have to be 0 or 1. Whether or not $a$
|
||||
* has any restrictions on it is unclear, however, for all the GF(P) Koblitz curves defined
|
||||
* in SEC2 v1.0 $a$ is $0$ so all of the methods defined herein will assume that it is.
|
||||
*
|
||||
* I suppose we could rename the $b$ coefficient to $a$, however, the documentation refers
|
||||
* to $b$ so we'll just keep it.
|
||||
*
|
||||
* If a later version of SEC2 comes out wherein some $a$ values are non-zero we can create a
|
||||
* new method for those. eg. KoblitzA1Prime.php or something.
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\BaseCurves;
|
||||
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Math\PrimeField;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
|
||||
|
||||
/**
|
||||
* Curves over y^2 = x^3 + b
|
||||
*
|
||||
* @package KoblitzPrime
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class KoblitzPrime extends Prime
|
||||
{
|
||||
// don't overwrite setCoefficients() with one that only accepts one parameter so that
|
||||
// one might be able to switch between KoblitzPrime and Prime more easily (for benchmarking
|
||||
// purposes).
|
||||
|
||||
/**
|
||||
* Multiply and Add Points
|
||||
*
|
||||
* Uses a efficiently computable endomorphism to achieve a slight speedup
|
||||
*
|
||||
* Adapted from https://git.io/vxbrP
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function multiplyAddPoints(array $points, array $scalars)
|
||||
{
|
||||
static $zero, $one, $two;
|
||||
if (!isset($two)) {
|
||||
$two = new BigInteger(2);
|
||||
$one = new BigInteger(1);
|
||||
}
|
||||
|
||||
if (!isset($this->beta)) {
|
||||
// get roots
|
||||
$inv = $this->one->divide($this->two)->negate();
|
||||
$s = $this->three->negate()->squareRoot()->multiply($inv);
|
||||
$betas = [
|
||||
$inv->add($s),
|
||||
$inv->subtract($s)
|
||||
];
|
||||
$this->beta = $betas[0]->compare($betas[1]) < 0 ? $betas[0] : $betas[1];
|
||||
//echo strtoupper($this->beta->toHex(true)) . "\n"; exit;
|
||||
}
|
||||
|
||||
if (!isset($this->basis)) {
|
||||
$factory = new PrimeField($this->order);
|
||||
$tempOne = $factory->newInteger($one);
|
||||
$tempTwo = $factory->newInteger($two);
|
||||
$tempThree = $factory->newInteger(new BigInteger(3));
|
||||
|
||||
$inv = $tempOne->divide($tempTwo)->negate();
|
||||
$s = $tempThree->negate()->squareRoot()->multiply($inv);
|
||||
|
||||
$lambdas = [
|
||||
$inv->add($s),
|
||||
$inv->subtract($s)
|
||||
];
|
||||
|
||||
$lhs = $this->multiplyPoint($this->p, $lambdas[0])[0];
|
||||
$rhs = $this->p[0]->multiply($this->beta);
|
||||
$lambda = $lhs->equals($rhs) ? $lambdas[0] : $lambdas[1];
|
||||
|
||||
$this->basis = static::extendedGCD($lambda->toBigInteger(), $this->order);
|
||||
///*
|
||||
foreach ($this->basis as $basis) {
|
||||
echo strtoupper($basis['a']->toHex(true)) . "\n";
|
||||
echo strtoupper($basis['b']->toHex(true)) . "\n\n";
|
||||
}
|
||||
exit;
|
||||
//*/
|
||||
}
|
||||
|
||||
$npoints = $nscalars = [];
|
||||
for ($i = 0; $i < count($points); $i++) {
|
||||
$p = $points[$i];
|
||||
$k = $scalars[$i]->toBigInteger();
|
||||
|
||||
// begin split
|
||||
list($v1, $v2) = $this->basis;
|
||||
|
||||
$c1 = $v2['b']->multiply($k);
|
||||
list($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);
|
||||
if ($this->order->compare($r->multiply($two)) <= 0) {
|
||||
$c2 = $c2->add($one);
|
||||
}
|
||||
|
||||
$p1 = $c1->multiply($v1['a']);
|
||||
$p2 = $c2->multiply($v2['a']);
|
||||
$q1 = $c1->multiply($v1['b']);
|
||||
$q2 = $c2->multiply($v2['b']);
|
||||
|
||||
$k1 = $k->subtract($p1)->subtract($p2);
|
||||
$k2 = $q1->add($q2)->negate();
|
||||
// end split
|
||||
|
||||
$beta = [
|
||||
$p[0]->multiply($this->beta),
|
||||
$p[1],
|
||||
clone $this->one
|
||||
];
|
||||
|
||||
if (isset($p['naf'])) {
|
||||
$beta['naf'] = array_map(function($p) {
|
||||
return [
|
||||
$p[0]->multiply($this->beta),
|
||||
$p[1],
|
||||
clone $this->one
|
||||
];
|
||||
}, $p['naf']);
|
||||
$beta['nafwidth'] = $p['nafwidth'];
|
||||
}
|
||||
|
||||
if ($k1->isNegative()) {
|
||||
$k1 = $k1->negate();
|
||||
$p = $this->negatePoint($p);
|
||||
}
|
||||
|
||||
if ($k2->isNegative()) {
|
||||
$k2 = $k2->negate();
|
||||
$beta = $this->negatePoint($beta);
|
||||
}
|
||||
|
||||
$pos = 2 * $i;
|
||||
$npoints[$pos] = $p;
|
||||
$nscalars[$pos] = $this->factory->newInteger($k1);
|
||||
|
||||
$pos++;
|
||||
$npoints[$pos] = $beta;
|
||||
$nscalars[$pos] = $this->factory->newInteger($k2);
|
||||
}
|
||||
|
||||
return parent::multiplyAddPoints($npoints, $nscalars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numerator and denominator of the slope
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function doublePointHelper(array $p)
|
||||
{
|
||||
$numerator = $this->three->multiply($p[0])->multiply($p[0]);
|
||||
$denominator = $this->two->multiply($p[1]);
|
||||
return [$numerator, $denominator];
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a jacobian coordinate on the curve
|
||||
*
|
||||
* See http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-dbl-2009-l
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function jacobianDoublePoint(array $p)
|
||||
{
|
||||
list($x1, $y1, $z1) = $p;
|
||||
$a = $x1->multiply($x1);
|
||||
$b = $y1->multiply($y1);
|
||||
$c = $b->multiply($b);
|
||||
$d = $x1->add($b);
|
||||
$d = $d->multiply($d)->subtract($a)->subtract($c)->multiply($this->two);
|
||||
$e = $this->three->multiply($a);
|
||||
$f = $e->multiply($e);
|
||||
$x3 = $f->subtract($this->two->multiply($d));
|
||||
$y3 = $e->multiply($d->subtract($x3))->subtract(
|
||||
$this->eight->multiply($c));
|
||||
$z3 = $this->two->multiply($y1)->multiply($z1);
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a "fresh" jacobian coordinate on the curve
|
||||
*
|
||||
* See http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-mdbl-2007-bl
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function jacobianDoublePointMixed(array $p)
|
||||
{
|
||||
list($x1, $y1) = $p;
|
||||
$xx = $x1->multiply($x1);
|
||||
$yy = $y1->multiply($y1);
|
||||
$yyyy = $yy->multiply($yy);
|
||||
$s = $x1->add($yy);
|
||||
$s = $s->multiply($s)->subtract($xx)->subtract($yyyy)->multiply($this->two);
|
||||
$m = $this->three->multiply($xx);
|
||||
$t = $m->multiply($m)->subtract($this->two->multiply($s));
|
||||
$x3 = $t;
|
||||
$y3 = $s->subtract($t);
|
||||
$y3 = $m->multiply($y3)->subtract($this->eight->multiply($yyyy));
|
||||
$z3 = $this->two->multiply($y1);
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not the x / y values satisfy the equation
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function verifyPoint(array $p)
|
||||
{
|
||||
list($x, $y) = $p;
|
||||
$lhs = $y->multiply($y);
|
||||
$temp = $x->multiply($x)->multiply($x);
|
||||
$rhs = $temp->add($this->b);
|
||||
|
||||
return $lhs->equals($rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$one = new BigInteger(1);
|
||||
$zero = new BigInteger();
|
||||
|
||||
$a = clone $one;
|
||||
$b = clone $zero;
|
||||
$c = clone $zero;
|
||||
$d = clone $one;
|
||||
|
||||
$stop = $v->bitwise_rightShift($v->getLength() >> 1);
|
||||
|
||||
$a1 = clone $zero;
|
||||
$b1 = clone $zero;
|
||||
$a2 = clone $zero;
|
||||
$b2 = clone $zero;
|
||||
|
||||
$postGreatestIndex = 0;
|
||||
|
||||
while (!$v->equals($zero)) {
|
||||
list($q) = $u->divide($v);
|
||||
|
||||
$temp = $u;
|
||||
$u = $v;
|
||||
$v = $temp->subtract($v->multiply($q));
|
||||
|
||||
$temp = $a;
|
||||
$a = $c;
|
||||
$c = $temp->subtract($a->multiply($q));
|
||||
|
||||
$temp = $b;
|
||||
$b = $d;
|
||||
$d = $temp->subtract($b->multiply($q));
|
||||
|
||||
if ($v->compare($stop) > 0) {
|
||||
$a0 = $v;
|
||||
$b0 = $c;
|
||||
} else {
|
||||
$postGreatestIndex++;
|
||||
}
|
||||
|
||||
if ($postGreatestIndex == 1) {
|
||||
$a1 = $v;
|
||||
$b1 = $c->negate();
|
||||
}
|
||||
|
||||
if ($postGreatestIndex == 2) {
|
||||
$rhs = $a0->multiply($a0)->add($b0->multiply($b0));
|
||||
$lhs = $v->multiply($v)->add($b->multiply($b));
|
||||
if ($lhs->compare($rhs) <= 0) {
|
||||
$a2 = $a0;
|
||||
$b2 = $b0->negate();
|
||||
} else {
|
||||
$a2 = $v;
|
||||
$b2 = $c->negate();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
['a' => $a1, 'b' => $b1],
|
||||
['a' => $a2, 'b' => $b2]
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,285 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Curves over y^2 = x^3 + a*x + x
|
||||
*
|
||||
* Technically, a Montgomery curve has a coefficient for y^2 but for Curve25519 and Curve448 that
|
||||
* coefficient is 1.
|
||||
*
|
||||
* Curve25519 and Curve448 do not make use of the y coordinate, which makes it unsuitable for use
|
||||
* with ECDSA / EdDSA. A few other differences between Curve25519 and Ed25519 are discussed at
|
||||
* https://crypto.stackexchange.com/a/43058/4520
|
||||
*
|
||||
* More info:
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Montgomery_curve
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2019 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\BaseCurves;
|
||||
|
||||
use phpseclib3\Math\Common\FiniteField\Integer;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Math\PrimeField;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\EC\Curves\Curve25519;
|
||||
use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
|
||||
|
||||
/**
|
||||
* Curves over y^2 = x^3 + a*x + x
|
||||
*
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class Montgomery extends Base
|
||||
{
|
||||
/**
|
||||
* Prime Field Integer factory
|
||||
*
|
||||
* @var \phpseclib3\Math\PrimeField
|
||||
*/
|
||||
protected $factory;
|
||||
|
||||
/**
|
||||
* Cofficient for x
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $a;
|
||||
|
||||
/**
|
||||
* Constant used for point doubling
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $a24;
|
||||
|
||||
/**
|
||||
* The Number Zero
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $zero;
|
||||
|
||||
/**
|
||||
* The Number One
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $one;
|
||||
|
||||
/**
|
||||
* Base Point
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $p;
|
||||
|
||||
/**
|
||||
* The modulo
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $modulo;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Sets the modulo
|
||||
*/
|
||||
public function setModulo(BigInteger $modulo)
|
||||
{
|
||||
$this->modulo = $modulo;
|
||||
$this->factory = new PrimeField($modulo);
|
||||
$this->zero = $this->factory->newInteger(new BigInteger());
|
||||
$this->one = $this->factory->newInteger(new BigInteger(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set coefficients a
|
||||
*/
|
||||
public function setCoefficients(BigInteger $a)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->a = $this->factory->newInteger($a);
|
||||
$two = $this->factory->newInteger(new BigInteger(2));
|
||||
$four = $this->factory->newInteger(new BigInteger(4));
|
||||
$this->a24 = $this->a->subtract($two)->divide($four);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set x and y coordinates for the base point
|
||||
*
|
||||
* @param BigInteger|PrimeInteger $x
|
||||
* @param BigInteger|PrimeInteger $y
|
||||
* @return PrimeInteger[]
|
||||
*/
|
||||
public function setBasePoint($x, $y)
|
||||
{
|
||||
switch (true) {
|
||||
case !$x instanceof BigInteger && !$x instanceof PrimeInteger:
|
||||
throw new \UnexpectedValueException('Argument 1 passed to Prime::setBasePoint() must be an instance of either BigInteger or PrimeField\Integer');
|
||||
case !$y instanceof BigInteger && !$y instanceof PrimeInteger:
|
||||
throw new \UnexpectedValueException('Argument 2 passed to Prime::setBasePoint() must be an instance of either BigInteger or PrimeField\Integer');
|
||||
}
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->p = [
|
||||
$x instanceof BigInteger ? $this->factory->newInteger($x) : $x,
|
||||
$y instanceof BigInteger ? $this->factory->newInteger($y) : $y
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the base point as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBasePoint()
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
/*
|
||||
if (!isset($this->p)) {
|
||||
throw new \RuntimeException('setBasePoint needs to be called before this method');
|
||||
}
|
||||
*/
|
||||
return $this->p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles and adds a point on a curve
|
||||
*
|
||||
* See https://tools.ietf.org/html/draft-ietf-tls-curve25519-01#appendix-A.1.3
|
||||
*
|
||||
* @return FiniteField[][]
|
||||
*/
|
||||
private function doubleAndAddPoint(array $p, array $q, PrimeInteger $x1)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p) || !count($q)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!isset($p[1])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to XZ coordinates');
|
||||
}
|
||||
|
||||
list($x2, $z2) = $p;
|
||||
list($x3, $z3) = $q;
|
||||
|
||||
$a = $x2->add($z2);
|
||||
$aa = $a->multiply($a);
|
||||
$b = $x2->subtract($z2);
|
||||
$bb = $b->multiply($b);
|
||||
$e = $aa->subtract($bb);
|
||||
$c = $x3->add($z3);
|
||||
$d = $x3->subtract($z3);
|
||||
$da = $d->multiply($a);
|
||||
$cb = $c->multiply($b);
|
||||
$temp = $da->add($cb);
|
||||
$x5 = $temp->multiply($temp);
|
||||
$temp = $da->subtract($cb);
|
||||
$z5 = $x1->multiply($temp->multiply($temp));
|
||||
$x4 = $aa->multiply($bb);
|
||||
$temp = static::class == Curve25519::class ? $bb : $aa;
|
||||
$z4 = $e->multiply($temp->add($this->a24->multiply($e)));
|
||||
|
||||
return [
|
||||
[$x4, $z4],
|
||||
[$x5, $z5]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply a point on the curve by a scalar
|
||||
*
|
||||
* Uses the montgomery ladder technique as described here:
|
||||
*
|
||||
* 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, Integer $d)
|
||||
{
|
||||
$p1 = [$this->one, $this->zero];
|
||||
$alreadyInternal = isset($x[1]);
|
||||
$p2 = $this->convertToInternal($p);
|
||||
$x = $p[0];
|
||||
|
||||
$b = $d->toBits();
|
||||
$b = str_pad($b, 256, '0', STR_PAD_LEFT);
|
||||
for ($i = 0; $i < strlen($b); $i++) {
|
||||
$b_i = (int) $b[$i];
|
||||
if ($b_i) {
|
||||
list($p2, $p1) = $this->doubleAndAddPoint($p2, $p1, $x);
|
||||
} else {
|
||||
list($p1, $p2) = $this->doubleAndAddPoint($p1, $p2, $x);
|
||||
}
|
||||
}
|
||||
|
||||
return $alreadyInternal ? $p1 : $this->convertToAffine($p1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an affine point to an XZ coordinate
|
||||
*
|
||||
* From https://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html
|
||||
*
|
||||
* XZ coordinates represent x y as X Z satsfying the following equations:
|
||||
*
|
||||
* x=X/Z
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToInternal(array $p)
|
||||
{
|
||||
if (empty($p)) {
|
||||
return [clone $this->zero, clone $this->one];
|
||||
}
|
||||
|
||||
if (isset($p[1])) {
|
||||
return $p;
|
||||
}
|
||||
|
||||
$p[1] = clone $this->one;
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the affine point
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToAffine(array $p)
|
||||
{
|
||||
if (!isset($p[1])) {
|
||||
return $p;
|
||||
}
|
||||
list($x, $z) = $p;
|
||||
return [$x->divide($z)];
|
||||
}
|
||||
}
|
|
@ -1,774 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Curves over y^2 = x^3 + a*x + b
|
||||
*
|
||||
* These are curves used in SEC 2 over prime fields: http://www.secg.org/SEC2-Ver-1.0.pdf
|
||||
* The curve is a weierstrass curve with a[1], a[3] and a[2] set to 0.
|
||||
*
|
||||
* Uses Jacobian Coordinates for speed if able:
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Jacobian_curve
|
||||
* https://en.wikibooks.org/wiki/Cryptography/Prime_Curve/Jacobian_Coordinates
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\BaseCurves;
|
||||
|
||||
use phpseclib3\Math\Common\FiniteField\Integer;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Math\PrimeField;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
|
||||
|
||||
/**
|
||||
* Curves over y^2 = x^3 + a*x + b
|
||||
*
|
||||
* @package Prime
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class Prime extends Base
|
||||
{
|
||||
/**
|
||||
* Prime Field Integer factory
|
||||
*
|
||||
* @var \phpseclib3\Math\PrimeFields
|
||||
*/
|
||||
protected $factory;
|
||||
|
||||
/**
|
||||
* Cofficient for x^1
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $a;
|
||||
|
||||
/**
|
||||
* Cofficient for x^0
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $b;
|
||||
|
||||
/**
|
||||
* Base Point
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $p;
|
||||
|
||||
/**
|
||||
* The number one over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $one;
|
||||
|
||||
/**
|
||||
* The number two over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $two;
|
||||
|
||||
/**
|
||||
* The number three over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $three;
|
||||
|
||||
/**
|
||||
* The number four over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $four;
|
||||
|
||||
/**
|
||||
* The number eight over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $eight;
|
||||
|
||||
/**
|
||||
* The modulo
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $modulo;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Sets the modulo
|
||||
*/
|
||||
public function setModulo(BigInteger $modulo)
|
||||
{
|
||||
$this->modulo = $modulo;
|
||||
$this->factory = new PrimeField($modulo);
|
||||
$this->two = $this->factory->newInteger(new BigInteger(2));
|
||||
$this->three = $this->factory->newInteger(new BigInteger(3));
|
||||
// used by jacobian coordinates
|
||||
$this->one = $this->factory->newInteger(new BigInteger(1));
|
||||
$this->four = $this->factory->newInteger(new BigInteger(4));
|
||||
$this->eight = $this->factory->newInteger(new BigInteger(8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set coefficients a and b
|
||||
*/
|
||||
public function setCoefficients(BigInteger $a, BigInteger $b)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->a = $this->factory->newInteger($a);
|
||||
$this->b = $this->factory->newInteger($b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set x and y coordinates for the base point
|
||||
*
|
||||
* @param BigInteger|PrimeInteger $x
|
||||
* @param BigInteger|PrimeInteger $y
|
||||
* @return PrimeInteger[]
|
||||
*/
|
||||
public function setBasePoint($x, $y)
|
||||
{
|
||||
switch (true) {
|
||||
case !$x instanceof BigInteger && !$x instanceof PrimeInteger:
|
||||
throw new \UnexpectedValueException('Argument 1 passed to Prime::setBasePoint() must be an instance of either BigInteger or PrimeField\Integer');
|
||||
case !$y instanceof BigInteger && !$y instanceof PrimeInteger:
|
||||
throw new \UnexpectedValueException('Argument 2 passed to Prime::setBasePoint() must be an instance of either BigInteger or PrimeField\Integer');
|
||||
}
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->p = [
|
||||
$x instanceof BigInteger ? $this->factory->newInteger($x) : $x,
|
||||
$y instanceof BigInteger ? $this->factory->newInteger($y) : $y
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the base point as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBasePoint()
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
/*
|
||||
if (!isset($this->p)) {
|
||||
throw new \RuntimeException('setBasePoint needs to be called before this method');
|
||||
}
|
||||
*/
|
||||
return $this->p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two "fresh" jacobian form on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function jacobianAddPointMixedXY(array $p, array $q)
|
||||
{
|
||||
list($u1, $s1) = $p;
|
||||
list($u2, $s2) = $q;
|
||||
if ($u1->equals($u2)) {
|
||||
if (!$s1->equals($s2)) {
|
||||
return [];
|
||||
} else {
|
||||
return $this->doublePoint($p);
|
||||
}
|
||||
}
|
||||
$h = $u2->subtract($u1);
|
||||
$r = $s2->subtract($s1);
|
||||
$h2 = $h->multiply($h);
|
||||
$h3 = $h2->multiply($h);
|
||||
$v = $u1->multiply($h2);
|
||||
$x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
|
||||
$y3 = $r->multiply(
|
||||
$v->subtract($x3))->subtract(
|
||||
$s1->multiply($h3));
|
||||
return [$x3, $y3, $h];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one "fresh" jacobian form on the curve
|
||||
*
|
||||
* The second parameter should be the "fresh" one
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function jacobianAddPointMixedX(array $p, array $q)
|
||||
{
|
||||
list($u1, $s1, $z1) = $p;
|
||||
list($x2, $y2) = $q;
|
||||
|
||||
$z12 = $z1->multiply($z1);
|
||||
|
||||
$u2 = $x2->multiply($z12);
|
||||
$s2 = $y2->multiply($z12->multiply($z1));
|
||||
if ($u1->equals($u2)) {
|
||||
if (!$s1->equals($s2)) {
|
||||
return [];
|
||||
} else {
|
||||
return $this->doublePoint($p);
|
||||
}
|
||||
}
|
||||
$h = $u2->subtract($u1);
|
||||
$r = $s2->subtract($s1);
|
||||
$h2 = $h->multiply($h);
|
||||
$h3 = $h2->multiply($h);
|
||||
$v = $u1->multiply($h2);
|
||||
$x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
|
||||
$y3 = $r->multiply(
|
||||
$v->subtract($x3))->subtract(
|
||||
$s1->multiply($h3));
|
||||
$z3 = $h->multiply($z1);
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two jacobian coordinates on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function jacobianAddPoint(array $p, array $q)
|
||||
{
|
||||
list($x1, $y1, $z1) = $p;
|
||||
list($x2, $y2, $z2) = $q;
|
||||
|
||||
$z12 = $z1->multiply($z1);
|
||||
$z22 = $z2->multiply($z2);
|
||||
|
||||
$u1 = $x1->multiply($z22);
|
||||
$u2 = $x2->multiply($z12);
|
||||
$s1 = $y1->multiply($z22->multiply($z2));
|
||||
$s2 = $y2->multiply($z12->multiply($z1));
|
||||
if ($u1->equals($u2)) {
|
||||
if (!$s1->equals($s2)) {
|
||||
return [];
|
||||
} else {
|
||||
return $this->doublePoint($p);
|
||||
}
|
||||
}
|
||||
$h = $u2->subtract($u1);
|
||||
$r = $s2->subtract($s1);
|
||||
$h2 = $h->multiply($h);
|
||||
$h3 = $h2->multiply($h);
|
||||
$v = $u1->multiply($h2);
|
||||
$x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
|
||||
$y3 = $r->multiply(
|
||||
$v->subtract($x3))->subtract(
|
||||
$s1->multiply($h3));
|
||||
$z3 = $h->multiply($z1)->multiply($z2);
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two points on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function addPoint(array $p, array $q)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p) || !count($q)) {
|
||||
if (count($q)) {
|
||||
return $q;
|
||||
}
|
||||
if (count($p)) {
|
||||
return $p;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// use jacobian coordinates
|
||||
if (isset($p[2]) && isset($q[2])) {
|
||||
if (isset($p['fresh']) && isset($q['fresh'])) {
|
||||
return $this->jacobianAddPointMixedXY($p, $q);
|
||||
}
|
||||
if (isset($p['fresh'])) {
|
||||
return $this->jacobianAddPointMixedX($q, $p);
|
||||
}
|
||||
if (isset($q['fresh'])) {
|
||||
return $this->jacobianAddPointMixedX($p, $q);
|
||||
}
|
||||
return $this->jacobianAddPoint($p, $q);
|
||||
}
|
||||
|
||||
if (isset($p[2]) || isset($q[2])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to Jacobi coordinates or vice versa');
|
||||
}
|
||||
|
||||
if ($p[0]->equals($q[0])) {
|
||||
if (!$p[1]->equals($q[1])) {
|
||||
return [];
|
||||
} else { // eg. doublePoint
|
||||
list($numerator, $denominator) = $this->doublePointHelper($p);
|
||||
}
|
||||
} else {
|
||||
$numerator = $q[1]->subtract($p[1]);
|
||||
$denominator = $q[0]->subtract($p[0]);
|
||||
}
|
||||
$slope = $numerator->divide($denominator);
|
||||
$x = $slope->multiply($slope)->subtract($p[0])->subtract($q[0]);
|
||||
$y = $slope->multiply($p[0]->subtract($x))->subtract($p[1]);
|
||||
|
||||
return [$x, $y];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numerator and denominator of the slope
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function doublePointHelper(array $p)
|
||||
{
|
||||
$numerator = $this->three->multiply($p[0])->multiply($p[0])->add($this->a);
|
||||
$denominator = $this->two->multiply($p[1]);
|
||||
return [$numerator, $denominator];
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a jacobian coordinate on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function jacobianDoublePoint(array $p)
|
||||
{
|
||||
list($x, $y, $z) = $p;
|
||||
$x2 = $x->multiply($x);
|
||||
$y2 = $y->multiply($y);
|
||||
$z2 = $z->multiply($z);
|
||||
$s = $this->four->multiply($x)->multiply($y2);
|
||||
$m1 = $this->three->multiply($x2);
|
||||
$m2 = $this->a->multiply($z2->multiply($z2));
|
||||
$m = $m1->add($m2);
|
||||
$x1 = $m->multiply($m)->subtract($this->two->multiply($s));
|
||||
$y1 = $m->multiply($s->subtract($x1))->subtract(
|
||||
$this->eight->multiply($y2->multiply($y2)));
|
||||
$z1 = $this->two->multiply($y)->multiply($z);
|
||||
return [$x1, $y1, $z1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a "fresh" jacobian coordinate on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
protected function jacobianDoublePointMixed(array $p)
|
||||
{
|
||||
list($x, $y) = $p;
|
||||
$x2 = $x->multiply($x);
|
||||
$y2 = $y->multiply($y);
|
||||
$s = $this->four->multiply($x)->multiply($y2);
|
||||
$m1 = $this->three->multiply($x2);
|
||||
$m = $m1->add($this->a);
|
||||
$x1 = $m->multiply($m)->subtract($this->two->multiply($s));
|
||||
$y1 = $m->multiply($s->subtract($x1))->subtract(
|
||||
$this->eight->multiply($y2->multiply($y2)));
|
||||
$z1 = $this->two->multiply($y);
|
||||
return [$x1, $y1, $z1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a point on a curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function doublePoint(array $p)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// use jacobian coordinates
|
||||
if (isset($p[2])) {
|
||||
if (isset($p['fresh'])) {
|
||||
return $this->jacobianDoublePointMixed($p);
|
||||
}
|
||||
return $this->jacobianDoublePoint($p);
|
||||
}
|
||||
|
||||
list($numerator, $denominator) = $this->doublePointHelper($p);
|
||||
|
||||
$slope = $numerator->divide($denominator);
|
||||
|
||||
$x = $slope->multiply($slope)->subtract($p[0])->subtract($p[0]);
|
||||
$y = $slope->multiply($p[0]->subtract($x))->subtract($p[1]);
|
||||
|
||||
return [$x, $y];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the X coordinate and the derived Y coordinate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function derivePoint($m)
|
||||
{
|
||||
$y = ord(Strings::shift($m));
|
||||
$x = new BigInteger($m, 256);
|
||||
$xp = $this->convertInteger($x);
|
||||
switch ($y) {
|
||||
case 2: $ypn = false; break;
|
||||
case 3: $ypn = true; break;
|
||||
default:
|
||||
throw new \RuntimeException('Coordinate not in recognized format');
|
||||
}
|
||||
$temp = $xp->multiply($this->a);
|
||||
$temp = $xp->multiply($xp)->multiply($xp)->add($temp);
|
||||
$temp = $temp->add($this->b);
|
||||
$b = $temp->squareRoot();
|
||||
if (!$b) {
|
||||
throw new \RuntimeException('Unable to derive Y coordinate');
|
||||
}
|
||||
$bn = $b->isOdd();
|
||||
$yp = $ypn == $bn ? $b : $b->negate();
|
||||
return [$xp, $yp];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not the x / y values satisfy the equation
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function verifyPoint(array $p)
|
||||
{
|
||||
list($x, $y) = $p;
|
||||
$lhs = $y->multiply($y);
|
||||
$temp = $x->multiply($this->a);
|
||||
$temp = $x->multiply($x)->multiply($x)->add($temp);
|
||||
$rhs = $temp->add($this->b);
|
||||
|
||||
return $lhs->equals($rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the modulo
|
||||
*
|
||||
* @return \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
public function getModulo()
|
||||
{
|
||||
return $this->modulo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the a coefficient
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function getA()
|
||||
{
|
||||
return $this->a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the a coefficient
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function getB()
|
||||
{
|
||||
return $this->b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply and Add Points
|
||||
*
|
||||
* Adapted from https://git.io/vxPUH
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function multiplyAddPoints(array $points, array $scalars)
|
||||
{
|
||||
$length = count($points);
|
||||
|
||||
foreach ($points as &$point) {
|
||||
$point = $this->convertToInternal($point);
|
||||
}
|
||||
|
||||
$wnd = [$this->getNAFPoints($points[0], 7)];
|
||||
$wndWidth = [isset($points[0]['nafwidth']) ? $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;
|
||||
}
|
||||
|
||||
$naf = [];
|
||||
|
||||
// comb all window NAFs
|
||||
|
||||
$max = 0;
|
||||
for ($i = $length - 1; $i >= 1; $i-= 2) {
|
||||
$a = $i - 1;
|
||||
$b = $i;
|
||||
if ($wndWidth[$a] != 1 || $wndWidth[$b] != 1) {
|
||||
$naf[$a] = $scalars[$a]->getNAF($wndWidth[$a]);
|
||||
$naf[$b] = $scalars[$b]->getNAF($wndWidth[$b]);
|
||||
$max = max(count($naf[$a]), count($naf[$b]), $max);
|
||||
continue;
|
||||
}
|
||||
|
||||
$comb = [
|
||||
$points[$a], // 1
|
||||
null, // 3
|
||||
null, // 5
|
||||
$points[$b] // 7
|
||||
];
|
||||
|
||||
$comb[1] = $this->addPoint($points[$a], $points[$b]);
|
||||
$comb[2] = $this->addPoint($points[$a], $this->negatePoint($points[$b]));
|
||||
|
||||
$index = [
|
||||
-3, /* -1 -1 */
|
||||
-1, /* -1 0 */
|
||||
-5, /* -1 1 */
|
||||
-7, /* 0 -1 */
|
||||
0, /* 0 -1 */
|
||||
7, /* 0 1 */
|
||||
5, /* 1 -1 */
|
||||
1, /* 1 0 */
|
||||
3 /* 1 1 */
|
||||
];
|
||||
|
||||
$jsf = self::getJSFPoints($scalars[$a], $scalars[$b]);
|
||||
|
||||
$max = max(count($jsf[0]), $max);
|
||||
if ($max > 0) {
|
||||
$naf[$a] = array_fill(0, $max, 0);
|
||||
$naf[$b] = array_fill(0, $max, 0);
|
||||
} else {
|
||||
$naf[$a] = [];
|
||||
$naf[$b] = [];
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $max; $j++) {
|
||||
$ja = isset($jsf[0][$j]) ? $jsf[0][$j] : 0;
|
||||
$jb = isset($jsf[1][$j]) ? $jsf[1][$j] : 0;
|
||||
|
||||
$naf[$a][$j] = $index[3 * ($ja + 1) + $jb + 1];
|
||||
$naf[$b][$j] = 0;
|
||||
$wnd[$a] = $comb;
|
||||
}
|
||||
}
|
||||
|
||||
$acc = [];
|
||||
$temp = [0, 0, 0, 0];
|
||||
for ($i = $max; $i >= 0; $i--) {
|
||||
$k = 0;
|
||||
while ($i >= 0) {
|
||||
$zero = true;
|
||||
for ($j = 0; $j < $length; $j++) {
|
||||
$temp[$j] = isset($naf[$j][$i]) ? $naf[$j][$i] : 0;
|
||||
if ($temp[$j] != 0) {
|
||||
$zero = false;
|
||||
}
|
||||
}
|
||||
if (!$zero) {
|
||||
break;
|
||||
}
|
||||
$k++;
|
||||
$i--;
|
||||
}
|
||||
|
||||
if ($i >= 0) {
|
||||
$k++;
|
||||
}
|
||||
while ($k--) {
|
||||
$acc = $this->doublePoint($acc);
|
||||
}
|
||||
|
||||
if ($i < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $length; $j++) {
|
||||
$z = $temp[$j];
|
||||
$p = null;
|
||||
if ($z == 0) {
|
||||
continue;
|
||||
}
|
||||
$p = $z > 0 ?
|
||||
$wnd[$j][($z - 1) >> 1] :
|
||||
$this->negatePoint($wnd[$j][(-$z - 1) >> 1]);
|
||||
$acc = $this->addPoint($acc, $p);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->convertToAffine($acc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Precomputes NAF points
|
||||
*
|
||||
* Adapted from https://git.io/vxY1f
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
private function getNAFPoints($point, $wnd)
|
||||
{
|
||||
if (isset($point['naf'])) {
|
||||
return $point['naf'];
|
||||
}
|
||||
|
||||
$res = [$point];
|
||||
$max = (1 << $wnd) - 1;
|
||||
$dbl = $max == 1 ? null : $this->doublePoint($point);
|
||||
for ($i = 1; $i < $max; $i++) {
|
||||
$res[] = $this->addPoint($res[$i - 1], $dbl);
|
||||
}
|
||||
|
||||
$point['naf'] = $res;
|
||||
|
||||
/*
|
||||
$str = '';
|
||||
foreach ($res as $re) {
|
||||
$re[0] = bin2hex($re[0]->toBytes());
|
||||
$re[1] = bin2hex($re[1]->toBytes());
|
||||
$str.= " ['$re[0]', '$re[1]'],\r\n";
|
||||
}
|
||||
file_put_contents('temp.txt', $str);
|
||||
exit;
|
||||
*/
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Precomputes points in Joint Sparse Form
|
||||
*
|
||||
* Adapted from https://git.io/vxrpD
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
private static function getJSFPoints(Integer $k1, Integer $k2)
|
||||
{
|
||||
static $three;
|
||||
if (!isset($three)) {
|
||||
$three = new BigInteger(3);
|
||||
}
|
||||
|
||||
$jsf = [[], []];
|
||||
$k1 = $k1->toBigInteger();
|
||||
$k2 = $k2->toBigInteger();
|
||||
$d1 = 0;
|
||||
$d2 = 0;
|
||||
|
||||
while ($k1->compare(new BigInteger(-$d1)) > 0 || $k2->compare(new BigInteger(-$d2)) > 0) {
|
||||
// first phase
|
||||
$m14 = $k1->testBit(0) + 2 * $k1->testBit(1);
|
||||
$m14+= $d1;
|
||||
$m14&= 3;
|
||||
|
||||
$m24 = $k2->testBit(0) + 2 * $k2->testBit(1);
|
||||
$m24+= $d2;
|
||||
$m24&= 3;
|
||||
|
||||
if ($m14 == 3) {
|
||||
$m14 = -1;
|
||||
}
|
||||
if ($m24 == 3) {
|
||||
$m24 = -1;
|
||||
}
|
||||
|
||||
$u1 = 0;
|
||||
if ($m14 & 1) { // if $m14 is odd
|
||||
$m8 = $k1->testBit(0) + 2 * $k1->testBit(1) + 4 * $k1->testBit(2);
|
||||
$m8+= $d1;
|
||||
$m8&= 7;
|
||||
$u1 = ($m8 == 3 || $m8 == 5) && $m24 == 2 ? -$m14 : $m14;
|
||||
}
|
||||
$jsf[0][] = $u1;
|
||||
|
||||
$u2 = 0;
|
||||
if ($m24 & 1) { // if $m24 is odd
|
||||
$m8 = $k2->testBit(0) + 2 * $k2->testBit(1) + 4 * $k2->testBit(2);
|
||||
$m8+= $d2;
|
||||
$m8&= 7;
|
||||
$u2 = ($m8 == 3 || $m8 == 5) && $m14 == 2 ? -$m24 : $m24;
|
||||
}
|
||||
$jsf[1][] = $u2;
|
||||
|
||||
// second phase
|
||||
if (2 * $d1 == $u1 + 1) {
|
||||
$d1 = 1 - $d1;
|
||||
}
|
||||
if (2 * $d2 == $u2 + 1) {
|
||||
$d2 = 1 - $d2;
|
||||
}
|
||||
$k1 = $k1->bitwise_rightShift(1);
|
||||
$k2 = $k2->bitwise_rightShift(1);
|
||||
}
|
||||
|
||||
return $jsf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the affine point
|
||||
*
|
||||
* A Jacobian Coordinate is of the form (x, y, z).
|
||||
* To convert a Jacobian Coordinate to an Affine Point
|
||||
* you do (x / z^2, y / z^3)
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToAffine(array $p)
|
||||
{
|
||||
if (!isset($p[2])) {
|
||||
return $p;
|
||||
}
|
||||
list($x, $y, $z) = $p;
|
||||
$z = $this->one->divide($z);
|
||||
$z2 = $z->multiply($z);
|
||||
return [
|
||||
$x->multiply($z2),
|
||||
$y->multiply($z2)->multiply($z)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an affine point to a jacobian coordinate
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToInternal(array $p)
|
||||
{
|
||||
if (isset($p[2])) {
|
||||
return $p;
|
||||
}
|
||||
|
||||
$p[2] = clone $this->one;
|
||||
$p['fresh'] = true;
|
||||
return $p;
|
||||
}
|
||||
}
|
|
@ -1,219 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Curves over a*x^2 + y^2 = 1 + d*x^2*y^2
|
||||
*
|
||||
* http://www.secg.org/SEC2-Ver-1.0.pdf provides for curves with custom parameters.
|
||||
* ie. the coefficients can be arbitrary set through specially formatted keys, etc.
|
||||
* As such, Prime.php is built very generically and it's not able to take full
|
||||
* advantage of curves with 0 coefficients to produce simplified point doubling,
|
||||
* point addition. Twisted Edwards curves, in contrast, do not have a way, currently,
|
||||
* to customize them. As such, we can omit the super generic stuff from this class
|
||||
* and let the named curves (Ed25519 and Ed448) define their own custom tailored
|
||||
* point addition and point doubling methods.
|
||||
*
|
||||
* More info:
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Twisted_Edwards_curve
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\BaseCurves;
|
||||
|
||||
use phpseclib3\Math\PrimeField;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
|
||||
|
||||
/**
|
||||
* Curves over a*x^2 + y^2 = 1 + d*x^2*y^2
|
||||
*
|
||||
* @package Prime
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @access public
|
||||
*/
|
||||
class TwistedEdwards extends Base
|
||||
{
|
||||
/**
|
||||
* The modulo
|
||||
*
|
||||
* @var BigInteger
|
||||
*/
|
||||
protected $modulo;
|
||||
|
||||
/**
|
||||
* Cofficient for x^2
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $a;
|
||||
|
||||
/**
|
||||
* Cofficient for x^2*y^2
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $d;
|
||||
|
||||
/**
|
||||
* Base Point
|
||||
*
|
||||
* @var object[]
|
||||
*/
|
||||
protected $p;
|
||||
|
||||
/**
|
||||
* The number zero over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $zero;
|
||||
|
||||
/**
|
||||
* The number one over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $one;
|
||||
|
||||
/**
|
||||
* The number two over the specified finite field
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $two;
|
||||
|
||||
/**
|
||||
* Sets the modulo
|
||||
*/
|
||||
public function setModulo(BigInteger $modulo)
|
||||
{
|
||||
$this->modulo = $modulo;
|
||||
$this->factory = new PrimeField($modulo);
|
||||
$this->zero = $this->factory->newInteger(new BigInteger(0));
|
||||
$this->one = $this->factory->newInteger(new BigInteger(1));
|
||||
$this->two = $this->factory->newInteger(new BigInteger(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set coefficients a and b
|
||||
*/
|
||||
public function setCoefficients(BigInteger $a, BigInteger $d)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->a = $this->factory->newInteger($a);
|
||||
$this->d = $this->factory->newInteger($d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set x and y coordinates for the base point
|
||||
*/
|
||||
public function setBasePoint($x, $y)
|
||||
{
|
||||
switch (true) {
|
||||
case !$x instanceof BigInteger && !$x instanceof PrimeInteger:
|
||||
throw new \UnexpectedValueException('Argument 1 passed to Prime::setBasePoint() must be an instance of either BigInteger or PrimeField\Integer');
|
||||
case !$y instanceof BigInteger && !$y instanceof PrimeInteger:
|
||||
throw new \UnexpectedValueException('Argument 2 passed to Prime::setBasePoint() must be an instance of either BigInteger or PrimeField\Integer');
|
||||
}
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
$this->p = [
|
||||
$x instanceof BigInteger ? $this->factory->newInteger($x) : $x,
|
||||
$y instanceof BigInteger ? $this->factory->newInteger($y) : $y
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the a coefficient
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function getA()
|
||||
{
|
||||
return $this->a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the a coefficient
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function getD()
|
||||
{
|
||||
return $this->d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the base point as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBasePoint()
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
/*
|
||||
if (!isset($this->p)) {
|
||||
throw new \RuntimeException('setBasePoint needs to be called before this method');
|
||||
}
|
||||
*/
|
||||
return $this->p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the affine point
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToAffine(array $p)
|
||||
{
|
||||
if (!isset($p[2])) {
|
||||
return $p;
|
||||
}
|
||||
list($x, $y, $z) = $p;
|
||||
$z = $this->one->divide($z);
|
||||
return [
|
||||
$x->multiply($z),
|
||||
$y->multiply($z)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the modulo
|
||||
*
|
||||
* @return \phpseclib3\Math\BigInteger
|
||||
*/
|
||||
public function getModulo()
|
||||
{
|
||||
return $this->modulo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not the x / y values satisfy the equation
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function verifyPoint(array $p)
|
||||
{
|
||||
list($x, $y) = $p;
|
||||
$x2 = $x->multiply($x);
|
||||
$y2 = $y->multiply($y);
|
||||
|
||||
$lhs = $this->a->multiply($x2)->add($y2);
|
||||
$rhs = $this->d->multiply($x2)->multiply($y2)->add($this->one);
|
||||
|
||||
return $lhs->equals($rhs);
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Curve25519
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2019 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Math\Common\FiniteField\Integer;
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Montgomery;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class Curve25519 extends Montgomery
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// 2^255 - 19
|
||||
$this->setModulo(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED', 16));
|
||||
$this->a24 = $this->factory->newInteger(new BigInteger('121666'));
|
||||
$this->p = [$this->factory->newInteger(new BigInteger(9))];
|
||||
// 2^252 + 0x14def9dea2f79cd65812631a5cf5d3ed
|
||||
$this->setOrder(new BigInteger('1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED', 16));
|
||||
|
||||
/*
|
||||
$this->setCoefficients(
|
||||
new BigInteger('486662'), // a
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger(9),
|
||||
new BigInteger('14781619447589544791020593568409986887264606134616475288964881837755586237401')
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, Integer $d)
|
||||
{
|
||||
//$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes())));
|
||||
//return [$this->factory->newInteger(new BigInteger($r, 256))];
|
||||
|
||||
$d = $d->toBytes();
|
||||
$d&= "\xF8" . str_repeat("\xFF", 30) . "\x7F";
|
||||
$d = strrev($d);
|
||||
$d|= "\x40";
|
||||
$d = $this->factory->newInteger(new BigInteger($d, -256));
|
||||
|
||||
return parent::multiplyPoint($p, $d);
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Curve448
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2019 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Math\Common\FiniteField\Integer;
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Montgomery;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class Curve448 extends Montgomery
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// 2^448 - 2^224 - 1
|
||||
$this->setModulo(new BigInteger(
|
||||
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
|
||||
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16));
|
||||
$this->a24 = $this->factory->newInteger(new BigInteger('39081'));
|
||||
$this->p = [$this->factory->newInteger(new BigInteger(5))];
|
||||
// 2^446 - 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d
|
||||
$this->setOrder(new BigInteger(
|
||||
'3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
|
||||
'7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16));
|
||||
|
||||
/*
|
||||
$this->setCoefficients(
|
||||
new BigInteger('156326'), // a
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger(5),
|
||||
new BigInteger(
|
||||
'355293926785568175264127502063783334808976399387714271831880898' .
|
||||
'435169088786967410002932673765864550910142774147268105838985595290' .
|
||||
'606362')
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, Integer $d)
|
||||
{
|
||||
//$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes())));
|
||||
//return [$this->factory->newInteger(new BigInteger($r, 256))];
|
||||
|
||||
$d = $d->toBytes();
|
||||
$d[0] = $d[0] & "\xFC";
|
||||
$d = strrev($d);
|
||||
$d|= "\x80";
|
||||
$d = $this->factory->newInteger(new BigInteger($d, 256));
|
||||
|
||||
return parent::multiplyPoint($p, $d);
|
||||
}
|
||||
}
|
|
@ -1,334 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Ed25519
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Hash;
|
||||
use phpseclib3\Crypt\Random;
|
||||
|
||||
class Ed25519 extends TwistedEdwards
|
||||
{
|
||||
const HASH = 'sha512';
|
||||
/*
|
||||
Per https://tools.ietf.org/html/rfc8032#page-6 EdDSA has several parameters, one of which is b:
|
||||
|
||||
2. An integer b with 2^(b-1) > p. EdDSA public keys have exactly b
|
||||
bits, and EdDSA signatures have exactly 2*b bits. b is
|
||||
recommended to be a multiple of 8, so public key and signature
|
||||
lengths are an integral number of octets.
|
||||
|
||||
SIZE corresponds to b
|
||||
*/
|
||||
const SIZE = 32;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// 2^255 - 19
|
||||
$this->setModulo(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED', 16));
|
||||
$this->setCoefficients(
|
||||
// -1
|
||||
new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC', 16), // a
|
||||
// -121665/121666
|
||||
new BigInteger('52036CEE2B6FFE738CC740797779E89800700A4D4141D8AB75EB4DCA135978A3', 16) // d
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('216936D3CD6E53FEC0A4E231FDD6DC5C692CC7609525A7B2C9562D608F25D51A', 16),
|
||||
new BigInteger('6666666666666666666666666666666666666666666666666666666666666658', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED', 16));
|
||||
// algorithm 14.47 from http://cacr.uwaterloo.ca/hac/about/chap14.pdf#page=16
|
||||
/*
|
||||
$this->setReduction(function($x) {
|
||||
$parts = $x->bitwise_split(255);
|
||||
$className = $this->className;
|
||||
|
||||
if (count($parts) > 2) {
|
||||
list(, $r) = $x->divide($className::$modulo);
|
||||
return $r;
|
||||
}
|
||||
|
||||
$zero = new BigInteger();
|
||||
$c = new BigInteger(19);
|
||||
|
||||
switch (count($parts)) {
|
||||
case 2:
|
||||
list($qi, $ri) = $parts;
|
||||
break;
|
||||
case 1:
|
||||
$qi = $zero;
|
||||
list($ri) = $parts;
|
||||
break;
|
||||
case 0:
|
||||
return $zero;
|
||||
}
|
||||
$r = $ri;
|
||||
|
||||
while ($qi->compare($zero) > 0) {
|
||||
$temp = $qi->multiply($c)->bitwise_split(255);
|
||||
if (count($temp) == 2) {
|
||||
list($qi, $ri) = $temp;
|
||||
} else {
|
||||
$qi = $zero;
|
||||
list($ri) = $temp;
|
||||
}
|
||||
$r = $r->add($ri);
|
||||
}
|
||||
|
||||
while ($r->compare($className::$modulo) > 0) {
|
||||
$r = $r->subtract($className::$modulo);
|
||||
}
|
||||
return $r;
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover X from Y
|
||||
*
|
||||
* Implements steps 2-4 at https://tools.ietf.org/html/rfc8032#section-5.1.3
|
||||
*
|
||||
* Used by EC\Keys\Common.php
|
||||
*
|
||||
* @param BigInteger $y
|
||||
* @param boolean $sign
|
||||
* @return object[]
|
||||
*/
|
||||
public function recoverX(BigInteger $y, $sign)
|
||||
{
|
||||
$y = $this->factory->newInteger($y);
|
||||
|
||||
$y2 = $y->multiply($y);
|
||||
$u = $y2->subtract($this->one);
|
||||
$v = $this->d->multiply($y2)->add($this->one);
|
||||
$x2 = $u->divide($v);
|
||||
if ($x2->equals($this->zero)) {
|
||||
if ($sign) {
|
||||
throw new \RuntimeException('Unable to recover X coordinate (x2 = 0)');
|
||||
}
|
||||
return clone $this->zero;
|
||||
}
|
||||
// find the square root
|
||||
/* we don't do $x2->squareRoot() because, quoting from
|
||||
https://tools.ietf.org/html/rfc8032#section-5.1.1:
|
||||
|
||||
"For point decoding or "decompression", square roots modulo p are
|
||||
needed. They can be computed using the Tonelli-Shanks algorithm or
|
||||
the special case for p = 5 (mod 8). To find a square root of a,
|
||||
first compute the candidate root x = a^((p+3)/8) (mod p)."
|
||||
*/
|
||||
$exp = $this->getModulo()->add(new BigInteger(3));
|
||||
$exp = $exp->bitwise_rightShift(3);
|
||||
$x = $x2->pow($exp);
|
||||
|
||||
// If v x^2 = -u (mod p), set x <-- x * 2^((p-1)/4), which is a square root.
|
||||
if (!$x->multiply($x)->subtract($x2)->equals($this->zero)) {
|
||||
$temp = $this->getModulo()->subtract(new BigInteger(1));
|
||||
$temp = $temp->bitwise_rightShift(2);
|
||||
$temp = $this->two->pow($temp);
|
||||
$x = $x->multiply($temp);
|
||||
if (!$x->multiply($x)->subtract($x2)->equals($this->zero)) {
|
||||
throw new \RuntimeException('Unable to recover X coordinate');
|
||||
}
|
||||
}
|
||||
if ($x->isOdd() != $sign) {
|
||||
$x = $x->negate();
|
||||
}
|
||||
|
||||
return [$x, $y];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Secret Scalar
|
||||
*
|
||||
* Implements steps 1-3 at https://tools.ietf.org/html/rfc8032#section-5.1.5
|
||||
*
|
||||
* Used by the various key handlers
|
||||
*
|
||||
* @param string $str
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function extractSecret($str)
|
||||
{
|
||||
if (strlen($str) != 32) {
|
||||
throw new \LengthException('Private Key should be 32-bytes long');
|
||||
}
|
||||
// 1. Hash the 32-byte private key using SHA-512, storing the digest in
|
||||
// a 64-octet large buffer, denoted h. Only the lower 32 bytes are
|
||||
// used for generating the public key.
|
||||
$hash = new Hash('sha512');
|
||||
$h = $hash->hash($str);
|
||||
$h = substr($h, 0, 32);
|
||||
// 2. Prune the buffer: The lowest three bits of the first octet are
|
||||
// cleared, the highest bit of the last octet is cleared, and the
|
||||
// second highest bit of the last octet is set.
|
||||
$h[0] = $h[0] & chr(0xF8);
|
||||
$h = strrev($h);
|
||||
$h[0] = ($h[0] & chr(0x3F)) | chr(0x40);
|
||||
// 3. Interpret the buffer as the little-endian integer, forming a
|
||||
// secret scalar s.
|
||||
$dA = new BigInteger($h, 256);
|
||||
$dA = $this->factory->newInteger($dA);
|
||||
|
||||
$dA->secret = $str;
|
||||
return $dA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a point as a string
|
||||
*
|
||||
* @param array $point
|
||||
* @return string
|
||||
*/
|
||||
public function encodePoint($point)
|
||||
{
|
||||
list($x, $y) = $point;
|
||||
$y = $y->toBytes();
|
||||
$y[0] = $y[0] & chr(0x7F);
|
||||
if ($x->isOdd()) {
|
||||
$y[0] = $y[0] | chr(0x80);
|
||||
}
|
||||
$y = strrev($y);
|
||||
|
||||
return $y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a random scalar multiplier
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function createRandomMultiplier()
|
||||
{
|
||||
return $this->extractSecret(Random::string(32));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an affine point to an extended homogeneous coordinate
|
||||
*
|
||||
* From https://tools.ietf.org/html/rfc8032#section-5.1.4 :
|
||||
*
|
||||
* A point (x,y) is represented in extended homogeneous coordinates (X, Y, Z, T),
|
||||
* with x = X/Z, y = Y/Z, x * y = T/Z.
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToInternal(array $p)
|
||||
{
|
||||
if (empty($p)) {
|
||||
return [clone $this->zero, clone $this->one, clone $this->one, clone $this->zero];
|
||||
}
|
||||
|
||||
if (isset($p[2])) {
|
||||
return $p;
|
||||
}
|
||||
|
||||
$p[2] = clone $this->one;
|
||||
$p[3] = $p[0]->multiply($p[1]);
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a point on a curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function doublePoint(array $p)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!isset($p[2])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa');
|
||||
}
|
||||
|
||||
// from https://tools.ietf.org/html/rfc8032#page-12
|
||||
|
||||
list($x1, $y1, $z1, $t1) = $p;
|
||||
|
||||
$a = $x1->multiply($x1);
|
||||
$b = $y1->multiply($y1);
|
||||
$c = $this->two->multiply($z1)->multiply($z1);
|
||||
$h = $a->add($b);
|
||||
$temp = $x1->add($y1);
|
||||
$e = $h->subtract($temp->multiply($temp));
|
||||
$g = $a->subtract($b);
|
||||
$f = $c->add($g);
|
||||
|
||||
$x3 = $e->multiply($f);
|
||||
$y3 = $g->multiply($h);
|
||||
$t3 = $e->multiply($h);
|
||||
$z3 = $f->multiply($g);
|
||||
|
||||
return [$x3, $y3, $z3, $t3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two points on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function addPoint(array $p, array $q)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p) || !count($q)) {
|
||||
if (count($q)) {
|
||||
return $q;
|
||||
}
|
||||
if (count($p)) {
|
||||
return $p;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!isset($p[2]) || !isset($q[2])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa');
|
||||
}
|
||||
|
||||
if ($p[0]->equals($q[0])) {
|
||||
return !$p[1]->equals($q[1]) ? [] : $this->doublePoint($p);
|
||||
}
|
||||
|
||||
// from https://tools.ietf.org/html/rfc8032#page-12
|
||||
|
||||
list($x1, $y1, $z1, $t1) = $p;
|
||||
list($x2, $y2, $z2, $t2) = $q;
|
||||
|
||||
$a = $y1->subtract($x1)->multiply($y2->subtract($x2));
|
||||
$b = $y1->add($x1)->multiply($y2->add($x2));
|
||||
$c = $t1->multiply($this->two)->multiply($this->d)->multiply($t2);
|
||||
$d = $z1->multiply($this->two)->multiply($z2);
|
||||
$e = $b->subtract($a);
|
||||
$f = $d->subtract($c);
|
||||
$g = $d->add($c);
|
||||
$h = $b->add($a);
|
||||
|
||||
$x3 = $e->multiply($f);
|
||||
$y3 = $g->multiply($h);
|
||||
$t3 = $e->multiply($h);
|
||||
$z3 = $f->multiply($g);
|
||||
|
||||
return [$x3, $y3, $z3, $t3];
|
||||
}
|
||||
}
|
|
@ -1,267 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Ed448
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
use phpseclib3\Crypt\Hash;
|
||||
use phpseclib3\Crypt\Random;
|
||||
|
||||
class Ed448 extends TwistedEdwards
|
||||
{
|
||||
const HASH = 'shake256-912';
|
||||
const SIZE = 57;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// 2^448 - 2^224 - 1
|
||||
$this->setModulo(new BigInteger(
|
||||
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
|
||||
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger(1),
|
||||
// -39081
|
||||
new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
|
||||
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6756', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('4F1970C66BED0DED221D15A622BF36DA9E146570470F1767EA6DE324' .
|
||||
'A3D3A46412AE1AF72AB66511433B80E18B00938E2626A82BC70CC05E', 16),
|
||||
new BigInteger('693F46716EB6BC248876203756C9C7624BEA73736CA3984087789C1E' .
|
||||
'05A0C2D73AD3FF1CE67C39C4FDBD132C4ED7C8AD9808795BF230FA14', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger(
|
||||
'3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
|
||||
'7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16));
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover X from Y
|
||||
*
|
||||
* Implements steps 2-4 at https://tools.ietf.org/html/rfc8032#section-5.2.3
|
||||
*
|
||||
* Used by EC\Keys\Common.php
|
||||
*
|
||||
* @param BigInteger $y
|
||||
* @param boolean $sign
|
||||
* @return object[]
|
||||
*/
|
||||
public function recoverX(BigInteger $y, $sign)
|
||||
{
|
||||
$y = $this->factory->newInteger($y);
|
||||
|
||||
$y2 = $y->multiply($y);
|
||||
$u = $y2->subtract($this->one);
|
||||
$v = $this->d->multiply($y2)->subtract($this->one);
|
||||
$x2 = $u->divide($v);
|
||||
if ($x2->equals($this->zero)) {
|
||||
if ($sign) {
|
||||
throw new \RuntimeException('Unable to recover X coordinate (x2 = 0)');
|
||||
}
|
||||
return clone $this->zero;
|
||||
}
|
||||
// find the square root
|
||||
$exp = $this->getModulo()->add(new BigInteger(1));
|
||||
$exp = $exp->bitwise_rightShift(2);
|
||||
$x = $x2->pow($exp);
|
||||
|
||||
if (!$x->multiply($x)->subtract($x2)->equals($this->zero)) {
|
||||
throw new \RuntimeException('Unable to recover X coordinate');
|
||||
}
|
||||
if ($x->isOdd() != $sign) {
|
||||
$x = $x->negate();
|
||||
}
|
||||
|
||||
return [$x, $y];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Secret Scalar
|
||||
*
|
||||
* Implements steps 1-3 at https://tools.ietf.org/html/rfc8032#section-5.2.5
|
||||
*
|
||||
* Used by the various key handlers
|
||||
*
|
||||
* @param string $str
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function extractSecret($str)
|
||||
{
|
||||
if (strlen($str) != 57) {
|
||||
throw new \LengthException('Private Key should be 57-bytes long');
|
||||
}
|
||||
// 1. Hash the 57-byte private key using SHAKE256(x, 114), storing the
|
||||
// digest in a 114-octet large buffer, denoted h. Only the lower 57
|
||||
// bytes are used for generating the public key.
|
||||
$hash = new Hash('shake256-912');
|
||||
$h = $hash->hash($str);
|
||||
$h = substr($h, 0, 57);
|
||||
// 2. Prune the buffer: The two least significant bits of the first
|
||||
// octet are cleared, all eight bits the last octet are cleared, and
|
||||
// the highest bit of the second to last octet is set.
|
||||
$h[0] = $h[0] & chr(0xFC);
|
||||
$h = strrev($h);
|
||||
$h[0] = "\0";
|
||||
$h[1] = $h[1] | chr(0x80);
|
||||
// 3. Interpret the buffer as the little-endian integer, forming a
|
||||
// secret scalar s.
|
||||
$dA = new BigInteger($h, 256);
|
||||
$dA = $this->factory->newInteger($dA);
|
||||
|
||||
$dA->secret = $str;
|
||||
return $dA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a point as a string
|
||||
*
|
||||
* @param array $point
|
||||
* @return string
|
||||
*/
|
||||
public function encodePoint($point)
|
||||
{
|
||||
list($x, $y) = $point;
|
||||
$y = "\0" . $y->toBytes();
|
||||
if ($x->isOdd()) {
|
||||
$y[0] = $y[0] | chr(0x80);
|
||||
}
|
||||
$y = strrev($y);
|
||||
|
||||
return $y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a random scalar multiplier
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer
|
||||
*/
|
||||
public function createRandomMultiplier()
|
||||
{
|
||||
return $this->extractSecret(Random::string(57));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an affine point to an extended homogeneous coordinate
|
||||
*
|
||||
* From https://tools.ietf.org/html/rfc8032#section-5.2.4 :
|
||||
*
|
||||
* A point (x,y) is represented in extended homogeneous coordinates (X, Y, Z, T),
|
||||
* with x = X/Z, y = Y/Z, x * y = T/Z.
|
||||
*
|
||||
* @return \phpseclib3\Math\PrimeField\Integer[]
|
||||
*/
|
||||
public function convertToInternal(array $p)
|
||||
{
|
||||
if (empty($p)) {
|
||||
return [clone $this->zero, clone $this->one, clone $this->one];
|
||||
}
|
||||
|
||||
if (isset($p[2])) {
|
||||
return $p;
|
||||
}
|
||||
|
||||
$p[2] = clone $this->one;
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doubles a point on a curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function doublePoint(array $p)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!isset($p[2])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa');
|
||||
}
|
||||
|
||||
// from https://tools.ietf.org/html/rfc8032#page-18
|
||||
|
||||
list($x1, $y1, $z1) = $p;
|
||||
|
||||
$b = $x1->add($y1);
|
||||
$b = $b->multiply($b);
|
||||
$c = $x1->multiply($x1);
|
||||
$d = $y1->multiply($y1);
|
||||
$e = $c->add($d);
|
||||
$h = $z1->multiply($z1);
|
||||
$j = $e->subtract($this->two->multiply($h));
|
||||
|
||||
$x3 = $b->subtract($e)->multiply($j);
|
||||
$y3 = $c->subtract($d)->multiply($e);
|
||||
$z3 = $e->multiply($j);
|
||||
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds two points on the curve
|
||||
*
|
||||
* @return FiniteField[]
|
||||
*/
|
||||
public function addPoint(array $p, array $q)
|
||||
{
|
||||
if (!isset($this->factory)) {
|
||||
throw new \RuntimeException('setModulo needs to be called before this method');
|
||||
}
|
||||
|
||||
if (!count($p) || !count($q)) {
|
||||
if (count($q)) {
|
||||
return $q;
|
||||
}
|
||||
if (count($p)) {
|
||||
return $p;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!isset($p[2]) || !isset($q[2])) {
|
||||
throw new \RuntimeException('Affine coordinates need to be manually converted to "Jacobi" coordinates or vice versa');
|
||||
}
|
||||
|
||||
if ($p[0]->equals($q[0])) {
|
||||
return !$p[1]->equals($q[1]) ? [] : $this->doublePoint($p);
|
||||
}
|
||||
|
||||
// from https://tools.ietf.org/html/rfc8032#page-17
|
||||
|
||||
list($x1, $y1, $z1) = $p;
|
||||
list($x2, $y2, $z2) = $q;
|
||||
|
||||
$a = $z1->multiply($z2);
|
||||
$b = $a->multiply($a);
|
||||
$c = $x1->multiply($x2);
|
||||
$d = $y1->multiply($y2);
|
||||
$e = $this->d->multiply($c)->multiply($d);
|
||||
$f = $b->subtract($e);
|
||||
$g = $b->add($e);
|
||||
$h = $x1->add($y1)->multiply($x2->add($y2));
|
||||
|
||||
$x3 = $a->multiply($f)->multiply($h->subtract($c)->subtract($d));
|
||||
$y3 = $a->multiply($g)->multiply($d->subtract($c));
|
||||
$z3 = $f->multiply($g);
|
||||
|
||||
return [$x3, $y3, $z3];
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP160r1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP160r1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('E95E4A5F737059DC60DFC7AD95B3D8139515620F', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('340E7BE2A280EB74E2BE61BADA745D97E8F7C300', 16),
|
||||
new BigInteger('1E589A8595423412134FAA2DBDEC95C8D8675E58', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('BED5AF16EA3F6A4F62938C4631EB5AF7BDBCDBC3', 16),
|
||||
new BigInteger('1667CB477A1A8EC338F94741669C976316DA6321', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16));
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP160t1
|
||||
*
|
||||
* This curve is a twisted version of brainpoolP160r1 with A = -3. With brainpool,
|
||||
* the curves ending in r1 are the "regular" curves and the curves ending in "t1"
|
||||
* are the twisted version of the r1 curves. Per https://tools.ietf.org/html/rfc5639#page-7
|
||||
* you can convert a point on an r1 curve to a point on a t1 curve thusly:
|
||||
*
|
||||
* F(x,y) := (x*Z^2, y*Z^3)
|
||||
*
|
||||
* The advantage of A = -3 is that some of the point doubling and point addition can be
|
||||
* slightly optimized. See http://hyperelliptic.org/EFD/g1p/auto-shortw-projective-3.html
|
||||
* vs http://hyperelliptic.org/EFD/g1p/auto-shortw-projective.html for example.
|
||||
*
|
||||
* phpseclib does not currently take advantage of this optimization opportunity
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP160t1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('E95E4A5F737059DC60DFC7AD95B3D8139515620F', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('E95E4A5F737059DC60DFC7AD95B3D8139515620C', 16), // eg. -3
|
||||
new BigInteger('7A556B6DAE535B7B51ED2C4D7DAA7A0B5C55F380', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('B199B13B9B34EFC1397E64BAEB05ACC265FF2378', 16),
|
||||
new BigInteger('ADD6718B7C7C1961F0991B842443772152C9E0AD', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16));
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP192r1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP192r1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('6A91174076B1E0E19C39C031FE8685C1CAE040E5C69A28EF', 16),
|
||||
new BigInteger('469A28EF7C28CCA3DC721D044F4496BCCA7EF4146FBF25C9', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('C0A0647EAAB6A48753B033C56CB0F0900A2F5C4853375FD6', 16),
|
||||
new BigInteger('14B690866ABD5BB88B5F4828C1490002E6773FA2FA299B8F', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16));
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP192t1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP192t1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86294', 16), // eg. -3
|
||||
new BigInteger('13D56FFAEC78681E68F9DEB43B35BEC2FB68542E27897B79', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('3AE9E58C82F63C30282E1FE7BBF43FA72C446AF6F4618129', 16),
|
||||
new BigInteger('097E2C5667C2223A902AB5CA449D0084B7E5B3DE7CCC01C9', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16));
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP224r1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP224r1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('68A5E62CA9CE6C1C299803A6C1530B514E182AD8B0042A59CAD29F43', 16),
|
||||
new BigInteger('2580F63CCFE44138870713B1A92369E33E2135D266DBB372386C400B', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('0D9029AD2C7E5CF4340823B2A87DC68C9E4CE3174C1E6EFDEE12C07D', 16),
|
||||
new BigInteger('58AA56F772C0726F24C6B89E4ECDAC24354B9E99CAA3F6D3761402CD', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16));
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP224t1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP224t1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FC', 16), // eg. -3
|
||||
new BigInteger('4B337D934104CD7BEF271BF60CED1ED20DA14C08B3BB64F18A60888D', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('6AB1E344CE25FF3896424E7FFE14762ECB49F8928AC0C76029B4D580', 16),
|
||||
new BigInteger('0374E9F5143E568CD23F3F4D7C0D4B1E41C8CC0D1C6ABD5F1A46DB4C', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16));
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP256r1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP256r1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('7D5A0975FC2C3057EEF67530417AFFE7FB8055C126DC5C6CE94A4B44F330B5D9', 16),
|
||||
new BigInteger('26DC5C6CE94A4B44F330B5D9BBD77CBF958416295CF7E1CE6BCCDC18FF8C07B6', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('8BD2AEB9CB7E57CB2C4B482FFC81B7AFB9DE27E1E3BD23C23A4453BD9ACE3262', 16),
|
||||
new BigInteger('547EF835C3DAC4FD97F8461A14611DC9C27745132DED8E545C1D54C72F046997', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7', 16));
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP256t1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP256t1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5374', 16), // eg. -3
|
||||
new BigInteger('662C61C430D84EA4FE66A7733D0B76B7BF93EBC4AF2F49256AE58101FEE92B04', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('A3E8EB3CC1CFE7B7732213B23A656149AFA142C47AAFBC2B79A191562E1305F4', 16),
|
||||
new BigInteger('2D996C823439C56D7F7B22E14644417E69BCB6DE39D027001DABE8F35B25C9BE', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7', 16));
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP320r1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP320r1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F9' .
|
||||
'2B9EC7893EC28FCD412B1F1B32E27', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('3EE30B568FBAB0F883CCEBD46D3F3BB8A2A73513F5EB79DA66190EB085FFA9F4' .
|
||||
'92F375A97D860EB4', 16),
|
||||
new BigInteger('520883949DFDBC42D3AD198640688A6FE13F41349554B49ACC31DCCD88453981' .
|
||||
'6F5EB4AC8FB1F1A6', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('43BD7E9AFB53D8B85289BCC48EE5BFE6F20137D10A087EB6E7871E2A10A599C7' .
|
||||
'10AF8D0D39E20611', 16),
|
||||
new BigInteger('14FDD05545EC1CC8AB4093247F77275E0743FFED117182EAA9C77877AAAC6AC7' .
|
||||
'D35245D1692E8EE1', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' .
|
||||
'82EC7EE8658E98691555B44C59311', 16));
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP320t1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP320t1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F9' .
|
||||
'2B9EC7893EC28FCD412B1F1B32E27', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28' .
|
||||
'FCD412B1F1B32E24', 16), // eg. -3
|
||||
new BigInteger('A7F561E038EB1ED560B3D147DB782013064C19F27ED27C6780AAF77FB8A547CE' .
|
||||
'B5B4FEF422340353', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger('925BE9FB01AFC6FB4D3E7D4990010F813408AB106C4F09CB7EE07868CC136FFF' .
|
||||
'3357F624A21BED52', 16),
|
||||
new BigInteger('63BA3A7A27483EBF6671DBEF7ABB30EBEE084E58A0B077AD42A5A0989D1EE71B' .
|
||||
'1B9BC0455FB0D2C3', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' .
|
||||
'82EC7EE8658E98691555B44C59311', 16));
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP384r1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP384r1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger(
|
||||
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
|
||||
'1874700133107EC53', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger(
|
||||
'7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503' .
|
||||
'AD4EB04A8C7DD22CE2826', 16),
|
||||
new BigInteger(
|
||||
'4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DB' .
|
||||
'C9943AB78696FA504C11', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger(
|
||||
'1D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D' .
|
||||
'646AAEF87B2E247D4AF1E', 16),
|
||||
new BigInteger(
|
||||
'8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E464621779' .
|
||||
'1811142820341263C5315', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger(
|
||||
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
|
||||
'03B883202E9046565', 16));
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP384t1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP384t1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger(
|
||||
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
|
||||
'1874700133107EC53', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger(
|
||||
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901' .
|
||||
'D1A71874700133107EC50', 16), // eg. -3
|
||||
new BigInteger(
|
||||
'7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B8' .
|
||||
'8805CED70355A33B471EE', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger(
|
||||
'18DE98B02DB9A306F2AFCD7235F72A819B80AB12EBD653172476FECD462AABFFC4FF191B946' .
|
||||
'A5F54D8D0AA2F418808CC', 16),
|
||||
new BigInteger(
|
||||
'25AB056962D30651A114AFD2755AD336747F93475B7A1FCA3B88F2B6A208CCFE469408584DC' .
|
||||
'2B2912675BF5B9E582928', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger(
|
||||
'8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
|
||||
'03B883202E9046565', 16));
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP512r1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP512r1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger(
|
||||
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
|
||||
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger(
|
||||
'7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA82' .
|
||||
'53AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA', 16),
|
||||
new BigInteger(
|
||||
'3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C' .
|
||||
'1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger(
|
||||
'81AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D' .
|
||||
'0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822', 16),
|
||||
new BigInteger(
|
||||
'7DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5' .
|
||||
'F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger(
|
||||
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
|
||||
'92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16));
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* brainpoolP512t1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
use phpseclib3\Crypt\EC\BaseCurves\Prime;
|
||||
use phpseclib3\Math\BigInteger;
|
||||
|
||||
class brainpoolP512t1 extends Prime
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->setModulo(new BigInteger(
|
||||
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
|
||||
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16));
|
||||
$this->setCoefficients(
|
||||
new BigInteger(
|
||||
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
|
||||
'66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0', 16), // eg. -3
|
||||
new BigInteger(
|
||||
'7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA23049' .
|
||||
'76540F6450085F2DAE145C22553B465763689180EA2571867423E', 16)
|
||||
);
|
||||
$this->setBasePoint(
|
||||
new BigInteger(
|
||||
'640ECE5C12788717B9C1BA06CBC2A6FEBA85842458C56DDE9DB1758D39C0313D82BA51735CD' .
|
||||
'B3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA', 16),
|
||||
new BigInteger(
|
||||
'5B534BD595F5AF0FA2C892376C84ACE1BB4E3019B71634C01131159CAE03CEE9D9932184BEE' .
|
||||
'F216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332', 16)
|
||||
);
|
||||
$this->setOrder(new BigInteger(
|
||||
'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
|
||||
'92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16));
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistb233
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistb233 extends sect233r1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistb409
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistb409 extends sect409r1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistk163
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistk163 extends sect163k1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistk233
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistk233 extends sect233k1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* sect283k1
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistk283 extends sect283k1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistk409
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistk409 extends sect409k1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistp192
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistp192 extends secp192r1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistp224
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistp224 extends secp224r1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistp256
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistp256 extends secp256r1
|
||||
{
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* nistp384
|
||||
*
|
||||
* PHP version 5 and 7
|
||||
*
|
||||
* @category Crypt
|
||||
* @package EC
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright 2017 Jim Wigginton
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
* @link http://pear.php.net/package/Math_BigInteger
|
||||
*/
|
||||
|
||||
namespace phpseclib3\Crypt\EC\Curves;
|
||||
|
||||
final class nistp384 extends secp384r1
|
||||
{
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue