src/wolfSSL/src/internal.c
int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method)
{
    XMEMSET(ctx, 0, sizeof(WOLFSSL_CTX));

    ctx->method   = method;
    ctx->refCount = 1;          /* so either CTX_free or SSL_free can release */
    ctx->heap     = ctx;        /* defaults to self */
    ctx->timeout  = WOLFSSL_SESSION_TIMEOUT;
    ctx->minDowngrade = TLSv1_MINOR;     /* current default */

    if (InitMutex(&ctx->countMutex) < 0) {
        WOLFSSL_MSG("Mutex error on CTX init");
        return BAD_MUTEX_E;
    }

#ifndef NO_DH
    ctx->minDhKeySz = MIN_DHKEY_SZ;
#endif

#ifdef HAVE_ECC
    ctx->eccTempKeySz = ECDHE_SIZE;
#endif

#ifndef WOLFSSL_USER_IO
    ctx->CBIORecv = EmbedReceive;
    ctx->CBIOSend = EmbedSend;
    #ifdef WOLFSSL_DTLS
        if (method->version.major == DTLS_MAJOR) {
            ctx->CBIORecv   = EmbedReceiveFrom;
            ctx->CBIOSend   = EmbedSendTo;
        }
    #endif
#endif /* WOLFSSL_USER_IO */

#ifdef HAVE_NETX
    ctx->CBIORecv = NetX_Receive;
    ctx->CBIOSend = NetX_Send;
#endif

#ifdef HAVE_NTRU
    if (method->side == WOLFSSL_CLIENT_END)
        ctx->haveNTRU = 1;           /* always on cliet side */
                                     /* server can turn on by loading key */
#endif
#ifdef HAVE_ECC
    if (method->side == WOLFSSL_CLIENT_END) {
        ctx->haveECDSAsig  = 1;        /* always on cliet side */
        ctx->haveECC  = 1;             /* server turns on with ECC key cert */
        ctx->haveStaticECC = 1;        /* server can turn on by loading key */
    }
#endif

#ifdef HAVE_CAVIUM
    ctx->devId = NO_CAVIUM_DEVICE;
#endif

#ifndef NO_CERTS
    ctx->cm = wolfSSL_CertManagerNew();
    if (ctx->cm == NULL) {
        WOLFSSL_MSG("Bad Cert Manager New");
        return BAD_CERT_MANAGER_ERROR;
    }
#endif

#if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER)
    ctx->ticketHint = SESSION_TICKET_HINT_DEFAULT;
#endif

    return 0;
}
/* Initialize SSL context, return 0 on success */
Initialize SSL context, return 0 on success
Initialize SSL context return 0 on success
int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method)
{
    XMEMSET(ctx, 0, sizeof(WOLFSSL_CTX));
    ctx->method   = method;
    ctx->refCount = 1;          
    ctx->heap     = ctx;        
    ctx->timeout  = WOLFSSL_SESSION_TIMEOUT;
    ctx->minDowngrade = TLSv1_MINOR;     
    if (InitMutex(&ctx->countMutex) < 0) {
        WOLFSSL_MSG("Mutex error on CTX init");
        return BAD_MUTEX_E;
    }
#ifndef NO_DH
    ctx->minDhKeySz = MIN_DHKEY_SZ;
#endif
#ifdef HAVE_ECC
    ctx->eccTempKeySz = ECDHE_SIZE;
#endif
#ifndef WOLFSSL_USER_IO
    ctx->CBIORecv = EmbedReceive;
    ctx->CBIOSend = EmbedSend;
    #ifdef WOLFSSL_DTLS
        if (method->version.major == DTLS_MAJOR) {
            ctx->CBIORecv   = EmbedReceiveFrom;
            ctx->CBIOSend   = EmbedSendTo;
        }
    #endif
#endif 
#ifdef HAVE_NETX
    ctx->CBIORecv = NetX_Receive;
    ctx->CBIOSend = NetX_Send;
#endif
#ifdef HAVE_NTRU
    if (method->side == WOLFSSL_CLIENT_END)
        ctx->haveNTRU = 1;           
#endif
#ifdef HAVE_ECC
    if (method->side == WOLFSSL_CLIENT_END) {
        ctx->haveECDSAsig  = 1;        
        ctx->haveECC  = 1;             
        ctx->haveStaticECC = 1;        
    }
#endif
#ifdef HAVE_CAVIUM
    ctx->devId = NO_CAVIUM_DEVICE;
#endif
#ifndef NO_CERTS
    ctx->cm = wolfSSL_CertManagerNew();
    if (ctx->cm == NULL) {
        WOLFSSL_MSG("Bad Cert Manager New");
        return BAD_CERT_MANAGER_ERROR;
    }
#endif
#if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER)
    ctx->ticketHint = SESSION_TICKET_HINT_DEFAULT;
#endif
    return 0;
}
int InitSSL_Ctx ( WOLFSSL_CTX * ctx , WOLFSSL_METHOD * method ) { XMEMSET ( ctx , 0 , sizeof ( WOLFSSL_CTX ) ) ; ctx -> method = method ; ctx -> refCount = 1 ; ctx -> heap = ctx ; ctx -> timeout = WOLFSSL_SESSION_TIMEOUT ; ctx -> minDowngrade = TLSv1_MINOR ; if ( InitMutex ( & ctx -> countMutex ) < 0 ) { WOLFSSL_MSG ( " " ) ; return BAD_MUTEX_E ; } #ifndef NO_DH ctx -> minDhKeySz = MIN_DHKEY_SZ ; #endif #ifdef HAVE_ECC ctx -> eccTempKeySz = ECDHE_SIZE ; #endif #ifndef WOLFSSL_USER_IO ctx -> CBIORecv = EmbedReceive ; ctx -> CBIOSend = EmbedSend ; #ifdef WOLFSSL_DTLS if ( method -> version . major == DTLS_MAJOR ) { ctx -> CBIORecv = EmbedReceiveFrom ; ctx -> CBIOSend = EmbedSendTo ; } #endif #endif #ifdef HAVE_NETX ctx -> CBIORecv = NetX_Receive ; ctx -> CBIOSend = NetX_Send ; #endif #ifdef HAVE_NTRU if ( method -> side == WOLFSSL_CLIENT_END ) ctx -> haveNTRU = 1 ; #endif #ifdef HAVE_ECC if ( method -> side == WOLFSSL_CLIENT_END ) { ctx -> haveECDSAsig = 1 ; ctx -> haveECC = 1 ; ctx -> haveStaticECC = 1 ; } #endif #ifdef HAVE_CAVIUM ctx -> devId = NO_CAVIUM_DEVICE ; #endif #ifndef NO_CERTS ctx -> cm = wolfSSL_CertManagerNew ( ) ; if ( ctx -> cm == NULL ) { WOLFSSL_MSG ( " " ) ; return BAD_CERT_MANAGER_ERROR ; } #endif #if defined ( HAVE_SESSION_TICKET ) && ! defined ( NO_WOLFSSL_SERVER ) ctx -> ticketHint = SESSION_TICKET_HINT_DEFAULT ; #endif return 0 ; }
Initialize SSL context, return 0 on success
Initialize SSL context return 0 on success
/* so either CTX_free or SSL_free can release */ /* defaults to self */ /* current default */ /* WOLFSSL_USER_IO */ /* always on cliet side */ /* server can turn on by loading key */ /* always on cliet side */ /* server turns on with ECC key cert */ /* server can turn on by loading key */