diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/ChangeKeyPasswordImpl.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/ChangeKeyPasswordImpl.java index 7f041e39..95377b12 100644 --- a/pgpainless-sop/src/main/java/org/pgpainless/sop/ChangeKeyPasswordImpl.java +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/ChangeKeyPasswordImpl.java @@ -14,7 +14,6 @@ import org.bouncycastle.bcpg.ArmoredOutputStream; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRingCollection; -import org.pgpainless.PGPainless; import org.pgpainless.exception.MissingPassphraseException; import org.pgpainless.key.OpenPgpFingerprint; import org.pgpainless.key.protection.SecretKeyRingProtector; @@ -54,7 +53,7 @@ public class ChangeKeyPasswordImpl implements ChangeKeyPassword { SecretKeyRingProtector newProtector = SecretKeyRingProtector.unlockAnyKeyWith(newPassphrase); PGPSecretKeyRingCollection secretKeyRingCollection; try { - secretKeyRingCollection = PGPainless.readKeyRing().secretKeyRingCollection(inputStream); + secretKeyRingCollection = KeyReader.readSecretKeys(inputStream, true); } catch (IOException e) { throw new SOPGPException.BadData(e); } diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/EncryptImpl.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/EncryptImpl.java index da895aed..08c58395 100644 --- a/pgpainless-sop/src/main/java/org/pgpainless/sop/EncryptImpl.java +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/EncryptImpl.java @@ -105,11 +105,7 @@ public class EncryptImpl implements Encrypt { @Override public Encrypt withCert(InputStream cert) throws SOPGPException.CertCannotEncrypt, SOPGPException.UnsupportedAsymmetricAlgo, SOPGPException.BadData { try { - PGPPublicKeyRingCollection certificates = PGPainless.readKeyRing() - .publicKeyRingCollection(cert); - if (certificates.size() == 0) { - throw new SOPGPException.BadData("No certificate data found."); - } + PGPPublicKeyRingCollection certificates = KeyReader.readPublicKeys(cert, true); encryptionOptions.addRecipients(certificates); } catch (KeyException.UnacceptableEncryptionKeyException e) { throw new SOPGPException.CertCannotEncrypt(e.getMessage(), e); diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/RevokeKeyImpl.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/RevokeKeyImpl.java index a99b904a..9c143b9e 100644 --- a/pgpainless-sop/src/main/java/org/pgpainless/sop/RevokeKeyImpl.java +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/RevokeKeyImpl.java @@ -66,7 +66,7 @@ public class RevokeKeyImpl implements RevokeKey { public Ready keys(InputStream keys) throws SOPGPException.BadData { PGPSecretKeyRingCollection secretKeyRings; try { - secretKeyRings = PGPainless.readKeyRing().secretKeyRingCollection(keys); + secretKeyRings = KeyReader.readSecretKeys(keys, true); } catch (IOException e) { throw new SOPGPException.BadData("Cannot decode secret keys.", e); }