wolfSSL Manual

Docs -> wolfSSL Manual

Chapter 17: wolfSSL API Reference


17.4  Callbacks


The functions in this section have to do with callbacks which the application is able to set in relation to wolfSSL.






CyaSSL_SetIOReadCtx


Synopsis:

void CyaSSL_SetIOReadCtx(CYASSL* ssl, void *ctx);


Description:

This function registers a context for the SSL session’s receive callback function.  By default, CyaSSL sets the file descriptor passed to CyaSSL_set_fd() as the context when CyaSSL is using the system’s TCP library.  If you’ve registered your own receive callback you may want to set a specific context for the session.  For example, if you’re using memory buffers the context may be a pointer to a structure describing where and how to access the memory buffers.


Return Values:

No return values are used for this function.


Parameters:


ssl - pointer to the SSL session, created with CyaSSL_new().


ctx - pointer to the context to be registered with the SSL session’s (ssl) receive callback function.


Example:


int sockfd;

CYASSL* ssl = 0;

...

// Manually setting the socket fd as the receive CTX, for example

CyaSSL_SetIOReadCtx(ssl, &sockfd);

...


See Also:

CyaSSL_SetIORecv

CyaSSL_SetIOSend

CyaSSL_SetIOWriteCtx






CyaSSL_SetIOWriteCtx


Synopsis:

void CyaSSL_SetIOWriteCtx(CYASSL* ssl, void *ctx);


Description:

This function registers a context for the SSL session’s send callback function.  By default, CyaSSL sets the file descriptor passed to CyaSSL_set_fd() as the context when CyaSSL is using the system’s TCP library.  If you’ve registered your own send callback you may want to set a specific context for the session.  For example, if you’re using memory buffers the context may be a pointer to a structure describing where and how to access the memory buffers.


Return Values:

No return values are used for this function.


Parameters:


ssl - pointer to the SSL session, created with CyaSSL_new().


ctx - pointer to the context to be registered with the SSL session’s (ssl) send callback function.


Example:


int sockfd;

CYASSL* ssl = 0;

...

// Manually setting the socket fd as the send CTX, for example

CyaSSL_SetIOSendCtx(ssl, &sockfd);

...


See Also:

CyaSSL_SetIORecv

CyaSSL_SetIOSend

CyaSSL_SetIOReadCtx






CyaSSL_SetIOReadFlags


Synopsis:

void CyaSSL_SetIOReadFlags( CYASSL* ssl, int flags);


Description:

This function sets the flags for the receive callback to use for the given SSL session.  The receive callback could be either the default CyaSSL EmbedReceive callback, or a custom callback specified by the user (see  CyaSSL_SetIORecv). The default flag value is set internally by CyaSSL to the value of 0.  


The default CyaSSL receive callback uses the recv() function to receive data from the socket.  From the recv() man page:


“The flags argument to a recv() function is formed by or'ing one or more of the values:


  1. MSG_OOBprocess out-of-band data

  2. MSG_PEEKpeek at incoming message

  3. MSG_WAITALLwait for full request or error


The MSG_OOB flag requests receipt of out-of-band data that would not be received in the normal data stream.  Some protocols place expedited data at the head of the normal data queue, and thus this flag cannot be used with such protocols.  The MSG_PEEK flag causes the receive operation to return data from the beginning of the receive queue without removing that data from the queue.  Thus, a subsequent receive call will return the same data.  The MSG_WAITALL flag requests that the operation block until the full request is satisfied.  However, the call may still return less data than requested if a signal is caught, an error or disconnect occurs, or the next data to be received is of a different type than that returned.”


Return Values:

No return values are used for this function.


Parameters:


ssl - pointer to the SSL session, created with CyaSSL_new().


flags - value of the I/O read flags for the specified SSL session (ssl).


Example:


CYASSL* ssl = 0;

...

// Manually setting recv flags to 0

CyaSSL_SetIOReadFlags(ssl, 0);

...


See Also:

CyaSSL_SetIORecv

CyaSSL_SetIOSend

CyaSSL_SetIOReadCtx






CyaSSL_SetIOWriteFlags


Synopsis:

void CyaSSL_SetIOWriteFlags( CYASSL* ssl, int flags);


Description:

This function sets the flags for the send callback to use for the given SSL session.  The send callback could be either the default CyaSSL EmbedSend callback, or a custom callback specified by the user (see  CyaSSL_SetIOSend). The default flag value is set internally by CyaSSL to the value of 0.  


The default CyaSSL send callback uses the send() function to send data from the socket.  From the send() man page:


“The flags parameter may include one or more of the following:


  1. #define MSG_OOB        0x1  /* process out-of-band data */

  2. #define MSG_DONTROUTE  0x4  /* bypass routing, use direct interface */


The flag MSG_OOB is used to send ``out-of-band'' data on sockets that support this notion (e.g.  SOCK_STREAM); the underlying protocol must also support ``out-of-band'' data.  MSG_DONTROUTE is usually used only by diagnostic or routing programs.”


Return Values:

No return values are used for this function.


Parameters:


ssl - pointer to the SSL session, created with CyaSSL_new().


flags - value of the I/O send flags for the specified SSL session (ssl).


Example:


CYASSL* ssl = 0;

...

// Manually setting send flags to 0

CyaSSL_SetIOSendFlags(ssl, 0);

...


See Also:

CyaSSL_SetIORecv

CyaSSL_SetIOSend

CyaSSL_SetIOReadCtx






CyaSSL_SetIORecv


Synopsis:

void CyaSSL_SetIORecv(CYASSL_CTX* ctx, CallbackIORecv callback);


typedef int (*CallbackIORecv)(char *buf, int sz, void *ctx);


Description:

This function registers a receive callback for CyaSSL to get input data.  By default, CyaSSL uses EmbedReceive() as the callback which uses the system’s TCP recv() function.  The user can register a function to get input from memory, some other network module, or from anywhere.  Please see the EmbedReceive() function in src/io.c as a guide for how the function should work and for error codes.  In particular, IO_ERR_WANT_READ should be returned for non blocking receive when no data is ready.


Return Values:

No return values are used for this function.


Parameters:


ctx - pointer to the SSL context, created with CyaSSL_CTX_new().


callback - function to be registered as the receive callback for the CyaSSL context, ctx. The signature of this function must follow that as shown above in the Synopsis section.


Example:


CYASSL_CTX* ctx = 0;


// Receive callback prototype

int MyEmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx);


// Register the custom receive callback with CyaSSL

CyaSSL_SetIORecv(ctx, MyEmbedReceive);


int MyEmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx)                   

{

// custom EmbedReceive function

}  


See Also:

CyaSSL_SetIOSend

CyaSSL_SetIOReadCtx

CyaSSL_SetIOWriteCtx






CyaSSL_SetIOSend


Synopsis:

void CyaSSL_SetIOSend(CYASSL_CTX* ctx, CallbackIOSend callback);


typedef int (*CallbackIOSend)(char *buf, int sz, void *ctx);


Description:

This function registers a send callback for CyaSSL to write output data.  By default, CyaSSL uses EmbedSend() as the callback which uses the system’s TCP send() function.  The user can register a function to send output to memory, some other network module, or to anywhere.  Please see the EmbedSend() function in src/io.c as a guide for how the function should work and for error codes.  In particular, IO_ERR_WANT_WRITE should be returned for non blocking send when the action cannot be taken yet.


Return Values:

No return values are used for this function.


Parameters:


ctx - pointer to the SSL context, created with CyaSSL_CTX_new().


callback - function to be registered as the send callback for the CyaSSL context, ctx. The signature of this function must follow that as shown above in the Synopsis section.


Example:


CYASSL_CTX* ctx = 0;


// Receive callback prototype

int MyEmbedSend(CYASSL *ssl, char *buf, int sz, void *ctx);


// Register the custom receive callback with CyaSSL

CyaSSL_SetIOSend(ctx, MyEmbedSend);


int MyEmbedSend(CYASSL *ssl, char *buf, int sz, void *ctx)                   

{

// custom EmbedSend function

}  


See Also:

CyaSSL_SetIORecv

CyaSSL_SetIOReadCtx

CyaSSL_SetIOWriteCtx






CyaSSL_CTX_SetCACb


Synopsis:

void CyaSSL_CTX_SetCACb(CYASSL_CTX* ctx, CallbackCACache callback);


typedef void (*CallbackCACache)(unsigned char* der, int sz, int type);


Description:

This function registers a callback with the SSL context (CYASSL_CTX) to be called when a new CA certificate is loaded into CyaSSL.  The callback is given a buffer with the DER-encoded certificate.


Return Values:

This function has no return value.


Parameters:


ctx - pointer to the SSL context, created with CyaSSL_CTX_new().


callback - function to be registered as the CA callback for the CyaSSL context, ctx. The signature of this function must follow that as shown above in the Synopsis section.


Example:


CYASSL_CTX* ctx = 0;


// CA callback prototype

int MyCACallback(unsigned char *der, int sz, int type);


// Register the custom CA callback with the SSL context

CyaSSL_CTX_SetCACb(ctx, MyCACallback);


int MyCACallback(unsigned char* der, int sz, int type)                   

{

/* custom CA callback function, DER-encoded cert

       located in “der” of size “sz” with type “type” */

}  


See Also:

CyaSSL_CTX_load_verify_locations






CyaSSL_connect_ex


Synopsis:

#include <cyassl/ssl.h>


int CyaSSL_connect_ex(CYASSL* ssl, HandShakeCallBack hsCb,

        TimeoutCallBack toCb,                   

                                            Timeval timeout);


typedef int (*HandShakeCallBack)(HandShakeInfo*);

typedef int (*TimeoutCallBack)(TimeoutInfo*);


typedef struct timeval Timeval;


typedef struct handShakeInfo_st {

char   cipherName[MAX_CIPHERNAME_SZ + 1];  /* negotiated name */

char   packetNames[MAX_PACKETS_HANDSHAKE][MAX_PACKETNAME_SZ+1];

                                         /* SSL packet names */

int    numberPackets;                 /* actual # of packets  */

int    negotiationError;              /* cipher/parameter err */

} HandShakeInfo;



typedef struct timeoutInfo_st {

chartimeoutName[MAX_TIMEOUT_NAME_SZ +1]; /*timeout Name*/

int        flags;                            /* for future use*/

int        numberPackets;              /* actual # of packets */

PacketInfo packets[MAX_PACKETS_HANDSHAKE]; /* list of packets */

Timeval    timeoutValue;              /* timer that caused it */

} TimeoutInfo;



typedef struct packetInfo_st {

     char        packetName[MAX_PACKETNAME_SZ + 1]; /* SSL name */

     Timeval     timestamp;               /* when it occured*/

     unsigned char value[MAX_VALUE_SZ];   /* if fits, it's here */

     unsigned char* bufferValue;       /* otherwise here (non 0) */

     int         valueSz;              /* sz of value or buffer */

} PacketInfo;


Description:

CyaSSL_connect_ex() is an extension that allows a HandShake Callback to be set.  This can be useful in embedded systems for debugging support when a debugger isn’t available and sniffing is impractical.  The HandShake Callback will be called whether or not a handshake error occurred.  No dynamic memory is used since the maximum number of SSL packets is known.  Packet names can be accessed through packetNames[].


The connect extension also allows a Timeout Callback to be set along with a timeout value.  This is useful if the user doesn’t want to wait for the TCP stack to timeout.


This extension can be called with either, both, or neither callbacks.


This function is only available when CyaSSL is compiled with the CYASSL_CALLBACKS define.


Return Values:

If successful the call will return SSL_SUCCESS.


GETTIME_ERROR will be returned if gettimeofday() encountered an error.


SETITIMER_ERROR will be returned if setitimer() encountered an error.


SIGACT_ERROR will be returned if sigaction() encountered an error.


SSL_FATAL_ERROR will be returned if the underlying SSL_connect() call encountered an error.


See Also:

CyaSSL_accept_ex






CyaSSL_accept_ex


Synopsis:

#include <cyassl/ssl.h>


int CyaSSL_accept_ex(CYASSL* ssl, HandShakeCallBack hsCb,

     TimeoutCallBack toCb,                   

                                         Timeval timeout);


typedef int (*HandShakeCallBack)(HandShakeInfo*);

typedef int (*TimeoutCallBack)(TimeoutInfo*);


typedef struct timeval Timeval;


typedef struct handShakeInfo_st {

char   cipherName[MAX_CIPHERNAME_SZ + 1];  /* negotiated name */

char   packetNames[MAX_PACKETS_HANDSHAKE][MAX_PACKETNAME_SZ+1];

                                         /* SSL packet names */

int    numberPackets;                 /* actual # of packets  */

int    negotiationError;              /* cipher/parameter err */

} HandShakeInfo;



typedef struct timeoutInfo_st {

chartimeoutName[MAX_TIMEOUT_NAME_SZ +1]; /*timeout Name*/

int        flags;                            /* for future use*/

int        numberPackets;              /* actual # of packets */

PacketInfo packets[MAX_PACKETS_HANDSHAKE]; /* list of packets */

Timeval    timeoutValue;              /* timer that caused it */

} TimeoutInfo;



typedef struct packetInfo_st {

     char        packetName[MAX_PACKETNAME_SZ + 1]; /* SSL name */

     Timeval     timestamp;               /* when it occured*/

     unsigned char value[MAX_VALUE_SZ];   /* if fits, it's here */

     unsigned char* bufferValue;       /* otherwise here (non 0) */

     int         valueSz;              /* sz of value or buffer */

} PacketInfo;


Description:

CyaSSL_accept_ex() is an extension that allows a HandShake Callback to be set.  This can be useful in embedded systems for debugging support when a debugger isn’t available and sniffing is impractical.  The HandShake Callback will be called whether or not a handshake error occurred.  No dynamic memory is used since the maximum number of SSL packets is known.  Packet names can be accessed through packetNames[].


The connect extension also allows a Timeout Callback to be set along with a timeout value.  This is useful if the user doesn’t want to wait for the TCP stack to timeout.


This extension can be called with either, both, or neither callbacks.


This function is only available when CyaSSL is compiled with the CYASSL_CALLBACKS define.


Return Values:

If successful the call will return SSL_SUCCESS.


GETTIME_ERROR will be returned if gettimeofday() encountered an error.


SETITIMER_ERROR will be returned if setitimer() encountered an error.


SIGACT_ERROR will be returned if sigaction() encountered an error.


SSL_FATAL_ERROR will be returned if the underlying SSL_accept() call encountered an error.


See Also:

CyaSSL_connect_ex






CyaSSL_SetLoggingCb


Synopsis:

#include <cyassl/ctaocrypt/logging.h>


int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb log_function);


typedef void (*CyaSSL_Logging_cb)(const int logLevel, const char *const logMessage);


Description:

This function registers a logging callback that will be used to handle the CyaSSL log message.  By default, if the system supports it fprintf() to stderr is used but by using this function anything can be done by the user.


Return Values:

If successful this function will return 0.


BAD_FUNC_ARG is the error that will be returned if a function pointer is not provided.


Parameters:


log_function - function to register as a logging callback.  Function signature must follow the above prototype.


Example:


int ret = 0;


// Logging callback prototype

void MyLoggingCallback(const int logLevel, const char* const logMessage);


// Register the custom logging callback with CyaSSL

ret = CyaSSL_SetLoggingCb(myLogCallback);

if (ret != 0) {

// failed to set logging callback

}


void MyLoggingCallback(const int logLevel, const char* const logMessage)

{

// custom logging function

}  


See Also:

CyaSSL_Debugging_ON

CyaSSL_Debugging_OFF






CyaSSL_SetTlsHmacInner


Synopsis:

#include <cyassl/ssl.h>


int CyaSSL_SetTlsHmacInner(CYASSL* ssl, unsigned char* inner, word32 sz,

      int content, int verify);


Description:

Allows caller to set the Hmac Inner vector for message sending/receiving.  The result is written to inner which should be at least CyaSSL_GetHmacSize() bytes.  The size of the message is specified by sz, content is the type of message, and verify specifies whether this is a verification of a peer message. Valid for cipher types excluding CYASSL_AEAD_TYPE.  


Return Values:

If successful the call will return 1.


BAD_FUNC_ARG will be returned for an error state. 


See Also:

CyaSSL_GetBulkCipher()

CyaSSL_GetHmacType()






CyaSSL_CTX_SetMacEncryptCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetMacEncryptCb(CYASSL_CTX*, CallbackMacEncrypt);


typedef int (*CallbackMacEncrypt)(CYASSL* ssl, unsigned char* macOut,

      const unsigned char* macIn, unsigned int macInSz, int macContent,

      int macVerify, unsigned char* encOut, const unsigned char* encIn,

      unsigned int encSz, void* ctx);


Description:

Allows caller to set the Atomic User Record Processing Mac/Encrypt Callback.  The callback should return 0 for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  macOut is the output buffer where the result of the mac should be stored.  macIn is the mac input buffer and macInSz notes the size of the buffer.  macContent and macVerify are needed for CyaSSL_SetTlsHmacInner() and be passed along as is.  encOut is the output buffer where the result on the encryption should be stored.  encIn is the input buffer to encrypt while encSz is the size of the input.  An example callback can be found cyassl/test.h myMacEncryptCb().


Return Values:

NA


See Also:

CyaSSL_SetMacEncryptCtx()

CyaSSL_GetMacEncryptCtx()






CyaSSL_SetMacEncryptCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetMacEncryptCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Atomic User Record Processing Mac/Encrypt Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetMacEncryptCb()

CyaSSL_GetMacEncryptCtx()






CyaSSL_GetMacEncryptCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetMacEncryptCtx(CYASSL*);


Description:

Allows caller to retrieve the Atomic User Record Processing Mac/Encrypt Callback Context previously stored with CyaSSL_SetMacEncryptCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetMacEncryptCb()

CyaSSL_SetMacEncryptCtx()






CyaSSL_CTX_SetDecryptVerifyCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetDecryptVerifyCb(CYASSL_CTX*, CallbackDecryptVerify);


typedef int (*CallbackDecryptVerify)(CYASSL* ssl,

      unsigned char* decOut, const unsigned char* decIn,

      unsigned int decSz, int content, int verify, unsigned int* padSz,

      void* ctx);


Description:

Allows caller to set the Atomic User Record Processing Decrypt/Verify Callback.  The callback should return 0 for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  decOut is the output buffer where the result of the decryption should be stored.  decIn is the encrypted input buffer and decInSz notes the size of the buffer.  content and verify are needed for CyaSSL_SetTlsHmacInner() and be passed along as is.  padSz is an output variable that should be set with the total value of the padding.  That is, the mac size plus any padding and pad bytes.  An example callback can be found cyassl/test.h myDecryptVerifyCb().


Return Values:

NA


See Also:

CyaSSL_SetMacEncryptCtx()

CyaSSL_GetMacEncryptCtx()






CyaSSL_SetDecryptVerifyCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetDecryptVerifyCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Atomic User Record Processing Decrypt/Verify Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetDecryptVerifyCb()

CyaSSL_GetDecryptVerifyCtx()






CyaSSL_GetDecryptVerifyCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetDecryptVerifyCtx(CYASSL*);


Description:

Allows caller to retrieve the Atomic User Record Processing Decrypt/Verify Callback Context previously stored with CyaSSL_SetDecryptVerifyCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetDecryptVerifyCb()

CyaSSL_SetDecryptVerifyCtx()






CyaSSL_CTX_SetEccSignCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetEccSignCb(CYASSL_CTX*, CallbackEccSign);


typedef int (*CallbackEccSign)(CYASSL* ssl,

      const unsigned char* in, unsigned int inSz,

      unsigned char* out, unsigned int* outSz,

      const unsigned char* keyDer, unsigned int keySz,

      void* ctx);


Description:

Allows caller to set the Public Key Callback for ECC Signing.  The callback should return 0 for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  in is the input buffer to sign while inSz denotes the length of the input.  out is the output buffer where the result of the signature should be stored.  outSz is an input/output variable that specifies the size of the output buffer upon invocation and the actual size of the signature should be stored there before returning.  keyDer is the ECC Private key in ASN1 format and keySz is the length of the key in bytes.  An example callback can be found cyassl/test.h myEccSign().


Return Values:

NA


See Also:

CyaSSL_SetEccSignCtx()

CyaSSL_GetEccSignCtx()






CyaSSL_SetEccSignCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetEccSignCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Public Key Ecc Signing Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetEccSignCb()

CyaSSL_GetEccSignCtx()






CyaSSL_GetEccSignCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetEccSignCtx(CYASSL*);


Description:

Allows caller to retrieve the Public Key Ecc Signing Callback Context previously stored with CyaSSL_SetEccSignCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetEccSignCb()

CyaSSL_SetEccSignCtx()






CyaSSL_CTX_SetEccVerifyCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetEccVerifyCb(CYASSL_CTX*, CallbackEccVerify);


typedef int (*CallbackEccVerify)(CYASSL* ssl,

      const unsigned char* sig, unsigned int sigSz,

      const unsigned char* hash, unsigned int hashSz,

      const unsigned char* keyDer, unsigned int keySz,

      int* result, void* ctx);


Description:

Allows caller to set the Public Key Callback for ECC Verification.  The callback should return 0 for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  sig is the signature to verify and sigSz denotes the length of the signature.  hash is an input buffer containing the digest of the message and hashSz denotes the length in bytes of the hash.  result is an output variable where the result of the verification should be stored, 1 for success and 0 for failure.  keyDer is the ECC Private key in ASN1 format and keySz is the length of the key in bytes.  An example callback can be found cyassl/test.h myEccVerify().


Return Values:

NA


See Also:

CyaSSL_SetEccVerifyCtx()

CyaSSL_GetEccVerifyCtx()






CyaSSL_SetEccVerifyCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetEccVerifyCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Public Key Ecc Verification Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetEccVerifyCb()

CyaSSL_GetEccVerifyCtx()






CyaSSL_GetEccVerifyCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetEccVerifyCtx(CYASSL*);


Description:

Allows caller to retrieve the Public Key Ecc Verification Callback Context previously stored with CyaSSL_SetEccVerifyCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetEccVerifyCb()

CyaSSL_SetEccVerifyCtx()






CyaSSL_CTX_SetRsaSignCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetEccRsaCb(CYASSL_CTX*, CallbackRsaSign);


typedef int (*CallbackRsaSign)(CYASSL* ssl,

      const unsigned char* in, unsigned int inSz,

      unsigned char* out, unsigned int* outSz,

      const unsigned char* keyDer, unsigned int keySz,

      void* ctx);


Description:

Allows caller to set the Public Key Callback for RSA Signing.  The callback should return 0 for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  in is the input buffer to sign while inSz denotes the length of the input.  out is the output buffer where the result of the signature should be stored.  outSz is an input/output variable that specifies the size of the output buffer upon invocation and the actual size of the signature should be stored there before returning.  keyDer is the RSA Private key in ASN1 format and keySz is the length of the key in bytes.  An example callback can be found cyassl/test.h myRsaSign().


Return Values:

NA


See Also:

CyaSSL_SetRsaSignCtx()

CyaSSL_GetRsaSignCtx()






CyaSSL_SetRsaSignCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetRsaSignCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Public Key RSA Signing Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetRsaSignCb()

CyaSSL_GetRsaSignCtx()






CyaSSL_GetRsaSignCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetRsaSignCtx(CYASSL*);


Description:

Allows caller to retrieve the Public Key RSA Signing Callback Context previously stored with CyaSSL_SetRsaSignCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetRsaSignCb()

CyaSSL_SetRsaSignCtx()






CyaSSL_CTX_SetRsaVerifyCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetRsaVerifyCb(CYASSL_CTX*, CallbackRsaVerify);


typedef int (*CallbackRsaVerify)(CYASSL* ssl,

      unsigned char* sig, unsigned int sigSz,

      unsigned char** out,

      const unsigned char* keyDer, unsigned int keySz,

      void* ctx);


Description:

Allows caller to set the Public Key Callback for RSA Verification.  The callback should return the number of plaintext bytes for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  sig is the signature to verify and sigSz denotes the length of the signature.  out should be set to the beginning of the verification buffer after the decryption process and any padding.  keyDer is the RSA Public key in ASN1 format and keySz is the length of the key in bytes.  An example callback can be found cyassl/test.h myRsaVerify().


Return Values:

NA


See Also:

CyaSSL_SetRsaVerifyCtx()

CyaSSL_GetRsaVerifyCtx()






CyaSSL_SetRsaVerifyCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetRsaVerifyCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Public Key RSA Verification Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetRsaVerifyCb()

CyaSSL_GetRsaVerifyCtx()






CyaSSL_GetRsaVerifyCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetRsaVerifyCtx(CYASSL*);


Description:

Allows caller to retrieve the Public Key RSA Verification Callback Context previously stored with CyaSSL_SetRsaVerifyCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetRsaVerifyCb()

CyaSSL_SetRsaVerifyCtx()






CyaSSL_CTX_SetRsaEncCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetRsaEncCb(CYASSL_CTX*, CallbackRsaEnc);


typedef int (*CallbackRsaEnc)(CYASSL* ssl,

      const unsigned char* in, unsigned int inSz,

      unsigned char* out, unsigned int* outSz,

      const unsigned char* keyDer, unsigned int keySz,

      void* ctx);


Description:

Allows caller to set the Public Key Callback for RSA Public Encrypt.  The callback should return 0 for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  in is the input buffer to encrypt while inSz denotes the length of the input.  out is the output buffer where the result of the encryption should be stored.  outSz is an input/output variable that specifies the size of the output buffer upon invocation and the actual size of the encryption should be stored there before returning.  keyDer is the RSA Public key in ASN1 format and keySz is the length of the key in bytes.  An example callback can be found cyassl/test.h myRsaEnc().


Return Values:

NA


See Also:

CyaSSL_SetRsaEncCtx()

CyaSSL_GetRsaEncCtx()






CyaSSL_SetRsaEncCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetRsaEncCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Public Key RSA Public Encrypt Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetRsaEncCb()

CyaSSL_GetRsaEncCtx()






CyaSSL_GetRsaEncCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetRsaEncCtx(CYASSL*);


Description:

Allows caller to retrieve the Public Key RSA Public Encrypt Callback Context previously stored with CyaSSL_SetRsaEncCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetRsaEncCb()

CyaSSL_SetRsaEncCtx()






CyaSSL_CTX_SetRsaDecCb


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_CTX_SetRsaDecCb(CYASSL_CTX*, CallbackRsaDec);


typedef int (*CallbackRsaDec)(CYASSL* ssl,

      unsigned char* in, unsigned int inSz,

      unsigned char** out,

      const unsigned char* keyDer, unsigned int keySz,

      void* ctx);


Description:

Allows caller to set the Public Key Callback for RSA Private Decrypt.  The callback should return the number of plaintext bytes for success or < 0 for an error.  The ssl and ctx pointers are available for the users convenience.  in is the input buffer to decrypt and inSz denotes the length of the input.  out should be set to the beginning of the decryption buffer after the decryption process and any padding.  keyDer is the RSA Private key in ASN1 format and keySz is the length of the key in bytes.  An example callback can be found cyassl/test.h myRsaDec().


Return Values:

NA


See Also:

CyaSSL_SetRsaDecCtx()

CyaSSL_GetRsaDecCtx()






CyaSSL_SetRsaDecCtx


Synopsis:

#include <cyassl/ssl.h>


void CyaSSL_SetRsaDecCtx(CYASSL*, void* ctx);


Description:

Allows caller to set the Public Key RSA Private Decrypt Callback Context to ctx.


Return Values:

NA


See Also:

CyaSSL_CTX_SetRsaDecCb()

CyaSSL_GetRsaDecCtx()






CyaSSL_GetRsaDecCtx


Synopsis:

#include <cyassl/ssl.h>


void* CyaSSL_GetRsaDecCtx(CYASSL*);


Description:

Allows caller to retrieve the Public Key RSA Private Decrypt Callback Context previously stored with CyaSSL_SetRsaDecCtx().


Return Values:

If successful the call will return a valid pointer to the context.


NULL will be returned for a blank context.


See Also:

CyaSSL_CTX_SetRsaDecCb()

CyaSSL_SetRsaDecCtx()




 

Questions? +1 (425) 245-8247