From: Cyperghost Date: Tue, 25 Jun 2024 11:43:48 +0000 (+0200) Subject: Upgrade composer packages X-Git-Tag: 6.1.0_Alpha_1~47^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2f7ab0d1ffd36165c0db23a860437a4212ddd9d6;p=GitHub%2FWoltLab%2FWCF.git Upgrade composer packages `web-token/jwt-library` to `3.3.50` `spomky-labs/pki-framework` to `1.2.1` --- diff --git a/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php index 71226d4395..c78e174c64 100644 --- a/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php +++ b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/AlgorithmIdentifier/AlgorithmIdentifier.php @@ -29,6 +29,8 @@ abstract class AlgorithmIdentifier implements AlgorithmIdentifierType final public const OID_SHA1_WITH_RSA_ENCRYPTION = '1.2.840.113549.1.1.5'; + final public const OID_RSASSA_PSS_ENCRYPTION = '1.2.840.113549.1.1.10'; + final public const OID_SHA256_WITH_RSA_ENCRYPTION = '1.2.840.113549.1.1.11'; final public const OID_SHA384_WITH_RSA_ENCRYPTION = '1.2.840.113549.1.1.12'; diff --git a/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/AlgorithmIdentifier/Asymmetric/RSAPSSSSAEncryptionAlgorithmIdentifier.php b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/AlgorithmIdentifier/Asymmetric/RSAPSSSSAEncryptionAlgorithmIdentifier.php new file mode 100644 index 0000000000..34aebd080a --- /dev/null +++ b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/AlgorithmIdentifier/Asymmetric/RSAPSSSSAEncryptionAlgorithmIdentifier.php @@ -0,0 +1,63 @@ +asNull(); + return self::create(); + } + + /** + * @return NullType + */ + protected function paramsASN1(): ?Element + { + return NullType::create(); + } +} diff --git a/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php index 0ead218024..f7f29bf003 100644 --- a/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php +++ b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/Asymmetric/OneAsymmetricKey.php @@ -24,6 +24,7 @@ use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RFC8410\Curve25519\X25519PrivateKey; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RFC8410\Curve448\Ed448PrivateKey; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RFC8410\Curve448\X448PrivateKey; use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RSA\RSAPrivateKey; +use SpomkyLabs\Pki\CryptoTypes\Asymmetric\RSA\RSASSAPSSPrivateKey; use UnexpectedValueException; use function in_array; @@ -184,6 +185,9 @@ class OneAsymmetricKey // RSA case AlgorithmIdentifier::OID_RSA_ENCRYPTION: return RSAPrivateKey::fromDER($this->privateKeyData); + // RSASSA-PSS + case AlgorithmIdentifier::OID_RSASSA_PSS_ENCRYPTION: + return RSASSAPSSPrivateKey::fromDER($this->privateKeyData); // elliptic curve case AlgorithmIdentifier::OID_EC_PUBLIC_KEY: $pk = ECPrivateKey::fromDER($this->privateKeyData); @@ -225,8 +229,9 @@ class OneAsymmetricKey return X448PrivateKey::fromOctetString(OctetString::fromDER($this->privateKeyData), $pubkey) ->withVersion($this->version) ->withAttributes($this->attributes); + default: + throw new RuntimeException('Private key ' . $algo->name() . ' not supported.'); } - throw new RuntimeException('Private key ' . $algo->name() . ' not supported.'); } /** diff --git a/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/Asymmetric/RSA/RSASSAPSSPrivateKey.php b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/Asymmetric/RSA/RSASSAPSSPrivateKey.php new file mode 100644 index 0000000000..89703e85b0 --- /dev/null +++ b/wcfsetup/install/files/lib/system/api/spomky-labs/pki-framework/src/CryptoTypes/Asymmetric/RSA/RSASSAPSSPrivateKey.php @@ -0,0 +1,226 @@ +at(0) + ->asInteger() + ->intNumber(); + if ($version !== 0) { + throw new UnexpectedValueException('Version must be 0.'); + } + // helper function get integer from given index + $get_int = static fn ($idx) => $seq->at($idx) + ->asInteger() + ->number(); + $n = $get_int(1); + $e = $get_int(2); + $d = $get_int(3); + $p = $get_int(4); + $q = $get_int(5); + $dp = $get_int(6); + $dq = $get_int(7); + $qi = $get_int(8); + return self::create($n, $e, $d, $p, $q, $dp, $dq, $qi); + } + + /** + * Initialize from DER data. + */ + public static function fromDER(string $data): self + { + return self::fromASN1(UnspecifiedType::fromDER($data)->asSequence()); + } + + /** + * @see PrivateKey::fromPEM() + */ + public static function fromPEM(PEM $pem): self + { + $pk = parent::fromPEM($pem); + if (! ($pk instanceof self)) { + throw new UnexpectedValueException('Not an RSA private key.'); + } + return $pk; + } + + /** + * Get modulus. + * + * @return string Base 10 integer + */ + public function modulus(): string + { + return $this->modulus; + } + + /** + * Get public exponent. + * + * @return string Base 10 integer + */ + public function publicExponent(): string + { + return $this->publicExponent; + } + + /** + * Get private exponent. + * + * @return string Base 10 integer + */ + public function privateExponent(): string + { + return $this->privateExponent; + } + + /** + * Get first prime factor. + * + * @return string Base 10 integer + */ + public function prime1(): string + { + return $this->prime1; + } + + /** + * Get second prime factor. + * + * @return string Base 10 integer + */ + public function prime2(): string + { + return $this->prime2; + } + + /** + * Get first factor exponent. + * + * @return string Base 10 integer + */ + public function exponent1(): string + { + return $this->exponent1; + } + + /** + * Get second factor exponent. + * + * @return string Base 10 integer + */ + public function exponent2(): string + { + return $this->exponent2; + } + + /** + * Get CRT coefficient of the second factor. + * + * @return string Base 10 integer + */ + public function coefficient(): string + { + return $this->coefficient; + } + + public function algorithmIdentifier(): AlgorithmIdentifierType + { + return RSAPSSSSAEncryptionAlgorithmIdentifier::create(); + } + + /** + * @return RSAPublicKey + */ + public function publicKey(): PublicKey + { + return RSAPublicKey::create($this->modulus, $this->publicExponent); + } + + /** + * Generate ASN.1 structure. + */ + public function toASN1(): Sequence + { + return Sequence::create( + Integer::create(0), + Integer::create($this->modulus), + Integer::create($this->publicExponent), + Integer::create($this->privateExponent), + Integer::create($this->prime1), + Integer::create($this->prime2), + Integer::create($this->exponent1), + Integer::create($this->exponent2), + Integer::create($this->coefficient) + ); + } + + public function toDER(): string + { + return $this->toASN1() + ->toDER(); + } + + public function toPEM(): PEM + { + return PEM::create(PEM::TYPE_PRIVATE_KEY, $this->toDER()); + } +}