Beispiel #1
0
 function toKey()
 {
     switch ($this->components['kty']) {
         case 'RSA':
             $rsa = new Crypt_RSA();
             $n = new Math_BigInteger('0x' . bin2hex(JOSE_URLSafeBase64::decode($this->components['n'])), 16);
             $e = new Math_BigInteger('0x' . bin2hex(JOSE_URLSafeBase64::decode($this->components['e'])), 16);
             if (array_key_exists('d', $this->components)) {
                 throw new JOSE_Exception_UnexpectedAlgorithm('RSA private key isn\'t supported');
             } else {
                 $pem_string = $rsa->_convertPublicKey($n, $e);
             }
             $rsa->loadKey($pem_string);
             return $rsa;
         default:
             throw new JOSE_Exception_UnexpectedAlgorithm('Unknown key type');
     }
 }
Beispiel #2
0
 /**
  * @param \Math_BigInteger $n
  * @param \Math_BigInteger $e
  * @return RSAPublicKey
  */
 public function buildPublicKey(\Math_BigInteger $n, \Math_BigInteger $e)
 {
     $public_key_pem = $this->rsa_imp->_convertPublicKey($n, $e);
     return new _RSAPublicKeyPEMFornat($public_key_pem);
 }