mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 03:17:58 +01:00
Add encrypt/decrypt test using existing keys
This commit is contained in:
parent
6dce063685
commit
790b0cf7de
1 changed files with 9 additions and 8 deletions
|
@ -41,6 +41,7 @@ import org.pgpainless.algorithm.PublicKeyAlgorithm;
|
|||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||
import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
||||
import org.pgpainless.key.TestKeys;
|
||||
import org.pgpainless.key.collection.PGPKeyRing;
|
||||
import org.pgpainless.key.generation.KeySpec;
|
||||
import org.pgpainless.key.generation.type.ElGamal_GENERAL;
|
||||
|
@ -65,10 +66,6 @@ public class EncryptDecryptTest {
|
|||
"Unfold the imagined happiness that both\n" +
|
||||
"Receive in either by this dear encounter.";
|
||||
|
||||
public EncryptDecryptTest() {
|
||||
LOGGER.log(Level.INFO, "Plain Length: " + testMessage.getBytes(UTF8).length);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void freshKeysRsaToElGamalTest()
|
||||
|
@ -122,6 +119,14 @@ public class EncryptDecryptTest {
|
|||
encryptDecryptForSecretKeyRings(sender, recipient);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void existingRsaKeysTest() throws IOException, PGPException {
|
||||
PGPKeyRing sender = new PGPKeyRing(TestKeys.getJulietPublicKeyRing(), TestKeys.getJulietSecretKeyRing());
|
||||
PGPKeyRing recipient = new PGPKeyRing(TestKeys.getRomeoPublicKeyRing(), TestKeys.getRomeoSecretKeyRing());
|
||||
|
||||
encryptDecryptForSecretKeyRings(sender, recipient);
|
||||
}
|
||||
|
||||
private void encryptDecryptForSecretKeyRings(PGPKeyRing sender, PGPKeyRing recipient)
|
||||
throws PGPException, IOException {
|
||||
PGPSecretKeyRing recipientSec = recipient.getSecretKeys();
|
||||
|
@ -146,10 +151,6 @@ public class EncryptDecryptTest {
|
|||
encryptor.close();
|
||||
byte[] encryptedSecretMessage = envelope.toByteArray();
|
||||
|
||||
LOGGER.log(Level.INFO, "Sender: " + PublicKeyAlgorithm.fromId(senderPub.getPublicKey().getAlgorithm()) +
|
||||
" Receiver: " + PublicKeyAlgorithm.fromId(recipientPub.getPublicKey().getAlgorithm()) +
|
||||
" Encrypted Length: " + encryptedSecretMessage.length);
|
||||
|
||||
OpenPgpMetadata encryptionResult = encryptor.getResult();
|
||||
|
||||
assertFalse(encryptionResult.getSignatureKeyIDs().isEmpty());
|
||||
|
|
Loading…
Reference in a new issue