#ifndef _SSL_THREADING_H_
#define _SSL_THREADING_H_ 1
#include <Security/SecureTransport.h>
#include <Security/Security.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SSL_PROTOCOL_IGNORE ((SSLProtocol)0x123456)
#define SSL_CLIENT_CERT_IGNORE ((SSLClientCertificateState)0x234567)
#define SSL_CIPHER_IGNORE ((SSLCipherSuite)0x345678)
typedef struct {
const char *hostName;
bool skipHostNameCheck;
unsigned short port;
SSLProtocol tryVersion; const char *acceptedProts;
const char *myCertKcName; const char *password; bool idIsTrustedRoot; bool disableCertVerify;
const char *anchorFile; bool replaceAnchors;
SSLAuthenticate authenticate;
bool resumeEnable;
const SSLCipherSuite *ciphers; bool nonBlocking;
const unsigned char *dhParams; unsigned dhParamsLen;
OSStatus expectRtn;
SSLProtocol expectVersion;
SSLClientCertificateState expectCertState;
SSLCipherSuite expectCipher;
bool quiet;
bool silent;
bool verbose;
pthread_mutex_t pthreadMutex;
pthread_cond_t pthreadCond;
bool serverReady;
unsigned clientDone;
bool serverAbort;
SSLProtocol negVersion; SSLCipherSuite negCipher; SSLClientCertificateState certState; OSStatus ortn;
} SslAppTestParams;
OSStatus sslAppClient(
SslAppTestParams *params);
OSStatus sslAppServe(
SslAppTestParams *params);
int sslRunSession(
SslAppTestParams *serverParams,
SslAppTestParams *clientParams,
const char *testDesc);
void sslShowResult(
char *whichSide, SslAppTestParams *params);
#define SSL_THR_SETUP(serverParams, clientParams, clientDefaults, serverDefault) \
{ \
unsigned short serverPort; \
serverPort = serverParams.port + 1; \
clientParams = clientDefaults; \
serverParams = serverDefaults; \
serverParams.port = serverPort; \
}
#define SSL_THR_RUN(serverParams, clientParams, desc, ourRtn) \
{ \
thisRtn = sslRunSession(&serverParams, &clientParams, desc); \
ourRtn += thisRtn; \
if(thisRtn) { \
if(testError(clientParams.quiet)) { \
goto done; \
} \
} \
}
#define SSL_THR_RUN_NUM(serverParams, clientParams, desc, ourRtn, testNum) \
{ \
thisRtn = sslRunSession(&serverParams, &clientParams, desc);\
ourRtn += thisRtn; \
if(thisRtn) { \
printf("***Error on test %u\n", testNum); \
if(testError(clientParams.quiet)) { \
goto done; \
} \
} \
}
#define THREADING_DEBUG 0
#if THREADING_DEBUG
#define sslThrDebug(side, end) \
printf("^^^%s thread %p %s\n", side, pthread_self(), end)
#else
#define sslThrDebug(side, end)
#endif
#ifdef __cplusplus
}
#endif
#endif