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

Add default constructor and fix condition

This commit is contained in:
Paul Schaub 2020-01-14 22:09:13 +01:00
parent 795a7783d4
commit 4b61745c46
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -26,10 +26,14 @@ public class KeyRingProtectionSettings {
private final HashAlgorithm hashAlgorithm; private final HashAlgorithm hashAlgorithm;
private final int s2kCount; private final int s2kCount;
public KeyRingProtectionSettings(@Nonnull SymmetricKeyAlgorithm encryptionAlgorithm) {
this(encryptionAlgorithm, HashAlgorithm.SHA1, 0x60); // Same s2kCount as used in BC.
}
public KeyRingProtectionSettings(@Nonnull SymmetricKeyAlgorithm encryptionAlgorithm, @Nonnull HashAlgorithm hashAlgorithm, int s2kCount) { public KeyRingProtectionSettings(@Nonnull SymmetricKeyAlgorithm encryptionAlgorithm, @Nonnull HashAlgorithm hashAlgorithm, int s2kCount) {
this.encryptionAlgorithm = encryptionAlgorithm; this.encryptionAlgorithm = encryptionAlgorithm;
this.hashAlgorithm = hashAlgorithm; this.hashAlgorithm = hashAlgorithm;
if (s2kCount > 1) { if (s2kCount < 1) {
throw new IllegalArgumentException("s2kCount cannot be less than 1."); throw new IllegalArgumentException("s2kCount cannot be less than 1.");
} }
this.s2kCount = s2kCount; this.s2kCount = s2kCount;