Package org.apache.commons.crypto.jna
Class OpenSsl20XNativeJna
- java.lang.Object
-
- org.apache.commons.crypto.jna.OpenSsl20XNativeJna
-
- All Implemented Interfaces:
OpenSslInterfaceNativeJna
final class OpenSsl20XNativeJna extends java.lang.Object implements OpenSslInterfaceNativeJna
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.Throwable
INIT_ERROR
(package private) static boolean
INIT_OK
-
Constructor Summary
Constructors Constructor Description OpenSsl20XNativeJna()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.sun.jna.ptr.PointerByReference
_ENGINE_by_id(java.lang.String string)
int
_ENGINE_cleanup()
TODO Appears to be deprecated as of OpenSSL 1.1.0.int
_ENGINE_finish(com.sun.jna.ptr.PointerByReference rdrandEngine)
int
_ENGINE_free(com.sun.jna.ptr.PointerByReference rdrandEngine)
int
_ENGINE_init(com.sun.jna.ptr.PointerByReference rdrandEngine)
void
_ENGINE_load_rdrand()
int
_ENGINE_set_default(com.sun.jna.ptr.PointerByReference rdrandEngine, int flags)
java.lang.String
_ERR_error_string(com.sun.jna.NativeLong err, char[] buff)
com.sun.jna.NativeLong
_ERR_peek_error()
com.sun.jna.ptr.PointerByReference
_EVP_aes_128_cbc()
com.sun.jna.ptr.PointerByReference
_EVP_aes_128_ctr()
com.sun.jna.ptr.PointerByReference
_EVP_aes_192_cbc()
com.sun.jna.ptr.PointerByReference
_EVP_aes_192_ctr()
com.sun.jna.ptr.PointerByReference
_EVP_aes_256_cbc()
com.sun.jna.ptr.PointerByReference
_EVP_aes_256_ctr()
void
_EVP_CIPHER_CTX_cleanup(com.sun.jna.ptr.PointerByReference context)
void
_EVP_CIPHER_CTX_free(com.sun.jna.ptr.PointerByReference context)
com.sun.jna.ptr.PointerByReference
_EVP_CIPHER_CTX_new()
int
_EVP_CIPHER_CTX_set_padding(com.sun.jna.ptr.PointerByReference context, int padding)
int
_EVP_CipherFinal_ex(com.sun.jna.ptr.PointerByReference context, java.nio.ByteBuffer outBuffer, int[] outlen)
int
_EVP_CipherInit_ex(com.sun.jna.ptr.PointerByReference context, com.sun.jna.ptr.PointerByReference algo, com.sun.jna.ptr.PointerByReference impl, byte[] encoded, byte[] iv, int cipherMode)
int
_EVP_CipherUpdate(com.sun.jna.ptr.PointerByReference context, java.nio.ByteBuffer outBuffer, int[] outlen, java.nio.ByteBuffer inBuffer, int remaining)
java.lang.Throwable
_INIT_ERROR()
boolean
_INIT_OK()
java.lang.String
_OpenSSL_version(int i)
int
_RAND_bytes(java.nio.ByteBuffer buf, int length)
com.sun.jna.ptr.PointerByReference
_RAND_get_rand_method()
com.sun.jna.ptr.PointerByReference
_RAND_SSLeay()
static com.sun.jna.ptr.PointerByReference
ENGINE_by_id(java.lang.String id)
Gets engine by id.static int
ENGINE_cleanup()
Cleanups before program exit, it will avoid memory leaks.static int
ENGINE_finish(com.sun.jna.ptr.PointerByReference e)
Releases all functional references.static int
ENGINE_free(com.sun.jna.ptr.PointerByReference e)
Frees the structural referencestatic int
ENGINE_init(com.sun.jna.ptr.PointerByReference e)
Obtains a functional reference from an existing structural reference.static int
ENGINE_set_default(com.sun.jna.ptr.PointerByReference e, int flags)
Sets the engine as the default for random number generation.static java.lang.String
ERR_error_string(com.sun.jna.NativeLong err, char[] null_)
Generates a human-readable string representing the error code e.static void
ERR_load_crypto_strings()
Registers the error strings for all libcrypto functions.static com.sun.jna.NativeLong
ERR_peek_error()
static com.sun.jna.ptr.PointerByReference
EVP_aes_128_cbc()
static com.sun.jna.ptr.PointerByReference
EVP_aes_128_ctr()
static com.sun.jna.ptr.PointerByReference
EVP_aes_192_cbc()
static com.sun.jna.ptr.PointerByReference
EVP_aes_192_ctr()
static com.sun.jna.ptr.PointerByReference
EVP_aes_256_cbc()
static com.sun.jna.ptr.PointerByReference
EVP_aes_256_ctr()
static void
EVP_CIPHER_CTX_cleanup(com.sun.jna.ptr.PointerByReference c)
Clears all information from a cipher context and free up any allocated * memory associate with it.static void
EVP_CIPHER_CTX_free(com.sun.jna.ptr.PointerByReference c)
Clears all information from a cipher context and free up any allocated memory associate with it, including ctx itself.static void
EVP_CIPHER_CTX_init(com.sun.jna.ptr.PointerByReference p)
EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset.static com.sun.jna.ptr.PointerByReference
EVP_CIPHER_CTX_new()
Creates a cipher context.static int
EVP_CIPHER_CTX_set_padding(com.sun.jna.ptr.PointerByReference c, int pad)
Enables or disables padding.static int
EVP_CipherFinal_ex(com.sun.jna.ptr.PointerByReference ctx, java.nio.ByteBuffer bout, int[] outl)
Finishes a multiple-part operation.static int
EVP_CipherInit_ex(com.sun.jna.ptr.PointerByReference ctx, com.sun.jna.ptr.PointerByReference cipher, com.sun.jna.ptr.PointerByReference impl, byte[] key, byte[] iv, int enc)
Init a cipher.static int
EVP_CipherUpdate(com.sun.jna.ptr.PointerByReference ctx, java.nio.ByteBuffer bout, int[] outl, java.nio.ByteBuffer in, int inl)
Continues a multiple-part encryption/decryption operation.static int
RAND_bytes(java.nio.ByteBuffer buf, int num)
Generates random data.static com.sun.jna.ptr.PointerByReference
RAND_get_rand_method()
OpenSSL uses for random number generation.static com.sun.jna.ptr.PointerByReference
RAND_SSLeay()
OpenSSL uses for random number generation.static com.sun.jna.NativeLong
SSLeay()
TODO (does not appear to be used yet)static java.lang.String
SSLeay_version(int type)
Retrieves version/build information about OpenSSL library.
-
-
-
Method Detail
-
ENGINE_by_id
public static com.sun.jna.ptr.PointerByReference ENGINE_by_id(java.lang.String id)
Gets engine by id.- Parameters:
id
- engine id.- Returns:
- engine instance
-
ENGINE_cleanup
public static int ENGINE_cleanup()
Cleanups before program exit, it will avoid memory leaks.- Returns:
- 0 on success, 1 otherwise.
-
ENGINE_finish
public static int ENGINE_finish(com.sun.jna.ptr.PointerByReference e)
Releases all functional references.- Parameters:
e
- engine reference.- Returns:
- 0 on success, 1 otherwise.
-
ENGINE_free
public static int ENGINE_free(com.sun.jna.ptr.PointerByReference e)
Frees the structural reference- Parameters:
e
- engine reference.- Returns:
- 0 on success, 1 otherwise.
-
ENGINE_init
public static int ENGINE_init(com.sun.jna.ptr.PointerByReference e)
Obtains a functional reference from an existing structural reference.- Parameters:
e
- engine reference- Returns:
- zero if the ENGINE was not already operational and couldn't be successfully initialized
-
ENGINE_set_default
public static int ENGINE_set_default(com.sun.jna.ptr.PointerByReference e, int flags)
Sets the engine as the default for random number generation.- Parameters:
e
- engine reference.flags
- ENGINE_METHOD_RAND.- Returns:
- zero if failed.
-
ERR_error_string
public static java.lang.String ERR_error_string(com.sun.jna.NativeLong err, char[] null_)
Generates a human-readable string representing the error code e.- Parameters:
err
- the error codenull_
- buf is NULL, the error string is placed in a static buffer- Returns:
- the human-readable error messages.
- See Also:
- ERR_error_string
-
ERR_load_crypto_strings
public static void ERR_load_crypto_strings()
Registers the error strings for all libcrypto functions.
-
ERR_peek_error
public static com.sun.jna.NativeLong ERR_peek_error()
- Returns:
- the earliest error code from the thread's error queue without modifying it.
-
EVP_aes_128_cbc
public static com.sun.jna.ptr.PointerByReference EVP_aes_128_cbc()
- Returns:
- an OpenSSL AES EVP cipher instance with a 128-bit key CBC mode.
-
EVP_aes_128_ctr
public static com.sun.jna.ptr.PointerByReference EVP_aes_128_ctr()
- Returns:
- an OpenSSL AES EVP cipher instance with a 128-bit key CTR mode.
-
EVP_aes_192_cbc
public static com.sun.jna.ptr.PointerByReference EVP_aes_192_cbc()
- Returns:
- an OpenSSL AES EVP cipher instance with a 192-bit key CBC mode.
-
EVP_aes_192_ctr
public static com.sun.jna.ptr.PointerByReference EVP_aes_192_ctr()
- Returns:
- an OpenSSL AES EVP cipher instance with a 192-bit key CTR mode.
-
EVP_aes_256_cbc
public static com.sun.jna.ptr.PointerByReference EVP_aes_256_cbc()
- Returns:
- an OpenSSL AES EVP cipher instance with a 256-bit key CBC mode.
-
EVP_aes_256_ctr
public static com.sun.jna.ptr.PointerByReference EVP_aes_256_ctr()
- Returns:
- an OpenSSL AES EVP cipher instance with a 256-bit key CTR mode.
-
EVP_CIPHER_CTX_cleanup
public static void EVP_CIPHER_CTX_cleanup(com.sun.jna.ptr.PointerByReference c)
Clears all information from a cipher context and free up any allocated * memory associate with it.- Parameters:
c
- openssl evp cipher
-
EVP_CIPHER_CTX_free
public static void EVP_CIPHER_CTX_free(com.sun.jna.ptr.PointerByReference c)
Clears all information from a cipher context and free up any allocated memory associate with it, including ctx itself.- Parameters:
c
- openssl evp cipher
-
EVP_CIPHER_CTX_init
public static void EVP_CIPHER_CTX_init(com.sun.jna.ptr.PointerByReference p)
EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset.- Parameters:
p
- cipher context
-
EVP_CIPHER_CTX_new
public static com.sun.jna.ptr.PointerByReference EVP_CIPHER_CTX_new()
Creates a cipher context.- Returns:
- a pointer to a newly created EVP_CIPHER_CTX for success and NULL for failure.
-
EVP_CIPHER_CTX_set_padding
public static int EVP_CIPHER_CTX_set_padding(com.sun.jna.ptr.PointerByReference c, int pad)
Enables or disables padding.- Parameters:
c
- cipher context.pad
- If the pad parameter is zero then no padding is performed.- Returns:
- always returns 1
-
EVP_CipherFinal_ex
public static int EVP_CipherFinal_ex(com.sun.jna.ptr.PointerByReference ctx, java.nio.ByteBuffer bout, int[] outl)
Finishes a multiple-part operation.- Parameters:
ctx
- cipher contextbout
- output byte bufferoutl
- output length- Returns:
- 1 for success and 0 for failure.
-
EVP_CipherInit_ex
public static int EVP_CipherInit_ex(com.sun.jna.ptr.PointerByReference ctx, com.sun.jna.ptr.PointerByReference cipher, com.sun.jna.ptr.PointerByReference impl, byte[] key, byte[] iv, int enc)
Init a cipher.- Parameters:
ctx
- cipher contextcipher
- evp cipher instanceimpl
- enginekey
- keyiv
- ivenc
- 1 for encryption, 0 for decryption- Returns:
- 1 for success and 0 for failure.
-
EVP_CipherUpdate
public static int EVP_CipherUpdate(com.sun.jna.ptr.PointerByReference ctx, java.nio.ByteBuffer bout, int[] outl, java.nio.ByteBuffer in, int inl)
Continues a multiple-part encryption/decryption operation.- Parameters:
ctx
- cipher contextbout
- output byte bufferoutl
- output lengthin
- input byte bufferinl
- input length- Returns:
- 1 for success and 0 for failure.
-
RAND_bytes
public static int RAND_bytes(java.nio.ByteBuffer buf, int num)
Generates random data.- Parameters:
buf
- the bytes for generated random.num
- buffer length.- Returns:
- 1 on success, 0 otherwise.
-
RAND_get_rand_method
public static com.sun.jna.ptr.PointerByReference RAND_get_rand_method()
OpenSSL uses for random number generation.- Returns:
- pointers to the respective methods.
-
RAND_SSLeay
public static com.sun.jna.ptr.PointerByReference RAND_SSLeay()
OpenSSL uses for random number generation.- Returns:
- pointers to the respective methods.
-
SSLeay
public static com.sun.jna.NativeLong SSLeay()
TODO (does not appear to be used yet)- Returns:
- OPENSSL_VERSION_NUMBER which is a numeric release version identifier
-
SSLeay_version
public static java.lang.String SSLeay_version(int type)
Retrieves version/build information about OpenSSL library. This is returned byOpenSslNativeJna.OpenSSLVersion(int)
- Parameters:
type
- type can be SSLEAY_VERSION, SSLEAY_CFLAGS, SSLEAY_BUILT_ON...- Returns:
- A pointer to a constant string describing the version of the OpenSSL library or giving information about the library build.
-
_ENGINE_by_id
public com.sun.jna.ptr.PointerByReference _ENGINE_by_id(java.lang.String string)
- Specified by:
_ENGINE_by_id
in interfaceOpenSslInterfaceNativeJna
-
_ENGINE_cleanup
public int _ENGINE_cleanup()
Description copied from interface:OpenSslInterfaceNativeJna
TODO Appears to be deprecated as of OpenSSL 1.1.0.- Specified by:
_ENGINE_cleanup
in interfaceOpenSslInterfaceNativeJna
-
_ENGINE_finish
public int _ENGINE_finish(com.sun.jna.ptr.PointerByReference rdrandEngine)
- Specified by:
_ENGINE_finish
in interfaceOpenSslInterfaceNativeJna
-
_ENGINE_free
public int _ENGINE_free(com.sun.jna.ptr.PointerByReference rdrandEngine)
- Specified by:
_ENGINE_free
in interfaceOpenSslInterfaceNativeJna
-
_ENGINE_init
public int _ENGINE_init(com.sun.jna.ptr.PointerByReference rdrandEngine)
- Specified by:
_ENGINE_init
in interfaceOpenSslInterfaceNativeJna
-
_ENGINE_load_rdrand
public void _ENGINE_load_rdrand()
- Specified by:
_ENGINE_load_rdrand
in interfaceOpenSslInterfaceNativeJna
-
_ENGINE_set_default
public int _ENGINE_set_default(com.sun.jna.ptr.PointerByReference rdrandEngine, int flags)
- Specified by:
_ENGINE_set_default
in interfaceOpenSslInterfaceNativeJna
-
_ERR_error_string
public java.lang.String _ERR_error_string(com.sun.jna.NativeLong err, char[] buff)
- Specified by:
_ERR_error_string
in interfaceOpenSslInterfaceNativeJna
-
_ERR_peek_error
public com.sun.jna.NativeLong _ERR_peek_error()
- Specified by:
_ERR_peek_error
in interfaceOpenSslInterfaceNativeJna
-
_EVP_aes_128_cbc
public com.sun.jna.ptr.PointerByReference _EVP_aes_128_cbc()
- Specified by:
_EVP_aes_128_cbc
in interfaceOpenSslInterfaceNativeJna
-
_EVP_aes_128_ctr
public com.sun.jna.ptr.PointerByReference _EVP_aes_128_ctr()
- Specified by:
_EVP_aes_128_ctr
in interfaceOpenSslInterfaceNativeJna
-
_EVP_aes_192_cbc
public com.sun.jna.ptr.PointerByReference _EVP_aes_192_cbc()
- Specified by:
_EVP_aes_192_cbc
in interfaceOpenSslInterfaceNativeJna
-
_EVP_aes_192_ctr
public com.sun.jna.ptr.PointerByReference _EVP_aes_192_ctr()
- Specified by:
_EVP_aes_192_ctr
in interfaceOpenSslInterfaceNativeJna
-
_EVP_aes_256_cbc
public com.sun.jna.ptr.PointerByReference _EVP_aes_256_cbc()
- Specified by:
_EVP_aes_256_cbc
in interfaceOpenSslInterfaceNativeJna
-
_EVP_aes_256_ctr
public com.sun.jna.ptr.PointerByReference _EVP_aes_256_ctr()
- Specified by:
_EVP_aes_256_ctr
in interfaceOpenSslInterfaceNativeJna
-
_EVP_CIPHER_CTX_cleanup
public void _EVP_CIPHER_CTX_cleanup(com.sun.jna.ptr.PointerByReference context)
- Specified by:
_EVP_CIPHER_CTX_cleanup
in interfaceOpenSslInterfaceNativeJna
-
_EVP_CIPHER_CTX_free
public void _EVP_CIPHER_CTX_free(com.sun.jna.ptr.PointerByReference context)
- Specified by:
_EVP_CIPHER_CTX_free
in interfaceOpenSslInterfaceNativeJna
-
_EVP_CIPHER_CTX_new
public com.sun.jna.ptr.PointerByReference _EVP_CIPHER_CTX_new()
- Specified by:
_EVP_CIPHER_CTX_new
in interfaceOpenSslInterfaceNativeJna
-
_EVP_CIPHER_CTX_set_padding
public int _EVP_CIPHER_CTX_set_padding(com.sun.jna.ptr.PointerByReference context, int padding)
- Specified by:
_EVP_CIPHER_CTX_set_padding
in interfaceOpenSslInterfaceNativeJna
-
_EVP_CipherFinal_ex
public int _EVP_CipherFinal_ex(com.sun.jna.ptr.PointerByReference context, java.nio.ByteBuffer outBuffer, int[] outlen)
- Specified by:
_EVP_CipherFinal_ex
in interfaceOpenSslInterfaceNativeJna
-
_EVP_CipherInit_ex
public int _EVP_CipherInit_ex(com.sun.jna.ptr.PointerByReference context, com.sun.jna.ptr.PointerByReference algo, com.sun.jna.ptr.PointerByReference impl, byte[] encoded, byte[] iv, int cipherMode)
- Specified by:
_EVP_CipherInit_ex
in interfaceOpenSslInterfaceNativeJna
-
_EVP_CipherUpdate
public int _EVP_CipherUpdate(com.sun.jna.ptr.PointerByReference context, java.nio.ByteBuffer outBuffer, int[] outlen, java.nio.ByteBuffer inBuffer, int remaining)
- Specified by:
_EVP_CipherUpdate
in interfaceOpenSslInterfaceNativeJna
-
_INIT_ERROR
public java.lang.Throwable _INIT_ERROR()
- Specified by:
_INIT_ERROR
in interfaceOpenSslInterfaceNativeJna
-
_INIT_OK
public boolean _INIT_OK()
- Specified by:
_INIT_OK
in interfaceOpenSslInterfaceNativeJna
-
_OpenSSL_version
public java.lang.String _OpenSSL_version(int i)
- Specified by:
_OpenSSL_version
in interfaceOpenSslInterfaceNativeJna
-
_RAND_bytes
public int _RAND_bytes(java.nio.ByteBuffer buf, int length)
- Specified by:
_RAND_bytes
in interfaceOpenSslInterfaceNativeJna
-
_RAND_get_rand_method
public com.sun.jna.ptr.PointerByReference _RAND_get_rand_method()
- Specified by:
_RAND_get_rand_method
in interfaceOpenSslInterfaceNativeJna
-
_RAND_SSLeay
public com.sun.jna.ptr.PointerByReference _RAND_SSLeay()
- Specified by:
_RAND_SSLeay
in interfaceOpenSslInterfaceNativeJna
-
-