Package org.pgpainless.key.protection

# Class KeyRingProtectionSettings

java.lang.Object
org.pgpainless.key.protection.KeyRingProtectionSettings

public class KeyRingProtectionSettings extends Object
Secret key protection settings for iterated and salted S2K.

## Constructor Summary

Constructors
Constructor
Description
`KeyRingProtectionSettings(SymmetricKeyAlgorithm encryptionAlgorithm)`
Create a `KeyRingProtectionSettings` object using the given encryption algorithm, SHA1 and 65536 iterations.
`KeyRingProtectionSettings(SymmetricKeyAlgorithm encryptionAlgorithm, HashAlgorithm hashAlgorithm, int s2kCount)`
Constructor for custom salted and iterated S2K protection settings.

## Method Summary

Modifier and Type
Method
Description
`SymmetricKeyAlgorithm`
`getEncryptionAlgorithm()`
Return the encryption algorithm.
`HashAlgorithm`
`getHashAlgorithm()`
Return the hash algorithm.
`int`
`getS2kCount()`
Return the (encoded!) s2k iteration count.
`static KeyRingProtectionSettings`
`secureDefaultSettings()`
Secure default settings using `SymmetricKeyAlgorithm.AES_256`, `HashAlgorithm.SHA256` and an iteration count of 65536.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### KeyRingProtectionSettings

public KeyRingProtectionSettings(@Nonnull SymmetricKeyAlgorithm encryptionAlgorithm)
Create a `KeyRingProtectionSettings` object using the given encryption algorithm, SHA1 and 65536 iterations.

Parameters:
  `encryptionAlgorithm` - encryption algorithm

### KeyRingProtectionSettings

public KeyRingProtectionSettings(@Nonnull SymmetricKeyAlgorithm encryptionAlgorithm, @Nonnull HashAlgorithm hashAlgorithm, int s2kCount)
Constructor for custom salted and iterated S2K protection settings. The salt gets randomly chosen by the library each time. Note, that the s2kCount is the already encoded single-octet number.

Parameters:
  `encryptionAlgorithm` - encryption algorithm
  `hashAlgorithm` - hash algorithm
  `s2kCount` - encoded s2k iteration count
See Also:
  - Encoding Formula

## Method Details

### secureDefaultSettings

public static KeyRingProtectionSettings secureDefaultSettings()
Secure default settings using `SymmetricKeyAlgorithm.AES_256`, `HashAlgorithm.SHA256` and an iteration count of 65536.

Returns:
  secure protection settings

### getEncryptionAlgorithm

@Nonnull public SymmetricKeyAlgorithm getEncryptionAlgorithm()
Return the encryption algorithm.

Returns:
  encryption algorithm

### getHashAlgorithm

@Nonnull public HashAlgorithm getHashAlgorithm()
Return the hash algorithm.

Returns:
  hash algorithm

### getS2kCount

public int getS2kCount()
Return the (encoded!) s2k iteration count.

Returns:
  encoded s2k count
See Also:
  - Encoding Formula