Class CryptoStreamGCMImpl
- java.lang.Object
-
- org.apache.fulcrum.jce.crypto.extended.CryptoStreamFactoryJ8Template
-
- org.apache.fulcrum.jce.crypto.algo.CryptoStreamGCMImpl
-
- All Implemented Interfaces:
CryptoStreamFactory,CryptoStreamFactoryJ8
public final class CryptoStreamGCMImpl extends CryptoStreamFactoryJ8Template
Concrete implementation for creating encrypting/decrypting streams. The implementation uses the JCA (Java Crypto Extension) supplied by SUN (using SunJCE 1.42). The implementation uses @seeCryptoParametersJ8.TYPES_IMPL.ALGORITHM_J8_GCMfor encryption which should be sufficent for most applications. The implementation also supplies a default password in the case that the programmer don't want to have additional hassles. It is easy to reengineer the password being used but much better than a hard-coded password in the application.- Author:
- Georg Kallidis
The Implementation for
CryptoParametersJ8.TYPESGCM.
-
-
Field Summary
Fields Modifier and Type Field Description protected static intIV_SIZE-
Fields inherited from class org.apache.fulcrum.jce.crypto.extended.CryptoStreamFactoryJ8Template
algorithm, count, instances, providerName, PROVIDERNAME, salt, SALT_SIZE
-
-
Constructor Summary
Constructors Constructor Description CryptoStreamGCMImpl()ConstructorCryptoStreamGCMImpl(byte[] salt)Constructor
-
Method Summary
Modifier and Type Method Description protected byte[]createCipher(InputStream is, int mode, char[] password)Create a Cipher.protected KeycreateKey(char[] password, byte[] salt)Create a AES/GCM key.-
Methods inherited from class org.apache.fulcrum.jce.crypto.extended.CryptoStreamFactoryJ8Template
generateSalt, getAlgorithm, getCount, getInputStream, getInputStream, getInputStream, getInputStream, getInstance, getInstance, getInstance, getOutputStream, getOutputStream, getOutputStream, getProviderName, getSalt, getSmartInputStream, getSmartInputStream, getType, resetInstances, setAlgorithm, setCount, setProviderName, setSalt, setType
-
-
-
-
Field Detail
-
IV_SIZE
protected static final int IV_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CryptoStreamGCMImpl
public CryptoStreamGCMImpl() throws GeneralSecurityExceptionConstructor- Throws:
GeneralSecurityException- - wrapsNoSuchAlgorithmException
-
CryptoStreamGCMImpl
public CryptoStreamGCMImpl(byte[] salt)
Constructor- Parameters:
salt- the salt for the GCM algorithm
-
-
Method Detail
-
createKey
protected Key createKey(char[] password, byte[] salt) throws GeneralSecurityException
Create a AES/GCM key.- Specified by:
createKeyin classCryptoStreamFactoryJ8Template- Parameters:
password- the password to use.salt- if provided this is used, otherweiseCryptoStreamFactoryJ8Template.getSalt().- Returns:
- the key
- Throws:
GeneralSecurityException- if creating the key failed
-
createCipher
protected byte[] createCipher(InputStream is, int mode, char[] password) throws GeneralSecurityException, IOException
Create a Cipher. Find additional information here:GCMParameterSpec- Specified by:
createCipherin classCryptoStreamFactoryJ8Template- Parameters:
mode- the cipher modepassword- the passwordis- the input stream- Returns:
- an instance of a cipher
- Throws:
GeneralSecurityException- if creating a cipher failedIOException- creating a cipher failed
-
-