Jose\KeyConverter\RSAKey::populateCRT PHP Method

populateCRT() private method

This method adds Chinese Remainder Theorem (CRT) parameters if primes 'p' and 'q' are available.
private populateCRT ( )
    private function populateCRT()
    {
        Assertion::keyExists($this->values, 'p', 'The prime "p" is not available.');
        Assertion::keyExists($this->values, 'q', 'The prime "q" is not available.');
        if (array_key_exists('dp', $this->values) && array_key_exists('dq', $this->values) && array_key_exists('qi', $this->values)) {
            return;
        }
        $one = BigInteger::createFromDecimal(1);
        $d = BigInteger::createFromBinaryString(Base64Url::decode($this->values['d']));
        $p = BigInteger::createFromBinaryString(Base64Url::decode($this->values['p']));
        $q = BigInteger::createFromBinaryString(Base64Url::decode($this->values['q']));
        $this->values['dp'] = Base64Url::encode($d->mod($p->subtract($one))->toBytes());
        $this->values['dq'] = Base64Url::encode($d->mod($q->subtract($one))->toBytes());
        $this->values['qi'] = Base64Url::encode($q->modInverse($p)->toBytes());
    }