public abstract class CryptorImplCipher extends AbstractCryptoAlgorithmWithRandom implements Cryptor
| Modifier and Type | Field and Description |
|---|---|
private Cipher |
cipher |
private CryptorConfig |
config |
private Key |
key |
private byte[] |
nonce |
private int |
nonceIndex
Index in
nonce or -1 if nonce has completely been processed. |
private int |
nonceSize |
provider| Constructor and Description |
|---|
CryptorImplCipher(RandomFactory randomFactory,
CryptorConfig config,
Key key)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
crypt(byte[] input,
int offset,
int length,
boolean complete) |
String |
getAlgorithm() |
protected Cipher |
getCipher() |
CryptorConfig |
getConfig() |
protected String |
getMode() |
int |
getNonceSize()
Unlike
Cipher this API is designed for ease of use. |
protected abstract boolean |
isEncryptor() |
private int |
readNonce(byte[] input,
int off,
int len) |
void |
reset()
Will reset the internal state of this object.
|
protected RuntimeException |
wrapSecurityException(Exception e) |
createSecureRandom, getRandomFactorygetProvidercreationFailedException, creationFailedException, creationFailedException, creationFailedException, getAlgorithm, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitprocess, process, processprivate final CryptorConfig config
private final Key key
private final int nonceSize
private Cipher cipher
private byte[] nonce
private int nonceIndex
nonce or -1 if nonce has completely been processed.public CryptorImplCipher(RandomFactory randomFactory, CryptorConfig config, Key key)
randomFactory - the RandomFactory to use.config - the CryptorConfig.key - the Key to use.public String getAlgorithm()
getAlgorithm in interface CryptoAlgorithmKey.getAlgorithm(),
Signature.getAlgorithm(),
MessageDigest.getAlgorithm(),
SecureRandom.getAlgorithm(),
Cipher.getAlgorithm()public int getNonceSize()
AbstractGetNonceSizeCipher this API is designed for ease of use. Some cryptographic algorithms require an
initialization 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 for crypt
and for streaming.getNonceSize in interface AbstractGetNonceSize0 for none.Cipher.getIV()protected abstract boolean isEncryptor()
public final CryptorConfig getConfig()
CryptorConfig.protected String getMode()
private int readNonce(byte[] input,
int off,
int len)
public byte[] crypt(byte[] input,
int offset,
int length,
boolean complete)
crypt in interface Cryptorinput - the next chunk of data to encrypt or decrypt.offset - the offset where to start in the input array.length - the number of bytes to read from the input array.complete - - true to complete the encryption or decryption in case this is the last chunk of data,
false otherwise.output array.Cipher.update(byte[], int, int),
Cipher.doFinal(byte[], int, int)protected RuntimeException wrapSecurityException(Exception e)
e - the Exception to wrap.RuntimeException.public void reset()
CryptoProcessorCryptor may not reusable. It is therefore preferable to always create a
fresh instance for each cryptographic task.reset in interface CryptoProcessorMessageDigest.reset()Copyright © 2001–2019 mmm-Team. All rights reserved.