Package org.refcodes.security
Interface Encrypter<ENC,DEC,EXC extends EncryptionException>
-
- Type Parameters:
ENC
- the generic typeDEC
- the generic typeEXC
- the generic type
public interface Encrypter<ENC,DEC,EXC extends EncryptionException>
Plain interface for providing straight forward encryption functionality as oftoEncrypted(Object)
and for forcing your plain functionality to provide a bridge to the Java Cryptographic Extension (JCE) framework'sCipherSpi
as oftoEncrypted(byte[], int, int, byte[], int)
. This way you can use your algorithms outside the JCE framework. This may be necessary when your Java's security settings prevent running your own JCE extensions from inside an (Oracle-) unsigned JAR.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
toEncrypted(byte[] aInput, int aInputOffset, int aInputLength, byte[] aOutput, int aOutputOffset)
For compatibility with the java.security framework, especially to be integrated in a sub-class of theCipherSpi
.ENC
toEncrypted(DEC aInput)
You pass in data of a given type and you get encrypted data of (another) given type.
-
-
-
Method Detail
-
toEncrypted
ENC toEncrypted(DEC aInput) throws EXC extends EncryptionException
You pass in data of a given type and you get encrypted data of (another) given type.- Parameters:
aInput
- The input data to be encrypted.- Returns:
- The encrypted output data.
- Throws:
EXC
- Thrown in case something went wrong upon encryption.EXC extends EncryptionException
-
toEncrypted
int toEncrypted(byte[] aInput, int aInputOffset, int aInputLength, byte[] aOutput, int aOutputOffset) throws javax.crypto.ShortBufferException, EncryptionException
For compatibility with the java.security framework, especially to be integrated in a sub-class of theCipherSpi
.- Parameters:
aInput
- The input to be encrypted.aInputOffset
- The offset to start encryption.aInputLength
- The length to be encryptedaOutput
- The output where to encrypt to.aOutputOffset
- The offset where to start writing the encrypted output.- Returns:
- The number of bytes encrypted.
- Throws:
javax.crypto.ShortBufferException
- In case you provided lengths and offsets not fitting with the provided arrays.EncryptionException
- Thrown in case an encryption issue occurred regarding theEncrypter
. Probably the configuration of yourEncrypter
does not fit the one of theDecrypter
.
-
-