Module io.github.mmm.crypto
Class SymmetricKeySpecFactoryImplPbe
- java.lang.Object
-
- io.github.mmm.crypto.symmetric.key.spec.SymmetricKeySpecFactoryImplPbe
-
- All Implemented Interfaces:
SymmetricKeySpecFactory
public class SymmetricKeySpecFactoryImplPbe extends Object implements SymmetricKeySpecFactory
Implementation ofSymmetricKeySpecFactory
for PBE (PBEKeySpec
). For sufficient security strength you should use a salt of20
bytes, akey length
of256
bits (never use less than128
bits) and a high number of iterations (e.g.65536
).- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
-
Constructor Summary
Constructors Constructor Description SymmetricKeySpecFactoryImplPbe()
The constructor.SymmetricKeySpecFactoryImplPbe(byte[] salt)
The constructor.SymmetricKeySpecFactoryImplPbe(byte[] salt, int iterationCount)
The constructor.SymmetricKeySpecFactoryImplPbe(byte[] salt, int iterationCount, int keyLength)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeySpec
createKeySpec(String password)
int
getIterationCount()
int
getKeyLength()
-
-
-
Constructor Detail
-
SymmetricKeySpecFactoryImplPbe
public SymmetricKeySpecFactoryImplPbe()
The constructor.
-
SymmetricKeySpecFactoryImplPbe
public SymmetricKeySpecFactoryImplPbe(byte[] salt)
The constructor.- Parameters:
salt
- thesalt
ornull
for no salting.
-
SymmetricKeySpecFactoryImplPbe
public SymmetricKeySpecFactoryImplPbe(byte[] salt, int iterationCount)
The constructor.- Parameters:
salt
- thesalt
ornull
for no salting.iterationCount
- theiteration count
.
-
SymmetricKeySpecFactoryImplPbe
public SymmetricKeySpecFactoryImplPbe(byte[] salt, int iterationCount, int keyLength)
The constructor.- Parameters:
salt
- thesalt
ornull
for no salting.iterationCount
- theiteration count
.keyLength
- thekey length
.
-
-
Method Detail
-
createKeySpec
public KeySpec createKeySpec(String password)
- Specified by:
createKeySpec
in interfaceSymmetricKeySpecFactory
- Parameters:
password
- the secret password.- Returns:
- the
KeySpec
for the given password. May contain additional information like salt.
-
getIterationCount
public int getIterationCount()
- Returns:
- the
iteration count
or0
for no iterations.
-
getKeyLength
public int getKeyLength()
- Returns:
- the
key length
in bits or0
if unspecified (to use defaults).
-
-