mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-27 05:17:59 +01:00
Disallow stripping of primary secret keys
This commit is contained in:
parent
64a50266f1
commit
3e7e6df3f9
1 changed files with 5 additions and 0 deletions
|
@ -451,6 +451,11 @@ public final class KeyRingUtils {
|
|||
public static PGPSecretKeyRing stripSecretKey(@Nonnull PGPSecretKeyRing secretKeys,
|
||||
long secretKeyId)
|
||||
throws IOException, PGPException {
|
||||
|
||||
if (secretKeys.getPublicKey().getKeyID() == secretKeyId) {
|
||||
throw new IllegalArgumentException("Bouncy Castle currently cannot deal with stripped secret primary keys.");
|
||||
}
|
||||
|
||||
if (secretKeys.getSecretKey(secretKeyId) == null) {
|
||||
throw new NoSuchElementException("PGPSecretKeyRing does not contain secret key " + Long.toHexString(secretKeyId));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue