/** * Initialize from RSAPublicKey. * * @param RSAPublicKey $pk * @return self */ public static function fromRSAPublicKey(RSAPublicKey $pk) { $n = ModulusParameter::fromNumber($pk->modulus()); $e = ExponentParameter::fromNumber($pk->publicExponent()); $key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA); return new self($key_type, $n, $e); }
/** * Initialize from RSAPrivateKey. * * @param RSAPrivateKey $pk * @return self */ public static function fromRSAPrivateKey(RSAPrivateKey $pk) { $n = ModulusParameter::fromNumber($pk->modulus()); $e = ExponentParameter::fromNumber($pk->publicExponent()); $d = PrivateExponentParameter::fromNumber($pk->privateExponent()); $p = FirstPrimeFactorParameter::fromNumber($pk->prime1()); $q = SecondPrimeFactorParameter::fromNumber($pk->prime2()); $dp = FirstFactorCRTExponentParameter::fromNumber($pk->exponent1()); $dq = SecondFactorCRTExponentParameter::fromNumber($pk->exponent2()); $qi = FirstCRTCoefficientParameter::fromNumber($pk->coefficient()); $key_type = new KeyTypeParameter(KeyTypeParameter::TYPE_RSA); return new self($key_type, $n, $e, $d, $p, $q, $dp, $dq, $qi); }