Package org.bouncycastle.bcpg
Class S2K
java.lang.Object
org.bouncycastle.bcpg.BCPGObject
org.bouncycastle.bcpg.S2K
- All Implemented Interfaces:
org.bouncycastle.util.Encodable
Parameter specifier for the PGP string-to-key password based key derivation function.
In iterated mode, S2K takes a single byte iteration count specifier, which is converted to an actual iteration count using a formula that grows the iteration count exponentially as the byte value increases.
e.g. 0x01 == 1088 iterations, and 0xFF == 65,011,712 iterations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intSalted key generation.static final intSalted and iterated key generation.static final intSimple key generation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidencode(BCPGOutputStream out) intGets thehash algorithmfor this S2K.longGets the actual (expanded) iteration count.byte[]getIV()Gets the iv/salt to use for the key generation.intGets the protection mode - only if GNU_DUMMY_S2KintgetType()Gets thedigest algorithmspecified.Methods inherited from class org.bouncycastle.bcpg.BCPGObject
getEncoded
-
Field Details
-
SIMPLE
public static final int SIMPLESimple key generation. A single non-salted iteration of a hash function- See Also:
-
SALTED
public static final int SALTEDSalted key generation. A single iteration of a hash function with a (unique) salt- See Also:
-
SALTED_AND_ITERATED
public static final int SALTED_AND_ITERATEDSalted and iterated key generation. Multiple iterations of a hash function, with a salt- See Also:
-
GNU_DUMMY_S2K
public static final int GNU_DUMMY_S2K- See Also:
-
GNU_PROTECTION_MODE_NO_PRIVATE_KEY
public static final int GNU_PROTECTION_MODE_NO_PRIVATE_KEY- See Also:
-
GNU_PROTECTION_MODE_DIVERT_TO_CARD
public static final int GNU_PROTECTION_MODE_DIVERT_TO_CARD- See Also:
-
-
Constructor Details
-
S2K
public S2K(int algorithm) Constructs a specifier for asimpleS2K generation.- Parameters:
algorithm- thedigest algorithmto use.
-
S2K
public S2K(int algorithm, byte[] iv) Constructs a specifier for asaltedS2K generation.- Parameters:
algorithm- thedigest algorithmto use.iv- the salt to apply to input to the key generation.
-
S2K
public S2K(int algorithm, byte[] iv, int itCount) Constructs a specifier for asalted and iteratedS2K generation.- Parameters:
algorithm- thedigest algorithmto iterate.iv- the salt to apply to input to the key generation.itCount- the single byte iteration count specifier.
-
-
Method Details
-
getType
public int getType()Gets thedigest algorithmspecified. -
getHashAlgorithm
public int getHashAlgorithm()Gets thehash algorithmfor this S2K. -
getIV
public byte[] getIV()Gets the iv/salt to use for the key generation. -
getIterationCount
public long getIterationCount()Gets the actual (expanded) iteration count. -
getProtectionMode
public int getProtectionMode()Gets the protection mode - only if GNU_DUMMY_S2K -
encode
- Specified by:
encodein classBCPGObject- Throws:
IOException
-