1/*
2 * sslRingBufferThreads.h - SecureTransport client and server thread
3 *		routines which use ringBufferIo for I/O (no sockets).
4 */
5
6#include <Security/SecureTransport.h>
7#include <clAppUtils/ringBufferIo.h>
8#include <CoreFoundation/CoreFoundation.h>
9
10#ifndef	_SSL_RING_BUFFER_THREADS_H_
11#define _SSL_RING_BUFFER_THREADS_H_
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/*
18 * arguments to client thread and server pseudothread
19 */
20typedef struct {
21	CFArrayRef			idArray;		/* required for server, optional for client */
22	CFArrayRef			trustedRoots;	/* generally from server's idArray */
23	unsigned			xferSize;		/* total bytes for client to write and server to
24										 * read */
25	void				*xferBuf;		/* move to/from here */
26	unsigned			chunkSize;		/* size of xferBuf; client writes this much at
27										 *   a time */
28	bool				runForever;		/* if true, ignore xferSize and move data forever
29										 *   or until error */
30	SSLCipherSuite		cipherSuite;
31	SSLProtocol			prot;
32	RingBuffer			*ringWrite;		/* I/O writes to this... */
33	RingBuffer			*ringRead;		/* ...and reads from this */
34
35	/* client's goFlag is &(server's iAmReady); vice versa */
36	bool				iAmReady;		/* this thread is ready for handshake */
37	bool				*goFlag;		/* when both threads see this, they start
38										 * their handshakes */
39	bool				*abortFlag;		/* anyone sets this on error */
40										/* everyone aborts when they see this true */
41	bool				pauseOnError;	/* call testError() on error */
42
43	/* returned on success */
44	SSLProtocol			negotiatedProt;
45	SSLCipherSuite		negotiatedCipher;
46
47	CFAbsoluteTime		startHandshake;
48	CFAbsoluteTime		startData;
49	CFAbsoluteTime		endData;
50} SslRingBufferArgs;
51
52/*
53 * Client thread - handshake and write sslArgs->xferSize bytes of data.
54 */
55void *sslRbClientThread(void *arg);
56
57/*
58 * Server function - like clientThread except it runs from the main thread.
59 * handshake and read sslArgs->xferSize bytes of data.
60 */
61OSStatus sslRbServerThread(SslRingBufferArgs *sslArgs);
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif	/* _SSL_RING_BUFFER_THREADS_H_*/
68