- java.lang.Object
-
- io.github.mmm.crypto.CryptoConfig
-
- io.github.mmm.crypto.algorithm.CryptoAlgorithmConfig
-
- io.github.mmm.crypto.crypt.CryptorConfig
-
- All Implemented Interfaces:
CryptoAlgorithm
,AbstractGetNonceSize
- Direct Known Subclasses:
AsymmetricCryptorConfig
,SymmetricCryptorConfig
public class CryptorConfig extends CryptoAlgorithmConfig implements AbstractGetNonceSize
- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
-
Field Summary
-
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 CryptorConfig(CipherTransformation transformation, SecurityProvider provider, int nonceSize)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getNonceSize()
UnlikeCipher
this API is designed for ease of use.CipherTransformation
getTransformation()
boolean
isCreateRandomNonce()
This method returnsfalse
by default.-
Methods inherited from class io.github.mmm.crypto.algorithm.CryptoAlgorithmConfig
getAlgorithm
-
Methods inherited from class io.github.mmm.crypto.CryptoConfig
getProvider
-
-
-
-
Constructor Detail
-
CryptorConfig
public CryptorConfig(CipherTransformation transformation, SecurityProvider provider, int nonceSize)
The constructor.- Parameters:
transformation
- thetransfomation
for theCipher
.provider
- theSecurityProvider
.nonceSize
- thenonce size
.
-
-
Method Detail
-
getTransformation
public CipherTransformation getTransformation()
- Returns:
- the
CipherTransformation
.
-
isCreateRandomNonce
public boolean isCreateRandomNonce()
This method returnsfalse
by default. You may override this method to create a random nonce individually but only if you know exactly what you are doing and what are the details about the cryptographic algorithm.- Returns:
true
if thenonce
should be created individually fromSecureRandom
,false
to get frominitialization vector
.
-
getNonceSize
public final int getNonceSize()
Description copied from interface:AbstractGetNonceSize
UnlikeCipher
this API is designed for ease of use. Some cryptographic algorithms require aninitialization vector
(IV) and others do not. With this API you do not have to care and cannot do things wrong. The nonce will be prepended automatically to the encrypted payload and reconstructed from there on decryption. This works both forcrypt
and forstreaming
.- Specified by:
getNonceSize
in interfaceAbstractGetNonceSize
- Returns:
- the size of the nonce in bytes or
0
for none. - See Also:
Cipher.getIV()
-
-