[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: PublicKey.php
<?php namespace Namshi\JOSE\Signer\OpenSSL; use InvalidArgumentException; use Namshi\JOSE\Signer\SignerInterface; use RuntimeException; /** * Class responsible to sign inputs with the a public key algorithm, after hashing it. */ abstract class PublicKey implements SignerInterface { /** * {@inheritdoc} */ public function sign($input, $key, $password = null) { $keyResource = $this->getKeyResource($key, $password); if (!$this->supportsKey($keyResource)) { throw new InvalidArgumentException('Invalid key supplied.'); } $signature = null; openssl_sign($input, $signature, $keyResource, $this->getHashingAlgorithm()); return $signature; } /** * {@inheritdoc} */ public function verify($key, $signature, $input) { $keyResource = $this->getKeyResource($key); if (!$this->supportsKey($keyResource)) { throw new InvalidArgumentException('Invalid key supplied.'); } $result = openssl_verify($input, $signature, $keyResource, $this->getHashingAlgorithm()); if ($result === -1) { throw new RuntimeException('Unknown error during verification.'); } return (bool) $result; } /** * Converts a string representation of a key into an OpenSSL resource. * * @param string|resource $key * @param string $password * * @return resource OpenSSL key resource */ protected function getKeyResource($key, $password = null) { if (is_resource($key)) { return $key; } $resource = openssl_pkey_get_public($key) ?: openssl_pkey_get_private($key, $password); if ($resource === false) { throw new RuntimeException('Could not read key resource: ' . openssl_error_string()); } return $resource; } /** * Check if the key is supported by this signer. * * @param resource $key Public or private key * * @return bool */ protected function supportsKey($key) { // OpenSSL 0.9.8+ $keyDetails = openssl_pkey_get_details($key); return isset($keyDetails['type']) ? $this->getSupportedPrivateKeyType() === $keyDetails['type'] : false; } /** * Returns the hashing algorithm used in this signer. * * @return string */ abstract protected function getHashingAlgorithm(); /** * Returns the private key type supported in this signer. * * @return string */ abstract protected function getSupportedPrivateKeyType(); }
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.43 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