Ignore:
Timestamp:
Feb 7, 2019, 8:36:33 AM (5 years ago)
Author:
coas-nagasima
Message:

wolfsslを3.15.7にバージョンアップ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/test.h

    r352 r372  
    1111#include <wolfssl/wolfcrypt/error-crypt.h>
    1212#include <wolfssl/wolfcrypt/random.h>
     13#include <wolfssl/wolfcrypt/mem_track.h>
     14#if defined(OPENSSL_EXTRA) && defined(SHOW_CERTS)
     15    #include <wolfssl/wolfcrypt/asn.h> /* for domain component NID value */
     16#endif
    1317
    1418#ifdef ATOMIC_USER
     
    2529        #include <wolfssl/wolfcrypt/ecc.h>
    2630    #endif /* HAVE_ECC */
     31    #ifndef NO_DH
     32        #include <wolfssl/wolfcrypt/dh.h>
     33    #endif /* !NO_DH */
    2734    #ifdef HAVE_ED25519
    2835        #include <wolfssl/wolfcrypt/ed25519.h>
     
    5966        #define sleep(t)  osDelay(t/1000+1) ;
    6067    #endif
    61 
    62     static int wolfssl_tcp_select(int sd, int timeout)
    63     {        return 0 ;  }
    64         #define tcp_select(sd,t)   wolfssl_tcp_select(sd, t)  /* avoid conflicting Keil TCP tcp_select */
    6568#elif defined(WOLFSSL_TIRTOS)
    6669    #include <string.h>
     
    122125    #include <wolfssl/wolfcrypt/port/cavium/cavium_nitrox.h>
    123126#endif
    124 
    125127#ifdef _MSC_VER
    126128    /* disable conversion warning */
     
    136138#ifndef WOLFSSL_HAVE_MIN
    137139    #define WOLFSSL_HAVE_MIN
    138     static INLINE word32 min(word32 a, word32 b)
     140    static WC_INLINE word32 min(word32 a, word32 b)
    139141    {
    140142        return a > b ? b : a;
     
    181183#endif
    182184
    183 
    184 #ifdef USE_WINDOWS_API
    185     #define CloseSocket(s) closesocket(s)
    186     #define StartTCP() { WSADATA wsd; WSAStartup(0x0002, &wsd); }
    187 #elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
    188     #define CloseSocket(s) closesocket(s)
    189     #define StartTCP()
    190 #else
    191     #define CloseSocket(s) close(s)
    192     #define StartTCP()
    193 #endif
    194185
    195186
     
    230221
    231222
     223#ifndef WOLFSSL_NO_TLS12
    232224#define SERVER_DEFAULT_VERSION 3
     225#else
     226#define SERVER_DEFAULT_VERSION 4
     227#endif
    233228#define SERVER_DTLS_DEFAULT_VERSION (-2)
    234229#define SERVER_INVALID_VERSION (-99)
     230#define SERVER_DOWNGRADE_VERSION (-98)
     231#ifndef WOLFSSL_NO_TLS12
    235232#define CLIENT_DEFAULT_VERSION 3
     233#else
     234#define CLIENT_DEFAULT_VERSION 4
     235#endif
    236236#define CLIENT_DTLS_DEFAULT_VERSION (-2)
    237237#define CLIENT_INVALID_VERSION (-99)
     238#define CLIENT_DOWNGRADE_VERSION (-98)
     239#define EITHER_DOWNGRADE_VERSION (-97)
    238240#if !defined(NO_FILESYSTEM) && defined(WOLFSSL_MAX_STRENGTH)
    239241    #define DEFAULT_MIN_DHKEY_BITS 2048
     242    #define DEFAULT_MAX_DHKEY_BITS 3072
    240243#else
    241244    #define DEFAULT_MIN_DHKEY_BITS 1024
     245    #define DEFAULT_MAX_DHKEY_BITS 2048
    242246#endif
    243247#if !defined(NO_FILESYSTEM) && defined(WOLFSSL_MAX_STRENGTH)
     
    257261#define eccCertFile    "certs/server-ecc.pem"
    258262#define eccKeyFile     "certs/ecc-key.pem"
     263#define eccRsaCertFile "certs/server-ecc-rsa.pem"
    259264#define svrCertFile    "certs/server-cert.pem"
    260265#define svrKeyFile     "certs/server-key.pem"
    261266#define cliCertFile    "certs/client-cert.pem"
     267#define cliCertDerFile "certs/client-cert.der"
    262268#define cliKeyFile     "certs/client-key.pem"
    263269#define ntruCertFile   "certs/ntru-cert.pem"
     
    268274#define caEccCertFile  "certs/ca-ecc-cert/pem"
    269275#define crlPemDir      "certs/crl"
     276#define edCertFile     "certs/ed25519/server-ed25519-cert.pem"
     277#define edKeyFile      "certs/ed25519/server-ed25519-priv.pem"
     278#define cliEdCertFile  "certs/ed25519/client-ed25519.pem"
     279#define cliEdKeyFile   "certs/ed25519/client-ed25519-priv.pem"
     280#define caEdCertFile   "certs/ed25519/ca-ed25519.pem"
    270281#ifdef HAVE_WNR
    271282    /* Whitewood netRandom default config file */
     
    276287#define eccCertFile    "./certs/server-ecc.pem"
    277288#define eccKeyFile     "./certs/ecc-key.pem"
     289#define eccRsaCertFile "./certs/server-ecc-rsa.pem"
    278290#define svrCertFile    "./certs/server-cert.pem"
    279291#define svrKeyFile     "./certs/server-key.pem"
    280292#define cliCertFile    "./certs/client-cert.pem"
     293#define cliCertDerFile "./certs/client-cert.der"
    281294#define cliKeyFile     "./certs/client-key.pem"
    282295#define ntruCertFile   "./certs/ntru-cert.pem"
     
    287300#define caEccCertFile  "./certs/ca-ecc-cert.pem"
    288301#define crlPemDir      "./certs/crl"
     302#define edCertFile     "./certs/ed25519/server-ed25519.pem"
     303#define edKeyFile      "./certs/ed25519/server-ed25519-priv.pem"
     304#define cliEdCertFile  "./certs/ed25519/client-ed25519.pem"
     305#define cliEdKeyFile   "./certs/ed25519/client-ed25519-priv.pem"
     306#define caEdCertFile   "./certs/ed25519/root-ed25519.pem"
    289307#ifdef HAVE_WNR
    290308    /* Whitewood netRandom default config file */
     
    304322
    305323
    306 static INLINE void InitTcpReady(tcp_ready* ready)
     324static WC_INLINE void InitTcpReady(tcp_ready* ready)
    307325{
    308326    ready->ready = 0;
     
    317335
    318336
    319 static INLINE void FreeTcpReady(tcp_ready* ready)
     337static WC_INLINE void FreeTcpReady(tcp_ready* ready)
    320338{
    321339#ifdef SINGLE_THREADED
     
    338356    ssl_callback ssl_ready;
    339357    ssl_callback on_result;
     358    WOLFSSL_CTX* ctx;
    340359} callback_functions;
    341360
     
    367386
    368387
    369 #if defined(__GNUC__)
    370     #define WC_NORETURN __attribute__((noreturn))
     388
     389#ifndef MY_EX_USAGE
     390#define MY_EX_USAGE 2
     391#endif
     392
     393#ifndef EXIT_FAILURE
     394#define EXIT_FAILURE 1
     395#endif
     396
     397#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
     398    #define XEXIT(rc)   return rc
     399    #define XEXIT_T(rc) return (THREAD_RETURN)rc
    371400#else
    372     #define WC_NORETURN
    373 #endif
    374 
    375 static INLINE WC_NORETURN void err_sys(const char* msg)
     401    #define XEXIT(rc)   exit((int)(rc))
     402    #define XEXIT_T(rc) exit((int)(rc))
     403#endif
     404
     405
     406static WC_INLINE
     407#ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
     408THREAD_RETURN
     409#else
     410WC_NORETURN void
     411#endif
     412err_sys(const char* msg)
    376413{
    377414    printf("wolfSSL error: %s\n", msg);
     
    387424#endif
    388425    {
    389         exit(EXIT_FAILURE);
    390     }
    391 }
    392 
    393 
    394 #define MY_EX_USAGE 2
     426        XEXIT_T(EXIT_FAILURE);
     427    }
     428}
     429
    395430
    396431extern int   myoptind;
    397432extern char* myoptarg;
    398433
    399 static INLINE int mygetopt(int argc, char** argv, const char* optstring)
     434static WC_INLINE int mygetopt(int argc, char** argv, const char* optstring)
    400435{
    401436    static char* next = NULL;
     
    461496
    462497
    463 #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
    464 
    465 static INLINE int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
     498#ifdef WOLFSSL_ENCRYPTED_KEYS
     499
     500static WC_INLINE int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
    466501{
    467502    (void)rw;
    468503    (void)userdata;
     504    if (userdata != NULL) {
     505        strncpy(passwd, (char*)userdata, sz);
     506        return (int)XSTRLEN((char*)userdata);
     507    }
     508    else {
    469509    strncpy(passwd, "yassl123", sz);
    470510    return 8;
    471511}
    472 
    473 #endif
    474 
     512}
     513
     514#endif
     515
     516static const char* client_showpeer_msg[][8] = {
     517    /* English */
     518    {
     519        "SSL version is",
     520        "SSL cipher suite is",
     521        "SSL curve name is",
     522        "SSL DH size is",
     523        "SSL reused session",
     524        "Alternate cert chain used",
     525        "peer's cert info:",
     526        NULL
     527    },
     528    /* Japanese */
     529    {
     530        "SSL バージョンは",
     531        "SSL 暗号スイートは",
     532        "SSL 曲線名は",
     533        "SSL DH サイズは",
     534        "SSL 再利用セッション",
     535        "代替証明チェーンを使用",
     536        "相手方証明書情報",
     537        NULL
     538    }
     539};
    475540
    476541#if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS)
    477 
    478 static INLINE void ShowX509(WOLFSSL_X509* x509, const char* hdr)
     542static const char* client_showx509_msg[][5] = {
     543    /* English */
     544    {
     545        "issuer",
     546        "subject",
     547        "altname",
     548        "serial number",
     549        NULL
     550    },
     551    /* Japanese */
     552    {
     553        "発行者",
     554        "サブジェクト",
     555        "代替名",
     556        "シリアル番号",
     557        NULL
     558    },
     559};
     560
     561/* lng_index is to specify the language for displaying message.              */
     562/* 0:English, 1:Japanese                                                     */
     563static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr,
     564                                                                 int lng_index)
    479565{
    480566    char* altName;
     
    484570    int   ret;
    485571    int   sz = sizeof(serial);
     572    const char** words = client_showx509_msg[lng_index];
    486573
    487574    if (x509 == NULL) {
     
    495582                                     wolfSSL_X509_get_subject_name(x509), 0, 0);
    496583
    497     printf("%s\n issuer : %s\n subject: %s\n", hdr, issuer, subject);
     584    printf("%s\n %s : %s\n %s: %s\n", hdr, words[0], issuer, words[1], subject);
    498585
    499586    while ( (altName = wolfSSL_X509_get_next_altname(x509)) != NULL)
    500         printf(" altname = %s\n", altName);
     587        printf(" %s = %s\n", words[2], altName);
    501588
    502589    ret = wolfSSL_X509_get_serial_number(x509, serial, &sz);
     
    508595        /* testsuite has multiple threads writing to stdout, get output
    509596           message ready to write once */
    510         strLen = sprintf(serialMsg, " serial number");
     597        strLen = sprintf(serialMsg, " %s", words[3]);
    511598        for (i = 0; i < sz; i++)
    512599            sprintf(serialMsg + strLen + (i*3), ":%02x ", serial[i]);
     
    516603    XFREE(subject, 0, DYNAMIC_TYPE_OPENSSL);
    517604    XFREE(issuer,  0, DYNAMIC_TYPE_OPENSSL);
     605
     606#if defined(OPENSSL_EXTRA) && defined(SHOW_CERTS)
     607    {
     608        WOLFSSL_BIO* bio;
     609        char buf[256]; /* should be size of ASN_NAME_MAX */
     610        int  textSz;
     611
     612
     613        /* print out domain component if certificate has it */
     614        textSz = wolfSSL_X509_NAME_get_text_by_NID(
     615                wolfSSL_X509_get_subject_name(x509), NID_domainComponent,
     616                buf, sizeof(buf));
     617        if (textSz > 0) {
     618            printf("Domain Component = %s\n", buf);
     619        }
     620
     621        bio = wolfSSL_BIO_new(wolfSSL_BIO_s_file());
     622        if (bio != NULL) {
     623            wolfSSL_BIO_set_fp(bio, stdout, BIO_NOCLOSE);
     624            wolfSSL_X509_print(bio, x509);
     625            wolfSSL_BIO_free(bio);
     626        }
     627    }
     628#endif
     629}
     630/* original ShowX509 to maintain compatibility */
     631static WC_INLINE void ShowX509(WOLFSSL_X509* x509, const char* hdr)
     632{
     633    ShowX509Ex(x509, hdr, 0);
    518634}
    519635
     
    521637
    522638#if defined(SESSION_CERTS) && defined(SHOW_CERTS)
    523 static INLINE void ShowX509Chain(WOLFSSL_X509_CHAIN* chain, int count,
     639static WC_INLINE void ShowX509Chain(WOLFSSL_X509_CHAIN* chain, int count,
    524640    const char* hdr)
    525641{
     
    544660#endif
    545661
    546 static INLINE void showPeer(WOLFSSL* ssl)
     662/* lng_index is to specify the language for displaying message.              */
     663/* 0:English, 1:Japanese                                                     */
     664static WC_INLINE void showPeerEx(WOLFSSL* ssl, int lng_index)
    547665{
    548666    WOLFSSL_CIPHER* cipher;
     667    const char** words = client_showpeer_msg[lng_index];
     668
    549669#ifdef HAVE_ECC
    550670    const char *name;
     
    556676    WOLFSSL_X509* peer = wolfSSL_get_peer_certificate(ssl);
    557677    if (peer)
    558         ShowX509(peer, "peer's cert info:");
     678        ShowX509Ex(peer, words[6], lng_index);
    559679    else
    560680        printf("peer has no cert!\n");
     
    565685    printf("Peer verify result = %lu\n", wolfSSL_get_verify_result(ssl));
    566686#endif /* SHOW_CERTS */
    567     printf("SSL version is %s\n", wolfSSL_get_version(ssl));
     687    printf("%s %s\n", words[0], wolfSSL_get_version(ssl));
    568688
    569689    cipher = wolfSSL_get_current_cipher(ssl);
    570690#ifdef HAVE_QSH
    571     printf("SSL cipher suite is %s%s\n", (wolfSSL_isQSH(ssl))? "QSH:": "",
     691    printf("%s %s%s\n", words[1], (wolfSSL_isQSH(ssl))? "QSH:": "",
    572692            wolfSSL_CIPHER_get_name(cipher));
    573693#else
    574     printf("SSL cipher suite is %s\n", wolfSSL_CIPHER_get_name(cipher));
     694    printf("%s %s\n", words[1], wolfSSL_CIPHER_get_name(cipher));
    575695#endif
    576696#ifdef HAVE_ECC
    577697    if ((name = wolfSSL_get_curve_name(ssl)) != NULL)
    578         printf("SSL curve name is %s\n", name);
     698        printf("%s %s\n", words[2], name);
    579699#endif
    580700#ifndef NO_DH
    581701    if ((bits = wolfSSL_GetDhKey_Sz(ssl)) > 0)
    582         printf("SSL DH size is %d bits\n", bits);
     702        printf("%s %d bits\n", words[3], bits);
    583703#endif
    584704    if (wolfSSL_session_reused(ssl))
    585         printf("SSL reused session\n");
     705        printf("%s\n", words[4]);
    586706#ifdef WOLFSSL_ALT_CERT_CHAINS
    587707    if (wolfSSL_is_peer_alt_cert_chain(ssl))
    588         printf("Alternate cert chain used\n");
     708        printf("%s\n", words[5]);
    589709#endif
    590710
     
    606726  (void)ssl;
    607727}
    608 
    609 
    610 static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
     728/* original showPeer to maintain compatibility */
     729static WC_INLINE void showPeer(WOLFSSL* ssl)
     730{
     731    showPeerEx(ssl, 0);
     732}
     733
     734static WC_INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
    611735                              word16 port, int udp, int sctp)
    612736{
     
    619743        err_sys("invalid argument to build_addr, addr is NULL");
    620744
    621     memset(addr, 0, sizeof(SOCKADDR_IN_T));
     745    XMEMSET(addr, 0, sizeof(SOCKADDR_IN_T));
    622746
    623747#ifndef TEST_IPV6
     
    662786    addr->sin6_family = AF_INET_V;
    663787    addr->sin6_port = XHTONS(port);
    664     if (peer == INADDR_ANY)
     788    if ((size_t)peer == INADDR_ANY) {
    665789        addr->sin6_addr = in6addr_any;
     790    }
    666791    else {
    667792        #ifdef HAVE_GETADDRINFO
     
    671796            char   strPort[80];
    672797
    673             memset(&hints, 0, sizeof(hints));
     798            XMEMSET(&hints, 0, sizeof(hints));
    674799
    675800            hints.ai_family   = AF_INET_V;
     
    707832
    708833
    709 static INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
     834static WC_INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
    710835{
    711836    (void)sctp;
     
    753878}
    754879
    755 static INLINE void tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port,
     880static WC_INLINE void tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port,
    756881                               int udp, int sctp, WOLFSSL* ssl)
    757882{
     
    770895
    771896
    772 static INLINE void udp_connect(SOCKET_T* sockfd, void* addr, int addrSz)
     897static WC_INLINE void udp_connect(SOCKET_T* sockfd, void* addr, int addrSz)
    773898{
    774899    if (connect(*sockfd, (const struct sockaddr*)addr, addrSz) != 0)
     
    787912#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_TCP_NET) && \
    788913                                 !defined(WOLFSSL_TIRTOS)
    789 static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
     914static WC_INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
    790915{
    791916    fd_set recvfds, errfds;
    792917    SOCKET_T nfds = socketfd + 1;
     918#if !defined(__INTEGRITY)
    793919    struct timeval timeout = { (to_sec > 0) ? to_sec : 0, 0};
     920#else
     921    struct timeval timeout;
     922#endif
    794923    int result;
    795924
     
    799928    FD_SET(socketfd, &errfds);
    800929
     930#if defined(__INTEGRITY)
     931    timeout.tv_sec = (long long)(to_sec > 0) ? to_sec : 0, 0;
     932#endif
    801933    result = select(nfds, &recvfds, NULL, &errfds, &timeout);
    802934
     
    812944    return TEST_SELECT_FAIL;
    813945}
    814 #elif defined(WOLFSSL_TIRTOS)
    815 static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
     946#elif defined(WOLFSSL_TIRTOS) || defined(WOLFSSL_KEIL_TCP_NET)
     947static WC_INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
    816948{
    817949    return TEST_RECV_READY;
     
    820952
    821953
    822 static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr,
     954static WC_INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr,
    823955                              int udp, int sctp)
    824956{
     
    844976        err_sys("tcp bind failed");
    845977    if (!udp) {
    846         if (listen(*sockfd, 5) != 0)
     978        #ifdef WOLFSSL_KEIL_TCP_NET
     979            #define SOCK_LISTEN_MAX_QUEUE 1
     980        #else
     981            #define SOCK_LISTEN_MAX_QUEUE 5
     982        #endif
     983        if (listen(*sockfd, SOCK_LISTEN_MAX_QUEUE) != 0)
    847984            err_sys("tcp listen failed");
    848985    }
     
    8631000
    8641001#if 0
    865 static INLINE int udp_read_connect(SOCKET_T sockfd)
     1002static WC_INLINE int udp_read_connect(SOCKET_T sockfd)
    8661003{
    8671004    SOCKADDR_IN_T cliaddr;
     
    8841021#endif
    8851022
    886 static INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
     1023static WC_INLINE void udp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
    8871024                              int useAnyAddr, word16 port, func_args* args)
    8881025{
     
    9411078}
    9421079
    943 static INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
     1080static WC_INLINE void tcp_accept(SOCKET_T* sockfd, SOCKET_T* clientfd,
    9441081                              func_args* args, word16 port, int useAnyAddr,
    9451082                              int udp, int sctp, int ready_file, int do_listen)
     
    9821119        if (ready_file) {
    9831120        #if !defined(NO_FILESYSTEM) || defined(FORCE_BUFFER_TEST)
    984             FILE* srf = NULL;
     1121            XFILE srf = NULL;
    9851122            if (args)
    9861123                ready = args->signal;
     
    10111148
    10121149
    1013 static INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
     1150static WC_INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
    10141151{
    10151152    #ifdef USE_WINDOWS_API
     
    10371174static const char* kIdentityStr = "Client_identity";
    10381175
    1039 static INLINE unsigned int my_psk_client_cb(WOLFSSL* ssl, const char* hint,
     1176static WC_INLINE unsigned int my_psk_client_cb(WOLFSSL* ssl, const char* hint,
    10401177        char* identity, unsigned int id_max_len, unsigned char* key,
    10411178        unsigned int key_max_len)
     
    10481185    strncpy(identity, kIdentityStr, id_max_len);
    10491186
     1187    if (wolfSSL_GetVersion(ssl) < WOLFSSL_TLSV1_3) {
    10501188    /* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
    10511189       unsigned binary */
    1052     key[0] = 26;
    1053     key[1] = 43;
    1054     key[2] = 60;
    1055     key[3] = 77;
     1190        key[0] = 0x1a;
     1191        key[1] = 0x2b;
     1192        key[2] = 0x3c;
     1193        key[3] = 0x4d;
     1194
    10561195
    10571196    return 4;   /* length of key in octets or 0 for error */
    10581197}
    1059 
    1060 
    1061 static INLINE unsigned int my_psk_server_cb(WOLFSSL* ssl, const char* identity,
     1198    else {
     1199        int i;
     1200        int b = 0x01;
     1201
     1202        for (i = 0; i < 32; i++, b += 0x22) {
     1203            if (b >= 0x100)
     1204                b = 0x01;
     1205            key[i] = b;
     1206        }
     1207
     1208        return 32;   /* length of key in octets or 0 for error */
     1209    }
     1210}
     1211
     1212
     1213static WC_INLINE unsigned int my_psk_server_cb(WOLFSSL* ssl, const char* identity,
    10621214        unsigned char* key, unsigned int key_max_len)
    10631215{
     
    10691221        return 0;
    10701222
     1223    if (wolfSSL_GetVersion(ssl) < WOLFSSL_TLSV1_3) {
    10711224    /* test key in hex is 0x1a2b3c4d , in decimal 439,041,101 , we're using
    10721225       unsigned binary */
    1073     key[0] = 26;
    1074     key[1] = 43;
    1075     key[2] = 60;
    1076     key[3] = 77;
     1226        key[0] = 0x1a;
     1227        key[1] = 0x2b;
     1228        key[2] = 0x3c;
     1229        key[3] = 0x4d;
     1230
    10771231
    10781232    return 4;   /* length of key in octets or 0 for error */
     1233}
     1234    else {
     1235        int i;
     1236        int b = 0x01;
     1237
     1238        for (i = 0; i < 32; i++, b += 0x22) {
     1239            if (b >= 0x100)
     1240                b = 0x01;
     1241            key[i] = b;
     1242        }
     1243
     1244        return 32;   /* length of key in octets or 0 for error */
     1245    }
     1246}
     1247
     1248
     1249static WC_INLINE unsigned int my_psk_client_tls13_cb(WOLFSSL* ssl,
     1250        const char* hint, char* identity, unsigned int id_max_len,
     1251        unsigned char* key, unsigned int key_max_len, const char** ciphersuite)
     1252{
     1253    int i;
     1254    int b = 0x01;
     1255
     1256    (void)ssl;
     1257    (void)hint;
     1258    (void)key_max_len;
     1259
     1260    /* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
     1261    strncpy(identity, kIdentityStr, id_max_len);
     1262
     1263    for (i = 0; i < 32; i++, b += 0x22) {
     1264        if (b >= 0x100)
     1265            b = 0x01;
     1266        key[i] = b;
     1267    }
     1268
     1269    *ciphersuite = "TLS13-AES128-GCM-SHA256";
     1270
     1271    return 32;   /* length of key in octets or 0 for error */
     1272}
     1273
     1274
     1275static WC_INLINE unsigned int my_psk_server_tls13_cb(WOLFSSL* ssl,
     1276        const char* identity, unsigned char* key, unsigned int key_max_len,
     1277        const char** ciphersuite)
     1278{
     1279    int i;
     1280    int b = 0x01;
     1281
     1282    (void)ssl;
     1283    (void)key_max_len;
     1284
     1285    /* see internal.h MAX_PSK_ID_LEN for PSK identity limit */
     1286    if (strncmp(identity, kIdentityStr, strlen(kIdentityStr)) != 0)
     1287        return 0;
     1288
     1289    for (i = 0; i < 32; i++, b += 0x22) {
     1290        if (b >= 0x100)
     1291            b = 0x01;
     1292        key[i] = b;
     1293    }
     1294
     1295    *ciphersuite = "TLS13-AES128-GCM-SHA256";
     1296
     1297    return 32;   /* length of key in octets or 0 for error */
    10791298}
    10801299
     
    10901309    #include <windows.h>
    10911310
    1092     static INLINE double current_time(int reset)
     1311    static WC_INLINE double current_time(int reset)
    10931312    {
    10941313        static int init = 0;
     
    11121331#else
    11131332
    1114 #if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_TCP_NET)
     1333#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_TCP_NET) && !defined(WOLFSSL_CHIBIOS)
    11151334    #include <sys/time.h>
    11161335
    1117     static INLINE double current_time(int reset)
     1336    static WC_INLINE double current_time(int reset)
    11181337    {
    11191338        struct timeval tv;
     
    11291348
    11301349
     1350#if defined(HAVE_OCSP) && defined(WOLFSSL_NONBLOCK_OCSP)
     1351static WC_INLINE int OCSPIOCb(void* ioCtx, const char* url, int urlSz,
     1352    unsigned char* request, int requestSz, unsigned char** response)
     1353{
     1354#ifdef TEST_NONBLOCK_CERTS
     1355    static int ioCbCnt = 0;
     1356#endif
     1357
     1358    (void)ioCtx;
     1359    (void)url;
     1360    (void)urlSz;
     1361    (void)request;
     1362    (void)requestSz;
     1363    (void)response;
     1364
     1365#ifdef TEST_NONBLOCK_CERTS
     1366    if (ioCbCnt) {
     1367        ioCbCnt = 0;
     1368        return EmbedOcspLookup(ioCtx, url, urlSz, request, requestSz, response);
     1369    }
     1370    else {
     1371        ioCbCnt = 1;
     1372        return WOLFSSL_CBIO_ERR_WANT_READ;
     1373    }
     1374#else
     1375    return EmbedOcspLookup(ioCtx, url, urlSz, request, requestSz, response);
     1376#endif
     1377}
     1378
     1379static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
     1380{
     1381    (void)ioCtx;
     1382    (void)response;
     1383}
     1384#endif
     1385
    11311386#if !defined(NO_CERTS)
    11321387    #if !defined(NO_FILESYSTEM) || \
     
    11341389
    11351390    /* reads file size, allocates buffer, reads into buffer, returns buffer */
    1136     static INLINE int load_file(const char* fname, byte** buf, size_t* bufLen)
     1391    static WC_INLINE int load_file(const char* fname, byte** buf, size_t* bufLen)
    11371392    {
    11381393        int ret;
    11391394        long int fileSz;
    1140         FILE* file;
     1395        XFILE file;
    11411396
    11421397        if (fname == NULL || buf == NULL || bufLen == NULL)
     
    11861441    };
    11871442
    1188     static INLINE void load_buffer(WOLFSSL_CTX* ctx, const char* fname, int type)
     1443    static WC_INLINE void load_buffer(WOLFSSL_CTX* ctx, const char* fname, int type)
    11891444    {
    11901445        int format = WOLFSSL_FILETYPE_PEM;
     
    12251480            free(buff);
    12261481    }
     1482
     1483    static WC_INLINE void load_ssl_buffer(WOLFSSL* ssl, const char* fname, int type)
     1484    {
     1485        int format = WOLFSSL_FILETYPE_PEM;
     1486        byte* buff = NULL;
     1487        size_t sz = 0;
     1488
     1489        if (load_file(fname, &buff, &sz) != 0) {
     1490            err_sys("can't open file for buffer load "
     1491                    "Please run from wolfSSL home directory if not");
     1492        }
     1493
     1494        /* determine format */
     1495        if (strstr(fname, ".der"))
     1496            format = WOLFSSL_FILETYPE_ASN1;
     1497
     1498        if (type == WOLFSSL_CA) {
     1499            /* verify certs (CA's) use the shared ctx->cm (WOLFSSL_CERT_MANAGER) */
     1500            WOLFSSL_CTX* ctx = wolfSSL_get_SSL_CTX(ssl);
     1501            if (wolfSSL_CTX_load_verify_buffer(ctx, buff, (long)sz, format)
     1502                                              != WOLFSSL_SUCCESS)
     1503                err_sys("can't load buffer ca file");
     1504        }
     1505        else if (type == WOLFSSL_CERT) {
     1506            if (wolfSSL_use_certificate_buffer(ssl, buff, (long)sz,
     1507                        format) != WOLFSSL_SUCCESS)
     1508                err_sys("can't load buffer cert file");
     1509        }
     1510        else if (type == WOLFSSL_KEY) {
     1511            if (wolfSSL_use_PrivateKey_buffer(ssl, buff, (long)sz,
     1512                        format) != WOLFSSL_SUCCESS)
     1513                err_sys("can't load buffer key file");
     1514        }
     1515        else if (type == WOLFSSL_CERT_CHAIN) {
     1516            if (wolfSSL_use_certificate_chain_buffer_format(ssl, buff,
     1517                    (long)sz, format) != WOLFSSL_SUCCESS)
     1518                err_sys("can't load cert chain buffer");
     1519        }
     1520
     1521        if (buff)
     1522            free(buff);
     1523    }
     1524
     1525    #ifdef TEST_PK_PRIVKEY
     1526    static WC_INLINE int load_key_file(const char* fname, byte** derBuf, word32* derLen)
     1527    {
     1528        int ret;
     1529        byte* buf = NULL;
     1530        size_t bufLen;
     1531
     1532        ret = load_file(fname, &buf, &bufLen);
     1533        if (ret != 0)
     1534            return ret;
     1535
     1536        *derBuf = (byte*)malloc(bufLen);
     1537        if (*derBuf == NULL) {
     1538            free(buf);
     1539            return MEMORY_E;
     1540        }
     1541
     1542        ret = wc_KeyPemToDer(buf, (word32)bufLen, *derBuf, (word32)bufLen, NULL);
     1543        if (ret < 0) {
     1544            free(buf);
     1545            free(*derBuf);
     1546            return ret;
     1547        }
     1548        *derLen = ret;
     1549        free(buf);
     1550
     1551        return 0;
     1552    }
     1553    #endif /* TEST_PK_PRIVKEY */
     1554
    12271555    #endif /* !NO_FILESYSTEM || (NO_FILESYSTEM && FORCE_BUFFER_TEST) */
    12281556#endif /* !NO_CERTS */
    12291557
    1230 static INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
     1558static int myVerifyFail = 0;
     1559static WC_INLINE int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
    12311560{
    12321561    char buffer[WOLFSSL_MAX_ERROR_SZ];
    1233 #ifdef OPENSSL_EXTRA
     1562#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
    12341563    WOLFSSL_X509* peer;
    12351564#endif
    12361565    (void)preverify;
     1566
     1567    /* Verify Callback Arguments:
     1568     * preverify:           1=Verify Okay, 0=Failure
     1569     * store->error:        Failure error code (0 indicates no failure)
     1570     * store->current_cert: Current WOLFSSL_X509 object (only with OPENSSL_EXTRA)
     1571     * store->error_depth:  Current Index
     1572     * store->domain:       Subject CN as string (null term)
     1573     * store->totalCerts:   Number of certs presented by peer
     1574     * store->certs[i]:     A `WOLFSSL_BUFFER_INFO` with plain DER for each cert
     1575     * store->store:        WOLFSSL_X509_STORE with CA cert chain
     1576     * store->store->cm:    WOLFSSL_CERT_MANAGER
     1577     * store->ex_data:      The WOLFSSL object pointer
     1578     * store->discardSessionCerts: When set to non-zero value session certs
     1579        will be discarded (only with SESSION_CERTS)
     1580     */
    12371581
    12381582    printf("In verification callback, error = %d, %s\n", store->error,
    12391583                                 wolfSSL_ERR_error_string(store->error, buffer));
    1240 #ifdef OPENSSL_EXTRA
     1584#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
    12411585    peer = store->current_cert;
    12421586    if (peer) {
     
    12641608#endif
    12651609
    1266     printf("\tSubject's domain name is %s\n", store->domain);
    1267 
    1268     printf("\tAllowing to continue anyway (shouldn't do this, EVER!!!)\n");
     1610    printf("\tSubject's domain name at %d is %s\n", store->error_depth, store->domain);
     1611
     1612    /* Testing forced fail case by return zero */
     1613    if (myVerifyFail) {
     1614        return 0; /* test failure case */
     1615    }
     1616
     1617    /* If error indicate we are overriding it for testing purposes */
     1618    if (store->error != 0) {
     1619        printf("\tAllowing failed certificate check, testing only "
     1620            "(shouldn't do this in production)\n");
     1621    }
     1622
     1623    /* A non-zero return code indicates failure override */
    12691624    return 1;
    12701625}
    12711626
    12721627
    1273 static INLINE int myDateCb(int preverify, WOLFSSL_X509_STORE_CTX* store)
     1628static WC_INLINE int myDateCb(int preverify, WOLFSSL_X509_STORE_CTX* store)
    12741629{
    12751630    char buffer[WOLFSSL_MAX_ERROR_SZ];
     
    12901645
    12911646
     1647#ifdef HAVE_EXT_CACHE
     1648
     1649static WC_INLINE WOLFSSL_SESSION* mySessGetCb(WOLFSSL* ssl, unsigned char* id,
     1650    int id_len, int* copy)
     1651{
     1652    (void)ssl;
     1653    (void)id;
     1654    (void)id_len;
     1655    (void)copy;
     1656
     1657    /* using internal cache, this is for testing only */
     1658    return NULL;
     1659}
     1660
     1661static WC_INLINE int mySessNewCb(WOLFSSL* ssl, WOLFSSL_SESSION* session)
     1662{
     1663    (void)ssl;
     1664    (void)session;
     1665
     1666    /* using internal cache, this is for testing only */
     1667    return 0;
     1668}
     1669
     1670static WC_INLINE void mySessRemCb(WOLFSSL_CTX* ctx, WOLFSSL_SESSION* session)
     1671{
     1672    (void)ctx;
     1673    (void)session;
     1674
     1675    /* using internal cache, this is for testing only */
     1676}
     1677
     1678#endif /* HAVE_EXT_CACHE */
     1679
     1680
    12921681#ifdef HAVE_CRL
    12931682
    1294 static INLINE void CRL_CallBack(const char* url)
     1683static WC_INLINE void CRL_CallBack(const char* url)
    12951684{
    12961685    printf("CRL callback url = %s\n", url);
     
    13001689
    13011690#ifndef NO_DH
    1302 static INLINE void SetDH(WOLFSSL* ssl)
     1691static WC_INLINE void SetDH(WOLFSSL* ssl)
    13031692{
    13041693    /* dh1024 p */
    1305     static unsigned char p[] =
     1694    static const unsigned char p[] =
    13061695    {
    13071696        0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
     
    13191708
    13201709    /* dh1024 g */
    1321     static unsigned char g[] =
     1710    static const unsigned char g[] =
    13221711    {
    13231712      0x02,
     
    13271716}
    13281717
    1329 static INLINE void SetDHCtx(WOLFSSL_CTX* ctx)
     1718static WC_INLINE void SetDHCtx(WOLFSSL_CTX* ctx)
    13301719{
    13311720    /* dh1024 p */
    1332     static unsigned char p[] =
     1721    static const unsigned char p[] =
    13331722    {
    13341723        0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
     
    13461735
    13471736    /* dh1024 g */
    1348     static unsigned char g[] =
     1737    static const unsigned char g[] =
    13491738    {
    13501739      0x02,
     
    13571746#ifndef NO_CERTS
    13581747
    1359 static INLINE void CaCb(unsigned char* der, int sz, int type)
     1748static WC_INLINE void CaCb(unsigned char* der, int sz, int type)
    13601749{
    13611750    (void)der;
     
    13721761    #define MAX_WOLF_ROOT_DEPTH 5
    13731762
    1374     static INLINE int ChangeToWolfRoot(void)
     1763    static WC_INLINE int ChangeToWolfRoot(void)
    13751764    {
    13761765        #if !defined(NO_FILESYSTEM) || defined(FORCE_BUFFER_TEST)
    13771766            int depth, res;
    1378             FILE* file;
     1767            XFILE file;
    13791768            for(depth = 0; depth <= MAX_WOLF_ROOT_DEPTH; depth++) {
    13801769                file = fopen(ntruKeyFile, "rb");
     
    14071796#define STACK_CHECK_VAL 0x01
    14081797
    1409 static INLINE int StackSizeCheck(func_args* args, thread_func tf)
     1798static WC_INLINE int StackSizeCheck(func_args* args, thread_func tf)
    14101799{
    14111800    int            ret, i, used;
     
    14761865#endif /* HAVE_STACK_SIZE */
    14771866
    1478 static INLINE void StackTrap(void)
     1867static WC_INLINE void StackTrap(void)
    14791868{
    14801869    struct rlimit  rl;
     
    14911880#else /* STACK_TRAP */
    14921881
    1493 static INLINE void StackTrap(void)
     1882static WC_INLINE void StackTrap(void)
    14941883{
    14951884}
     
    15141903
    15151904
    1516 static INLINE int myMacEncryptCb(WOLFSSL* ssl, unsigned char* macOut,
     1905static WC_INLINE int myMacEncryptCb(WOLFSSL* ssl, unsigned char* macOut,
    15171906       const unsigned char* macIn, unsigned int macInSz, int macContent,
    15181907       int macVerify, unsigned char* encOut, const unsigned char* encIn,
     
    15821971
    15831972
    1584 static INLINE int myDecryptVerifyCb(WOLFSSL* ssl,
     1973static WC_INLINE int myDecryptVerifyCb(WOLFSSL* ssl,
    15851974       unsigned char* decOut, const unsigned char* decIn,
    15861975       unsigned int decSz, int macContent, int macVerify,
     
    15961985    Hmac hmac;
    15971986    byte myInner[WOLFSSL_TLS_HMAC_INNER_SZ];
    1598     byte verify[MAX_DIGEST_SIZE];
     1987    byte verify[WC_MAX_DIGEST_SIZE];
    15991988    const char* tlsStr = "TLS";
    16001989
     
    16802069
    16812070
    1682 static INLINE void SetupAtomicUser(WOLFSSL_CTX* ctx, WOLFSSL* ssl)
     2071static WC_INLINE void SetupAtomicUser(WOLFSSL_CTX* ctx, WOLFSSL* ssl)
    16832072{
    16842073    AtomicEncCtx* encCtx;
     
    16882077    if (encCtx == NULL)
    16892078        err_sys("AtomicEncCtx malloc failed");
    1690     memset(encCtx, 0, sizeof(AtomicEncCtx));
     2079    XMEMSET(encCtx, 0, sizeof(AtomicEncCtx));
    16912080
    16922081    decCtx = (AtomicDecCtx*)malloc(sizeof(AtomicDecCtx));
     
    16952084        err_sys("AtomicDecCtx malloc failed");
    16962085    }
    1697     memset(decCtx, 0, sizeof(AtomicDecCtx));
     2086    XMEMSET(decCtx, 0, sizeof(AtomicDecCtx));
    16982087
    16992088    wolfSSL_CTX_SetMacEncryptCb(ctx, myMacEncryptCb);
     
    17052094
    17062095
    1707 static INLINE void FreeAtomicUser(WOLFSSL* ssl)
     2096static WC_INLINE void FreeAtomicUser(WOLFSSL* ssl)
    17082097{
    17092098    AtomicEncCtx* encCtx = (AtomicEncCtx*)wolfSSL_GetMacEncryptCtx(ssl);
     
    17172106
    17182107#ifdef WOLFSSL_STATIC_MEMORY
    1719 static INLINE int wolfSSL_PrintStats(WOLFSSL_MEM_STATS* stats)
     2108static WC_INLINE int wolfSSL_PrintStats(WOLFSSL_MEM_STATS* stats)
    17202109{
    17212110    word16 i;
     
    17442133#ifdef HAVE_PK_CALLBACKS
    17452134
     2135typedef struct PkCbInfo {
     2136    const char* ourKey;
     2137#ifdef TEST_PK_PRIVKEY
     2138    union {
    17462139#ifdef HAVE_ECC
    1747 
    1748 static INLINE int myEccSign(WOLFSSL* ssl, const byte* in, word32 inSz,
    1749         byte* out, word32* outSz, const byte* key, word32 keySz, void* ctx)
    1750 {
     2140        ecc_key ecc;
     2141    #endif
     2142    #ifdef HAVE_CURVE25519
     2143        curve25519_key curve;
     2144    #endif
     2145    } keyGen;
     2146#endif
     2147} PkCbInfo;
     2148
     2149#if defined(DEBUG_PK_CB) || defined(TEST_PK_PRIVKEY)
     2150    #define WOLFSSL_PKMSG(_f_, ...) printf(_f_, ##__VA_ARGS__)
     2151#else
     2152    #define WOLFSSL_PKMSG(_f_, ...)
     2153#endif
     2154
     2155#ifdef HAVE_ECC
     2156
     2157static WC_INLINE int myEccKeyGen(WOLFSSL* ssl, ecc_key* key, word32 keySz,
     2158    int ecc_curve, void* ctx)
     2159{
     2160    int       ret;
    17512161    WC_RNG  rng;
    1752     int     ret;
    1753     word32  idx = 0;
    1754     ecc_key myKey;
     2162    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
     2163    ecc_key*  new_key = key;
     2164#ifdef TEST_PK_PRIVKEY
     2165    byte qx[MAX_ECC_BYTES], qy[MAX_ECC_BYTES];
     2166    word32 qxLen = sizeof(qx), qyLen = sizeof(qy);
     2167    new_key = &cbInfo->keyGen.ecc;
     2168#endif
    17552169
    17562170    (void)ssl;
    1757     (void)ctx;
     2171    (void)cbInfo;
     2172
     2173    WOLFSSL_PKMSG("PK ECC KeyGen: keySz %d, Curve ID %d\n", keySz, ecc_curve);
    17582174
    17592175    ret = wc_InitRng(&rng);
     
    17612177        return ret;
    17622178
     2179    ret = wc_ecc_init(new_key);
     2180    if (ret == 0) {
     2181        /* create new key */
     2182        ret = wc_ecc_make_key_ex(&rng, keySz, new_key, ecc_curve);
     2183
     2184    #ifdef TEST_PK_PRIVKEY
     2185        if (ret == 0) {
     2186            /* extract public portion from new key into `key` arg */
     2187            ret = wc_ecc_export_public_raw(new_key, qx, &qxLen, qy, &qyLen);
     2188            if (ret == 0) {
     2189                /* load public portion only into key */
     2190                ret = wc_ecc_import_unsigned(key, qx, qy, NULL, ecc_curve);
     2191            }
     2192            (void)qxLen;
     2193            (void)qyLen;
     2194        }
     2195    #endif
     2196    }
     2197
     2198    WOLFSSL_PKMSG("PK ECC KeyGen: ret %d\n", ret);
     2199
     2200    wc_FreeRng(&rng);
     2201
     2202    return ret;
     2203}
     2204
     2205static WC_INLINE int myEccSign(WOLFSSL* ssl, const byte* in, word32 inSz,
     2206        byte* out, word32* outSz, const byte* key, word32 keySz, void* ctx)
     2207{
     2208    int     ret;
     2209    WC_RNG    rng;
     2210    word32  idx = 0;
     2211    ecc_key myKey;
     2212    byte*     keyBuf = (byte*)key;
     2213    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
     2214
     2215    (void)ssl;
     2216    (void)cbInfo;
     2217
     2218    WOLFSSL_PKMSG("PK ECC Sign: inSz %d, keySz %d\n", inSz, keySz);
     2219
     2220#ifdef TEST_PK_PRIVKEY
     2221    ret = load_key_file(cbInfo->ourKey, &keyBuf, &keySz);
     2222    if (ret != 0)
     2223        return ret;
     2224#endif
     2225
     2226    ret = wc_InitRng(&rng);
     2227    if (ret != 0)
     2228        return ret;
     2229
    17632230    ret = wc_ecc_init(&myKey);
    17642231    if (ret == 0) {
    1765         ret = wc_EccPrivateKeyDecode(key, &idx, &myKey, keySz);
    1766         if (ret == 0)
     2232        ret = wc_EccPrivateKeyDecode(keyBuf, &idx, &myKey, keySz);
     2233        if (ret == 0) {
     2234            WOLFSSL_PKMSG("PK ECC Sign: Curve ID %d\n", myKey.dp->id);
    17672235            ret = wc_ecc_sign_hash(in, inSz, out, outSz, &rng, &myKey);
     2236        }
    17682237        wc_ecc_free(&myKey);
    17692238    }
    17702239    wc_FreeRng(&rng);
    17712240
     2241#ifdef TEST_PK_PRIVKEY
     2242    free(keyBuf);
     2243#endif
     2244
     2245    WOLFSSL_PKMSG("PK ECC Sign: ret %d outSz %d\n", ret, *outSz);
     2246
    17722247    return ret;
    17732248}
    17742249
    17752250
    1776 static INLINE int myEccVerify(WOLFSSL* ssl, const byte* sig, word32 sigSz,
     2251static WC_INLINE int myEccVerify(WOLFSSL* ssl, const byte* sig, word32 sigSz,
    17772252        const byte* hash, word32 hashSz, const byte* key, word32 keySz,
    17782253        int* result, void* ctx)
    17792254{
    17802255    int     ret;
     2256    word32    idx = 0;
    17812257    ecc_key myKey;
     2258    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    17822259
    17832260    (void)ssl;
    1784     (void)ctx;
     2261    (void)cbInfo;
     2262
     2263    WOLFSSL_PKMSG("PK ECC Verify: sigSz %d, hashSz %d, keySz %d\n", sigSz, hashSz, keySz);
    17852264
    17862265    ret = wc_ecc_init(&myKey);
    17872266    if (ret == 0) {
    1788         ret = wc_ecc_import_x963(key, keySz, &myKey);
     2267        ret = wc_EccPublicKeyDecode(key, &idx, &myKey, keySz);
    17892268        if (ret == 0)
    17902269            ret = wc_ecc_verify_hash(sig, sigSz, hash, hashSz, result, &myKey);
     
    17922271    }
    17932272
     2273    WOLFSSL_PKMSG("PK ECC Verify: ret %d, result %d\n", ret, *result);
     2274
    17942275    return ret;
    17952276}
    17962277
    1797 static INLINE int myEccSharedSecret(WOLFSSL* ssl, ecc_key* otherKey,
     2278static WC_INLINE int myEccSharedSecret(WOLFSSL* ssl, ecc_key* otherKey,
    17982279        unsigned char* pubKeyDer, unsigned int* pubKeySz,
    17992280        unsigned char* out, unsigned int* outlen,
     
    18042285    ecc_key* pubKey = NULL;
    18052286    ecc_key  tmpKey;
     2287    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    18062288
    18072289    (void)ssl;
    1808     (void)ctx;
     2290    (void)cbInfo;
     2291
     2292    WOLFSSL_PKMSG("PK ECC PMS: Side %s, Peer Curve %d\n",
     2293        side == WOLFSSL_CLIENT_END ? "client" : "server", otherKey->dp->id);
    18092294
    18102295    ret = wc_ecc_init(&tmpKey);
     
    18362321    /* for server: import public key */
    18372322    else if (side == WOLFSSL_SERVER_END) {
     2323    #ifdef TEST_PK_PRIVKEY
     2324        privKey = &cbInfo->keyGen.ecc;
     2325    #else
    18382326        privKey = otherKey;
     2327    #endif
    18392328        pubKey = &tmpKey;
    18402329
     
    18572346    }
    18582347
     2348#ifdef TEST_PK_PRIVKEY
     2349    if (side == WOLFSSL_SERVER_END) {
     2350        wc_ecc_free(&cbInfo->keyGen.ecc);
     2351    }
     2352#endif
     2353
    18592354    wc_ecc_free(&tmpKey);
    18602355
     2356    WOLFSSL_PKMSG("PK ECC PMS: ret %d, PubKeySz %d, OutLen %d\n", ret, *pubKeySz, *outlen);
     2357
    18612358    return ret;
    18622359}
    18632360
    18642361#ifdef HAVE_ED25519
    1865 static INLINE int myEd25519Sign(WOLFSSL* ssl, const byte* in, word32 inSz,
     2362static WC_INLINE int myEd25519Sign(WOLFSSL* ssl, const byte* in, word32 inSz,
    18662363        byte* out, word32* outSz, const byte* key, word32 keySz, void* ctx)
    18672364{
     
    18692366    word32      idx = 0;
    18702367    ed25519_key myKey;
     2368    byte*       keyBuf = (byte*)key;
     2369    PkCbInfo*   cbInfo = (PkCbInfo*)ctx;
    18712370
    18722371    (void)ssl;
    1873     (void)ctx;
     2372    (void)cbInfo;
     2373
     2374    WOLFSSL_PKMSG("PK 25519 Sign: inSz %d, keySz %d\n", inSz, keySz);
     2375
     2376#ifdef TEST_PK_PRIVKEY
     2377    ret = load_key_file(cbInfo->ourKey, &keyBuf, &keySz);
     2378    if (ret != 0)
     2379        return ret;
     2380#endif
    18742381
    18752382    ret = wc_ed25519_init(&myKey);
    18762383    if (ret == 0) {
    1877         ret = wc_Ed25519PrivateKeyDecode(key, &idx, &myKey, keySz);
     2384        ret = wc_Ed25519PrivateKeyDecode(keyBuf, &idx, &myKey, keySz);
    18782385        if (ret == 0)
    18792386            ret = wc_ed25519_sign_msg(in, inSz, out, outSz, &myKey);
     
    18812388    }
    18822389
     2390#ifdef TEST_PK_PRIVKEY
     2391    free(keyBuf);
     2392#endif
     2393
     2394    WOLFSSL_PKMSG("PK 25519 Sign: ret %d, outSz %d\n", ret, *outSz);
     2395
    18832396    return ret;
    18842397}
    18852398
    18862399
    1887 static INLINE int myEd25519Verify(WOLFSSL* ssl, const byte* sig, word32 sigSz,
     2400static WC_INLINE int myEd25519Verify(WOLFSSL* ssl, const byte* sig, word32 sigSz,
    18882401        const byte* msg, word32 msgSz, const byte* key, word32 keySz,
    18892402        int* result, void* ctx)
     
    18912404    int         ret;
    18922405    ed25519_key myKey;
     2406    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    18932407
    18942408    (void)ssl;
    1895     (void)ctx;
     2409    (void)cbInfo;
     2410
     2411    WOLFSSL_PKMSG("PK 25519 Verify: sigSz %d, msgSz %d, keySz %d\n", sigSz, msgSz, keySz);
    18962412
    18972413    ret = wc_ed25519_init(&myKey);
     
    19042420    }
    19052421
     2422    WOLFSSL_PKMSG("PK 25519 Verify: ret %d, result %d\n", ret, *result);
     2423
    19062424    return ret;
    19072425}
     
    19092427
    19102428#ifdef HAVE_CURVE25519
    1911 static INLINE int myX25519SharedSecret(WOLFSSL* ssl, curve25519_key* otherKey,
     2429static WC_INLINE int myX25519KeyGen(WOLFSSL* ssl, curve25519_key* key,
     2430    unsigned int keySz, void* ctx)
     2431{
     2432    int       ret;
     2433    WC_RNG    rng;
     2434    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
     2435
     2436    (void)ssl;
     2437    (void)cbInfo;
     2438
     2439    WOLFSSL_PKMSG("PK 25519 KeyGen: keySz %d\n", keySz);
     2440
     2441    ret = wc_InitRng(&rng);
     2442    if (ret != 0)
     2443        return ret;
     2444
     2445    ret = wc_curve25519_make_key(&rng, keySz, key);
     2446
     2447    wc_FreeRng(&rng);
     2448
     2449    WOLFSSL_PKMSG("PK 25519 KeyGen: ret %d\n", ret);
     2450
     2451    return ret;
     2452}
     2453
     2454static WC_INLINE int myX25519SharedSecret(WOLFSSL* ssl, curve25519_key* otherKey,
    19122455        unsigned char* pubKeyDer, unsigned int* pubKeySz,
    19132456        unsigned char* out, unsigned int* outlen,
     
    19182461    curve25519_key* pubKey = NULL;
    19192462    curve25519_key  tmpKey;
     2463    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    19202464
    19212465    (void)ssl;
    1922     (void)ctx;
     2466    (void)cbInfo;
     2467
     2468    WOLFSSL_PKMSG("PK 25519 PMS: side %s\n",
     2469        side == WOLFSSL_CLIENT_END ? "client" : "server");
    19232470
    19242471    ret = wc_curve25519_init(&tmpKey);
     
    19652512    wc_curve25519_free(&tmpKey);
    19662513
     2514    WOLFSSL_PKMSG("PK 25519 PMS: ret %d, pubKeySz %d, outLen %d\n",
     2515        ret, *pubKeySz, *outlen);
     2516
    19672517    return ret;
    19682518}
     
    19712521#endif /* HAVE_ECC */
    19722522
     2523#ifndef NO_DH
     2524static WC_INLINE int myDhCallback(WOLFSSL* ssl, struct DhKey* key,
     2525        const unsigned char* priv, unsigned int privSz,
     2526        const unsigned char* pubKeyDer, unsigned int pubKeySz,
     2527        unsigned char* out, unsigned int* outlen,
     2528        void* ctx)
     2529{
     2530    int ret;
     2531    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
     2532
     2533    (void)ssl;
     2534    (void)cbInfo;
     2535
     2536    /* return 0 on success */
     2537    ret = wc_DhAgree(key, out, outlen, priv, privSz, pubKeyDer, pubKeySz);
     2538
     2539    WOLFSSL_PKMSG("PK ED Agree: ret %d, privSz %d, pubKeySz %d, outlen %d\n",
     2540        ret, privSz, pubKeySz, *outlen);
     2541
     2542    return ret;
     2543};
     2544
     2545#endif /* !NO_DH */
     2546
    19732547#ifndef NO_RSA
    19742548
    1975 static INLINE int myRsaSign(WOLFSSL* ssl, const byte* in, word32 inSz,
     2549static WC_INLINE int myRsaSign(WOLFSSL* ssl, const byte* in, word32 inSz,
    19762550        byte* out, word32* outSz, const byte* key, word32 keySz, void* ctx)
    19772551{
     
    19802554    word32  idx = 0;
    19812555    RsaKey  myKey;
     2556    byte*   keyBuf = (byte*)key;
     2557    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    19822558
    19832559    (void)ssl;
    1984     (void)ctx;
     2560    (void)cbInfo;
     2561
     2562    WOLFSSL_PKMSG("PK RSA Sign: inSz %d, keySz %d\n", inSz, keySz);
     2563
     2564#ifdef TEST_PK_PRIVKEY
     2565    ret = load_key_file(cbInfo->ourKey, &keyBuf, &keySz);
     2566    if (ret != 0)
     2567        return ret;
     2568#endif
    19852569
    19862570    ret = wc_InitRng(&rng);
     
    19902574    ret = wc_InitRsaKey(&myKey, NULL);
    19912575    if (ret == 0) {
    1992         ret = wc_RsaPrivateKeyDecode(key, &idx, &myKey, keySz);
     2576        ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, keySz);
    19932577        if (ret == 0)
    19942578            ret = wc_RsaSSL_Sign(in, inSz, out, *outSz, &myKey, &rng);
     
    20012585    wc_FreeRng(&rng);
    20022586
     2587#ifdef TEST_PK_PRIVKEY
     2588    free(keyBuf);
     2589#endif
     2590
     2591    WOLFSSL_PKMSG("PK RSA Sign: ret %d, outSz %d\n", ret, *outSz);
     2592
    20032593    return ret;
    20042594}
    20052595
    20062596
    2007 static INLINE int myRsaVerify(WOLFSSL* ssl, byte* sig, word32 sigSz,
    2008         byte** out,
    2009         const byte* key, word32 keySz,
    2010         void* ctx)
     2597static WC_INLINE int myRsaVerify(WOLFSSL* ssl, byte* sig, word32 sigSz,
     2598        byte** out, const byte* key, word32 keySz, void* ctx)
    20112599{
    20122600    int     ret;
    20132601    word32  idx = 0;
    20142602    RsaKey  myKey;
     2603    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    20152604
    20162605    (void)ssl;
    2017     (void)ctx;
     2606    (void)cbInfo;
     2607
     2608    WOLFSSL_PKMSG("PK RSA Verify: sigSz %d, keySz %d\n", sigSz, keySz);
    20182609
    20192610    ret = wc_InitRsaKey(&myKey, NULL);
     
    20252616    }
    20262617
     2618    WOLFSSL_PKMSG("PK RSA Verify: ret %d\n", ret);
     2619
    20272620    return ret;
    20282621}
    20292622
     2623static WC_INLINE int myRsaSignCheck(WOLFSSL* ssl, byte* sig, word32 sigSz,
     2624        byte** out, const byte* key, word32 keySz, void* ctx)
     2625{
     2626    int     ret;
     2627    word32  idx = 0;
     2628    RsaKey  myKey;
     2629    byte*   keyBuf = (byte*)key;
     2630    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
     2631
     2632    (void)ssl;
     2633    (void)cbInfo;
     2634
     2635    WOLFSSL_PKMSG("PK RSA SignCheck: sigSz %d, keySz %d\n", sigSz, keySz);
     2636
     2637#ifdef TEST_PK_PRIVKEY
     2638    ret = load_key_file(cbInfo->ourKey, &keyBuf, &keySz);
     2639    if (ret != 0)
     2640        return ret;
     2641#endif
     2642
     2643    ret = wc_InitRsaKey(&myKey, NULL);
     2644    if (ret == 0) {
     2645        ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, keySz);
     2646        if (ret == 0)
     2647            ret = wc_RsaSSL_VerifyInline(sig, sigSz, out, &myKey);
     2648        wc_FreeRsaKey(&myKey);
     2649    }
     2650#ifdef TEST_PK_PRIVKEY
     2651    free(keyBuf);
     2652#endif
     2653
     2654    WOLFSSL_PKMSG("PK RSA SignCheck: ret %d\n", ret);
     2655
     2656    return ret;
     2657}
     2658
    20302659#ifdef WC_RSA_PSS
    2031 static INLINE int myRsaPssSign(WOLFSSL* ssl, const byte* in, word32 inSz,
     2660static WC_INLINE int myRsaPssSign(WOLFSSL* ssl, const byte* in, word32 inSz,
    20322661        byte* out, word32* outSz, int hash, int mgf, const byte* key,
    20332662        word32 keySz, void* ctx)
     
    20382667    word32           idx = 0;
    20392668    RsaKey           myKey;
     2669    byte*            keyBuf = (byte*)key;
     2670    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    20402671
    20412672    (void)ssl;
    2042     (void)ctx;
     2673    (void)cbInfo;
     2674
     2675    WOLFSSL_PKMSG("PK RSA PSS Sign: inSz %d, hash %d, mgf %d, keySz %d\n",
     2676        inSz, hash, mgf, keySz);
     2677
     2678#ifdef TEST_PK_PRIVKEY
     2679    ret = load_key_file(cbInfo->ourKey, &keyBuf, &keySz);
     2680    if (ret != 0)
     2681        return ret;
     2682#endif
    20432683
    20442684    switch (hash) {
     
    20662706    ret = wc_InitRsaKey(&myKey, NULL);
    20672707    if (ret == 0) {
    2068         ret = wc_RsaPrivateKeyDecode(key, &idx, &myKey, keySz);
     2708        ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, keySz);
    20692709        if (ret == 0) {
    20702710            ret = wc_RsaPSS_Sign(in, inSz, out, *outSz, hashType, mgf, &myKey,
     
    20792719    wc_FreeRng(&rng);
    20802720
     2721#ifdef TEST_PK_PRIVKEY
     2722    free(keyBuf);
     2723#endif
     2724
     2725    WOLFSSL_PKMSG("PK RSA PSS Sign: ret %d, outSz %d\n", ret, *outSz);
     2726
    20812727    return ret;
    20822728}
    20832729
    20842730
    2085 static INLINE int myRsaPssVerify(WOLFSSL* ssl, byte* sig, word32 sigSz,
     2731static WC_INLINE int myRsaPssVerify(WOLFSSL* ssl, byte* sig, word32 sigSz,
    20862732        byte** out, int hash, int mgf, const byte* key, word32 keySz, void* ctx)
    20872733{
    2088     enum wc_HashType hashType = WC_HASH_TYPE_NONE;
    20892734    int              ret;
    20902735    word32           idx = 0;
    20912736    RsaKey           myKey;
     2737    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
     2738    enum wc_HashType hashType = WC_HASH_TYPE_NONE;
    20922739
    20932740    (void)ssl;
    2094     (void)ctx;
     2741    (void)cbInfo;
     2742
     2743    WOLFSSL_PKMSG("PK RSA PSS Verify: sigSz %d, hash %d, mgf %d, keySz %d\n",
     2744        sigSz, hash, mgf, keySz);
    20952745
    20962746    switch (hash) {
     
    21222772    }
    21232773
     2774    WOLFSSL_PKMSG("PK RSA PSS Verify: ret %d\n", ret);
     2775
    21242776    return ret;
    21252777}
    2126 #endif
    2127 
    2128 
    2129 static INLINE int myRsaEnc(WOLFSSL* ssl, const byte* in, word32 inSz,
     2778
     2779static WC_INLINE int myRsaPssSignCheck(WOLFSSL* ssl, byte* sig, word32 sigSz,
     2780        byte** out, int hash, int mgf, const byte* key, word32 keySz, void* ctx)
     2781{
     2782    int       ret;
     2783    word32    idx = 0;
     2784    RsaKey    myKey;
     2785    byte*     keyBuf = (byte*)key;
     2786    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
     2787    enum wc_HashType hashType = WC_HASH_TYPE_NONE;
     2788
     2789    (void)ssl;
     2790    (void)cbInfo;
     2791
     2792    WOLFSSL_PKMSG("PK RSA PSS SignCheck: sigSz %d, hash %d, mgf %d, keySz %d\n",
     2793        sigSz, hash, mgf, keySz);
     2794
     2795#ifdef TEST_PK_PRIVKEY
     2796    ret = load_key_file(cbInfo->ourKey, &keyBuf, &keySz);
     2797    if (ret != 0)
     2798        return ret;
     2799#endif
     2800
     2801    switch (hash) {
     2802#ifndef NO_SHA256
     2803        case SHA256h:
     2804            hashType = WC_HASH_TYPE_SHA256;
     2805            break;
     2806#endif
     2807#ifdef WOLFSSL_SHA384
     2808        case SHA384h:
     2809            hashType = WC_HASH_TYPE_SHA384;
     2810            break;
     2811#endif
     2812#ifdef WOLFSSL_SHA512
     2813        case SHA512h:
     2814            hashType = WC_HASH_TYPE_SHA512;
     2815            break;
     2816#endif
     2817    }
     2818
     2819    ret = wc_InitRsaKey(&myKey, NULL);
     2820    if (ret == 0) {
     2821        ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, keySz);
     2822        if (ret == 0) {
     2823            ret = wc_RsaPSS_VerifyInline(sig, sigSz, out, hashType, mgf,
     2824                                         &myKey);
     2825            }
     2826        wc_FreeRsaKey(&myKey);
     2827    }
     2828
     2829#ifdef TEST_PK_PRIVKEY
     2830    free(keyBuf);
     2831#endif
     2832
     2833    WOLFSSL_PKMSG("PK RSA PSS SignCheck: ret %d\n", ret);
     2834
     2835    return ret;
     2836}
     2837#endif
     2838
     2839
     2840static WC_INLINE int myRsaEnc(WOLFSSL* ssl, const byte* in, word32 inSz,
    21302841                           byte* out, word32* outSz, const byte* key,
    21312842                           word32 keySz, void* ctx)
     
    21352846    RsaKey  myKey;
    21362847    WC_RNG  rng;
     2848    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    21372849
    21382850    (void)ssl;
    2139     (void)ctx;
     2851    (void)cbInfo;
     2852
     2853    WOLFSSL_PKMSG("PK RSA Enc: inSz %d, keySz %d\n", inSz, keySz);
    21402854
    21412855    ret = wc_InitRng(&rng);
     
    21572871    wc_FreeRng(&rng);
    21582872
     2873    WOLFSSL_PKMSG("PK RSA Enc: ret %d, outSz %d\n", ret, *outSz);
     2874
    21592875    return ret;
    21602876}
    21612877
    2162 static INLINE int myRsaDec(WOLFSSL* ssl, byte* in, word32 inSz,
     2878static WC_INLINE int myRsaDec(WOLFSSL* ssl, byte* in, word32 inSz,
    21632879                           byte** out,
    21642880                           const byte* key, word32 keySz, void* ctx)
     
    21672883    word32  idx = 0;
    21682884    RsaKey  myKey;
     2885    byte*     keyBuf = (byte*)key;
     2886    PkCbInfo* cbInfo = (PkCbInfo*)ctx;
    21692887
    21702888    (void)ssl;
    2171     (void)ctx;
     2889    (void)cbInfo;
     2890
     2891    WOLFSSL_PKMSG("PK RSA Dec: inSz %d, keySz %d\n", inSz, keySz);
     2892
     2893#ifdef TEST_PK_PRIVKEY
     2894    ret = load_key_file(cbInfo->ourKey, &keyBuf, &keySz);
     2895    if (ret != 0)
     2896        return ret;
     2897#endif
    21722898
    21732899    ret = wc_InitRsaKey(&myKey, NULL);
    21742900    if (ret == 0) {
    2175         ret = wc_RsaPrivateKeyDecode(key, &idx, &myKey, keySz);
     2901        ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, keySz);
    21762902        if (ret == 0) {
    21772903            #ifdef WC_RSA_BLINDING
     
    21872913    }
    21882914
     2915#ifdef TEST_PK_PRIVKEY
     2916    free(keyBuf);
     2917#endif
     2918
     2919    WOLFSSL_PKMSG("PK RSA Dec: ret %d\n", ret);
     2920
    21892921    return ret;
    21902922}
     
    21922924#endif /* NO_RSA */
    21932925
    2194 static INLINE void SetupPkCallbacks(WOLFSSL_CTX* ctx, WOLFSSL* ssl)
     2926static WC_INLINE void SetupPkCallbacks(WOLFSSL_CTX* ctx)
    21952927{
    21962928    (void)ctx;
    2197     (void)ssl;
    21982929
    21992930    #ifdef HAVE_ECC
     2931        wolfSSL_CTX_SetEccKeyGenCb(ctx, myEccKeyGen);
    22002932        wolfSSL_CTX_SetEccSignCb(ctx, myEccSign);
    22012933        wolfSSL_CTX_SetEccVerifyCb(ctx, myEccVerify);
    22022934        wolfSSL_CTX_SetEccSharedSecretCb(ctx, myEccSharedSecret);
    22032935    #endif /* HAVE_ECC */
     2936    #ifndef NO_DH
     2937        wolfSSL_CTX_SetDhAgreeCb(ctx, myDhCallback);
     2938    #endif
    22042939    #ifdef HAVE_ED25519
    22052940        wolfSSL_CTX_SetEd25519SignCb(ctx, myEd25519Sign);
     
    22072942    #endif
    22082943    #ifdef HAVE_CURVE25519
     2944        wolfSSL_CTX_SetX25519KeyGenCb(ctx, myX25519KeyGen);
    22092945        wolfSSL_CTX_SetX25519SharedSecretCb(ctx, myX25519SharedSecret);
    22102946    #endif
     
    22122948        wolfSSL_CTX_SetRsaSignCb(ctx, myRsaSign);
    22132949        wolfSSL_CTX_SetRsaVerifyCb(ctx, myRsaVerify);
     2950        wolfSSL_CTX_SetRsaSignCheckCb(ctx, myRsaSignCheck);
    22142951        #ifdef WC_RSA_PSS
    22152952            wolfSSL_CTX_SetRsaPssSignCb(ctx, myRsaPssSign);
    22162953            wolfSSL_CTX_SetRsaPssVerifyCb(ctx, myRsaPssVerify);
     2954            wolfSSL_CTX_SetRsaPssSignCheckCb(ctx, myRsaPssSignCheck);
    22172955        #endif
    22182956        wolfSSL_CTX_SetRsaEncCb(ctx, myRsaEnc);
     
    22212959}
    22222960
     2961static WC_INLINE void SetupPkCallbackContexts(WOLFSSL* ssl, void* myCtx)
     2962{
     2963    #ifdef HAVE_ECC
     2964        wolfSSL_SetEccKeyGenCtx(ssl, myCtx);
     2965        wolfSSL_SetEccSignCtx(ssl, myCtx);
     2966        wolfSSL_SetEccVerifyCtx(ssl, myCtx);
     2967        wolfSSL_SetEccSharedSecretCtx(ssl, myCtx);
     2968    #endif /* HAVE_ECC */
     2969    #ifndef NO_DH
     2970        wolfSSL_SetDhAgreeCtx(ssl, myCtx);
     2971    #endif
     2972    #ifdef HAVE_ED25519
     2973        wolfSSL_SetEd25519SignCtx(ssl, myCtx);
     2974        wolfSSL_SetEd25519VerifyCtx(ssl, myCtx);
     2975    #endif
     2976    #ifdef HAVE_CURVE25519
     2977        wolfSSL_SetX25519KeyGenCtx(ssl, myCtx);
     2978        wolfSSL_SetX25519SharedSecretCtx(ssl, myCtx);
     2979    #endif
     2980    #ifndef NO_RSA
     2981        wolfSSL_SetRsaSignCtx(ssl, myCtx);
     2982        wolfSSL_SetRsaVerifyCtx(ssl, myCtx);
     2983        #ifdef WC_RSA_PSS
     2984            wolfSSL_SetRsaPssSignCtx(ssl, myCtx);
     2985            wolfSSL_SetRsaPssVerifyCtx(ssl, myCtx);
     2986        #endif
     2987        wolfSSL_SetRsaEncCtx(ssl, myCtx);
     2988        wolfSSL_SetRsaDecCtx(ssl, myCtx);
     2989    #endif /* NO_RSA */
     2990}
     2991
    22232992#endif /* HAVE_PK_CALLBACKS */
    2224 
    22252993
    22262994
     
    22312999
    22323000/* HP/UX doesn't have strsep, needed by test/suites.c */
    2233 static INLINE char* strsep(char **stringp, const char *delim)
     3001static WC_INLINE char* strsep(char **stringp, const char *delim)
    22343002{
    22353003    char* start;
     
    22553023   len does not include null terminating character,
    22563024   num is number of characters in tempfn name to randomize */
    2257 static INLINE const char* mymktemp(char *tempfn, int len, int num)
     3025static WC_INLINE const char* mymktemp(char *tempfn, int len, int num)
    22583026{
    22593027    int x, size;
     
    22853053
    22863054    wc_FreeRng(&rng);
     3055    (void)rng; /* for WC_NO_RNG case */
    22873056
    22883057    return tempfn;
     
    23013070    } key_ctx;
    23023071
    2303     static key_ctx myKey_ctx;
    2304     static WC_RNG myKey_rng;
    2305 
    2306     static INLINE int TicketInit(void)
     3072    static THREAD_LS_T key_ctx myKey_ctx;
     3073    static THREAD_LS_T WC_RNG myKey_rng;
     3074
     3075    static WC_INLINE int TicketInit(void)
    23073076    {
    23083077        int ret = wc_InitRng(&myKey_rng);
     
    23183087    }
    23193088
    2320     static INLINE void TicketCleanup(void)
     3089    static WC_INLINE void TicketCleanup(void)
    23213090    {
    23223091        wc_FreeRng(&myKey_rng);
    23233092    }
    23243093
    2325     static INLINE int myTicketEncCb(WOLFSSL* ssl,
     3094    static WC_INLINE int myTicketEncCb(WOLFSSL* ssl,
    23263095                             byte key_name[WOLFSSL_TICKET_NAME_SZ],
    23273096                             byte iv[WOLFSSL_TICKET_IV_SZ],
     
    23893158#endif  /* HAVE_SESSION_TICKET && CHACHA20 && POLY1305 */
    23903159
    2391 static INLINE word16 GetRandomPort(void)
     3160static WC_INLINE word16 GetRandomPort(void)
    23923161{
    23933162    word16 port = 0;
     
    23963165    WC_RNG rng;
    23973166    if (wc_InitRng(&rng) == 0) {
    2398         wc_RNG_GenerateBlock(&rng, (byte*)&port, sizeof(port));
     3167        if (wc_RNG_GenerateBlock(&rng, (byte*)&port, sizeof(port)) == 0) {
    23993168        port |= 0xC000; /* Make sure its in the 49152 - 65535 range */
     3169        }
    24003170        wc_FreeRng(&rng);
    24013171    }
     3172    (void)rng; /* for WC_NO_RNG case */
    24023173    return port;
    24033174}
Note: See TracChangeset for help on using the changeset viewer.