One Hat Cyber Team
Your IP:
216.73.216.102
Server IP:
198.54.114.155
Server:
Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
5.6.40
Create File
|
Create Folder
Execute
Dir :
~
/
home
/
fluxyjvi
/
public_html
/
assets
/
images
/
Edit File:
Signer.tar
Hmac/Sha384.php 0000644 00000000444 15107365567 0007120 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Hmac; use Lcobucci\JWT\Signer\Hmac; final class Sha384 extends Hmac { public function algorithmId(): string { return 'HS384'; } public function algorithm(): string { return 'sha384'; } } Hmac/Sha256.php 0000644 00000000444 15107365567 0007116 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Hmac; use Lcobucci\JWT\Signer\Hmac; final class Sha256 extends Hmac { public function algorithmId(): string { return 'HS256'; } public function algorithm(): string { return 'sha256'; } } Hmac/Sha512.php 0000644 00000000444 15107365570 0007103 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Hmac; use Lcobucci\JWT\Signer\Hmac; final class Sha512 extends Hmac { public function algorithmId(): string { return 'HS512'; } public function algorithm(): string { return 'sha512'; } } Rsa/Sha384.php 0000644 00000000511 15107365570 0006762 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Rsa; use Lcobucci\JWT\Signer\Rsa; use const OPENSSL_ALGO_SHA384; final class Sha384 extends Rsa { public function algorithmId(): string { return 'RS384'; } public function algorithm(): int { return OPENSSL_ALGO_SHA384; } } Rsa/Sha256.php 0000644 00000000511 15107365570 0006760 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Rsa; use Lcobucci\JWT\Signer\Rsa; use const OPENSSL_ALGO_SHA256; final class Sha256 extends Rsa { public function algorithmId(): string { return 'RS256'; } public function algorithm(): int { return OPENSSL_ALGO_SHA256; } } Rsa/Sha512.php 0000644 00000000511 15107365570 0006753 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Rsa; use Lcobucci\JWT\Signer\Rsa; use const OPENSSL_ALGO_SHA512; final class Sha512 extends Rsa { public function algorithmId(): string { return 'RS512'; } public function algorithm(): int { return OPENSSL_ALGO_SHA512; } } Ecdsa/Sha384.php 0000644 00000000624 15107365570 0007261 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Ecdsa; use Lcobucci\JWT\Signer\Ecdsa; use const OPENSSL_ALGO_SHA384; final class Sha384 extends Ecdsa { public function algorithmId(): string { return 'ES384'; } public function algorithm(): int { return OPENSSL_ALGO_SHA384; } public function keyLength(): int { return 96; } } Ecdsa/SignatureConverter.php 0000644 00000002012 15107365570 0012131 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Ecdsa; /** * Manipulates the result of a ECDSA signature (points R and S) according to the * JWA specs. * * OpenSSL creates a signature using the ASN.1 format and, according the JWA specs, * the signature for JWTs must be the concatenated values of points R and S (in * big-endian octet order). * * @internal * * @see https://tools.ietf.org/html/rfc7518#page-9 * @see https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One */ interface SignatureConverter { /** * Converts the signature generated by OpenSSL into what JWA defines * * @throws ConversionFailed When there was an issue during the format conversion. */ public function fromAsn1(string $signature, int $length): string; /** * Converts the JWA signature into something OpenSSL understands * * @throws ConversionFailed When there was an issue during the format conversion. */ public function toAsn1(string $points, int $length): string; } Ecdsa/Sha256.php 0000644 00000000624 15107365570 0007257 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Ecdsa; use Lcobucci\JWT\Signer\Ecdsa; use const OPENSSL_ALGO_SHA256; final class Sha256 extends Ecdsa { public function algorithmId(): string { return 'ES256'; } public function algorithm(): int { return OPENSSL_ALGO_SHA256; } public function keyLength(): int { return 64; } } Ecdsa/Sha512.php 0000644 00000000625 15107365570 0007253 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Ecdsa; use Lcobucci\JWT\Signer\Ecdsa; use const OPENSSL_ALGO_SHA512; final class Sha512 extends Ecdsa { public function algorithmId(): string { return 'ES512'; } public function algorithm(): int { return OPENSSL_ALGO_SHA512; } public function keyLength(): int { return 132; } } Ecdsa/ConversionFailed.php 0000644 00000001137 15107365570 0011541 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Ecdsa; use InvalidArgumentException; use Lcobucci\JWT\Exception; final class ConversionFailed extends InvalidArgumentException implements Exception { public static function invalidLength(): self { return new self('Invalid signature length.'); } public static function incorrectStartSequence(): self { return new self('Invalid data. Should start with a sequence.'); } public static function integerExpected(): self { return new self('Invalid data. Should contain an integer.'); } } Ecdsa/MultibyteStringConverter.php 0000644 00000011130 15107365570 0013336 0 ustar 00 <?php declare(strict_types=1); /* * The MIT License (MIT) * * Copyright (c) 2014-2018 Spomky-Labs * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. * * @link https://github.com/web-token/jwt-framework/blob/v1.2/src/Component/Core/Util/ECSignature.php */ namespace Lcobucci\JWT\Signer\Ecdsa; use function assert; use function bin2hex; use function dechex; use function hex2bin; use function hexdec; use function is_string; use function mb_strlen; use function mb_substr; use function str_pad; use const STR_PAD_LEFT; /** * ECDSA signature converter using ext-mbstring * * @internal */ final class MultibyteStringConverter implements SignatureConverter { private const ASN1_SEQUENCE = '30'; private const ASN1_INTEGER = '02'; private const ASN1_MAX_SINGLE_BYTE = 128; private const ASN1_LENGTH_2BYTES = '81'; private const ASN1_BIG_INTEGER_LIMIT = '7f'; private const ASN1_NEGATIVE_INTEGER = '00'; private const BYTE_SIZE = 2; public function toAsn1(string $points, int $length): string { $points = bin2hex($points); if (self::octetLength($points) !== $length) { throw ConversionFailed::invalidLength(); } $pointR = self::preparePositiveInteger(mb_substr($points, 0, $length, '8bit')); $pointS = self::preparePositiveInteger(mb_substr($points, $length, null, '8bit')); $lengthR = self::octetLength($pointR); $lengthS = self::octetLength($pointS); $totalLength = $lengthR + $lengthS + self::BYTE_SIZE + self::BYTE_SIZE; $lengthPrefix = $totalLength > self::ASN1_MAX_SINGLE_BYTE ? self::ASN1_LENGTH_2BYTES : ''; $asn1 = hex2bin( self::ASN1_SEQUENCE . $lengthPrefix . dechex($totalLength) . self::ASN1_INTEGER . dechex($lengthR) . $pointR . self::ASN1_INTEGER . dechex($lengthS) . $pointS ); assert(is_string($asn1)); return $asn1; } private static function octetLength(string $data): int { return (int) (mb_strlen($data, '8bit') / self::BYTE_SIZE); } private static function preparePositiveInteger(string $data): string { if (mb_substr($data, 0, self::BYTE_SIZE, '8bit') > self::ASN1_BIG_INTEGER_LIMIT) { return self::ASN1_NEGATIVE_INTEGER . $data; } while ( mb_substr($data, 0, self::BYTE_SIZE, '8bit') === self::ASN1_NEGATIVE_INTEGER && mb_substr($data, 2, self::BYTE_SIZE, '8bit') <= self::ASN1_BIG_INTEGER_LIMIT ) { $data = mb_substr($data, 2, null, '8bit'); } return $data; } public function fromAsn1(string $signature, int $length): string { $message = bin2hex($signature); $position = 0; if (self::readAsn1Content($message, $position, self::BYTE_SIZE) !== self::ASN1_SEQUENCE) { throw ConversionFailed::incorrectStartSequence(); } // @phpstan-ignore-next-line if (self::readAsn1Content($message, $position, self::BYTE_SIZE) === self::ASN1_LENGTH_2BYTES) { $position += self::BYTE_SIZE; } $pointR = self::retrievePositiveInteger(self::readAsn1Integer($message, $position)); $pointS = self::retrievePositiveInteger(self::readAsn1Integer($message, $position)); $points = hex2bin(str_pad($pointR, $length, '0', STR_PAD_LEFT) . str_pad($pointS, $length, '0', STR_PAD_LEFT)); assert(is_string($points)); return $points; } private static function readAsn1Content(string $message, int &$position, int $length): string { $content = mb_substr($message, $position, $length, '8bit'); $position += $length; return $content; } private static function readAsn1Integer(string $message, int &$position): string { if (self::readAsn1Content($message, $position, self::BYTE_SIZE) !== self::ASN1_INTEGER) { throw ConversionFailed::integerExpected(); } $length = (int) hexdec(self::readAsn1Content($message, $position, self::BYTE_SIZE)); return self::readAsn1Content($message, $position, $length * self::BYTE_SIZE); } private static function retrievePositiveInteger(string $data): string { while ( mb_substr($data, 0, self::BYTE_SIZE, '8bit') === self::ASN1_NEGATIVE_INTEGER && mb_substr($data, 2, self::BYTE_SIZE, '8bit') > self::ASN1_BIG_INTEGER_LIMIT ) { $data = mb_substr($data, 2, null, '8bit'); } return $data; } } None.php 0000644 00000001122 15107365570 0006161 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; use Lcobucci\JWT\Signer; final class None implements Signer { public function algorithmId(): string { return 'none'; } // @phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter public function sign(string $payload, Key $key): string { return ''; } // @phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter public function verify(string $expected, string $payload, Key $key): bool { return $expected === ''; } } CannotSignPayload.php 0000644 00000000564 15107365571 0010651 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; use InvalidArgumentException; use Lcobucci\JWT\Exception; final class CannotSignPayload extends InvalidArgumentException implements Exception { public static function errorHappened(string $error): self { return new self('There was an error while creating the signature: ' . $error); } } Key.php 0000644 00000000245 15107365571 0006020 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; interface Key { public function contents(): string; public function passphrase(): string; } Hmac.php 0000644 00000001055 15107365571 0006140 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; use Lcobucci\JWT\Signer; use function hash_equals; use function hash_hmac; abstract class Hmac implements Signer { final public function sign(string $payload, Key $key): string { return hash_hmac($this->algorithm(), $payload, $key->contents(), true); } final public function verify(string $expected, string $payload, Key $key): bool { return hash_equals($expected, $this->sign($payload, $key)); } abstract public function algorithm(): string; } Key/InMemory.php 0000644 00000003221 15107365571 0007554 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Key; use Lcobucci\JWT\Encoding\CannotDecodeContent; use Lcobucci\JWT\Signer\Key; use SplFileObject; use Throwable; use function assert; use function base64_decode; use function is_string; final class InMemory implements Key { private string $contents; private string $passphrase; private function __construct(string $contents, string $passphrase) { $this->contents = $contents; $this->passphrase = $passphrase; } public static function empty(): self { return new self('', ''); } public static function plainText(string $contents, string $passphrase = ''): self { return new self($contents, $passphrase); } public static function base64Encoded(string $contents, string $passphrase = ''): self { $decoded = base64_decode($contents, true); if ($decoded === false) { throw CannotDecodeContent::invalidBase64String(); } return new self($decoded, $passphrase); } /** @throws FileCouldNotBeRead */ public static function file(string $path, string $passphrase = ''): self { try { $file = new SplFileObject($path); } catch (Throwable $exception) { throw FileCouldNotBeRead::onPath($path, $exception); } $contents = $file->fread($file->getSize()); assert(is_string($contents)); return new self($contents, $passphrase); } public function contents(): string { return $this->contents; } public function passphrase(): string { return $this->passphrase; } } Key/LocalFileReference.php 0000644 00000002315 15107365571 0011471 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Key; use Lcobucci\JWT\Signer\Key; use function file_exists; use function strpos; use function substr; /** @deprecated please use {@see InMemory} instead */ final class LocalFileReference implements Key { private const PATH_PREFIX = 'file://'; private string $path; private string $passphrase; private string $contents; private function __construct(string $path, string $passphrase) { $this->path = $path; $this->passphrase = $passphrase; } /** @throws FileCouldNotBeRead */ public static function file(string $path, string $passphrase = ''): self { if (strpos($path, self::PATH_PREFIX) === 0) { $path = substr($path, 7); } if (! file_exists($path)) { throw FileCouldNotBeRead::onPath($path); } return new self($path, $passphrase); } public function contents(): string { if (! isset($this->contents)) { $this->contents = InMemory::file($this->path)->contents(); } return $this->contents; } public function passphrase(): string { return $this->passphrase; } } Key/FileCouldNotBeRead.php 0000644 00000000723 15107365571 0011413 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer\Key; use InvalidArgumentException; use Lcobucci\JWT\Exception; use Throwable; final class FileCouldNotBeRead extends InvalidArgumentException implements Exception { public static function onPath(string $path, ?Throwable $cause = null): self { return new self( 'The path "' . $path . '" does not contain a valid key file', 0, $cause ); } } Rsa.php 0000644 00000001065 15107365571 0006016 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; use const OPENSSL_KEYTYPE_RSA; abstract class Rsa extends OpenSSL { final public function sign(string $payload, Key $key): string { return $this->createSignature($key->contents(), $key->passphrase(), $payload); } final public function verify(string $expected, string $payload, Key $key): bool { return $this->verifySignature($expected, $payload, $key->contents()); } final public function keyType(): int { return OPENSSL_KEYTYPE_RSA; } } InvalidKeyProvided.php 0000644 00000001000 15107365571 0011012 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; use InvalidArgumentException; use Lcobucci\JWT\Exception; final class InvalidKeyProvided extends InvalidArgumentException implements Exception { public static function cannotBeParsed(string $details): self { return new self('It was not possible to parse your key, reason: ' . $details); } public static function incompatibleKey(): self { return new self('This key is not compatible with this signer'); } } Ecdsa.php 0000644 00000002507 15107365571 0006312 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; use Lcobucci\JWT\Signer\Ecdsa\MultibyteStringConverter; use Lcobucci\JWT\Signer\Ecdsa\SignatureConverter; use const OPENSSL_KEYTYPE_EC; abstract class Ecdsa extends OpenSSL { private SignatureConverter $converter; public function __construct(SignatureConverter $converter) { $this->converter = $converter; } public static function create(): Ecdsa { return new static(new MultibyteStringConverter()); // @phpstan-ignore-line } final public function sign(string $payload, Key $key): string { return $this->converter->fromAsn1( $this->createSignature($key->contents(), $key->passphrase(), $payload), $this->keyLength() ); } final public function verify(string $expected, string $payload, Key $key): bool { return $this->verifySignature( $this->converter->toAsn1($expected, $this->keyLength()), $payload, $key->contents() ); } final public function keyType(): int { return OPENSSL_KEYTYPE_EC; } /** * Returns the length of each point in the signature, so that we can calculate and verify R and S points properly * * @internal */ abstract public function keyLength(): int; } OpenSSL.php 0000644 00000006640 15107365571 0006560 0 ustar 00 <?php declare(strict_types=1); namespace Lcobucci\JWT\Signer; use Lcobucci\JWT\Signer; use OpenSSLAsymmetricKey; use function array_key_exists; use function assert; use function is_array; use function is_bool; use function is_string; use function openssl_error_string; use function openssl_free_key; use function openssl_pkey_get_details; use function openssl_pkey_get_private; use function openssl_pkey_get_public; use function openssl_sign; use function openssl_verify; abstract class OpenSSL implements Signer { /** * @throws CannotSignPayload * @throws InvalidKeyProvided */ final protected function createSignature( string $pem, string $passphrase, string $payload ): string { $key = $this->getPrivateKey($pem, $passphrase); try { $signature = ''; if (! openssl_sign($payload, $signature, $key, $this->algorithm())) { $error = openssl_error_string(); assert(is_string($error)); throw CannotSignPayload::errorHappened($error); } return $signature; } finally { $this->freeKey($key); } } /** * @return resource|OpenSSLAsymmetricKey * * @throws CannotSignPayload */ private function getPrivateKey(string $pem, string $passphrase) { $privateKey = openssl_pkey_get_private($pem, $passphrase); $this->validateKey($privateKey); return $privateKey; } /** @throws InvalidKeyProvided */ final protected function verifySignature( string $expected, string $payload, string $pem ): bool { $key = $this->getPublicKey($pem); $result = openssl_verify($payload, $expected, $key, $this->algorithm()); $this->freeKey($key); return $result === 1; } /** * @return resource|OpenSSLAsymmetricKey * * @throws InvalidKeyProvided */ private function getPublicKey(string $pem) { $publicKey = openssl_pkey_get_public($pem); $this->validateKey($publicKey); return $publicKey; } /** * Raises an exception when the key type is not the expected type * * @param resource|OpenSSLAsymmetricKey|bool $key * * @throws InvalidKeyProvided */ private function validateKey($key): void { if (is_bool($key)) { $error = openssl_error_string(); assert(is_string($error)); throw InvalidKeyProvided::cannotBeParsed($error); } $details = openssl_pkey_get_details($key); assert(is_array($details)); if (! array_key_exists('key', $details) || $details['type'] !== $this->keyType()) { throw InvalidKeyProvided::incompatibleKey(); } } /** @param resource|OpenSSLAsymmetricKey $key */ private function freeKey($key): void { if ($key instanceof OpenSSLAsymmetricKey) { return; } openssl_free_key($key); // Deprecated and no longer necessary as of PHP >= 8.0 } /** * Returns the type of key to be used to create/verify the signature (using OpenSSL constants) * * @internal */ abstract public function keyType(): int; /** * Returns which algorithm to be used to create/verify the signature (using OpenSSL constants) * * @internal */ abstract public function algorithm(): int; }
Simpan