com.wolfssl
Class WolfSSL

java.lang.Object
  extended by 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
static int ASN_INPUT_E
          ASN input error, not enough data
static int BAD_FUNC_ARG
          Bad function argument provided
static int BAD_MUTEX_ERROR
          Bad mutex
static int BAD_PATH_ERROR
          Bad path for opendir
static int BUFFER_E
          Output buffer too small or input too large
static int CACHE_MATCH_ERROR
          Cache header match error
static int CYASSL_AEAD_TYPE
           
static int cyassl_aes
           
static int cyassl_aes_ccm
           
static int cyassl_aes_gcm
           
static int CYASSL_BLOCK_TYPE
           
static int CYASSL_CBIO_ERR_CONN_CLOSE
           
static int CYASSL_CBIO_ERR_CONN_RST
           
static int CYASSL_CBIO_ERR_GENERAL
           
static int CYASSL_CBIO_ERR_ISR
           
static int CYASSL_CBIO_ERR_TIMEOUT
           
static int CYASSL_CBIO_ERR_WANT_READ
           
static int CYASSL_CBIO_ERR_WANT_WRITE
           
static int cyassl_cipher_null
           
static int CYASSL_CLIENT_END
           
static int CYASSL_CRL_CHECKALL
           
static int CYASSL_CRL_MONITOR
          Monitor this CRL directory flag
static int CYASSL_CRL_START_MON
          Start CRL monitoring flag
static int cyassl_des
           
static int cyassl_des40
           
static int cyassl_hc128
           
static int cyassl_idea
           
static int CYASSL_OCSP_ENABLE
           
static int CYASSL_OCSP_NO_NONCE
           
static int CYASSL_OCSP_URL_OVERRIDE
           
static int cyassl_rabbit
           
static int cyassl_rc2
           
static int cyassl_rc4
           
static int CYASSL_SERVER_END
           
static int CYASSL_STREAM_TYPE
           
static int CYASSL_TLS_HMAC_INNER_SZ
           
static int cyassl_triple_des
           
static int GEN_COOKIE_E
           
static int MD5
           
static int MEMORY_E
          Out of memory error
static int MONITOR_RUNNING_E
          CRL Monitor already running
static int NO_PASSWORD
          No password provided by user
static int NOT_COMPILED_IN
          Feature not compiled in
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_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
          ASN1
static int SSL_FILETYPE_PEM
           
static int SSL_FILETYPE_RAW
          NTRU raw key blog
static int SSL_HANDSHAKE_FAILURE
           
static int SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
           
static int SSL_NOT_IMPLEMENTED
           
static int SSL_OP_NO_SSLv2
           
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_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 error
 
Constructor Summary
WolfSSL()
          Initializes the wolfSSL library for use.
 
Method Summary
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_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_ServerMethod()
          Indicates that the application is a server and will only support the DTLS 1.0 protocol.
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 getSessionCacheMemsize()
          Gets how big the session cache save buffer needs to be.
static void loadLibrary()
          Loads JNI library; must be called prior to any other calls in this class.
static void loadLibrary(java.lang.String libPath)
          Load JNI library; 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 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_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()
          Indicates that the application is a client and will only support the SSL 3.0 protocol.
static long SSLv3_ServerMethod()
          Indicates that the application is a server and will only support the SSL 3.0 protocol.
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_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_ServerMethod()
          Indicates that the application is a server and will only support the TLS 1.2 protocol.
static long TLSv1_ClientMethod()
          Indicates that the application is a client and 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 byte[] x509_getDer(long x509)
          Returns the DER-encoded form of the certificate pointed to by x509.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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_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.

See Also:
WolfSSLContext.setVerify(long, int, WolfSSLVerifyCallback), Constant Field Values

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 CyaSSL, 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.

See Also:
WolfSSLContext.setVerify(long, int, WolfSSLVerifyCallback), Constant Field Values

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).

See Also:
WolfSSLContext.setVerify(long, int, WolfSSLVerifyCallback), Constant Field Values

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

CYASSL_CRL_CHECKALL

public static final int CYASSL_CRL_CHECKALL
See Also:
Constant Field Values

CYASSL_OCSP_ENABLE

public static final int CYASSL_OCSP_ENABLE
See Also:
Constant Field Values

CYASSL_OCSP_URL_OVERRIDE

public static final int CYASSL_OCSP_URL_OVERRIDE
See Also:
Constant Field Values

CYASSL_OCSP_NO_NONCE

public static final int CYASSL_OCSP_NO_NONCE
See Also:
Constant Field Values

CYASSL_CBIO_ERR_GENERAL

public static final int CYASSL_CBIO_ERR_GENERAL
See Also:
Constant Field Values

CYASSL_CBIO_ERR_WANT_READ

public static final int CYASSL_CBIO_ERR_WANT_READ
See Also:
Constant Field Values

CYASSL_CBIO_ERR_WANT_WRITE

public static final int CYASSL_CBIO_ERR_WANT_WRITE
See Also:
Constant Field Values

CYASSL_CBIO_ERR_CONN_RST

public static final int CYASSL_CBIO_ERR_CONN_RST
See Also:
Constant Field Values

CYASSL_CBIO_ERR_ISR

public static final int CYASSL_CBIO_ERR_ISR
See Also:
Constant Field Values

CYASSL_CBIO_ERR_CONN_CLOSE

public static final int CYASSL_CBIO_ERR_CONN_CLOSE
See Also:
Constant Field Values

CYASSL_CBIO_ERR_TIMEOUT

public static final int CYASSL_CBIO_ERR_TIMEOUT
See Also:
Constant Field Values

CYASSL_SERVER_END

public static final int CYASSL_SERVER_END
See Also:
Constant Field Values

CYASSL_CLIENT_END

public static final int CYASSL_CLIENT_END
See Also:
Constant Field Values

CYASSL_BLOCK_TYPE

public static final int CYASSL_BLOCK_TYPE
See Also:
Constant Field Values

CYASSL_STREAM_TYPE

public static final int CYASSL_STREAM_TYPE
See Also:
Constant Field Values

CYASSL_AEAD_TYPE

public static final int CYASSL_AEAD_TYPE
See Also:
Constant Field Values

CYASSL_TLS_HMAC_INNER_SZ

public static final int CYASSL_TLS_HMAC_INNER_SZ
See Also:
Constant Field Values

cyassl_cipher_null

public static final int cyassl_cipher_null
See Also:
Constant Field Values

cyassl_rc4

public static final int cyassl_rc4
See Also:
Constant Field Values

cyassl_rc2

public static final int cyassl_rc2
See Also:
Constant Field Values

cyassl_des

public static final int cyassl_des
See Also:
Constant Field Values

cyassl_triple_des

public static final int cyassl_triple_des
See Also:
Constant Field Values

cyassl_des40

public static final int cyassl_des40
See Also:
Constant Field Values

cyassl_idea

public static final int cyassl_idea
See Also:
Constant Field Values

cyassl_aes

public static final int cyassl_aes
See Also:
Constant Field Values

cyassl_aes_gcm

public static final int cyassl_aes_gcm
See Also:
Constant Field Values

cyassl_aes_ccm

public static final int cyassl_aes_ccm
See Also:
Constant Field Values

cyassl_hc128

public static final int cyassl_hc128
See Also:
Constant Field Values

cyassl_rabbit

public static final int cyassl_rabbit
See Also:
Constant Field Values

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_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

CYASSL_CRL_MONITOR

public static final int CYASSL_CRL_MONITOR
Monitor this CRL directory flag

See Also:
Constant Field Values

CYASSL_CRL_START_MON

public static final int CYASSL_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
Constructor Detail

WolfSSL

public WolfSSL()
        throws WolfSSLException
Initializes the wolfSSL library for use.

Throws:
WolfSSLException
Method Detail

loadLibrary

public static void loadLibrary()
                        throws java.lang.UnsatisfiedLinkError
Loads JNI library; must be called prior to any other calls in this class.

Throws:
java.lang.UnsatisfiedLinkError - if the library is not found.

loadLibrary

public static void loadLibrary(java.lang.String libPath)
                        throws java.lang.UnsatisfiedLinkError
Load JNI library; must be called prior to any other calls in this package.

Throws:
java.lang.UnsatisfiedLinkError - if the library is not found.

SSLv3_ServerMethod

public static final long SSLv3_ServerMethod()
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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_METHOD structure if successful, null on failure.
See Also:
WolfSSLContext.newContext(long)

SSLv3_ClientMethod

public static final long SSLv3_ClientMethod()
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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 CYASSL_METHOD structure to be used when creating the SSL/TLS context with newContext().

Returns:
A pointer to the created CYASSL_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 by getError()
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.


debuggingON

public static final int debuggingON()
Turns on debug logging at runtime. To enable logging at build time, use --enable-debug or define DEBUG_CYASSL. 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.

See Also:
debuggingON(), setLoggingCb(WolfSSLLoggingCallback)

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 corresponding memrestoreSessionCache() method.

Parameters:
mem - buffer to store session cache in
sz - 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 restored
sz - 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)

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 CYASSL_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