
net.sf.mmm.crypto.symmetric.crypt.aes.SymmetricCryptorConfigAes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mmm-crypto-jce Show documentation
Show all versions of mmm-crypto-jce Show documentation
Library for simple and more secure usage of cryptography (JCA and JCE).
The newest version!
package net.sf.mmm.crypto.symmetric.crypt.aes;
import net.sf.mmm.crypto.crypt.CipherTransformation;
import net.sf.mmm.crypto.provider.SecurityProvider;
import net.sf.mmm.crypto.symmetric.crypt.SymmetricCryptorConfig;
/**
* SecurityCryptorAlgorithmSymmetricConfig for
* AES.
* Attention: JCA/JCE is buggy (creates a nonce of 12 on encryption but expects 16 bytes nonce on decryption,
* etc.). Therefore you shall only use this with {@link SecurityProvider#BC BouncyCastle}.
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 1.0.0
*/
public class SymmetricCryptorConfigAes extends SymmetricCryptorConfig {
/** {@link CipherTransformation#getAlgorithm() Cipher algorithm} {@value}. */
public static final String ALGORITHM_AES = "AES";
/**
* {@link CipherTransformation} for {@link #ALGORITHM_AES AES} with {@link CipherTransformation#MODE_GCM GCM} and
* {@link CipherTransformation#PADDING_NONE no padding}.
*/
public static final CipherTransformation TRANSFORMATION_AES_GCM_NOPADDING = new CipherTransformation(ALGORITHM_AES,
CipherTransformation.MODE_GCM, CipherTransformation.PADDING_NONE);
/**
* The constructor.
*
* @param mode the {@link CipherTransformation#getMode() cipher mode}.
* @param padding the {@link CipherTransformation#getPadding() cipher padding}.
* @param provider the {@link SecurityProvider}.
* @param nonceSize the {@link #getNonceSize() nonce-size}.
*/
public SymmetricCryptorConfigAes(String mode, String padding, SecurityProvider provider, int nonceSize) {
super(new CipherTransformation(ALGORITHM_AES, mode, padding), provider, nonceSize);
}
/**
* The constructor.
*
* @param provider the {@link SecurityProvider}.
*/
public SymmetricCryptorConfigAes(SecurityProvider provider) {
this(provider, 16);
}
/**
* The constructor.
*
* @param provider the {@link SecurityProvider}.
* @param nonceSize the {@link #getNonceSize() nonce-size}.
*/
public SymmetricCryptorConfigAes(SecurityProvider provider, int nonceSize) {
super(TRANSFORMATION_AES_GCM_NOPADDING, provider, nonceSize);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy