Horde_Pgp_Element_PrivateKey::getUnencryptedKey PHP Method

getUnencryptedKey() public method

Return the unencrypted version of the private key.
public getUnencryptedKey ( string $passphrase = null ) : Horde_Pgp_Element_PrivateKey
$passphrase string The passphrase used to encrypt the key.
return Horde_Pgp_Element_PrivateKey Unencrypted key.
    public function getUnencryptedKey($passphrase = null)
    {
        $out = null;
        foreach ($this->_getSecretKeyPackets() as $k => $v) {
            if (!strlen($v->encrypted_data)) {
                continue;
            }
            if (is_null($out)) {
                $out = clone $this->message;
            }
            $out[$k] = OpenPGP_Crypt_Symmetric::decryptSecretKey($passphrase, $v);
            if (is_null($out[$k])) {
                throw new Horde_Pgp_Exception(Horde_Pgp_Translation::t("Could not unencrypt private key."));
            }
        }
        return new Horde_Pgp_Element_PrivateKey($out);
    }