Package fr.dyade.aaa.common.crypto
Class CryptoTool
- java.lang.Object
-
- fr.dyade.aaa.common.crypto.CryptoTool
-
- All Implemented Interfaces:
Crypto
- Direct Known Subclasses:
AESGCMTools,AESTool
public abstract class CryptoTool extends Object implements Crypto
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCryptoTool(String password, String salt, int iterationCount, int keyLength)Derive the key from given password and salt.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description byte[]decrypt(byte[] cipherText)byte[]decrypt(byte[] cipherText, byte[] nonce)byte[]decrypt(byte[] cipherText, int offset, int length)byte[]decrypt(byte[] cipherText, int offset, int length, byte[] nonce)byte[]encrypt(byte[] clearText)byte[]encrypt(byte[] clearText, byte[] nonce)byte[]encrypt(byte[] clearText, int offset, int length)byte[]encrypt(byte[] clearText, int offset, int length, byte[] nonce)(package private) abstract CiphergetCipher(int mode)(package private) abstract CiphergetCipher(int mode, byte[] nonce)
-
-
-
Field Detail
-
key
protected SecretKey key
-
-
Constructor Detail
-
CryptoTool
protected CryptoTool(String password, String salt, int iterationCount, int keyLength) throws NoSuchAlgorithmException, InvalidKeySpecException
Derive the key from given password and salt.- Parameters:
password-salt-iterationCount-keyLength-- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
-
Method Detail
-
getCipher
abstract Cipher getCipher(int mode) throws GeneralSecurityException
- Throws:
GeneralSecurityException
-
getCipher
abstract Cipher getCipher(int mode, byte[] nonce) throws GeneralSecurityException
- Throws:
GeneralSecurityException
-
encrypt
public byte[] encrypt(byte[] clearText) throws GeneralSecurityException- Specified by:
encryptin interfaceCrypto- Throws:
GeneralSecurityException
-
encrypt
public byte[] encrypt(byte[] clearText, int offset, int length) throws GeneralSecurityException- Specified by:
encryptin interfaceCrypto- Throws:
GeneralSecurityException
-
encrypt
public byte[] encrypt(byte[] clearText, byte[] nonce) throws GeneralSecurityException- Specified by:
encryptin interfaceCrypto- Throws:
GeneralSecurityException
-
encrypt
public byte[] encrypt(byte[] clearText, int offset, int length, byte[] nonce) throws GeneralSecurityException- Specified by:
encryptin interfaceCrypto- Throws:
GeneralSecurityException
-
decrypt
public byte[] decrypt(byte[] cipherText) throws GeneralSecurityException- Specified by:
decryptin interfaceCrypto- Throws:
GeneralSecurityException
-
decrypt
public byte[] decrypt(byte[] cipherText, int offset, int length) throws GeneralSecurityException- Specified by:
decryptin interfaceCrypto- Throws:
GeneralSecurityException
-
decrypt
public byte[] decrypt(byte[] cipherText, byte[] nonce) throws GeneralSecurityException- Specified by:
decryptin interfaceCrypto- Throws:
GeneralSecurityException
-
decrypt
public byte[] decrypt(byte[] cipherText, int offset, int length, byte[] nonce) throws GeneralSecurityException- Specified by:
decryptin interfaceCrypto- Throws:
GeneralSecurityException
-
-