diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/modification/secretkeyring/SecretKeyRingEditor.java b/pgpainless-core/src/main/java/org/pgpainless/key/modification/secretkeyring/SecretKeyRingEditor.java index 057d8b36..52eccb0e 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/modification/secretkeyring/SecretKeyRingEditor.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/modification/secretkeyring/SecretKeyRingEditor.java @@ -15,7 +15,7 @@ */ package org.pgpainless.key.modification.secretkeyring; -import static org.pgpainless.key.util.KeyUtils.unlockSecretKey; +import static org.pgpainless.key.util.KeyRingUtils.unlockSecretKey; import java.security.InvalidAlgorithmParameterException; import java.security.NoSuchAlgorithmException; diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/util/KeyRingUtils.java b/pgpainless-core/src/main/java/org/pgpainless/key/util/KeyRingUtils.java index c75fb95c..5ececa47 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/util/KeyRingUtils.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/util/KeyRingUtils.java @@ -19,9 +19,14 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.bouncycastle.openpgp.PGPException; +import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; +import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; +import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; +import org.pgpainless.key.protection.SecretKeyRingProtector; public class KeyRingUtils { @@ -34,4 +39,10 @@ public class KeyRingUtils { PGPPublicKeyRing publicKeyRing = new PGPPublicKeyRing(publicKeyList); return publicKeyRing; } + + public static PGPPrivateKey unlockSecretKey(PGPSecretKey secretKey, SecretKeyRingProtector protector) throws PGPException { + PBESecretKeyDecryptor secretKeyDecryptor = protector.getDecryptor(secretKey.getKeyID()); + PGPPrivateKey privateKey = secretKey.extractPrivateKey(secretKeyDecryptor); + return privateKey; + } } diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/util/KeyUtils.java b/pgpainless-core/src/main/java/org/pgpainless/key/util/KeyUtils.java deleted file mode 100644 index 291b3b9f..00000000 --- a/pgpainless-core/src/main/java/org/pgpainless/key/util/KeyUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2020 Paul Schaub. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.pgpainless.key.util; - -import org.bouncycastle.openpgp.PGPException; -import org.bouncycastle.openpgp.PGPPrivateKey; -import org.bouncycastle.openpgp.PGPSecretKey; -import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; -import org.pgpainless.key.protection.SecretKeyRingProtector; - -public class KeyUtils { - - public static PGPPrivateKey unlockSecretKey(PGPSecretKey secretKey, SecretKeyRingProtector protector) throws PGPException { - PBESecretKeyDecryptor secretKeyDecryptor = protector.getDecryptor(secretKey.getKeyID()); - PGPPrivateKey privateKey = secretKey.extractPrivateKey(secretKeyDecryptor); - return privateKey; - } -}