Package jadex.commons.security.random
Class OpenSslAesCtr
- java.lang.Object
-
- jadex.commons.security.random.OpenSslAesCtr
-
public class OpenSslAesCtr extends java.lang.ObjectAccess to OpenSSL AES counter mode.
-
-
Field Summary
Fields Modifier and Type Field Description protected static byte[]BUFFER_INPUTEmpty static input buffer as sourceprotected static com.sun.jna.ptr.IntByReferenceBUFFER_SIZE_PBuffer size as C reference.protected com.sun.jna.PointerevpCipherContextCurrent cipher context.static java.lang.StringJNA_LIBRARY_NAMEOpenSSL Crypto lib name.static com.sun.jna.NativeLibraryJNA_NATIVE_LIBOpenSSL Crypto lib.
-
Constructor Summary
Constructors Constructor Description OpenSslAesCtr()Create an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidERR_load_crypto_strings()static voidERR_print_errors_fp(com.sun.jna.Pointer fp)static com.sun.jna.PointerEVP_aes_128_ctr()static com.sun.jna.PointerEVP_aes_256_ctr()static com.sun.jna.PointerEVP_aes_256_ecb()static voidEVP_CIPHER_CTX_free(com.sun.jna.Pointer ctx)static com.sun.jna.PointerEVP_CIPHER_CTX_new()static intEVP_CIPHER_CTX_set_padding(com.sun.jna.Pointer context, int padding)static intEVP_EncryptFinal_ex(com.sun.jna.Pointer ctx, byte[] out, com.sun.jna.ptr.IntByReference outlen)static intEVP_EncryptInit_ex(com.sun.jna.Pointer context, com.sun.jna.Pointer ciphertype, com.sun.jna.Pointer impl, byte[] key, byte[] iv)static intEVP_EncryptUpdate(com.sun.jna.Pointer context, byte[] out, com.sun.jna.ptr.IntByReference outlen, byte[] in, int inlen)voidinit(byte[] key, byte[] iv)Initialize the cipher.static booleanisEnabled()Checks if the library is in a usable state.byte[]nextBytes()Retrieves the next buffer of random values.static voidOpenSSL_add_all_ciphers()static voidOPENSSL_config(java.lang.String config_name)
-
-
-
Field Detail
-
JNA_LIBRARY_NAME
public static final java.lang.String JNA_LIBRARY_NAME
OpenSSL Crypto lib name.- See Also:
- Constant Field Values
-
JNA_NATIVE_LIB
public static final com.sun.jna.NativeLibrary JNA_NATIVE_LIB
OpenSSL Crypto lib.
-
BUFFER_INPUT
protected static final byte[] BUFFER_INPUT
Empty static input buffer as source
-
BUFFER_SIZE_P
protected static final com.sun.jna.ptr.IntByReference BUFFER_SIZE_P
Buffer size as C reference.
-
evpCipherContext
protected com.sun.jna.Pointer evpCipherContext
Current cipher context.
-
-
Method Detail
-
ERR_load_crypto_strings
public static void ERR_load_crypto_strings()
-
OpenSSL_add_all_ciphers
public static void OpenSSL_add_all_ciphers()
-
OPENSSL_config
public static void OPENSSL_config(java.lang.String config_name)
-
EVP_CIPHER_CTX_new
public static com.sun.jna.Pointer EVP_CIPHER_CTX_new()
-
EVP_CIPHER_CTX_free
public static void EVP_CIPHER_CTX_free(com.sun.jna.Pointer ctx)
-
EVP_CIPHER_CTX_set_padding
public static int EVP_CIPHER_CTX_set_padding(com.sun.jna.Pointer context, int padding)
-
EVP_aes_256_ctr
public static com.sun.jna.Pointer EVP_aes_256_ctr()
-
EVP_aes_128_ctr
public static com.sun.jna.Pointer EVP_aes_128_ctr()
-
EVP_aes_256_ecb
public static com.sun.jna.Pointer EVP_aes_256_ecb()
-
EVP_EncryptInit_ex
public static int EVP_EncryptInit_ex(com.sun.jna.Pointer context, com.sun.jna.Pointer ciphertype, com.sun.jna.Pointer impl, byte[] key, byte[] iv)
-
EVP_EncryptUpdate
public static int EVP_EncryptUpdate(com.sun.jna.Pointer context, byte[] out, com.sun.jna.ptr.IntByReference outlen, byte[] in, int inlen)
-
EVP_EncryptFinal_ex
public static int EVP_EncryptFinal_ex(com.sun.jna.Pointer ctx, byte[] out, com.sun.jna.ptr.IntByReference outlen)
-
ERR_print_errors_fp
public static void ERR_print_errors_fp(com.sun.jna.Pointer fp)
-
isEnabled
public static final boolean isEnabled()
Checks if the library is in a usable state.
-
init
public void init(byte[] key, byte[] iv)Initialize the cipher.- Parameters:
key- The key.iv- The IV to use.
-
nextBytes
public byte[] nextBytes()
Retrieves the next buffer of random values.- Returns:
- The next buffer of random values.
-
-