public class CompactPasswordKey extends java.lang.Object implements ISecretKey
CryptoMain.setDefaultKeyIterationCount(int)
to globally set an iteration count for the whole application or use
CompactPasswordKey.GenerationParametersCPK
to set the iteration count individually.
WrapUtil
is a helper class to easily wrap and re-wrap encryption keys for this case.Modifier and Type | Class and Description |
---|---|
static class |
CompactPasswordKey.GenerationParametersCPK
None of these parameters have to be set, defaults will be used instead for each single parameter being not set.
|
Modifier and Type | Method and Description |
---|---|
static CompactPasswordKey.GenerationParametersCPK |
createParameters()
Create an empty parameters object to set single parameters that shall be changed from defaults
|
static CompactPasswordKey.GenerationParametersCPK |
createParameters(java.lang.String hmacAlgorithm,
int keyLengthInBytes,
int saltLengthInBytes,
int iterationCount,
java.lang.String checksumEncryptionAlgorithm)
None of these parameters have to be set, defaults will be used instead for each single parameter being not set.
|
static CompactPasswordKey |
generateKey(Secret passwordOrSecret) |
static CompactPasswordKey |
generateKey(Secret passwordOrSecret,
boolean passwordChecksum) |
static CompactPasswordKey |
generateKey(Secret passwordOrSecret,
boolean passwordChecksum,
CompactPasswordKey.GenerationParametersCPK parameters) |
static CompactPasswordKey |
generateKey(Secret passwordOrSecret,
CompactPasswordKey.GenerationParametersCPK parameters) |
java.lang.String |
getHMACAlgorithm() |
int |
getIterationCount() |
javax.crypto.spec.SecretKeySpec |
getJCESecretKeySpec() |
byte[] |
getKeyCloneInBytes()
Returns a new copy of the key
|
byte[] |
getKeyInBytes() |
byte[] |
getSaltInBytes() |
boolean |
hasChecksum() |
boolean |
isPasswordValid() |
static CompactPasswordKey |
newInstance(Secret passwordOrSecret)
Creates an uninitialized key.
|
CompactPasswordKey |
readFromBase64(java.lang.String base64) |
CompactPasswordKey |
readFromBytes(byte[] bytes) |
CompactPasswordKey |
readFromFile(java.io.File file) |
CompactPasswordKey |
readFromFile(java.lang.String file) |
CompactPasswordKey |
readFromHex(java.lang.String hex) |
CompactPasswordKey |
readFromJsonObject(morg.json.JSONObject json) |
CompactPasswordKey |
readFromJsonString(java.lang.String json) |
CompactPasswordKey |
readFromStream(java.io.InputStream in) |
void |
wipe()
Wipes the key (bytes) in this object - meaning overwrites it with arbitrary data.
|
java.lang.String |
writeToBase64()
Base64 URL-safe by default
|
byte[] |
writeToBytes() |
void |
writeToFile(java.io.File file) |
void |
writeToFile(java.lang.String file) |
java.lang.String |
writeToHex() |
morg.json.JSONObject |
writeToJsonObject() |
java.lang.String |
writeToJsonString() |
void |
writeToStream(java.io.OutputStream out) |
public byte[] getKeyInBytes()
getKeyInBytes
in interface ISecretKey
public byte[] getKeyCloneInBytes()
public byte[] getSaltInBytes()
public int getIterationCount()
public java.lang.String getHMACAlgorithm()
public boolean hasChecksum()
public boolean isPasswordValid()
public byte[] writeToBytes()
public java.lang.String writeToBase64()
public java.lang.String writeToHex()
public java.lang.String writeToJsonString()
public morg.json.JSONObject writeToJsonObject()
public void writeToStream(java.io.OutputStream out)
public void writeToFile(java.lang.String file)
public void writeToFile(java.io.File file)
public CompactPasswordKey readFromBytes(byte[] bytes)
public CompactPasswordKey readFromBase64(java.lang.String base64)
public CompactPasswordKey readFromHex(java.lang.String hex)
public CompactPasswordKey readFromJsonString(java.lang.String json)
public CompactPasswordKey readFromJsonObject(morg.json.JSONObject json)
public CompactPasswordKey readFromStream(java.io.InputStream in)
public CompactPasswordKey readFromFile(java.lang.String file)
public CompactPasswordKey readFromFile(java.io.File file)
public javax.crypto.spec.SecretKeySpec getJCESecretKeySpec()
public void wipe()
wipe
in interface ISecretKey
public static final CompactPasswordKey generateKey(Secret passwordOrSecret)
public static final CompactPasswordKey generateKey(Secret passwordOrSecret, boolean passwordChecksum)
public static final CompactPasswordKey generateKey(Secret passwordOrSecret, CompactPasswordKey.GenerationParametersCPK parameters)
public static final CompactPasswordKey generateKey(Secret passwordOrSecret, boolean passwordChecksum, CompactPasswordKey.GenerationParametersCPK parameters)
public static final CompactPasswordKey newInstance(Secret passwordOrSecret)
passwordOrSecret
- public static final CompactPasswordKey.GenerationParametersCPK createParameters()
public static final CompactPasswordKey.GenerationParametersCPK createParameters(java.lang.String hmacAlgorithm, int keyLengthInBytes, int saltLengthInBytes, int iterationCount, java.lang.String checksumEncryptionAlgorithm)