- 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 intgetNonceSize()UnlikeCipherthis API is designed for ease of use.CipherTransformationgetTransformation()booleanisCreateRandomNonce()This method returnsfalseby 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- thetransfomationfor theCipher.provider- theSecurityProvider.nonceSize- thenonce size.
-
-
Method Detail
-
getTransformation
public CipherTransformation getTransformation()
- Returns:
- the
CipherTransformation.
-
isCreateRandomNonce
public boolean isCreateRandomNonce()
This method returnsfalseby 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:
trueif thenonceshould be created individually fromSecureRandom,falseto get frominitialization vector.
-
getNonceSize
public final int getNonceSize()
Description copied from interface:AbstractGetNonceSizeUnlikeCipherthis 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 forcryptand forstreaming.- Specified by:
getNonceSizein interfaceAbstractGetNonceSize- Returns:
- the size of the nonce in bytes or
0for none. - See Also:
Cipher.getIV()
-
-