Class WolfSSL
- java.lang.Object
-
- com.wolfssl.WolfSSL
-
public class WolfSSL extends java.lang.ObjectBase 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 intASN_INPUT_EASN input error, not enough datastatic intBAD_FUNC_ARGBad function argument providedstatic intBAD_MUTEX_ERRORBad mutexstatic intBAD_PATH_ERRORBad path for opendirstatic intBUFFER_EOutput buffer too small or input too largestatic intCACHE_MATCH_ERRORCache header match errorstatic intDSAkstatic intECDSAkstatic intED25519kstatic intGEN_COOKIE_Estatic intJNI_SESSION_UNAVAILABLEstatic intMD5static intMEMORY_EOut of memory errorstatic intMONITOR_RUNNING_ECRL Monitor already runningstatic intNO_PASSWORDNo password provided by userstatic intNOT_COMPILED_INFeature not compiled instatic intNTRUkstatic intRSAkstatic intSHAstatic intSHA256static intSHA384static intSHA512static intSSL_BAD_CERTTYPEstatic intSSL_BAD_FILEstatic intSSL_BAD_FILETYPEstatic intSSL_BAD_PATHstatic intSSL_BAD_STATstatic intSSL_ERROR_NONEstatic intSSL_ERROR_SOCKET_PEER_CLOSEDstatic intSSL_ERROR_SSLstatic intSSL_ERROR_SYSCALLstatic intSSL_ERROR_WANT_ACCEPTstatic intSSL_ERROR_WANT_CONNECTstatic intSSL_ERROR_WANT_READstatic intSSL_ERROR_WANT_WRITEstatic intSSL_ERROR_WANT_X509_LOOKUPstatic intSSL_ERROR_ZERO_RETURNstatic intSSL_FAILUREstatic intSSL_FATAL_ERRORstatic intSSL_FILETYPE_ASN1static intSSL_FILETYPE_DEFAULTASN1static intSSL_FILETYPE_PEMstatic intSSL_FILETYPE_RAWNTRU raw key blogstatic intSSL_HANDSHAKE_FAILUREstatic intSSL_MODE_ACCEPT_MOVING_WRITE_BUFFERstatic intSSL_NOT_IMPLEMENTEDstatic intSSL_OP_NO_COMPRESSIONstatic intSSL_OP_NO_SSLv2static intSSL_OP_NO_SSLv3static intSSL_OP_NO_TLSv1static intSSL_OP_NO_TLSv1_1static intSSL_OP_NO_TLSv1_2static intSSL_OP_NO_TLSv1_3static intSSL_R_SSLV3_ALERT_BAD_CERTIFICATEstatic intSSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWNstatic intSSL_R_TLSV1_ALERT_UNKNOWN_CAstatic intSSL_RECEIVED_SHUTDOWNstatic intSSL_SENT_SHUTDOWNstatic intSSL_SESS_CACHE_BOTHstatic intSSL_SESS_CACHE_CLIENTstatic intSSL_SESS_CACHE_NO_AUTO_CLEARstatic intSSL_SESS_CACHE_NO_INTERNAL_LOOKUPstatic intSSL_SESS_CACHE_OFFstatic intSSL_SESS_CACHE_SERVERstatic intSSL_SHUTDOWN_NOT_DONEstatic intSSL_SUCCESSstatic intSSL_UNKNOWNstatic intSSL_VERIFY_CLIENT_ONCEstatic intSSL_VERIFY_FAIL_IF_NO_PEER_CERTVerification mode for peer certificates.static intSSL_VERIFY_NONEVerification mode for peer certificates.static intSSL_VERIFY_PEERVerification mode for peer certificates.static intTHREAD_CREATE_EThread create errorstatic intWOLFSSL_AEAD_TYPEstatic intwolfssl_aesstatic intwolfssl_aes_ccmstatic intwolfssl_aes_gcmstatic intWOLFSSL_BLOCK_TYPEstatic intWOLFSSL_CBIO_ERR_CONN_CLOSEstatic intWOLFSSL_CBIO_ERR_CONN_RSTstatic intWOLFSSL_CBIO_ERR_GENERALstatic intWOLFSSL_CBIO_ERR_ISRstatic intWOLFSSL_CBIO_ERR_TIMEOUTstatic intWOLFSSL_CBIO_ERR_WANT_READstatic intWOLFSSL_CBIO_ERR_WANT_WRITEstatic intwolfssl_cipher_nullstatic intWOLFSSL_CLIENT_ENDstatic intWOLFSSL_CRL_CHECKALLstatic intWOLFSSL_CRL_MONITORMonitor this CRL directory flagstatic intWOLFSSL_CRL_START_MONStart CRL monitoring flagstatic intwolfssl_desstatic intwolfssl_des40static intwolfssl_hc128static intwolfssl_ideastatic intWOLFSSL_OCSP_NO_NONCEstatic intWOLFSSL_OCSP_URL_OVERRIDEstatic intwolfssl_rabbitstatic intwolfssl_rc2static intwolfssl_rc4static intWOLFSSL_SERVER_ENDstatic intWOLFSSL_STREAM_TYPEstatic intWOLFSSL_TLS_HMAC_INNER_SZstatic intwolfssl_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 intcleanup()Un-initializes the wolfSSL library from further use.static voiddebuggingOFF()Turns off runtime debug log messages.static intdebuggingON()Turns on debug logging at runtime.static longDTLSv1_2_ClientMethod()Indicates that the application is a client and will only support the DTLS 1.2 protocol.static longDTLSv1_2_Method()Indicates that the application will only support the DTLS 1.2 protocol.static longDTLSv1_2_ServerMethod()Indicates that the application is a server and will only support the DTLS 1.2 protocol.static longDTLSv1_ClientMethod()Indicates that the application is a client and will only support the DTLS 1.0 protocol.static longDTLSv1_Method()Indicates that the application will only support the DTLS 1.0 protocol.static longDTLSv1_ServerMethod()Indicates that the application is a server and will only support the DTLS 1.0 protocol.static booleanEccEnabled()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.StringgetErrorString(long errNumber)Converts an error code returned by getError() into a more human- readable error string.static intgetHmacMaxSize()Returns the wolfSSL max HMAC digest size.static intgetPkcs8TraditionalOffset(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 intgetSessionCacheMemsize()Gets how big the session cache save buffer needs to be.static intisEnabledAtomicUser()Checks if Atomic User support is enabled in wolfSSL native library.static intisEnabledCRL()Checks if CRL support is enabled in wolfSSL native library.static intisEnabledCRLMonitor()Checks if CRL Monitor support is enabled in wolfSSL native library.static intisEnabledDTLS()Checks if DTLS support is enabled in wolfSSL native library.static intisEnabledOCSP()Checks if OCSP support is enabled in wolfSSL native library.static intisEnabledPKCallbacks()Checks if Public Key Callback support is enabled in wolfSSL native library.static intisEnabledPSK()Checks if PSK support is enabled in wolfSSL native library.static voidloadLibrary()Loads JNI library; must be called prior to any other calls in this class.static voidloadLibrary(java.lang.String libName)Load JNI library with a specific name; must be called prior to any other calls in this package.static voidloadLibraryAbsolute(java.lang.String libPath)Loads dynamic JNI library from a specific path; must be called prior to any other calls in this package.static intmemrestoreSessionCache(byte[] mem, int sz)Restores the persistant session cache from memory buffer.static intmemsaveSessionCache(byte[] mem, int sz)Persists session cache to memory buffer.static voidnativeFree(long ptr)static booleanRsaEnabled()Tests if RSA support has been compiled into the native wolfSSL library.static intsetLoggingCb(WolfSSLLoggingCallback cb)Registers the callback to be used for Logging debug and trace messages.static longSSLv23_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 longSSLv23_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 longSSLv23_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 longSSLv3_ClientMethod()Deprecated.SSL 3.0 is now considered insecure.static longSSLv3_ServerMethod()Deprecated.SSL 3.0 is now considered insecure.static longTLSv1_1_ClientMethod()Indicates that the application is a client and will only support the TLS 1.1 protocol.static longTLSv1_1_Method()Indicates that the application will only support the TLS 1.1 protocol.static longTLSv1_1_ServerMethod()Indicates that the application is a server and will only support the TLS 1.1 protocol.static longTLSv1_2_ClientMethod()Indicates that the application is a client and will only support the TLS 1.2 protocol.static longTLSv1_2_Method()Indicates that the application will only support the TLS 1.2 protocol.static longTLSv1_2_ServerMethod()Indicates that the application is a server and will only support the TLS 1.2 protocol.static longTLSv1_3_Method()Indicates that the application will only support the TLS 1.3 protocol.static longTLSv1_ClientMethod()Indicates that the application is a client and will only support the TLS 1.0 protocol.static longTLSv1_Method()Indicates that the application will only support the TLS 1.0 protocol.static longTLSv1_ServerMethod()Indicates that the application is a server and will only support the TLS 1.0 protocol.static booleanTLSv11Enabled()Tests if TLS 1.1 has been compiled into the native wolfSSL library.static booleanTLSv12Enabled()Tests if TLS 1.2 has been compiled into the native wolfSSL library.static booleanTLSv13Enabled()Tests if TLS 1.3 has been compiled into the native wolfSSL library.static booleanTLSv1Enabled()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 WolfSSLExceptionInitializes 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.UnsatisfiedLinkErrorLoads 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.UnsatisfiedLinkErrorLoad 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.UnsatisfiedLinkErrorLoads 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
errNumberon 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_SUCCESSupon success,BAD_MUTEX_ERRORon 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_SUCCESSupon success.NOT_COMPILED_INif 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_NONEupon success,BAD_FUNC_ARGif input is null,NOT_COMPILED_INif 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_SUCCESSon success,SSL_FAILUREon general failure,BUFFER_Eif the memory buffer is too small to store the session cache in,BAD_MUTEX_ERRORif the session cache mutex lock failed,BAD_FUNC_ARGif 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_SUCCESSupon success,SSL_FAILUREupon general failure,BUFFER_Eif the memory buffer is too small,CACHE_MATCH_ERRORif the session cache header match failed and there were differences in how the cache and the current library are configured,BAD_MUTEX_ERRORif the session cache mutex lock failed,BAD_FUNC_ARGif 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
nullif 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
-
-