Implement encryptSecretKey
Allow encrypting a decrypted secret key, which is especially useful for generating a new encrypted secret key. Defaults to AES256, S2K iter+salt SHA512, always uses s2k_useage 254 with sha1 integrity protection of the encrypted key material. Also add an example to parallel keygen.php that generates a key and then encrypts it with a passphrase.
This commit is contained in:
@@ -143,6 +143,13 @@ class Decryption extends PHPUnit_Framework_TestCase {
|
||||
$this->assertSame(!!$skey, true);
|
||||
}
|
||||
|
||||
public function testEncryptSecretKeyRoundtrip() {
|
||||
$key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/data/helloKey.gpg'));
|
||||
$enkey = OpenPGP_Crypt_Symmetric::encryptSecretKey("password", $key[0]);
|
||||
$skey = OpenPGP_Crypt_Symmetric::decryptSecretKey("password", $enkey);
|
||||
$this->assertEquals($key[0], $skey);
|
||||
}
|
||||
|
||||
public function testAlreadyDecryptedSecretKey() {
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage("Data is already unencrypted");
|
||||
|
Reference in New Issue
Block a user