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;
}
public static KeyRingProtectionSettings secureDefaultSettings() {
return new KeyRingProtectionSettings(SymmetricKeyAlgorithm.AES_256);
}
public @Nonnull SymmetricKeyAlgorithm getEncryptionAlgorithm() {
return encryptionAlgorithm;
}

View File

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

View File

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