- java.lang.Object
-
- io.github.mmm.crypto.CryptoConfig
-
- io.github.mmm.crypto.algorithm.CryptoAlgorithmConfig
-
- io.github.mmm.crypto.hash.HashConfig
-
- All Implemented Interfaces:
AbstractCryptoFactory
,AbstractGetIterationCount
,CryptoAlgorithm
,HashFactory
public class HashConfig extends CryptoAlgorithmConfig implements AbstractGetIterationCount, HashFactory
- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALGORITHM_NONE
The dummy hash algorithm NONE for no hashing (e.g.-
Fields inherited from class io.github.mmm.crypto.algorithm.CryptoAlgorithmConfig
algorithm
-
Fields inherited from class io.github.mmm.crypto.CryptoConfig
provider
-
-
Constructor Summary
Constructors Constructor Description HashConfig(String algorithm)
The constructor.HashConfig(String algorithm, int iterationCount)
The constructor.HashConfig(String algorithm, SecurityProvider provider)
The constructor.HashConfig(String algorithm, SecurityProvider provider, int iterationCount)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HashConfig
decrementIterationCount()
int
getIterationCount()
HashAccess
newAccess()
HashCreator
newHashCreator()
-
Methods inherited from class io.github.mmm.crypto.algorithm.CryptoAlgorithmConfig
getAlgorithm
-
Methods inherited from class io.github.mmm.crypto.CryptoConfig
getProvider
-
-
-
-
Field Detail
-
ALGORITHM_NONE
public static final String ALGORITHM_NONE
The dummy hash algorithm NONE for no hashing (e.g. plain signing without prior hashing).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HashConfig
public HashConfig(String algorithm)
The constructor.- Parameters:
algorithm
- thehash algorithm
.
-
HashConfig
public HashConfig(String algorithm, int iterationCount)
The constructor.- Parameters:
algorithm
- thehash algorithm
.iterationCount
- theiteration count
.
-
HashConfig
public HashConfig(String algorithm, SecurityProvider provider)
The constructor.- Parameters:
algorithm
- thehash algorithm
.provider
- theSecurityProvider
.
-
HashConfig
public HashConfig(String algorithm, SecurityProvider provider, int iterationCount)
The constructor.- Parameters:
algorithm
- thehash algorithm
.provider
- theSecurityProvider
.iterationCount
- theiteration count
.
-
-
Method Detail
-
getIterationCount
public int getIterationCount()
- Specified by:
getIterationCount
in interfaceAbstractGetIterationCount
- Returns:
- the iteration count representing the number of repetitive iterations of an
algorithm
such as a hash function. A value of1
means that the algorithm is applied only a single time. This can be fine for simple hashing. Any higher number means an according repetition of the algorithm. The higher the number the higher the computation time. While e.g. for password checks a high iteration count may only mean an overhead of roughly one second, an attacker who wants to try every password with a brute force attack will require an extra ordinary magnitude of additional computing power. Therefore in case of a password algorithm such as PBKDF2 a higher number will mean higher security. However, the value is always a trade-off between usability and security. Further, a too high number might even open the door to denial of service attacks (DoS). A good value can only be defined for a particular algorithm in combination of the current hardware resources and computation power that increase over time. - See Also:
PBEKeySpec.getIterationCount()
-
decrementIterationCount
public HashConfig decrementIterationCount()
- Returns:
- a
HashConfig
with the samealgorithm
but aniteration count
decreased by 1. If theiteration count
is already1
thennull
is returned.
-
newAccess
public HashAccess newAccess()
- Returns:
- a new
HashAccess
for this configuration.
-
newHashCreator
public HashCreator newHashCreator()
- Specified by:
newHashCreator
in interfaceHashFactory
- Returns:
- a new instance of
HashCreator
for the configured hash algorithm of this factory.
-
-