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.
SALTED mode is like SIMPLE, but uses an additional salt value.
This mode is deprecated and MUST NOT be generated.
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.
SALTED_AND_ITERATED mode uses both iteration and a salt value.
This mode is recommended for applications that want to stay backwards compatible.
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.
| Modifier and Type | Class and Description |
|---|---|
| public static class | S2K.
Parameters for Argon2 S2K. |
| public static class | S2K.
Parameters for the |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| public static final int | ARGON_2
Memory-hard, salted key generation using Argon2 hash algorithm. |
| private static final int | |
| public static final int | GNU_DUMMY_S2K
GNU S2K extension. |
| public static final int | GNU_PROTECTION_MODE_DIVERT_TO_CARD
A stub to access smartcards. |
| public static final int | GNU_PROTECTION_MODE_INTERNAL
The (GnuPG) internal representation of a private key. |
| public static final int | GNU_PROTECTION_MODE_NO_PRIVATE_KEY
Do not store the secret part at all. |
| pack-priv int | |
| pack-priv byte[] | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| public static final int | SALTED
Deprecated
use Salted key generation.
SALTED_AND_ITERATED or ARGON_2 instead.
|
| public static final int | SALTED_AND_ITERATED
Salted and iterated key generation. |
| public static final int | SIMPLE
Deprecated
use Simple key generation.
SALTED_AND_ITERATED or ARGON_2 instead.
|
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| public | |
| public | S2K(int
the algorithm, byte[] digest algorithm to use.the salt to apply to input to the key generation. iv)Constructs a specifier for a |
| public | S2K(int
the algorithm, byte[] digest algorithm to iterate.the salt to apply to input to the key generation. iv, int the single byte iteration count specifier. itCount)Constructs a specifier for a |
| public | S2K(S2K.
argon2 parameters argon2ParamsConstructs a specifier for an |
| public | S2K(S2K.
GNU_DUMMY_S2K parameters gnuDummyParamsConstruct a specifier for an S2K using the |
| Modifier and Type | Method and Description |
|---|---|
| public static S2K | Returns: S2Kargon2 parameters parametersReturn a new S2K instance using the parameters |
| public void | encode(BCPGOutputStream
packet output stream out)Implements abstract org. Encode the packet into the given |
| public int | |
| public long | |
| public byte[] | |
| public int | Returns: memory size exponentGets the memory size exponent - only if ARGON_2. |
| public int | |
| public int | |
| public int | Returns: GNU dummy-s2k protection modeGets the protection mode - only if GNU_DUMMY_S2K. |
| public int | |
| public static S2K | Returns: S2KGNU Dummy S2K parameters parametersReturn a new S2K instance using the parameters |
| public static S2K | Returns: S2Khash algorithm tag algorithm, byte[] salt salt, int number of iterations iterationCount)Return a new S2K instance using the algorithm |
| public static S2K | |
| public static S2K | |
| private void | writeOneOctetOrThrow(BCPGOutputStream
output stream out, int value val, String name of the value for the error message valName)Throw an |
| algorithm | back to summary |
|---|---|
| pack-priv int algorithm | |
| ARGON_2 | back to summary |
|---|---|
| public static final int ARGON_2 Memory-hard, salted key generation using Argon2 hash algorithm.
| |
| EXPBIAS | back to summary |
|---|---|
| private static final int EXPBIAS | |
| GNU_DUMMY_S2K | back to summary |
|---|---|
| public static final int GNU_DUMMY_S2K GNU S2K extension.
| |
| GNU_PROTECTION_MODE_DIVERT_TO_CARD | back to summary |
|---|---|
| public static final int GNU_PROTECTION_MODE_DIVERT_TO_CARD A stub to access smartcards.
| |
| GNU_PROTECTION_MODE_INTERNAL | back to summary |
|---|---|
| public static final int GNU_PROTECTION_MODE_INTERNAL The (GnuPG) internal representation of a private key.
| |
| GNU_PROTECTION_MODE_NO_PRIVATE_KEY | back to summary |
|---|---|
| public static final int GNU_PROTECTION_MODE_NO_PRIVATE_KEY Do not store the secret part at all.
| |
| itCount | back to summary |
|---|---|
| pack-priv int itCount | |
| iv | back to summary |
|---|---|
| pack-priv byte[] iv | |
| memorySizeExponent | back to summary |
|---|---|
| pack-priv int memorySizeExponent | |
| parallelism | back to summary |
|---|---|
| pack-priv int parallelism | |
| passes | back to summary |
|---|---|
| pack-priv int passes | |
| protectionMode | back to summary |
|---|---|
| pack-priv int protectionMode | |
| SALTED | back to summary |
|---|---|
| public static final int SALTED
Deprecated use Salted key generation. A single iteration of a hash function with a (unique) salt. This method is deprecated to use, since it can be brute-forced when used with a low-entropy string, such as those typically provided by users. Therefore, in OpenPGP v6, an implementation SHOULD NOT generate a Salted S2K, unless the implementation knows that the input string is high-entropy. | |
| SALTED_AND_ITERATED | back to summary |
|---|---|
| public static final int SALTED_AND_ITERATED Salted and iterated key generation. Multiple iterations of a hash function, with a salt.
This method MAY be used if | |
| SIMPLE | back to summary |
|---|---|
| public static final int SIMPLE
Deprecated use Simple key generation. A single non-salted iteration of a hash function. This method is deprecated to use, since it can be brute-forced when used with a low-entropy string, such as those typically provided by users. Additionally, the usage of Simple S2K can lead to key and IV reuse. Therefore, in OpenPGP v6, Therefore, when generating an S2K specifier, an implementation MUST NOT use Simple S2K. | |
| type | back to summary |
|---|---|
| pack-priv int type | |
| S2K | back to summary |
|---|---|
| pack-priv S2K(InputStream in) throws IOException Parse an S2K specifier from an OpenPGP packet input stream.
| |
| S2K | back to summary |
|---|---|
| public S2K(int algorithm) Constructs a specifier for a
| |
| S2K | back to summary |
|---|---|
| public S2K(int algorithm, byte[] iv) Constructs a specifier for a
| |
| S2K | back to summary |
|---|---|
| public S2K(int algorithm, byte[] iv, int itCount) Constructs a specifier for a
| |
| S2K | back to summary |
|---|---|
| public S2K(S2K. Constructs a specifier for an
| |
| S2K | back to summary |
|---|---|
| public S2K(S2K. Construct a specifier for an S2K using the
| |
| argon2S2K | back to summary |
|---|---|
| public static S2K argon2S2K(S2K. Return a new S2K instance using the parameters.
| |
| encode | back to summary |
|---|---|
| public void encode(BCPGOutputStream out) throws IOException Implements abstract org. Encode the packet into the given
| |
| getHashAlgorithm | back to summary |
|---|---|
| public int getHashAlgorithm() Gets the
| |
| getIterationCount | back to summary |
|---|---|
| public long getIterationCount() Gets the actual (expanded) iteration count.
Only used for
| |
| getIV | back to summary |
|---|---|
| public byte[] getIV() Gets the iv/salt to use for the key generation.
The value of this field depends on the S2K
| |
| getMemorySizeExponent | back to summary |
|---|---|
| public int getMemorySizeExponent() Gets the memory size exponent - only if ARGON_2.
| |
| getParallelism | back to summary |
|---|---|
| public int getParallelism() Gets the degree of parallelism - only if ARGON_2.
| |
| getPasses | back to summary |
|---|---|
| public int getPasses() Return the number of passes - only Argon2.
| |
| getProtectionMode | back to summary |
|---|---|
| public int getProtectionMode() Gets the protection mode - only if GNU_DUMMY_S2K.
| |
| getType | back to summary |
|---|---|
| public int getType() Gets the S2K specifier type.
| |
| gnuDummyS2K | back to summary |
|---|---|
| public static S2K gnuDummyS2K(S2K. Return a new S2K instance using the parameters.
| |
| saltedAndIteratedS2K | back to summary |
|---|---|
| public static S2K saltedAndIteratedS2K(int algorithm, byte[] salt, int iterationCount) Return a new S2K instance using the algorithm, saltand iterationCount.
| |
| saltedS2K | back to summary |
|---|---|
| public static S2K saltedS2K(int algorithm, byte[] salt) Return a new S2K instance using the algorithmand salt.
| |
| simpleS2K | back to summary |
|---|---|
| public static S2K simpleS2K(int algorithm) Return a new S2K instance using the algorithm.
| |
| writeOneOctetOrThrow | back to summary |
|---|---|
| private void writeOneOctetOrThrow(BCPGOutputStream out, int val, String valName) throws IOException Throw an
| |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final int | |
| private final int | |
| private final byte[] |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Argon2Params(SecureRandom secureRandom)
Uniformly safe and recommended parameters not tailored to any hardware. |
| public | Argon2Params(int
number of iterations, must be greater than 0 passes, int number of lanes, must be greater 0 parallelism, int exponent for memory consumption, must be between memSizeExp, SecureRandom 3 + ⌈log₂p⌉and 31 secure random generator to initialize the salt vector secureRandom)Create customized Argon2 S2K parameters. |
| public | Argon2Params(byte[]
16 bytes of random salt salt, int number of iterations, must be greater than 0 passes, int number of lanes, must be greater 0 parallelism, int exponent for memory consumption, must be between memSizeExp)3 + ⌈log₂p⌉and 31 Create customized Argon2 S2K parameters. |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public int | |
| public int | |
| public byte[] | |
| public static S2K. | Returns: safe parameters for memory constrained environmentsRecommended parameters for memory constrained environments (64MiB RAM). |
| private static byte[] | Returns: saltrandom number generator instance secureRandom)Generate 16 bytes of random salt. |
| public static S2K. | universallyRecommendedParameters()
Uniformly safe and recommended parameters not tailored to any hardware. |
| memSizeExp | back to summary |
|---|---|
| private final int memSizeExp | |
| parallelism | back to summary |
|---|---|
| private final int parallelism | |
| passes | back to summary |
|---|---|
| private final int passes | |
| salt | back to summary |
|---|---|
| private final byte[] salt | |
| Argon2Params | back to summary |
|---|---|
| public Argon2Params() Uniformly safe and recommended parameters not tailored to any hardware. Uses Argon2id, 1 pass, 4 parallelism, 2 GiB RAM.
| |
| Argon2Params | back to summary |
|---|---|
| public Argon2Params(SecureRandom secureRandom) Uniformly safe and recommended parameters not tailored to any hardware. Uses Argon2id, 1 pass, 4 parallelism, 2 GiB RAM.
| |
| Argon2Params | back to summary |
|---|---|
| public Argon2Params(int passes, int parallelism, int memSizeExp, SecureRandom secureRandom) Create customized Argon2 S2K parameters.
| |
| Argon2Params | back to summary |
|---|---|
| public Argon2Params(byte[] salt, int passes, int parallelism, int memSizeExp) Create customized Argon2 S2K parameters.
| |
| getMemSizeExp | back to summary |
|---|---|
| public int getMemSizeExp() Return the exponent indicating the memory size m.
| |
| getParallelism | back to summary |
|---|---|
| public int getParallelism() Return the factor of parallelism p.
| |
| getPasses | back to summary |
|---|---|
| public int getPasses() Return the number of passes t.
| |
| getSalt | back to summary |
|---|---|
| public byte[] getSalt() Return a 16-byte byte array containing the salt S.
| |
| memoryConstrainedParameters | back to summary |
|---|---|
| public static S2K. Recommended parameters for memory constrained environments (64MiB RAM). Uses Argon2id with 3 passes, 4 lanes and 64 MiB RAM.
| |
| mineSalt | back to summary |
|---|---|
| private static byte[] mineSalt(SecureRandom secureRandom) Generate 16 bytes of random salt.
| |
| universallyRecommendedParameters | back to summary |
|---|---|
| public static S2K. Uniformly safe and recommended parameters not tailored to any hardware. Uses Argon2id, 1 pass, 4 parallelism, 2 GiB RAM.
| |
GNU_DUMMY_S2K method.
| Modifier and Type | Field and Description |
|---|---|
| private final int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static S2K. | Returns: paramsFactory method for a GNU Dummy S2K indicating a private key located on a smart card. |
| public int | |
| public static S2K. | |
| public static S2K. |
| protectionMode | back to summary |
|---|---|
| private final int protectionMode | |
| GNUDummyParams | back to summary |
|---|---|
| private GNUDummyParams(int protectionMode) | |
| divertToCard | back to summary |
|---|---|
| public static S2K. Factory method for a GNU Dummy S2K indicating a private key located on a smart card.
| |
| getProtectionMode | back to summary |
|---|---|
| public int getProtectionMode() Return the GNU Dummy S2K protection method.
| |
| internal | back to summary |
|---|---|
| public static S2K. Factory method for a GNU Dummy S2K indicating an internal private key.
| |
| noPrivateKey | back to summary |
|---|---|
| public static S2K. Factory method for a GNU Dummy S2K indicating a missing private key.
| |