Module io.github.mmm.crypto
Class SymmetricKeyCreatorImpl<K extends SecretKey>
- java.lang.Object
-
- io.github.mmm.crypto.algorithm.AbstractSecurityAlgorithm
-
- io.github.mmm.crypto.algorithm.AbstractCryptoAlgorithmWithProvider
-
- io.github.mmm.crypto.symmetric.key.SymmetricKeyCreatorImpl<K>
-
- Type Parameters:
K
- type ofSecretKey
.
- All Implemented Interfaces:
CryptoAlgorithm
,KeyCreator
,SymmetricKeyCreator<K>
public class SymmetricKeyCreatorImpl<K extends SecretKey> extends AbstractCryptoAlgorithmWithProvider implements SymmetricKeyCreator<K>
Implementation ofSymmetricKeyCreator
.- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from class io.github.mmm.crypto.algorithm.AbstractCryptoAlgorithmWithProvider
provider
-
-
Constructor Summary
Constructors Constructor Description SymmetricKeyCreatorImpl(SymmetricKeyConfig config)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
asData(K key)
K
createKey(byte[] key)
K
createKey(String password)
String
getAlgorithm()
int
getKeyLength()
int
getKeyLength(K key)
-
Methods inherited from class io.github.mmm.crypto.algorithm.AbstractCryptoAlgorithmWithProvider
getProvider
-
Methods inherited from class io.github.mmm.crypto.algorithm.AbstractSecurityAlgorithm
creationFailedException, creationFailedException, creationFailedException, creationFailedException, getAlgorithm, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.crypto.symmetric.key.SymmetricKeyCreator
asBinary, verifyKey
-
-
-
-
Constructor Detail
-
SymmetricKeyCreatorImpl
public SymmetricKeyCreatorImpl(SymmetricKeyConfig config)
The constructor.- Parameters:
config
- theSymmetricKeyConfig
.
-
-
Method Detail
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceCryptoAlgorithm
- Returns:
- the name of the underlying algorithm (e.g. "RSA", "NONEwithECDSA", etc.).
- See Also:
Key.getAlgorithm()
,Signature.getAlgorithm()
,MessageDigest.getAlgorithm()
,SecureRandom.getAlgorithm()
,Cipher.getAlgorithm()
-
getKeyLength
public int getKeyLength()
- Specified by:
getKeyLength
in interfaceKeyCreator
- Returns:
- the length of the key in bits. The bigger the key length the stronger and more secure the encryption but
also the more computation power is required. Reasonable values depend on the
algorithm
: A recent value for RSA is 4096 bits while for PBKDF2 256 may be sufficient.
-
getKeyLength
public int getKeyLength(K key)
- Specified by:
getKeyLength
in interfaceSymmetricKeyCreator<K extends SecretKey>
- Parameters:
key
- theSecretKey
.- Returns:
- the
key length
of the given key.
-
createKey
public K createKey(String password)
- Specified by:
createKey
in interfaceSymmetricKeyCreator<K extends SecretKey>
- Parameters:
password
- the secret password.- Returns:
- the according
SecretKey
.
-
createKey
public K createKey(byte[] key)
- Specified by:
createKey
in interfaceSymmetricKeyCreator<K extends SecretKey>
- Parameters:
key
- theSecretKey
asencoded data
.- Returns:
- the deserialized
SecretKey
.
-
-