1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-23 04:42:06 +01:00

Add KeyRingProtectionSettings.secureDefaultSettings() factory method

This commit is contained in:
Paul Schaub 2020-08-31 12:37:34 +02:00
parent 20f32926bb
commit 2af60454f5
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 6 additions and 2 deletions

View file

@ -39,6 +39,10 @@ public class KeyRingProtectionSettings {
this.s2kCount = s2kCount; this.s2kCount = s2kCount;
} }
public static KeyRingProtectionSettings secureDefaultSettings() {
return new KeyRingProtectionSettings(SymmetricKeyAlgorithm.AES_256);
}
public @Nonnull SymmetricKeyAlgorithm getEncryptionAlgorithm() { public @Nonnull SymmetricKeyAlgorithm getEncryptionAlgorithm() {
return encryptionAlgorithm; return encryptionAlgorithm;
} }

View file

@ -54,7 +54,7 @@ public class PasswordBasedSecretKeyRingProtector implements SecretKeyRingProtect
} }
public static PasswordBasedSecretKeyRingProtector forKey(PGPKeyRing keyRing, Passphrase passphrase) { public static PasswordBasedSecretKeyRingProtector forKey(PGPKeyRing keyRing, Passphrase passphrase) {
KeyRingProtectionSettings protectionSettings = new KeyRingProtectionSettings(SymmetricKeyAlgorithm.AES_256); KeyRingProtectionSettings protectionSettings = KeyRingProtectionSettings.secureDefaultSettings();
SecretKeyPassphraseProvider passphraseProvider = new SecretKeyPassphraseProvider() { SecretKeyPassphraseProvider passphraseProvider = new SecretKeyPassphraseProvider() {
@Override @Override
@Nullable @Nullable

View file

@ -32,7 +32,7 @@ public class PassphraseProtectedKeyTest {
* Protector that holds only the password of cryptie. * Protector that holds only the password of cryptie.
*/ */
private final PasswordBasedSecretKeyRingProtector protector = new PasswordBasedSecretKeyRingProtector( private final PasswordBasedSecretKeyRingProtector protector = new PasswordBasedSecretKeyRingProtector(
new KeyRingProtectionSettings(SymmetricKeyAlgorithm.AES_256), KeyRingProtectionSettings.secureDefaultSettings(),
new SecretKeyPassphraseProvider() { new SecretKeyPassphraseProvider() {
@Nullable @Nullable
@Override @Override