1 /* ======================================================================== 2 * Copyright 1988-2006 University of Washington 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * 11 * ======================================================================== 12 */ 13 14 /* 15 * Program: SSL routines 16 * 17 * Author: Mark Crispin 18 * Networks and Distributed Computing 19 * Computing & Communications 20 * University of Washington 21 * Administration Building, AG-44 22 * Seattle, WA 98195 23 * Internet: MRC@CAC.Washington.EDU 24 * 25 * Date: 7 February 2001 26 * Last Edited: 30 August 2006 27 */ 28 29 /* SSL driver */ 30 31 struct ssl_driver { /* must parallel NETDRIVER in mail.h */ 32 SSLSTREAM *(*open) (char *host,char *service,unsigned long port); 33 SSLSTREAM *(*aopen) (NETMBX *mb,char *service,char *usrbuf); 34 char *(*getline) (SSLSTREAM *stream); 35 long (*getbuffer) (SSLSTREAM *stream,unsigned long size,char *buffer); 36 long (*soutr) (SSLSTREAM *stream,char *string); 37 long (*sout) (SSLSTREAM *stream,char *string,unsigned long size); 38 void (*close) (SSLSTREAM *stream); 39 char *(*host) (SSLSTREAM *stream); 40 char *(*remotehost) (SSLSTREAM *stream); 41 unsigned long (*port) (SSLSTREAM *stream); 42 char *(*localhost) (SSLSTREAM *stream); 43 }; 44 45 46 /* SSL stdio stream */ 47 48 typedef struct ssl_stdiostream { 49 SSLSTREAM *sslstream; /* SSL stream */ 50 int octr; /* output counter */ 51 char *optr; /* output pointer */ 52 char obuf[SSLBUFLEN]; /* output buffer */ 53 } SSLSTDIOSTREAM; 54 55 56 /* Function prototypes */ 57 58 SSLSTREAM *ssl_open (char *host,char *service,unsigned long port); 59 SSLSTREAM *ssl_aopen (NETMBX *mb,char *service,char *usrbuf); 60 char *ssl_getline (SSLSTREAM *stream); 61 long ssl_getbuffer (SSLSTREAM *stream,unsigned long size,char *buffer); 62 long ssl_getdata (SSLSTREAM *stream); 63 long ssl_soutr (SSLSTREAM *stream,char *string); 64 long ssl_sout (SSLSTREAM *stream,char *string,unsigned long size); 65 void ssl_close (SSLSTREAM *stream); 66 char *ssl_host (SSLSTREAM *stream); 67 char *ssl_remotehost (SSLSTREAM *stream); 68 unsigned long ssl_port (SSLSTREAM *stream); 69 char *ssl_localhost (SSLSTREAM *stream); 70 long ssl_server_input_wait (long seconds); 71