Note
Some Ciphers are using Padding. OneAndZeroesPadding is used as default padding. However padding can still be specified, but mode is not supported; if you try to instantiate the cipher with something else than "NONE" as mode NoSuchAlgorithmException is thrown.
| Modifier and Type | Field and Description |
|---|---|
| protected ByteArrayOutputStream | buf
Internal buffer |
| protected int | cipherTextSize
The maximum number of bytes the cipher can encrypt. |
| protected int | maxPlainTextSize
The maximum number of bytes the cipher can decrypt. |
| protected AlgorithmParameterSpec | paramSpec
ParameterSpec used with this cipher |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | checkLength(int
length of the input to check inLen)Check if the message length plus the length of the input length can be en/decrypted. |
| public final byte[] | Returns: a new buffer with the resultthe input buffer input, int the offset where the input starts inOff, int the input length inLen)Implements abstract org. Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized). |
| public final int | Returns: the output lengththe input buffer input, int the offset where the input starts inOff, int the input length inLen, byte[] the buffer for the result output, int the offset where the result is stored outOff)Implements abstract org. Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized). |
| public final int | Returns: if the cipher is not a hybrid one the max plain/cipher text size is returned, otherwise 0 is returnedImplements abstract org. Return the block size (in bytes). |
| public final byte[] | Returns: null since no initialization vector is used.Implements abstract org. Return the initialization vector. |
| public final int | Returns: the length of the ciphertext or 0 if the input is too long.the length of the input inLen)Implements abstract org. Return the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inLen (in bytes). |
| public final AlgorithmParameterSpec | Returns: the parameters used with this cipher, or null if this cipher does not use any parameters.Implements abstract org. Returns the parameters used with this cipher. |
| protected abstract void | initCipherDecrypt(Key
the key which has to be used to decrypt data key, AlgorithmParameterSpec the algorithm parameters params)Initialize the AsymmetricBlockCipher with a certain key for data encryption. |
| protected abstract void | initCipherEncrypt(Key
the key which has to be used to encrypt data key, AlgorithmParameterSpec the algorithm parameters params, SecureRandom the source of randomness sr)Initialize the AsymmetricBlockCipher with a certain key for data encryption. |
| public final void | initDecrypt(Key
the encryption or decryption key. key)Initialize the cipher for decryption by forwarding it to
|
| public final void | initDecrypt(Key
the key which has to be used to decrypt data. key, AlgorithmParameterSpec the algorithm parameters. params)Implements abstract org. This method initializes the AsymmetricBlockCipher with a certain key for data decryption. |
| public final void | initEncrypt(Key
the encryption or decryption key. key)Initializes the cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom). |
| public final void | initEncrypt(Key
the encryption or decryption key. key, SecureRandom the source of randomness. random)Initialize this cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom, AlgorithmParameterSpec). |
| public final void | initEncrypt(Key
the encryption or decryption key. key, AlgorithmParameterSpec the algorithm parameters. params)Initializes the cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom, AlgorithmParameterSpec). |
| public final void | initEncrypt(Key
the key which has to be used to encrypt data. key, AlgorithmParameterSpec the algorithm parameters. params, SecureRandom the source of randomness. secureRandom)Implements abstract org. This method initializes the AsymmetricBlockCipher with a certain key for data encryption. |
| protected abstract byte[] | Returns: the decrypted messagethe ciphertext to be decrypted (the ciphertext length is
less than or equal to maxCipherTextSize) input)Decrypt the ciphertext stored in input. |
| protected abstract byte[] | Returns: the encrypted message (it has length equal to maxCipherTextSize_)the message to be encrypted (usually the message length is
less than or equal to maxPlainTextSize) input)Encrypt the message stored in input. |
| protected final void | setMode(String
the cipher mode (unused) modeName)Implements abstract org. Since asymmetric block ciphers do not support modes, this method does nothing. |
| protected final void | setPadding(String
the name of the padding scheme (not used) paddingName)Implements abstract org. Since asymmetric block ciphers do not support padding, this method does nothing. |
| public final byte[] | Returns: a new buffer with the result (always empty)byte array containing the next part of the input input, int index in the array where the input starts inOff, int length of the input inLen)Implements abstract org. Continue a multiple-part encryption or decryption operation. |
| public final int | Returns: the length of the output (always 0)the input buffer input, int the offset where the input starts inOff, int the input length inLen, byte[] the output buffer output, int the offset where the result is stored outOff)Implements abstract org. Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part. |
| buf | back to summary |
|---|---|
| protected ByteArrayOutputStream buf Internal buffer | |
| cipherTextSize | back to summary |
|---|---|
| protected int cipherTextSize The maximum number of bytes the cipher can encrypt. | |
| maxPlainTextSize | back to summary |
|---|---|
| protected int maxPlainTextSize The maximum number of bytes the cipher can decrypt. | |
| paramSpec | back to summary |
|---|---|
| protected AlgorithmParameterSpec paramSpec ParameterSpec used with this cipher | |
| AsymmetricBlockCipher | back to summary |
|---|---|
| public AsymmetricBlockCipher() The AsymmetricBlockCipher() constructor | |
| checkLength | back to summary |
|---|---|
| protected void checkLength(int inLen) throws IllegalBlockSizeException Check if the message length plus the length of the input length can be
en/decrypted. This method uses the specific values
| |
| doFinal | back to summary |
|---|---|
| public final byte[] doFinal(byte[] input, int inOff, int inLen) throws IllegalBlockSizeException, BadPaddingException Implements abstract org. Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).
| |
| doFinal | back to summary |
|---|---|
| public final int doFinal(byte[] input, int inOff, int inLen, byte[] output, int outOff) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException Implements abstract org. Finish a multiple-part encryption or decryption operation (depending on how this cipher was initialized).
| |
| getBlockSize | back to summary |
|---|---|
| public final int getBlockSize() Implements abstract org. Return the block size (in bytes). Note although the ciphers extending this class are not block ciphers, the method was adopted to return the maximal plaintext and ciphertext sizes for non hybrid ciphers. If the cipher is hybrid, it returns 0.
| |
| getIV | back to summary |
|---|---|
| public final byte[] getIV() Implements abstract org. Doc from org. Return the initialization vector. This is useful in the context of password-based encryption or decryption, where the IV is derived from a user-provided passphrase.
| |
| getOutputSize | back to summary |
|---|---|
| public final int getOutputSize(int inLen) Implements abstract org. Return the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inLen (in bytes). This call takes into account any unprocessed (buffered) data from a previous update call, and padding. The actual output length of the next update() or doFinal() call may be smaller than the length returned by this method. If the input length plus the length of the buffered data exceeds the maximum length, 0 is returned.
| |
| getParameters | back to summary |
|---|---|
| public final AlgorithmParameterSpec getParameters() Implements abstract org. Returns the parameters used with this cipher. The returned parameters may be the same that were used to initialize this cipher, or may contain the default set of parameters or a set of randomly generated parameters used by the underlying cipher implementation (provided that the underlying cipher implementation uses a default set of parameters or creates new parameters if it needs parameters but was not initialized with any).
| |
| initCipherDecrypt | back to summary |
|---|---|
| protected abstract void initCipherDecrypt(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException Initialize the AsymmetricBlockCipher with a certain key for data encryption.
| |
| initCipherEncrypt | back to summary |
|---|---|
| protected abstract void initCipherEncrypt(Key key, AlgorithmParameterSpec params, SecureRandom sr) throws InvalidKeyException, InvalidAlgorithmParameterException Initialize the AsymmetricBlockCipher with a certain key for data encryption.
| |
| initDecrypt | back to summary |
|---|---|
| public final void initDecrypt(Key key) throws InvalidKeyException Initialize the cipher for decryption by forwarding it to
If this cipher requires any algorithm parameters that cannot be derived from the given key, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption, and raise an InvalidKeyException if it is being initialized for decryption. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).
| |
| initDecrypt | back to summary |
|---|---|
| public final void initDecrypt(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException Implements abstract org. This method initializes the AsymmetricBlockCipher with a certain key for data decryption. If this cipher (including its underlying feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random. Note that when a Cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it
| |
| initEncrypt | back to summary |
|---|---|
| public final void initEncrypt(Key key) throws InvalidKeyException Initializes the cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom). If this cipher requires any algorithm parameters that cannot be derived from the given key, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption, and raise an InvalidKeyException if it is being initialized for decryption. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).
| |
| initEncrypt | back to summary |
|---|---|
| public final void initEncrypt(Key key, SecureRandom random) throws InvalidKeyException Initialize this cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom, AlgorithmParameterSpec). If this cipher requires any algorithm parameters that cannot be derived from the given key, the underlying cipher implementation is supposed to generate the required parameters itself (using provider-specific default or random values) if it is being initialized for encryption, and raise an InvalidKeyException if it is being initialized for decryption. The generated parameters can be retrieved using engineGetParameters or engineGetIV (if the parameter is an IV).
| |
| initEncrypt | back to summary |
|---|---|
| public final void initEncrypt(Key key, AlgorithmParameterSpec params) throws InvalidKeyException, InvalidAlgorithmParameterException Initializes the cipher for encryption by forwarding it to initEncrypt(Key, FlexiSecureRandom, AlgorithmParameterSpec).
| |
| initEncrypt | back to summary |
|---|---|
| public final void initEncrypt(Key key, AlgorithmParameterSpec params, SecureRandom secureRandom) throws InvalidKeyException, InvalidAlgorithmParameterException Implements abstract org. This method initializes the AsymmetricBlockCipher with a certain key for data encryption. If this cipher (including its underlying feedback or padding scheme) requires any random bytes (e.g., for parameter generation), it will get them from random. Note that when a Cipher object is initialized, it loses all previously-acquired state. In other words, initializing a Cipher is equivalent to creating a new instance of that Cipher and initializing it
| |
| messageDecrypt | back to summary |
|---|---|
| protected abstract byte[] messageDecrypt(byte[] input) throws IllegalBlockSizeException, BadPaddingException Decrypt the ciphertext stored in input. The method should also perform an additional length check.
| |
| messageEncrypt | back to summary |
|---|---|
| protected abstract byte[] messageEncrypt(byte[] input) throws IllegalBlockSizeException, BadPaddingException Encrypt the message stored in input. The method should also perform an additional length check.
| |
| setMode | back to summary |
|---|---|
| protected final void setMode(String modeName) Implements abstract org. Since asymmetric block ciphers do not support modes, this method does nothing.
| |
| setPadding | back to summary |
|---|---|
| protected final void setPadding(String paddingName) Implements abstract org. Since asymmetric block ciphers do not support padding, this method does nothing.
| |
| update | back to summary |
|---|---|
| public final byte[] update(byte[] input, int inOff, int inLen) Implements abstract org. Continue a multiple-part encryption or decryption operation. This method just writes the input into an internal buffer.
| |
| update | back to summary |
|---|---|
| public final int update(byte[] input, int inOff, int inLen, byte[] output, int outOff) Implements abstract org. Continue a multiple-part encryption or decryption operation (depending on how this cipher was initialized), processing another data part.
| |