org.bouncycastle.util.Encodable
public class S2K extends BCPGObject
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.
Modifier and Type | Field | Description |
---|---|---|
static int |
GNU_DUMMY_S2K |
|
static int |
GNU_PROTECTION_MODE_DIVERT_TO_CARD |
|
static int |
GNU_PROTECTION_MODE_NO_PRIVATE_KEY |
|
static int |
SALTED |
Salted key generation.
|
static int |
SALTED_AND_ITERATED |
Salted and iterated key generation.
|
static int |
SIMPLE |
Simple key generation.
|
Constructor | Description |
---|---|
S2K(int algorithm) |
Constructs a specifier for a
simple S2K generation. |
S2K(int algorithm,
byte[] iv) |
Constructs a specifier for a
salted S2K generation. |
S2K(int algorithm,
byte[] iv,
int itCount) |
Constructs a specifier for a
salted and iterated S2K generation. |
Modifier and Type | Method | Description |
---|---|---|
void |
encode(BCPGOutputStream out) |
|
int |
getHashAlgorithm() |
Gets the
hash algorithm for this S2K. |
long |
getIterationCount() |
Gets the actual (expanded) iteration count.
|
byte[] |
getIV() |
Gets the iv/salt to use for the key generation.
|
int |
getProtectionMode() |
Gets the protection mode - only if GNU_DUMMY_S2K
|
int |
getType() |
Gets the
digest algorithm specified. |
getEncoded
public static final int SIMPLE
public static final int SALTED
public static final int SALTED_AND_ITERATED
public static final int GNU_DUMMY_S2K
public static final int GNU_PROTECTION_MODE_NO_PRIVATE_KEY
public static final int GNU_PROTECTION_MODE_DIVERT_TO_CARD
public S2K(int algorithm)
simple
S2K generation.algorithm
- the digest algorithm
to use.public S2K(int algorithm, byte[] iv)
salted
S2K generation.algorithm
- the digest algorithm
to use.iv
- the salt to apply to input to the key generation.public S2K(int algorithm, byte[] iv, int itCount)
salted and iterated
S2K generation.algorithm
- the digest algorithm
to iterate.iv
- the salt to apply to input to the key generation.itCount
- the single byte iteration count specifier.public int getType()
digest algorithm
specified.public int getHashAlgorithm()
hash algorithm
for this S2K.public byte[] getIV()
public long getIterationCount()
public int getProtectionMode()
public void encode(BCPGOutputStream out) throws java.io.IOException
encode
in class BCPGObject
java.io.IOException