@Private
public final class OpensslCipher
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
static int |
DECRYPT_MODE |
|
static int |
ENCRYPT_MODE |
| Modifier and Type | Method | Description |
|---|---|---|
void |
clean() |
Forcibly clean the context.
|
int |
doFinal(java.nio.ByteBuffer output) |
Finishes a multiple-part operation.
|
protected void |
finalize() |
|
static OpensslCipher |
getInstance(java.lang.String transformation) |
|
static OpensslCipher |
getInstance(java.lang.String transformation,
java.lang.String engineId) |
Return an
OpensslCipher object that implements the specified
transformation. |
static java.lang.String |
getLibraryName() |
|
static java.lang.String |
getLoadingFailureReason() |
|
void |
init(int mode,
byte[] key,
byte[] iv) |
Initialize this cipher with a key and IV.
|
static boolean |
isSupported(CipherSuite suite) |
|
int |
update(java.nio.ByteBuffer input,
java.nio.ByteBuffer output) |
Continues a multiple-part encryption or decryption operation.
|
public static final int ENCRYPT_MODE
public static final int DECRYPT_MODE
public static java.lang.String getLoadingFailureReason()
public static OpensslCipher getInstance(java.lang.String transformation) throws java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmExceptionjavax.crypto.NoSuchPaddingExceptionpublic static OpensslCipher getInstance(java.lang.String transformation, java.lang.String engineId) throws java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException
OpensslCipher object that implements the specified
transformation.transformation - the name of the transformation, e.g.,
AES/CTR/NoPadding.engineId - the openssl engine to use.if not set,
defalut engine will be used.OpensslCipher objectjava.security.NoSuchAlgorithmException - if transformation is null,
empty, in an invalid format, or if Openssl doesn't implement the
specified algorithm.javax.crypto.NoSuchPaddingException - if transformation contains
a padding scheme that is not available.public static boolean isSupported(CipherSuite suite)
public void init(int mode,
byte[] key,
byte[] iv)
mode - ENCRYPT_MODE or DECRYPT_MODEkey - crypto keyiv - crypto ivpublic int update(java.nio.ByteBuffer input,
java.nio.ByteBuffer output)
throws javax.crypto.ShortBufferException
All input.remaining() bytes starting at
input.position() are processed. The result is stored in
the output buffer.
Upon return, the input buffer's position will be equal to its limit; its limit will not have changed. The output buffer's position will have advanced by n, when n is the value returned by this method; the output buffer's limit will not have changed.
If output.remaining() bytes are insufficient to hold the
result, a ShortBufferException is thrown.
input - the input ByteBufferoutput - the output ByteBufferoutputjavax.crypto.ShortBufferException - if there is insufficient space in the
output bufferpublic int doFinal(java.nio.ByteBuffer output)
throws javax.crypto.ShortBufferException,
javax.crypto.IllegalBlockSizeException,
javax.crypto.BadPaddingException
The result is stored in the output buffer. Upon return, the output buffer's position will have advanced by n, where n is the value returned by this method; the output buffer's limit will not have changed.
Ifoutput.remaining() bytes are insufficient to hold the result,
a ShortBufferException is thrown.
Upon finishing, this method resets this cipher object to the state it was in when previously initialized. That is, the object is available to encrypt or decrypt more data.
If any exception is thrown, this cipher object need to be reset before it can be used again.output - the output ByteBufferoutputjavax.crypto.ShortBufferException - if there is insufficient space in the output buffer.javax.crypto.IllegalBlockSizeException - This exception is thrown when the length
of data provided to a block cipher is incorrect.javax.crypto.BadPaddingException - This exception is thrown when a particular
padding mechanism is expected for the input
data but the data is not padded properly.public void clean()
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic static java.lang.String getLibraryName()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.