X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/80e2389990082500d76eb566d4946be3e786c3ef..d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb:/SecurityTests/clxutils/sslSession/sslSession.cpp?ds=sidebyside diff --git a/SecurityTests/clxutils/sslSession/sslSession.cpp b/SecurityTests/clxutils/sslSession/sslSession.cpp new file mode 100644 index 00000000..3f691c85 --- /dev/null +++ b/SecurityTests/clxutils/sslSession/sslSession.cpp @@ -0,0 +1,293 @@ +/* + * sslSession.cpp - basic 2-thread SSL server/client session + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define PORT_DEF 4000 +#define HOST_DEF "localhost" +#define DH_PARAMS "dhParams_512.der" + +static void usage(char **argv) +{ + printf("Usage: %s server_kc [options]\n", argv[0]); + printf("options:\n"); + printf(" P=port (default = %d)\n", PORT_DEF); + printf(" c=client_kc (default is none)\n"); + printf(" d (DSA, default is RSA)\n"); + printf(" f (D-H, default is RSA)\n"); + printf(" a anchor File for client side (typically, the server's cert)\n"); + printf(" A anchor file for server side (typically, the client's cert)\n"); + printf(" h hostname (default is %s)\n", HOST_DEF); + printf(" k (skip hostname check)\n"); + printf(" b (non blocking I/O)\n"); + printf(" u Require client authentication\n"); + printf(" x Expect policy verify error on client side\n"); + printf(" X Expect policy verify error on server side\n"); + printf(" z=kc_pwd\n"); + printf(" R (ringBuffer I/O)\n"); + printf(" l=loops (default 1)\n"); + printf(" q(uiet)\n"); + printf(" v(erbose)\n"); + exit(1); +} + +#define IGNORE_SIGPIPE 1 +#if IGNORE_SIGPIPE +#include + +void sigpipe(int sig) +{ +} +#endif /* IGNORE_SIGPIPE */ + +static SSLCipherSuite ciphers[] = { + SSL_RSA_WITH_RC4_128_SHA, SSL_NO_SUCH_CIPHERSUITE +}; + +/* + * Default params for each test. Main() adjust this per cmd line + * args. + */ +SslAppTestParams serverDefaults = +{ + "no name here", + false, // skipHostNameCHeck + PORT_DEF, + NULL, NULL, // RingBuffers + false, // noProtSpec + kTLSProtocol1, + NULL, // acceptedProts - not used in this test + NULL, // myCerts - const + NULL, // password + true, // idIsTrustedRoot + false, // disableCertVerify + NULL, // anchorFile + false, // replaceAnchors + kNeverAuthenticate, + false, // resumeEnable + ciphers, // ciphers + false, // nonBlocking + NULL, // dhParams + 0, // dhParamsLen + noErr, // expectRtn + kTLSProtocol1, // expectVersion + kSSLClientCertNone, + SSL_CIPHER_IGNORE, + false, // quiet + false, // silent + false, // verbose + {0}, // lock + {0}, // cond + false, // serverReady + 0, // clientDone + false, // serverAbort + /* returned */ + kSSLProtocolUnknown, + SSL_NULL_WITH_NULL_NULL, + kSSLClientCertNone, + noHardwareErr + +}; + +SslAppTestParams clientDefaults = +{ + HOST_DEF, + false, // skipHostNameCHeck + PORT_DEF, + NULL, NULL, // RingBuffers + false, // noProtSpec + kTLSProtocol1, + NULL, // acceptedProts - not used in this test + NULL, // myCerts - const + NULL, // password + true, // idIsTrustedRoot + false, // disableCertVerify + NULL, // anchorFile + false, // replaceAnchors + kNeverAuthenticate, + false, // resumeEnable + NULL, // ciphers + false, // nonBlocking + NULL, // dhParams + 0, // dhParamsLen + noErr, // expectRtn + kTLSProtocol1, // expectVersion + kSSLClientCertNone, + SSL_CIPHER_IGNORE, + false, // quiet + false, // silent + false, // verbose + {0}, // lock + {0}, // cond + false, // serverReady + 0, // clientDone + false, // serverAbort + /* returned */ + kSSLProtocolUnknown, + SSL_NULL_WITH_NULL_NULL, + kSSLClientCertNone, + noHardwareErr + +}; + +int main(int argc, char **argv) +{ + int ourRtn = 0; + char *argp; + bool dhEnable = false; + unsigned loop; + unsigned loops = 1; + bool ringBufferIo = false; + RingBuffer serverToClientRing; + RingBuffer clientToServerRing; + + if(argc < 2) { + usage(argv); + } + serverDefaults.myCertKcName = argv[1]; + for(int arg=2; arg