|
Bouncy Castle Cryptography Library 1.79 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--org.bouncycastle.bcpg.BCPGObject
|
+--org.bouncycastle.bcpg.S2K
Parameter specifier for the PGP string-to-key password based key derivation function.
There are different S2K modes:
In SIMPLE mode, a single iteration of the hash algorithm is performed to derived a key
from the given passphrase.
This mode is deprecated and MUST NOT be generated.
The SALTED mode is like SIMPLE, but uses an additional salt value.
This mode is deprecated and MUST NOT be generated.
In SALTED_AND_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.
The SALTED_AND_ITERATED mode uses both iteration and a salt value.
This mode is recommended for applications that want to stay backwards compatible.
The new ARGON_2 mode does key derivation using salted Argon2, which is a memory-hard hash algorithm.
This mode is generally recommended over SALTED_AND_ITERATED.
| Inner Class Summary | |
static class |
S2K.Argon2Params
Parameters for Argon2 S2K. |
static class |
S2K.GNUDummyParams
Parameters for the GNU_DUMMY_S2K method. |
| Field Summary | |
static int |
ARGON_2
Memory-hard, salted key generation using Argon2 hash algorithm. |
static int |
GNU_DUMMY_S2K
GNU S2K extension. |
static int |
GNU_PROTECTION_MODE_DIVERT_TO_CARD
A stub to access smartcards. |
static int |
GNU_PROTECTION_MODE_INTERNAL
The (GnuPG) internal representation of a private key. |
static int |
GNU_PROTECTION_MODE_NO_PRIVATE_KEY
Do not store the secret part at all. |
static int |
SALTED
Deprecated. use SALTED_AND_ITERATED or ARGON_2 instead. |
static int |
SALTED_AND_ITERATED
Salted and iterated key generation. |
static int |
SIMPLE
Deprecated. use SALTED_AND_ITERATED or ARGON_2 instead. |
| Constructor Summary | |
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. |
|
S2K(S2K.Argon2Params argon2Params)
Constructs a specifier for an S2K method using Argon2. |
|
S2K(S2K.GNUDummyParams gnuDummyParams)
Construct a specifier for an S2K using the GNU_DUMMY_S2K method. |
|
| Method Summary | |
static S2K |
argon2S2K(S2K.Argon2Params parameters)
Return a new S2K instance using the ARGON_2 method, using the given argon2 parameters |
void |
encode(BCPGOutputStream out)
Encode the packet into the given BCPGOutputStream. |
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 |
getMemorySizeExponent()
Gets the memory size exponent - only if ARGON_2. |
int |
getParallelism()
Gets the degree of parallelism - only if ARGON_2. |
int |
getPasses()
Return the number of passes - only Argon2. |
int |
getProtectionMode()
Gets the protection mode - only if GNU_DUMMY_S2K. |
int |
getType()
Gets the S2K specifier type. |
static S2K |
gnuDummyS2K(S2K.GNUDummyParams parameters)
Return a new S2K instance using the GNU_DUMMY_S2K method, using the given GNU Dummy S2K parameters |
static S2K |
saltedAndIteratedS2K(int algorithm,
byte[] salt,
int iterationCount)
Return a new S2K instance using the SALTED_AND_ITERATED method, using the given hash algorithm |
static S2K |
saltedS2K(int algorithm,
byte[] salt)
Return a new S2K instance using the SALTED method, using the given hash algorithm |
static S2K |
simpleS2K(int algorithm)
Return a new S2K instance using the SIMPLE method, using the given hash algorithm |
| Methods inherited from class org.bouncycastle.bcpg.BCPGObject |
getEncoded |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int SIMPLE
SALTED_AND_ITERATED or ARGON_2 instead.
public static final int SALTED
SALTED_AND_ITERATED or ARGON_2 instead.
public static final int SALTED_AND_ITERATED
ARGON_2 is not available.public static final int ARGON_2
S2K.Argon2Paramspublic static final int GNU_DUMMY_S2K
S2K.GNUDummyParamspublic static final int GNU_PROTECTION_MODE_NO_PRIVATE_KEY
S2K.GNUDummyParamspublic static final int GNU_PROTECTION_MODE_DIVERT_TO_CARD
S2K.GNUDummyParamspublic static final int GNU_PROTECTION_MODE_INTERNAL
S2K.GNUDummyParams| Constructor Detail |
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 S2K(S2K.Argon2Params argon2Params)
S2K method using Argon2.argon2Params - argon2 parameterspublic S2K(S2K.GNUDummyParams gnuDummyParams)
GNU_DUMMY_S2K method.gnuDummyParams - GNU_DUMMY_S2K parameters| Method Detail |
public static S2K simpleS2K(int algorithm)
SIMPLE method, using the given hash algorithm.algorithm - hash algorithm tag
public static S2K saltedS2K(int algorithm,
byte[] salt)
SALTED method, using the given hash algorithm
and salt.algorithm - hash algorithm tagsalt - salt
public static S2K saltedAndIteratedS2K(int algorithm,
byte[] salt,
int iterationCount)
SALTED_AND_ITERATED method, using the given hash algorithm,
salt and iterationCount.algorithm - hash algorithm tagsalt - saltiterationCount - number of iterationspublic static S2K argon2S2K(S2K.Argon2Params parameters)
ARGON_2 method, using the given argon2 parameters.parameters - argon2 parameterspublic static S2K gnuDummyS2K(S2K.GNUDummyParams parameters)
GNU_DUMMY_S2K method, using the given GNU Dummy S2K parameters.parameters - GNU Dummy S2K parameterspublic int getType()
SIMPLE,
SALTED,
SALTED_AND_ITERATED,
ARGON_2public int getHashAlgorithm()
hash algorithm for this S2K.
Only used for SIMPLE, SALTED, SALTED_AND_ITERATEDpublic byte[] getIV()
#type:
SIMPLE: null
SALTED: 8 octets
SALTED_AND_ITERATED: 8 octets
ARGON_2: 16 octets
public long getIterationCount()
SALTED_AND_ITERATED.public int getPasses()
public int getProtectionMode()
GNU_PROTECTION_MODE_NO_PRIVATE_KEY,
GNU_PROTECTION_MODE_DIVERT_TO_CARDpublic int getParallelism()
public int getMemorySizeExponent()
public void encode(BCPGOutputStream out)
throws java.io.IOException
BCPGOutputStream.encode in class BCPGObjectout - packet output streamjava.io.IOException -
|
Bouncy Castle Cryptography Library 1.79 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||