Class WolfSSL
- java.lang.Object
-
- com.wolfssl.WolfSSL
-
public class WolfSSL extends java.lang.Object
Base class which wraps the native WolfSSL embedded SSL library. This class contains library init and cleanup methods, general callback methods, as well as error codes and general wolfSSL codes.- Version:
- 1.1, September 2013
- Author:
- wolfSSL
-
-
Field Summary
Fields Modifier and Type Field Description static int
ASN_INPUT_E
ASN input error, not enough datastatic int
BAD_FUNC_ARG
Bad function argument providedstatic int
BAD_MUTEX_ERROR
Bad mutexstatic int
BAD_PATH_ERROR
Bad path for opendirstatic int
BUFFER_E
Output buffer too small or input too largestatic int
CACHE_MATCH_ERROR
Cache header match errorstatic int
DSAk
static int
ECDSAk
static int
ED25519k
static int
GEN_COOKIE_E
static int
JNI_SESSION_UNAVAILABLE
static int
MD5
static int
MEMORY_E
Out of memory errorstatic int
MONITOR_RUNNING_E
CRL Monitor already runningstatic int
NO_PASSWORD
No password provided by userstatic int
NOT_COMPILED_IN
Feature not compiled instatic int
NTRUk
static int
RSAk
static int
SHA
static int
SHA256
static int
SHA384
static int
SHA512
static int
SSL_BAD_CERTTYPE
static int
SSL_BAD_FILE
static int
SSL_BAD_FILETYPE
static int
SSL_BAD_PATH
static int
SSL_BAD_STAT
static int
SSL_ERROR_NONE
static int
SSL_ERROR_SOCKET_PEER_CLOSED
static int
SSL_ERROR_SSL
static int
SSL_ERROR_SYSCALL
static int
SSL_ERROR_WANT_ACCEPT
static int
SSL_ERROR_WANT_CONNECT
static int
SSL_ERROR_WANT_READ
static int
SSL_ERROR_WANT_WRITE
static int
SSL_ERROR_WANT_X509_LOOKUP
static int
SSL_ERROR_ZERO_RETURN
static int
SSL_FAILURE
static int
SSL_FATAL_ERROR
static int
SSL_FILETYPE_ASN1
static int
SSL_FILETYPE_DEFAULT
ASN1static int
SSL_FILETYPE_PEM
static int
SSL_FILETYPE_RAW
NTRU raw key blogstatic int
SSL_HANDSHAKE_FAILURE
static int
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
static int
SSL_NOT_IMPLEMENTED
static int
SSL_OP_NO_COMPRESSION
static int
SSL_OP_NO_SSLv2
static int
SSL_OP_NO_SSLv3
static int
SSL_OP_NO_TLSv1
static int
SSL_OP_NO_TLSv1_1
static int
SSL_OP_NO_TLSv1_2
static int
SSL_OP_NO_TLSv1_3
static int
SSL_R_SSLV3_ALERT_BAD_CERTIFICATE
static int
SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN
static int
SSL_R_TLSV1_ALERT_UNKNOWN_CA
static int
SSL_RECEIVED_SHUTDOWN
static int
SSL_SENT_SHUTDOWN
static int
SSL_SESS_CACHE_BOTH
static int
SSL_SESS_CACHE_CLIENT
static int
SSL_SESS_CACHE_NO_AUTO_CLEAR
static int
SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
static int
SSL_SESS_CACHE_OFF
static int
SSL_SESS_CACHE_SERVER
static int
SSL_SHUTDOWN_NOT_DONE
static int
SSL_SUCCESS
static int
SSL_UNKNOWN
static int
SSL_VERIFY_CLIENT_ONCE
static int
SSL_VERIFY_FAIL_IF_NO_PEER_CERT
Verification mode for peer certificates.static int
SSL_VERIFY_NONE
Verification mode for peer certificates.static int
SSL_VERIFY_PEER
Verification mode for peer certificates.static int
THREAD_CREATE_E
Thread create errorstatic int
WOLFSSL_AEAD_TYPE
static int
wolfssl_aes
static int
wolfssl_aes_ccm
static int
wolfssl_aes_gcm
static int
WOLFSSL_BLOCK_TYPE
static int
WOLFSSL_CBIO_ERR_CONN_CLOSE
static int
WOLFSSL_CBIO_ERR_CONN_RST
static int
WOLFSSL_CBIO_ERR_GENERAL
static int
WOLFSSL_CBIO_ERR_ISR
static int
WOLFSSL_CBIO_ERR_TIMEOUT
static int
WOLFSSL_CBIO_ERR_WANT_READ
static int
WOLFSSL_CBIO_ERR_WANT_WRITE
static int
wolfssl_cipher_null
static int
WOLFSSL_CLIENT_END
static int
WOLFSSL_CRL_CHECKALL
static int
WOLFSSL_CRL_MONITOR
Monitor this CRL directory flagstatic int
WOLFSSL_CRL_START_MON
Start CRL monitoring flagstatic int
wolfssl_des
static int
wolfssl_des40
static int
wolfssl_hc128
static int
wolfssl_idea
static int
WOLFSSL_OCSP_NO_NONCE
static int
WOLFSSL_OCSP_URL_OVERRIDE
static int
wolfssl_rabbit
static int
wolfssl_rc2
static int
wolfssl_rc4
static int
WOLFSSL_SERVER_END
static int
WOLFSSL_STREAM_TYPE
static int
WOLFSSL_TLS_HMAC_INNER_SZ
static int
wolfssl_triple_des
-
Constructor Summary
Constructors Constructor Description WolfSSL()
Initializes the wolfSSL library for use.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static int
cleanup()
Un-initializes the wolfSSL library from further use.static void
debuggingOFF()
Turns off runtime debug log messages.static int
debuggingON()
Turns on debug logging at runtime.static long
DTLSv1_2_ClientMethod()
Indicates that the application is a client and will only support the DTLS 1.2 protocol.static long
DTLSv1_2_Method()
Indicates that the application will only support the DTLS 1.2 protocol.static long
DTLSv1_2_ServerMethod()
Indicates that the application is a server and will only support the DTLS 1.2 protocol.static long
DTLSv1_ClientMethod()
Indicates that the application is a client and will only support the DTLS 1.0 protocol.static long
DTLSv1_Method()
Indicates that the application will only support the DTLS 1.0 protocol.static long
DTLSv1_ServerMethod()
Indicates that the application is a server and will only support the DTLS 1.0 protocol.static boolean
EccEnabled()
Tests if ECC support has been compiled into the native wolfSSL library.static java.lang.String[]
getCiphers()
static java.lang.String[]
getCiphersIana()
Gets a list of all cipher suites supported and uses the format TLS_*static java.lang.String
getErrorString(long errNumber)
Converts an error code returned by getError() into a more human- readable error string.static int
getHmacMaxSize()
Returns the wolfSSL max HMAC digest size.static int
getPkcs8TraditionalOffset(byte[] in, long idx, long sz)
Strips off PKCS#8 header from byte array.static java.lang.String[]
getProtocols()
Checks which protocols where built into wolfSSLstatic java.lang.String[]
getProtocolsMask(long mask)
Checks which protocols where built into wolfSSL with Maskstatic int
getSessionCacheMemsize()
Gets how big the session cache save buffer needs to be.static int
isEnabledAtomicUser()
Checks if Atomic User support is enabled in wolfSSL native library.static int
isEnabledCRL()
Checks if CRL support is enabled in wolfSSL native library.static int
isEnabledCRLMonitor()
Checks if CRL Monitor support is enabled in wolfSSL native library.static int
isEnabledDTLS()
Checks if DTLS support is enabled in wolfSSL native library.static int
isEnabledOCSP()
Checks if OCSP support is enabled in wolfSSL native library.static int
isEnabledPKCallbacks()
Checks if Public Key Callback support is enabled in wolfSSL native library.static int
isEnabledPSK()
Checks if PSK support is enabled in wolfSSL native library.static void
loadLibrary()
Loads JNI library; must be called prior to any other calls in this class.static void
loadLibrary(java.lang.String libName)
Load JNI library with a specific name; must be called prior to any other calls in this package.static void
loadLibraryAbsolute(java.lang.String libPath)
Loads dynamic JNI library from a specific path; must be called prior to any other calls in this package.static int
memrestoreSessionCache(byte[] mem, int sz)
Restores the persistant session cache from memory buffer.static int
memsaveSessionCache(byte[] mem, int sz)
Persists session cache to memory buffer.static void
nativeFree(long ptr)
static boolean
RsaEnabled()
Tests if RSA support has been compiled into the native wolfSSL library.static int
setLoggingCb(WolfSSLLoggingCallback cb)
Registers the callback to be used for Logging debug and trace messages.static long
SSLv23_ClientMethod()
Indicates that the application is a client and will use the highest possible SSL/TLS version from SSL 3.0 up to TLS 1.2.static long
SSLv23_Method()
Indicates that the application will use the highest possible SSL/TLS version from SSL 3.0 up to TLS 1.2, but is side-independent at creation time.static long
SSLv23_ServerMethod()
Indicates that the application is a server and will use the highest possible SSL/TLS version from SSL 3.0 up to TLS 1.2.static long
SSLv3_ClientMethod()
Deprecated.SSL 3.0 is now considered insecure.static long
SSLv3_ServerMethod()
Deprecated.SSL 3.0 is now considered insecure.static long
TLSv1_1_ClientMethod()
Indicates that the application is a client and will only support the TLS 1.1 protocol.static long
TLSv1_1_Method()
Indicates that the application will only support the TLS 1.1 protocol.static long
TLSv1_1_ServerMethod()
Indicates that the application is a server and will only support the TLS 1.1 protocol.static long
TLSv1_2_ClientMethod()
Indicates that the application is a client and will only support the TLS 1.2 protocol.static long
TLSv1_2_Method()
Indicates that the application will only support the TLS 1.2 protocol.static long
TLSv1_2_ServerMethod()
Indicates that the application is a server and will only support the TLS 1.2 protocol.static long
TLSv1_3_Method()
Indicates that the application will only support the TLS 1.3 protocol.static long
TLSv1_ClientMethod()
Indicates that the application is a client and will only support the TLS 1.0 protocol.static long
TLSv1_Method()
Indicates that the application will only support the TLS 1.0 protocol.static long
TLSv1_ServerMethod()
Indicates that the application is a server and will only support the TLS 1.0 protocol.static boolean
TLSv11Enabled()
Tests if TLS 1.1 has been compiled into the native wolfSSL library.static boolean
TLSv12Enabled()
Tests if TLS 1.2 has been compiled into the native wolfSSL library.static boolean
TLSv13Enabled()
Tests if TLS 1.3 has been compiled into the native wolfSSL library.static boolean
TLSv1Enabled()
Tests if TLS 1.0 has been compiled into the native wolfSSL library.static byte[]
x509_getDer(long x509)
Returns the DER-encoded form of the certificate pointed to by x509.
-
-
-
Field Detail
-
JNI_SESSION_UNAVAILABLE
public static final int JNI_SESSION_UNAVAILABLE
- See Also:
- Constant Field Values
-
SSL_ERROR_NONE
public static final int SSL_ERROR_NONE
- See Also:
- Constant Field Values
-
SSL_FAILURE
public static final int SSL_FAILURE
- See Also:
- Constant Field Values
-
SSL_SUCCESS
public static final int SSL_SUCCESS
- See Also:
- Constant Field Values
-
SSL_SHUTDOWN_NOT_DONE
public static final int SSL_SHUTDOWN_NOT_DONE
- See Also:
- Constant Field Values
-
SSL_BAD_CERTTYPE
public static final int SSL_BAD_CERTTYPE
- See Also:
- Constant Field Values
-
SSL_BAD_STAT
public static final int SSL_BAD_STAT
- See Also:
- Constant Field Values
-
SSL_BAD_PATH
public static final int SSL_BAD_PATH
- See Also:
- Constant Field Values
-
SSL_BAD_FILETYPE
public static final int SSL_BAD_FILETYPE
- See Also:
- Constant Field Values
-
SSL_BAD_FILE
public static final int SSL_BAD_FILE
- See Also:
- Constant Field Values
-
SSL_NOT_IMPLEMENTED
public static final int SSL_NOT_IMPLEMENTED
- See Also:
- Constant Field Values
-
SSL_UNKNOWN
public static final int SSL_UNKNOWN
- See Also:
- Constant Field Values
-
SSL_FATAL_ERROR
public static final int SSL_FATAL_ERROR
- See Also:
- Constant Field Values
-
SSL_FILETYPE_ASN1
public static final int SSL_FILETYPE_ASN1
- See Also:
- Constant Field Values
-
SSL_FILETYPE_PEM
public static final int SSL_FILETYPE_PEM
- See Also:
- Constant Field Values
-
SSL_FILETYPE_DEFAULT
public static final int SSL_FILETYPE_DEFAULT
ASN1- See Also:
- Constant Field Values
-
SSL_FILETYPE_RAW
public static final int SSL_FILETYPE_RAW
NTRU raw key blog- See Also:
- Constant Field Values
-
SSL_VERIFY_NONE
public static final int SSL_VERIFY_NONE
Verification mode for peer certificates.Client mode: the client will not verify the certificate received from the server and the handshake will continue as normal.
Server mode: the server will not send a certificate request to the client. As such, client verification will not be enabled.
-
SSL_VERIFY_PEER
public static final int SSL_VERIFY_PEER
Verification mode for peer certificates.Client mode: the client will verify the certificate received from the server during the handshake. This is turned on by default in wolfSSL, therefore, using this option has no effect.
Server mode: the server will send a certificate request to the client and verify the client certificate which is received.
-
SSL_VERIFY_FAIL_IF_NO_PEER_CERT
public static final int SSL_VERIFY_FAIL_IF_NO_PEER_CERT
Verification mode for peer certificates.Client mode: no effect when used on the client side.
Server mode: the verification will fail on the server side if the client fails to send a certificate when requested to do so (when using SSL_VERIFY_PEER on the SSL server).
-
SSL_VERIFY_CLIENT_ONCE
public static final int SSL_VERIFY_CLIENT_ONCE
- See Also:
- Constant Field Values
-
SSL_SESS_CACHE_OFF
public static final int SSL_SESS_CACHE_OFF
- See Also:
- Constant Field Values
-
SSL_SESS_CACHE_CLIENT
public static final int SSL_SESS_CACHE_CLIENT
- See Also:
- Constant Field Values
-
SSL_SESS_CACHE_SERVER
public static final int SSL_SESS_CACHE_SERVER
- See Also:
- Constant Field Values
-
SSL_SESS_CACHE_BOTH
public static final int SSL_SESS_CACHE_BOTH
- See Also:
- Constant Field Values
-
SSL_SESS_CACHE_NO_AUTO_CLEAR
public static final int SSL_SESS_CACHE_NO_AUTO_CLEAR
- See Also:
- Constant Field Values
-
SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
public static final int SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
- See Also:
- Constant Field Values
-
SSL_ERROR_WANT_READ
public static final int SSL_ERROR_WANT_READ
- See Also:
- Constant Field Values
-
SSL_ERROR_WANT_WRITE
public static final int SSL_ERROR_WANT_WRITE
- See Also:
- Constant Field Values
-
SSL_ERROR_WANT_CONNECT
public static final int SSL_ERROR_WANT_CONNECT
- See Also:
- Constant Field Values
-
SSL_ERROR_WANT_ACCEPT
public static final int SSL_ERROR_WANT_ACCEPT
- See Also:
- Constant Field Values
-
SSL_ERROR_SYSCALL
public static final int SSL_ERROR_SYSCALL
- See Also:
- Constant Field Values
-
SSL_ERROR_WANT_X509_LOOKUP
public static final int SSL_ERROR_WANT_X509_LOOKUP
- See Also:
- Constant Field Values
-
SSL_ERROR_ZERO_RETURN
public static final int SSL_ERROR_ZERO_RETURN
- See Also:
- Constant Field Values
-
SSL_ERROR_SSL
public static final int SSL_ERROR_SSL
- See Also:
- Constant Field Values
-
SSL_ERROR_SOCKET_PEER_CLOSED
public static final int SSL_ERROR_SOCKET_PEER_CLOSED
- See Also:
- Constant Field Values
-
WOLFSSL_CRL_CHECKALL
public static final int WOLFSSL_CRL_CHECKALL
- See Also:
- Constant Field Values
-
WOLFSSL_OCSP_URL_OVERRIDE
public static final int WOLFSSL_OCSP_URL_OVERRIDE
- See Also:
- Constant Field Values
-
WOLFSSL_OCSP_NO_NONCE
public static final int WOLFSSL_OCSP_NO_NONCE
- See Also:
- Constant Field Values
-
WOLFSSL_CBIO_ERR_GENERAL
public static final int WOLFSSL_CBIO_ERR_GENERAL
- See Also:
- Constant Field Values
-
WOLFSSL_CBIO_ERR_WANT_READ
public static final int WOLFSSL_CBIO_ERR_WANT_READ
- See Also:
- Constant Field Values
-
WOLFSSL_CBIO_ERR_WANT_WRITE
public static final int WOLFSSL_CBIO_ERR_WANT_WRITE
- See Also:
- Constant Field Values
-
WOLFSSL_CBIO_ERR_CONN_RST
public static final int WOLFSSL_CBIO_ERR_CONN_RST
- See Also:
- Constant Field Values
-
WOLFSSL_CBIO_ERR_ISR
public static final int WOLFSSL_CBIO_ERR_ISR
- See Also:
- Constant Field Values
-
WOLFSSL_CBIO_ERR_CONN_CLOSE
public static final int WOLFSSL_CBIO_ERR_CONN_CLOSE
- See Also:
- Constant Field Values
-
WOLFSSL_CBIO_ERR_TIMEOUT
public static final int WOLFSSL_CBIO_ERR_TIMEOUT
- See Also:
- Constant Field Values
-
WOLFSSL_SERVER_END
public static final int WOLFSSL_SERVER_END
- See Also:
- Constant Field Values
-
WOLFSSL_CLIENT_END
public static final int WOLFSSL_CLIENT_END
- See Also:
- Constant Field Values
-
WOLFSSL_BLOCK_TYPE
public static final int WOLFSSL_BLOCK_TYPE
- See Also:
- Constant Field Values
-
WOLFSSL_STREAM_TYPE
public static final int WOLFSSL_STREAM_TYPE
- See Also:
- Constant Field Values
-
WOLFSSL_AEAD_TYPE
public static final int WOLFSSL_AEAD_TYPE
- See Also:
- Constant Field Values
-
WOLFSSL_TLS_HMAC_INNER_SZ
public static final int WOLFSSL_TLS_HMAC_INNER_SZ
- See Also:
- Constant Field Values
-
wolfssl_cipher_null
public static int wolfssl_cipher_null
-
wolfssl_rc4
public static int wolfssl_rc4
-
wolfssl_rc2
public static int wolfssl_rc2
-
wolfssl_des
public static int wolfssl_des
-
wolfssl_triple_des
public static int wolfssl_triple_des
-
wolfssl_des40
public static int wolfssl_des40
-
wolfssl_idea
public static int wolfssl_idea
-
wolfssl_aes
public static int wolfssl_aes
-
wolfssl_aes_gcm
public static int wolfssl_aes_gcm
-
wolfssl_aes_ccm
public static int wolfssl_aes_ccm
-
wolfssl_hc128
public static int wolfssl_hc128
-
wolfssl_rabbit
public static int wolfssl_rabbit
-
GEN_COOKIE_E
public static final int GEN_COOKIE_E
- See Also:
- Constant Field Values
-
SSL_SENT_SHUTDOWN
public static final int SSL_SENT_SHUTDOWN
- See Also:
- Constant Field Values
-
SSL_RECEIVED_SHUTDOWN
public static final int SSL_RECEIVED_SHUTDOWN
- See Also:
- Constant Field Values
-
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
public static final int SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
- See Also:
- Constant Field Values
-
SSL_OP_NO_SSLv2
public static final int SSL_OP_NO_SSLv2
- See Also:
- Constant Field Values
-
SSL_OP_NO_SSLv3
public static final int SSL_OP_NO_SSLv3
- See Also:
- Constant Field Values
-
SSL_OP_NO_TLSv1
public static final int SSL_OP_NO_TLSv1
- See Also:
- Constant Field Values
-
SSL_OP_NO_TLSv1_1
public static final int SSL_OP_NO_TLSv1_1
- See Also:
- Constant Field Values
-
SSL_OP_NO_TLSv1_2
public static final int SSL_OP_NO_TLSv1_2
- See Also:
- Constant Field Values
-
SSL_OP_NO_COMPRESSION
public static final int SSL_OP_NO_COMPRESSION
- See Also:
- Constant Field Values
-
SSL_OP_NO_TLSv1_3
public static final int SSL_OP_NO_TLSv1_3
- See Also:
- Constant Field Values
-
SSL_HANDSHAKE_FAILURE
public static final int SSL_HANDSHAKE_FAILURE
- See Also:
- Constant Field Values
-
SSL_R_TLSV1_ALERT_UNKNOWN_CA
public static final int SSL_R_TLSV1_ALERT_UNKNOWN_CA
- See Also:
- Constant Field Values
-
SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN
public static final int SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN
- See Also:
- Constant Field Values
-
SSL_R_SSLV3_ALERT_BAD_CERTIFICATE
public static final int SSL_R_SSLV3_ALERT_BAD_CERTIFICATE
- See Also:
- Constant Field Values
-
WOLFSSL_CRL_MONITOR
public static final int WOLFSSL_CRL_MONITOR
Monitor this CRL directory flag- See Also:
- Constant Field Values
-
WOLFSSL_CRL_START_MON
public static final int WOLFSSL_CRL_START_MON
Start CRL monitoring flag- See Also:
- Constant Field Values
-
BAD_MUTEX_ERROR
public static final int BAD_MUTEX_ERROR
Bad mutex- See Also:
- Constant Field Values
-
BAD_PATH_ERROR
public static final int BAD_PATH_ERROR
Bad path for opendir- See Also:
- Constant Field Values
-
MONITOR_RUNNING_E
public static final int MONITOR_RUNNING_E
CRL Monitor already running- See Also:
- Constant Field Values
-
THREAD_CREATE_E
public static final int THREAD_CREATE_E
Thread create error- See Also:
- Constant Field Values
-
CACHE_MATCH_ERROR
public static final int CACHE_MATCH_ERROR
Cache header match error- See Also:
- Constant Field Values
-
MEMORY_E
public static final int MEMORY_E
Out of memory error- See Also:
- Constant Field Values
-
BUFFER_E
public static final int BUFFER_E
Output buffer too small or input too large- See Also:
- Constant Field Values
-
ASN_INPUT_E
public static final int ASN_INPUT_E
ASN input error, not enough data- See Also:
- Constant Field Values
-
BAD_FUNC_ARG
public static final int BAD_FUNC_ARG
Bad function argument provided- See Also:
- Constant Field Values
-
NOT_COMPILED_IN
public static final int NOT_COMPILED_IN
Feature not compiled in- See Also:
- Constant Field Values
-
NO_PASSWORD
public static final int NO_PASSWORD
No password provided by user- See Also:
- Constant Field Values
-
MD5
public static final int MD5
- See Also:
- Constant Field Values
-
SHA
public static final int SHA
- See Also:
- Constant Field Values
-
SHA256
public static final int SHA256
- See Also:
- Constant Field Values
-
SHA512
public static final int SHA512
- See Also:
- Constant Field Values
-
SHA384
public static final int SHA384
- See Also:
- Constant Field Values
-
DSAk
public static final int DSAk
- See Also:
- Constant Field Values
-
RSAk
public static final int RSAk
- See Also:
- Constant Field Values
-
NTRUk
public static final int NTRUk
- See Also:
- Constant Field Values
-
ECDSAk
public static final int ECDSAk
- See Also:
- Constant Field Values
-
ED25519k
public static final int ED25519k
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WolfSSL
public WolfSSL() throws WolfSSLException
Initializes the wolfSSL library for use.- Throws:
WolfSSLException
- if wolfSSL library fails to initialize correctly
-
-
Method Detail
-
nativeFree
public static void nativeFree(long ptr)
-
loadLibrary
public static void loadLibrary() throws java.lang.UnsatisfiedLinkError
Loads JNI library; must be called prior to any other calls in this class. The native library is expected to be be called "wolfssljni", and must be on the system library search path.- Throws:
java.lang.UnsatisfiedLinkError
- if the library is not found.
-
loadLibrary
public static void loadLibrary(java.lang.String libName) throws java.lang.UnsatisfiedLinkError
Load JNI library with a specific name; must be called prior to any other calls in this package. The native library needs to be located on the system library search path.- Parameters:
libName
- name of native JNI library- Throws:
java.lang.UnsatisfiedLinkError
- if the library is not found.
-
loadLibraryAbsolute
public static void loadLibraryAbsolute(java.lang.String libPath) throws java.lang.UnsatisfiedLinkError
Loads dynamic JNI library from a specific path; must be called prior to any other calls in this package. This function gives the application more control over the exact native library being loaded, as both WolfSSL.loadLibrary() and WolfSSL.loadLibrary(String libName) search for a library on the system library search path. This function allows the appliation to specify a specific absolute path to the native library file to load, thus guaranteeing the exact library loaded and helping to prevent against malicious attackers from attempting to override the library being loaded.- Parameters:
libPath
- complete path name to the native dynamic JNI library- Throws:
java.lang.UnsatisfiedLinkError
- if the library is not found.
-
TLSv1Enabled
public static boolean TLSv1Enabled()
Tests if TLS 1.0 has been compiled into the native wolfSSL library. TLS 1.0 is disabled by default in native wolfSSL, unless the user has configured wolfSSL with "--enable-tls10".- Returns:
- 1 if enabled, otherwise 0 if not compiled in.
-
TLSv11Enabled
public static boolean TLSv11Enabled()
Tests if TLS 1.1 has been compiled into the native wolfSSL library.- Returns:
- 1 if enabled, otherwise 0 if not compiled in.
-
TLSv12Enabled
public static boolean TLSv12Enabled()
Tests if TLS 1.2 has been compiled into the native wolfSSL library.- Returns:
- 1 if enabled, otherwise 0 if not compiled in.
-
TLSv13Enabled
public static boolean TLSv13Enabled()
Tests if TLS 1.3 has been compiled into the native wolfSSL library.- Returns:
- 1 if enabled, otherwise 0 if not compiled in.
-
EccEnabled
public static boolean EccEnabled()
Tests if ECC support has been compiled into the native wolfSSL library.- Returns:
- 1 if enabled, otherwise 0 if not compiled in.
-
RsaEnabled
public static boolean RsaEnabled()
Tests if RSA support has been compiled into the native wolfSSL library.- Returns:
- 1 if enabled, otherwise 0 if not compiled in.
-
SSLv3_ServerMethod
@Deprecated public static final long SSLv3_ServerMethod()
Deprecated.SSL 3.0 is now considered insecure.Indicates that the application is a server and will only support the SSL 3.0 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
SSLv3_ClientMethod
@Deprecated public static final long SSLv3_ClientMethod()
Deprecated.SSL 3.0 is now considered insecure.Indicates that the application is a client and will only support the SSL 3.0 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_Method
public static final long TLSv1_Method()
Indicates that the application will only support the TLS 1.0 protocol. Application is side-independent at this time, and client/server side will be determined at connect/accept stage. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_ServerMethod
public static final long TLSv1_ServerMethod()
Indicates that the application is a server and will only support the TLS 1.0 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_ClientMethod
public static final long TLSv1_ClientMethod()
Indicates that the application is a client and will only support the TLS 1.0 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_1_Method
public static final long TLSv1_1_Method()
Indicates that the application will only support the TLS 1.1 protocol. Application is side-independent at this time, and client/server side will be determined at connect/accept stage. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_1_ServerMethod
public static final long TLSv1_1_ServerMethod()
Indicates that the application is a server and will only support the TLS 1.1 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_1_ClientMethod
public static final long TLSv1_1_ClientMethod()
Indicates that the application is a client and will only support the TLS 1.1 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_2_Method
public static final long TLSv1_2_Method()
Indicates that the application will only support the TLS 1.2 protocol. Application is side-independent at this time, and client/server side will be determined at connect/accept stage. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_2_ServerMethod
public static final long TLSv1_2_ServerMethod()
Indicates that the application is a server and will only support the TLS 1.2 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_2_ClientMethod
public static final long TLSv1_2_ClientMethod()
Indicates that the application is a client and will only support the TLS 1.2 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
TLSv1_3_Method
public static final long TLSv1_3_Method()
Indicates that the application will only support the TLS 1.3 protocol. Application is side-independent at this time, and client/server side will be determined at connect/accept stage. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
DTLSv1_Method
public static final long DTLSv1_Method()
Indicates that the application will only support the DTLS 1.0 protocol. Application is side-independent at this time, and client/server side will be determined at connect/accept stage. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
DTLSv1_ServerMethod
public static final long DTLSv1_ServerMethod()
Indicates that the application is a server and will only support the DTLS 1.0 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
DTLSv1_ClientMethod
public static final long DTLSv1_ClientMethod()
Indicates that the application is a client and will only support the DTLS 1.0 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
DTLSv1_2_Method
public static final long DTLSv1_2_Method()
Indicates that the application will only support the DTLS 1.2 protocol. Application is side-independent at this time, and client/server side will be determined at connect/accept stage. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
DTLSv1_2_ServerMethod
public static final long DTLSv1_2_ServerMethod()
Indicates that the application is a server and will only support the DTLS 1.2 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
DTLSv1_2_ClientMethod
public static final long DTLSv1_2_ClientMethod()
Indicates that the application is a client and will only support the DTLS 1.2 protocol. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
SSLv23_Method
public static final long SSLv23_Method()
Indicates that the application will use the highest possible SSL/TLS version from SSL 3.0 up to TLS 1.2, but is side-independent at creation time. Client/server side will be determined at connect/accept stage. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
SSLv23_ServerMethod
public static final long SSLv23_ServerMethod()
Indicates that the application is a server and will use the highest possible SSL/TLS version from SSL 3.0 up to TLS 1.2. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
SSLv23_ClientMethod
public static final long SSLv23_ClientMethod()
Indicates that the application is a client and will use the highest possible SSL/TLS version from SSL 3.0 up to TLS 1.2. This method allocates memory for and initializes a new native WOLFSSL_METHOD structure to be used when creating the SSL/TLS context with newContext().- Returns:
- A pointer to the created WOLFSSL_METHOD structure if successful, null on failure.
- See Also:
WolfSSLContext.newContext(long)
-
getErrorString
public static final java.lang.String getErrorString(long errNumber)
Converts an error code returned by getError() into a more human- readable error string. The maximum length of the returned string is 80 characters by default, as defined by MAX_ERROR_SZ in the native wolfSSL error.h header file.- Parameters:
errNumber
- error code returned bygetError()
- Returns:
- output String containing human-readable error
string matching
errNumber
on success. On failure, this method returns a String with the appropriate failure reason. - See Also:
WolfSSLSession.getError(long, int)
-
cleanup
public static final int cleanup()
Un-initializes the wolfSSL library from further use. Doesn't have to be called, though it will free any resources used by the library.- Returns:
SSL_SUCCESS
upon success,BAD_MUTEX_ERROR
on mutex error.
-
debuggingON
public static final int debuggingON()
Turns on debug logging at runtime. To enable logging at build time, use --enable-debug or define DEBUG_WOLFSSL. Debugging must be enabled at build time in order for the method to have any effect.- Returns:
SSL_SUCCESS
upon success.NOT_COMPILED_IN
if logging isnt' enabled for this wolfSSL build.- See Also:
debuggingOFF()
,setLoggingCb(WolfSSLLoggingCallback)
-
debuggingOFF
public static final void debuggingOFF()
Turns off runtime debug log messages. If they're already off, no action is taken.
-
setLoggingCb
public static final int setLoggingCb(WolfSSLLoggingCallback cb)
Registers the callback to be used for Logging debug and trace messages.- Parameters:
cb
- Callback to be used for logging debug messages- Returns:
SSL_ERROR_NONE
upon success,BAD_FUNC_ARG
if input is null,NOT_COMPILED_IN
if wolfSSL was not compiled with debugging support enabled.- See Also:
debuggingON()
,debuggingOFF()
-
memsaveSessionCache
public static int memsaveSessionCache(byte[] mem, int sz)
Persists session cache to memory buffer. This method can be used to persist the current session cache to a memory buffer for storage. The cache can be loaded back into wolfSSL using the correspondingmemrestoreSessionCache()
method.- Parameters:
mem
- buffer to store session cache insz
- size of the input buffer, mem- Returns:
SSL_SUCCESS
on success,SSL_FAILURE
on general failure,BUFFER_E
if the memory buffer is too small to store the session cache in,BAD_MUTEX_ERROR
if the session cache mutex lock failed,BAD_FUNC_ARG
if invalid parameters are used.- See Also:
memrestoreSessionCache(byte[], int)
,getSessionCacheMemsize()
,WolfSSLContext.memsaveCertCache(long, byte[], int, int[])
,WolfSSLContext.memrestoreCertCache(long, byte[], int)
,WolfSSLContext.getCertCacheMemsize(long)
-
memrestoreSessionCache
public static int memrestoreSessionCache(byte[] mem, int sz)
Restores the persistant session cache from memory buffer. This function restores a session cache that was previously saved to a memory buffer.- Parameters:
mem
- buffer containing persistant session cache to be restoredsz
- size of the input buffer, mem- Returns:
SSL_SUCCESS
upon success,SSL_FAILURE
upon general failure,BUFFER_E
if the memory buffer is too small,CACHE_MATCH_ERROR
if the session cache header match failed and there were differences in how the cache and the current library are configured,BAD_MUTEX_ERROR
if the session cache mutex lock failed,BAD_FUNC_ARG
if invalid parameters are used.- See Also:
memsaveSessionCache(byte[], int)
,getSessionCacheMemsize()
,WolfSSLContext.memsaveCertCache(long, byte[], int, int[])
,WolfSSLContext.memrestoreCertCache(long, byte[], int)
,WolfSSLContext.getCertCacheMemsize(long)
-
getSessionCacheMemsize
public static int getSessionCacheMemsize()
Gets how big the session cache save buffer needs to be. Use this method to determine how large the buffer needs to be to store the persistant session cache into memory.- Returns:
- size, in bytes, of how large the output buffer should be to store the session cache into memory.
- See Also:
memsaveSessionCache(byte[], int)
,memrestoreSessionCache(byte[], int)
,WolfSSLContext.memsaveCertCache(long, byte[], int, int[])
,WolfSSLContext.memrestoreCertCache(long, byte[], int)
,WolfSSLContext.getCertCacheMemsize(long)
-
getPkcs8TraditionalOffset
public static int getPkcs8TraditionalOffset(byte[] in, long idx, long sz)
Strips off PKCS#8 header from byte array. This function starts reading the input array for a PKCS#8 header, beginning at input offset, idx. If found, it returns the offset of the inner traditional data.- Parameters:
in
- input buffer containing PKCS#8 formatted keyidx
- index/offset into input array to begin readingsz
- size of input array- Returns:
- offset where the traditional key begins, or negative on failure.
-
x509_getDer
public static byte[] x509_getDer(long x509)
Returns the DER-encoded form of the certificate pointed to by x509.- Parameters:
x509
- pointer (long) to a native WOLFSSL_X509 object. This objects represents an X.509 certificate.- Returns:
- DER-encoded certificate or
null
if the input buffer is null.
-
getHmacMaxSize
public static int getHmacMaxSize()
Returns the wolfSSL max HMAC digest size. Specifically, returns the value of the native wolfSSL MAX_DIGEST_SIZE define.- Returns:
- value of native MAX_DIGEST_SIZE define
-
getCiphers
public static java.lang.String[] getCiphers()
-
getCiphersIana
public static java.lang.String[] getCiphersIana()
Gets a list of all cipher suites supported and uses the format TLS_*- Returns:
- list of all cipher suites supported
-
isEnabledCRL
public static int isEnabledCRL()
Checks if CRL support is enabled in wolfSSL native library.- Returns:
- 1 if enabled, 0 if not compiled in
-
isEnabledCRLMonitor
public static int isEnabledCRLMonitor()
Checks if CRL Monitor support is enabled in wolfSSL native library.- Returns:
- 1 if enabled, 0 if not compiled in
-
isEnabledOCSP
public static int isEnabledOCSP()
Checks if OCSP support is enabled in wolfSSL native library.- Returns:
- 1 if enabled, 0 if not compiled in
-
isEnabledPSK
public static int isEnabledPSK()
Checks if PSK support is enabled in wolfSSL native library.- Returns:
- 1 if enabled, 0 if not compiled in
-
isEnabledDTLS
public static int isEnabledDTLS()
Checks if DTLS support is enabled in wolfSSL native library.- Returns:
- 1 if enabled, 0 if not compiled in
-
isEnabledAtomicUser
public static int isEnabledAtomicUser()
Checks if Atomic User support is enabled in wolfSSL native library.- Returns:
- 1 if enabled, 0 if not compiled in
-
isEnabledPKCallbacks
public static int isEnabledPKCallbacks()
Checks if Public Key Callback support is enabled in wolfSSL native library.- Returns:
- 1 if enabled, 0 if not compiled in
-
getProtocols
public static java.lang.String[] getProtocols()
Checks which protocols where built into wolfSSL- Returns:
- an array of Strings for supported protocols
-
getProtocolsMask
public static java.lang.String[] getProtocolsMask(long mask)
Checks which protocols where built into wolfSSL with Mask- Parameters:
mask
- flags prohibiting TLS version (i.e. SSL_OP_NO_xxx)- Returns:
- an array of Strings for supported protocols
-
-