xref: /onnv-gate/usr/src/common/openssl/ssl/ssl_locl.h (revision 2139:6243c3338933)
10Sstevel@tonic-gate /* ssl/ssl_locl.h */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate  * All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * This package is an SSL implementation written
60Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
110Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
130Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate  * the code are not to be removed.
180Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate  * as the author of the parts of the library used.
200Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate  *
230Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate  * are met:
260Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate  *    must display the following acknowledgement:
330Sstevel@tonic-gate  *    "This product includes cryptographic software written by
340Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate  *    being used are not cryptographic related :-).
370Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate  * SUCH DAMAGE.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
550Sstevel@tonic-gate  * copied and put under another distribution licence
560Sstevel@tonic-gate  * [including the GNU Public Licence.]
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate /* ====================================================================
590Sstevel@tonic-gate  * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
600Sstevel@tonic-gate  *
610Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
620Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
630Sstevel@tonic-gate  * are met:
640Sstevel@tonic-gate  *
650Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
660Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
670Sstevel@tonic-gate  *
680Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
690Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in
700Sstevel@tonic-gate  *    the documentation and/or other materials provided with the
710Sstevel@tonic-gate  *    distribution.
720Sstevel@tonic-gate  *
730Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this
740Sstevel@tonic-gate  *    software must display the following acknowledgment:
750Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
760Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
770Sstevel@tonic-gate  *
780Sstevel@tonic-gate  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
790Sstevel@tonic-gate  *    endorse or promote products derived from this software without
800Sstevel@tonic-gate  *    prior written permission. For written permission, please contact
810Sstevel@tonic-gate  *    openssl-core@openssl.org.
820Sstevel@tonic-gate  *
830Sstevel@tonic-gate  * 5. Products derived from this software may not be called "OpenSSL"
840Sstevel@tonic-gate  *    nor may "OpenSSL" appear in their names without prior written
850Sstevel@tonic-gate  *    permission of the OpenSSL Project.
860Sstevel@tonic-gate  *
870Sstevel@tonic-gate  * 6. Redistributions of any form whatsoever must retain the following
880Sstevel@tonic-gate  *    acknowledgment:
890Sstevel@tonic-gate  *    "This product includes software developed by the OpenSSL Project
900Sstevel@tonic-gate  *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
910Sstevel@tonic-gate  *
920Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
930Sstevel@tonic-gate  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
940Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
950Sstevel@tonic-gate  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
960Sstevel@tonic-gate  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
970Sstevel@tonic-gate  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
980Sstevel@tonic-gate  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
990Sstevel@tonic-gate  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1000Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1010Sstevel@tonic-gate  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1020Sstevel@tonic-gate  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1030Sstevel@tonic-gate  * OF THE POSSIBILITY OF SUCH DAMAGE.
1040Sstevel@tonic-gate  * ====================================================================
1050Sstevel@tonic-gate  *
1060Sstevel@tonic-gate  * This product includes cryptographic software written by Eric Young
1070Sstevel@tonic-gate  * (eay@cryptsoft.com).  This product includes software written by Tim
1080Sstevel@tonic-gate  * Hudson (tjh@cryptsoft.com).
1090Sstevel@tonic-gate  *
1100Sstevel@tonic-gate  */
111*2139Sjp161948 /* ====================================================================
112*2139Sjp161948  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
113*2139Sjp161948  * ECC cipher suite support in OpenSSL originally developed by
114*2139Sjp161948  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
115*2139Sjp161948  */
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate #ifndef HEADER_SSL_LOCL_H
1180Sstevel@tonic-gate #define HEADER_SSL_LOCL_H
1190Sstevel@tonic-gate #include <stdlib.h>
1200Sstevel@tonic-gate #include <time.h>
1210Sstevel@tonic-gate #include <string.h>
1220Sstevel@tonic-gate #include <errno.h>
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate #include "e_os.h"
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate #include <openssl/buffer.h>
1270Sstevel@tonic-gate #include <openssl/comp.h>
1280Sstevel@tonic-gate #include <openssl/bio.h>
1290Sstevel@tonic-gate #include <openssl/stack.h>
130*2139Sjp161948 #ifndef OPENSSL_NO_RSA
131*2139Sjp161948 #include <openssl/rsa.h>
132*2139Sjp161948 #endif
133*2139Sjp161948 #ifndef OPENSSL_NO_DSA
134*2139Sjp161948 #include <openssl/dsa.h>
135*2139Sjp161948 #endif
1360Sstevel@tonic-gate #include <openssl/err.h>
1370Sstevel@tonic-gate #include <openssl/ssl.h>
1380Sstevel@tonic-gate #include <openssl/symhacks.h>
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate #ifdef OPENSSL_BUILD_SHLIBSSL
1410Sstevel@tonic-gate # undef OPENSSL_EXTERN
1420Sstevel@tonic-gate # define OPENSSL_EXTERN OPENSSL_EXPORT
1430Sstevel@tonic-gate #endif
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate #define PKCS1_CHECK
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate #define c2l(c,l)	(l = ((unsigned long)(*((c)++)))     , \
1480Sstevel@tonic-gate 			 l|=(((unsigned long)(*((c)++)))<< 8), \
1490Sstevel@tonic-gate 			 l|=(((unsigned long)(*((c)++)))<<16), \
1500Sstevel@tonic-gate 			 l|=(((unsigned long)(*((c)++)))<<24))
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate /* NOTE - c is not incremented as per c2l */
1530Sstevel@tonic-gate #define c2ln(c,l1,l2,n)	{ \
1540Sstevel@tonic-gate 			c+=n; \
1550Sstevel@tonic-gate 			l1=l2=0; \
1560Sstevel@tonic-gate 			switch (n) { \
1570Sstevel@tonic-gate 			case 8: l2 =((unsigned long)(*(--(c))))<<24; \
1580Sstevel@tonic-gate 			case 7: l2|=((unsigned long)(*(--(c))))<<16; \
1590Sstevel@tonic-gate 			case 6: l2|=((unsigned long)(*(--(c))))<< 8; \
1600Sstevel@tonic-gate 			case 5: l2|=((unsigned long)(*(--(c))));     \
1610Sstevel@tonic-gate 			case 4: l1 =((unsigned long)(*(--(c))))<<24; \
1620Sstevel@tonic-gate 			case 3: l1|=((unsigned long)(*(--(c))))<<16; \
1630Sstevel@tonic-gate 			case 2: l1|=((unsigned long)(*(--(c))))<< 8; \
1640Sstevel@tonic-gate 			case 1: l1|=((unsigned long)(*(--(c))));     \
1650Sstevel@tonic-gate 				} \
1660Sstevel@tonic-gate 			}
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #define l2c(l,c)	(*((c)++)=(unsigned char)(((l)    )&0xff), \
1690Sstevel@tonic-gate 			 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
1700Sstevel@tonic-gate 			 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
1710Sstevel@tonic-gate 			 *((c)++)=(unsigned char)(((l)>>24)&0xff))
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate #define n2l(c,l)	(l =((unsigned long)(*((c)++)))<<24, \
1740Sstevel@tonic-gate 			 l|=((unsigned long)(*((c)++)))<<16, \
1750Sstevel@tonic-gate 			 l|=((unsigned long)(*((c)++)))<< 8, \
1760Sstevel@tonic-gate 			 l|=((unsigned long)(*((c)++))))
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate #define l2n(l,c)	(*((c)++)=(unsigned char)(((l)>>24)&0xff), \
1790Sstevel@tonic-gate 			 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
1800Sstevel@tonic-gate 			 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
1810Sstevel@tonic-gate 			 *((c)++)=(unsigned char)(((l)    )&0xff))
1820Sstevel@tonic-gate 
183*2139Sjp161948 #define l2n6(l,c)	(*((c)++)=(unsigned char)(((l)>>40)&0xff), \
184*2139Sjp161948 			 *((c)++)=(unsigned char)(((l)>>32)&0xff), \
185*2139Sjp161948 			 *((c)++)=(unsigned char)(((l)>>24)&0xff), \
186*2139Sjp161948 			 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
187*2139Sjp161948 			 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
188*2139Sjp161948 			 *((c)++)=(unsigned char)(((l)    )&0xff))
189*2139Sjp161948 
190*2139Sjp161948 #define n2l6(c,l)	(l =((BN_ULLONG)(*((c)++)))<<40, \
191*2139Sjp161948 			 l|=((BN_ULLONG)(*((c)++)))<<32, \
192*2139Sjp161948 			 l|=((BN_ULLONG)(*((c)++)))<<24, \
193*2139Sjp161948 			 l|=((BN_ULLONG)(*((c)++)))<<16, \
194*2139Sjp161948 			 l|=((BN_ULLONG)(*((c)++)))<< 8, \
195*2139Sjp161948 			 l|=((BN_ULLONG)(*((c)++))))
196*2139Sjp161948 
1970Sstevel@tonic-gate /* NOTE - c is not incremented as per l2c */
1980Sstevel@tonic-gate #define l2cn(l1,l2,c,n)	{ \
1990Sstevel@tonic-gate 			c+=n; \
2000Sstevel@tonic-gate 			switch (n) { \
2010Sstevel@tonic-gate 			case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
2020Sstevel@tonic-gate 			case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
2030Sstevel@tonic-gate 			case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
2040Sstevel@tonic-gate 			case 5: *(--(c))=(unsigned char)(((l2)    )&0xff); \
2050Sstevel@tonic-gate 			case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
2060Sstevel@tonic-gate 			case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
2070Sstevel@tonic-gate 			case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
2080Sstevel@tonic-gate 			case 1: *(--(c))=(unsigned char)(((l1)    )&0xff); \
2090Sstevel@tonic-gate 				} \
2100Sstevel@tonic-gate 			}
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate #define n2s(c,s)	((s=(((unsigned int)(c[0]))<< 8)| \
2130Sstevel@tonic-gate 			    (((unsigned int)(c[1]))    )),c+=2)
2140Sstevel@tonic-gate #define s2n(s,c)	((c[0]=(unsigned char)(((s)>> 8)&0xff), \
2150Sstevel@tonic-gate 			  c[1]=(unsigned char)(((s)    )&0xff)),c+=2)
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate #define n2l3(c,l)	((l =(((unsigned long)(c[0]))<<16)| \
2180Sstevel@tonic-gate 			     (((unsigned long)(c[1]))<< 8)| \
2190Sstevel@tonic-gate 			     (((unsigned long)(c[2]))    )),c+=3)
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate #define l2n3(l,c)	((c[0]=(unsigned char)(((l)>>16)&0xff), \
2220Sstevel@tonic-gate 			  c[1]=(unsigned char)(((l)>> 8)&0xff), \
2230Sstevel@tonic-gate 			  c[2]=(unsigned char)(((l)    )&0xff)),c+=3)
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate /* LOCAL STUFF */
2260Sstevel@tonic-gate 
2270Sstevel@tonic-gate #define SSL_DECRYPT	0
2280Sstevel@tonic-gate #define SSL_ENCRYPT	1
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate #define TWO_BYTE_BIT	0x80
2310Sstevel@tonic-gate #define SEC_ESC_BIT	0x40
2320Sstevel@tonic-gate #define TWO_BYTE_MASK	0x7fff
2330Sstevel@tonic-gate #define THREE_BYTE_MASK	0x3fff
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate #define INC32(a)	((a)=((a)+1)&0xffffffffL)
2360Sstevel@tonic-gate #define DEC32(a)	((a)=((a)-1)&0xffffffffL)
2370Sstevel@tonic-gate #define MAX_MAC_SIZE	20 /* up from 16 for SSLv3 */
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate /*
2400Sstevel@tonic-gate  * Define the Bitmasks for SSL_CIPHER.algorithms.
2410Sstevel@tonic-gate  * This bits are used packed as dense as possible. If new methods/ciphers
2420Sstevel@tonic-gate  * etc will be added, the bits a likely to change, so this information
2430Sstevel@tonic-gate  * is for internal library use only, even though SSL_CIPHER.algorithms
2440Sstevel@tonic-gate  * can be publicly accessed.
2450Sstevel@tonic-gate  * Use the according functions for cipher management instead.
2460Sstevel@tonic-gate  *
2470Sstevel@tonic-gate  * The bit mask handling in the selection and sorting scheme in
2480Sstevel@tonic-gate  * ssl_create_cipher_list() has only limited capabilities, reflecting
2490Sstevel@tonic-gate  * that the different entities within are mutually exclusive:
2500Sstevel@tonic-gate  * ONLY ONE BIT PER MASK CAN BE SET AT A TIME.
2510Sstevel@tonic-gate  */
252*2139Sjp161948 #define SSL_MKEY_MASK		0x000000FFL
2530Sstevel@tonic-gate #define SSL_kRSA		0x00000001L /* RSA key exchange */
2540Sstevel@tonic-gate #define SSL_kDHr		0x00000002L /* DH cert RSA CA cert */
2550Sstevel@tonic-gate #define SSL_kDHd		0x00000004L /* DH cert DSA CA cert */
2560Sstevel@tonic-gate #define SSL_kFZA		0x00000008L
2570Sstevel@tonic-gate #define SSL_kEDH		0x00000010L /* tmp DH key no DH cert */
2580Sstevel@tonic-gate #define SSL_kKRB5		0x00000020L /* Kerberos5 key exchange */
259*2139Sjp161948 #define SSL_kECDH               0x00000040L /* ECDH w/ long-term keys */
260*2139Sjp161948 #define SSL_kECDHE              0x00000080L /* ephemeral ECDH */
2610Sstevel@tonic-gate #define SSL_EDH			(SSL_kEDH|(SSL_AUTH_MASK^SSL_aNULL))
2620Sstevel@tonic-gate 
263*2139Sjp161948 #define SSL_AUTH_MASK		0x00007F00L
264*2139Sjp161948 #define SSL_aRSA		0x00000100L /* Authenticate with RSA */
265*2139Sjp161948 #define SSL_aDSS 		0x00000200L /* Authenticate with DSS */
2660Sstevel@tonic-gate #define SSL_DSS 		SSL_aDSS
267*2139Sjp161948 #define SSL_aFZA 		0x00000400L
268*2139Sjp161948 #define SSL_aNULL 		0x00000800L /* no Authenticate, ADH */
269*2139Sjp161948 #define SSL_aDH 		0x00001000L /* no Authenticate, ADH */
270*2139Sjp161948 #define SSL_aKRB5               0x00002000L /* Authenticate with KRB5 */
271*2139Sjp161948 #define SSL_aECDSA              0x00004000L /* Authenticate with ECDSA */
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate #define SSL_NULL		(SSL_eNULL)
2740Sstevel@tonic-gate #define SSL_ADH			(SSL_kEDH|SSL_aNULL)
2750Sstevel@tonic-gate #define SSL_RSA			(SSL_kRSA|SSL_aRSA)
2760Sstevel@tonic-gate #define SSL_DH			(SSL_kDHr|SSL_kDHd|SSL_kEDH)
277*2139Sjp161948 #define SSL_ECDH		(SSL_kECDH|SSL_kECDHE)
2780Sstevel@tonic-gate #define SSL_FZA			(SSL_aFZA|SSL_kFZA|SSL_eFZA)
2790Sstevel@tonic-gate #define SSL_KRB5                (SSL_kKRB5|SSL_aKRB5)
2800Sstevel@tonic-gate 
281*2139Sjp161948 #define SSL_ENC_MASK		0x043F8000L
282*2139Sjp161948 #define SSL_DES			0x00008000L
283*2139Sjp161948 #define SSL_3DES		0x00010000L
284*2139Sjp161948 #define SSL_RC4			0x00020000L
285*2139Sjp161948 #define SSL_RC2			0x00040000L
286*2139Sjp161948 #define SSL_IDEA		0x00080000L
287*2139Sjp161948 #define SSL_eFZA		0x00100000L
288*2139Sjp161948 #define SSL_eNULL		0x00200000L
289*2139Sjp161948 #define SSL_AES			0x04000000L
2900Sstevel@tonic-gate 
291*2139Sjp161948 #define SSL_MAC_MASK		0x00c00000L
292*2139Sjp161948 #define SSL_MD5			0x00400000L
293*2139Sjp161948 #define SSL_SHA1		0x00800000L
2940Sstevel@tonic-gate #define SSL_SHA			(SSL_SHA1)
2950Sstevel@tonic-gate 
296*2139Sjp161948 #define SSL_SSL_MASK		0x03000000L
297*2139Sjp161948 #define SSL_SSLV2		0x01000000L
298*2139Sjp161948 #define SSL_SSLV3		0x02000000L
2990Sstevel@tonic-gate #define SSL_TLSV1		SSL_SSLV3	/* for now */
3000Sstevel@tonic-gate 
301*2139Sjp161948 /* we have used 07ffffff - 5 bits left to go. */
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate /*
3040Sstevel@tonic-gate  * Export and cipher strength information. For each cipher we have to decide
3050Sstevel@tonic-gate  * whether it is exportable or not. This information is likely to change
3060Sstevel@tonic-gate  * over time, since the export control rules are no static technical issue.
3070Sstevel@tonic-gate  *
3080Sstevel@tonic-gate  * Independent of the export flag the cipher strength is sorted into classes.
3090Sstevel@tonic-gate  * SSL_EXP40 was denoting the 40bit US export limit of past times, which now
3100Sstevel@tonic-gate  * is at 56bit (SSL_EXP56). If the exportable cipher class is going to change
3110Sstevel@tonic-gate  * again (eg. to 64bit) the use of "SSL_EXP*" becomes blurred even more,
3120Sstevel@tonic-gate  * since SSL_EXP64 could be similar to SSL_LOW.
3130Sstevel@tonic-gate  * For this reason SSL_MICRO and SSL_MINI macros are included to widen the
3140Sstevel@tonic-gate  * namespace of SSL_LOW-SSL_HIGH to lower values. As development of speed
3150Sstevel@tonic-gate  * and ciphers goes, another extension to SSL_SUPER and/or SSL_ULTRA would
3160Sstevel@tonic-gate  * be possible.
3170Sstevel@tonic-gate  */
3180Sstevel@tonic-gate #define SSL_EXP_MASK		0x00000003L
3190Sstevel@tonic-gate #define SSL_NOT_EXP		0x00000001L
3200Sstevel@tonic-gate #define SSL_EXPORT		0x00000002L
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate #define SSL_STRONG_MASK		0x000000fcL
3230Sstevel@tonic-gate #define SSL_STRONG_NONE		0x00000004L
3240Sstevel@tonic-gate #define SSL_EXP40		0x00000008L
3250Sstevel@tonic-gate #define SSL_MICRO		(SSL_EXP40)
3260Sstevel@tonic-gate #define SSL_EXP56		0x00000010L
3270Sstevel@tonic-gate #define SSL_MINI		(SSL_EXP56)
3280Sstevel@tonic-gate #define SSL_LOW			0x00000020L
3290Sstevel@tonic-gate #define SSL_MEDIUM		0x00000040L
3300Sstevel@tonic-gate #define SSL_HIGH		0x00000080L
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate /* we have used 000000ff - 24 bits left to go */
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate /*
3350Sstevel@tonic-gate  * Macros to check the export status and cipher strength for export ciphers.
3360Sstevel@tonic-gate  * Even though the macros for EXPORT and EXPORT40/56 have similar names,
3370Sstevel@tonic-gate  * their meaning is different:
3380Sstevel@tonic-gate  * *_EXPORT macros check the 'exportable' status.
3390Sstevel@tonic-gate  * *_EXPORT40/56 macros are used to check whether a certain cipher strength
3400Sstevel@tonic-gate  *          is given.
3410Sstevel@tonic-gate  * Since the SSL_IS_EXPORT* and SSL_EXPORT* macros depend on the correct
3420Sstevel@tonic-gate  * algorithm structure element to be passed (algorithms, algo_strength) and no
3430Sstevel@tonic-gate  * typechecking can be done as they are all of type unsigned long, their
3440Sstevel@tonic-gate  * direct usage is discouraged.
3450Sstevel@tonic-gate  * Use the SSL_C_* macros instead.
3460Sstevel@tonic-gate  */
3470Sstevel@tonic-gate #define SSL_IS_EXPORT(a)	((a)&SSL_EXPORT)
3480Sstevel@tonic-gate #define SSL_IS_EXPORT56(a)	((a)&SSL_EXP56)
3490Sstevel@tonic-gate #define SSL_IS_EXPORT40(a)	((a)&SSL_EXP40)
3500Sstevel@tonic-gate #define SSL_C_IS_EXPORT(c)	SSL_IS_EXPORT((c)->algo_strength)
3510Sstevel@tonic-gate #define SSL_C_IS_EXPORT56(c)	SSL_IS_EXPORT56((c)->algo_strength)
3520Sstevel@tonic-gate #define SSL_C_IS_EXPORT40(c)	SSL_IS_EXPORT40((c)->algo_strength)
3530Sstevel@tonic-gate 
3540Sstevel@tonic-gate #define SSL_EXPORT_KEYLENGTH(a,s)	(SSL_IS_EXPORT40(s) ? 5 : \
3550Sstevel@tonic-gate 				 ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7)
3560Sstevel@tonic-gate #define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024)
3570Sstevel@tonic-gate #define SSL_C_EXPORT_KEYLENGTH(c)	SSL_EXPORT_KEYLENGTH((c)->algorithms, \
3580Sstevel@tonic-gate 				(c)->algo_strength)
3590Sstevel@tonic-gate #define SSL_C_EXPORT_PKEYLENGTH(c)	SSL_EXPORT_PKEYLENGTH((c)->algo_strength)
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate #define SSL_ALL			0xffffffffL
3630Sstevel@tonic-gate #define SSL_ALL_CIPHERS		(SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\
3640Sstevel@tonic-gate 				SSL_MAC_MASK)
3650Sstevel@tonic-gate #define SSL_ALL_STRENGTHS	(SSL_EXP_MASK|SSL_STRONG_MASK)
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate /* Mostly for SSLv3 */
3680Sstevel@tonic-gate #define SSL_PKEY_RSA_ENC	0
3690Sstevel@tonic-gate #define SSL_PKEY_RSA_SIGN	1
3700Sstevel@tonic-gate #define SSL_PKEY_DSA_SIGN	2
3710Sstevel@tonic-gate #define SSL_PKEY_DH_RSA		3
3720Sstevel@tonic-gate #define SSL_PKEY_DH_DSA		4
373*2139Sjp161948 #define SSL_PKEY_ECC            5
374*2139Sjp161948 #define SSL_PKEY_NUM		6
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate /* SSL_kRSA <- RSA_ENC | (RSA_TMP & RSA_SIGN) |
3770Sstevel@tonic-gate  * 	    <- (EXPORT & (RSA_ENC | RSA_TMP) & RSA_SIGN)
3780Sstevel@tonic-gate  * SSL_kDH  <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN)
3790Sstevel@tonic-gate  * SSL_kEDH <- RSA_ENC | RSA_SIGN | DSA_SIGN
3800Sstevel@tonic-gate  * SSL_aRSA <- RSA_ENC | RSA_SIGN
3810Sstevel@tonic-gate  * SSL_aDSS <- DSA_SIGN
3820Sstevel@tonic-gate  */
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate /*
3850Sstevel@tonic-gate #define CERT_INVALID		0
3860Sstevel@tonic-gate #define CERT_PUBLIC_KEY		1
3870Sstevel@tonic-gate #define CERT_PRIVATE_KEY	2
3880Sstevel@tonic-gate */
3890Sstevel@tonic-gate 
390*2139Sjp161948 #ifndef OPENSSL_NO_EC
391*2139Sjp161948 /* From ECC-TLS draft, used in encoding the curve type in
392*2139Sjp161948  * ECParameters
393*2139Sjp161948  */
394*2139Sjp161948 #define EXPLICIT_PRIME_CURVE_TYPE  1
395*2139Sjp161948 #define EXPLICIT_CHAR2_CURVE_TYPE  2
396*2139Sjp161948 #define NAMED_CURVE_TYPE           3
397*2139Sjp161948 #endif  /* OPENSSL_NO_EC */
398*2139Sjp161948 
3990Sstevel@tonic-gate typedef struct cert_pkey_st
4000Sstevel@tonic-gate 	{
4010Sstevel@tonic-gate 	X509 *x509;
4020Sstevel@tonic-gate 	EVP_PKEY *privatekey;
4030Sstevel@tonic-gate 	} CERT_PKEY;
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate typedef struct cert_st
4060Sstevel@tonic-gate 	{
4070Sstevel@tonic-gate 	/* Current active set */
4080Sstevel@tonic-gate 	CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array
4090Sstevel@tonic-gate 			 * Probably it would make more sense to store
4100Sstevel@tonic-gate 			 * an index, not a pointer. */
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate 	/* The following masks are for the key and auth
4130Sstevel@tonic-gate 	 * algorithms that are supported by the certs below */
4140Sstevel@tonic-gate 	int valid;
4150Sstevel@tonic-gate 	unsigned long mask;
4160Sstevel@tonic-gate 	unsigned long export_mask;
4170Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
4180Sstevel@tonic-gate 	RSA *rsa_tmp;
4190Sstevel@tonic-gate 	RSA *(*rsa_tmp_cb)(SSL *ssl,int is_export,int keysize);
4200Sstevel@tonic-gate #endif
4210Sstevel@tonic-gate #ifndef OPENSSL_NO_DH
4220Sstevel@tonic-gate 	DH *dh_tmp;
4230Sstevel@tonic-gate 	DH *(*dh_tmp_cb)(SSL *ssl,int is_export,int keysize);
4240Sstevel@tonic-gate #endif
425*2139Sjp161948 #ifndef OPENSSL_NO_ECDH
426*2139Sjp161948 	EC_KEY *ecdh_tmp;
427*2139Sjp161948 	/* Callback for generating ephemeral ECDH keys */
428*2139Sjp161948 	EC_KEY *(*ecdh_tmp_cb)(SSL *ssl,int is_export,int keysize);
429*2139Sjp161948 #endif
4300Sstevel@tonic-gate 
4310Sstevel@tonic-gate 	CERT_PKEY pkeys[SSL_PKEY_NUM];
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate 	int references; /* >1 only if SSL_copy_session_id is used */
4340Sstevel@tonic-gate 	} CERT;
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate 
4370Sstevel@tonic-gate typedef struct sess_cert_st
4380Sstevel@tonic-gate 	{
4390Sstevel@tonic-gate 	STACK_OF(X509) *cert_chain; /* as received from peer (not for SSL2) */
4400Sstevel@tonic-gate 
4410Sstevel@tonic-gate 	/* The 'peer_...' members are used only by clients. */
4420Sstevel@tonic-gate 	int peer_cert_type;
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate 	CERT_PKEY *peer_key; /* points to an element of peer_pkeys (never NULL!) */
4450Sstevel@tonic-gate 	CERT_PKEY peer_pkeys[SSL_PKEY_NUM];
4460Sstevel@tonic-gate 	/* Obviously we don't have the private keys of these,
4470Sstevel@tonic-gate 	 * so maybe we shouldn't even use the CERT_PKEY type here. */
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate #ifndef OPENSSL_NO_RSA
4500Sstevel@tonic-gate 	RSA *peer_rsa_tmp; /* not used for SSL 2 */
4510Sstevel@tonic-gate #endif
4520Sstevel@tonic-gate #ifndef OPENSSL_NO_DH
4530Sstevel@tonic-gate 	DH *peer_dh_tmp; /* not used for SSL 2 */
4540Sstevel@tonic-gate #endif
455*2139Sjp161948 #ifndef OPENSSL_NO_ECDH
456*2139Sjp161948 	EC_KEY *peer_ecdh_tmp;
457*2139Sjp161948 #endif
4580Sstevel@tonic-gate 
4590Sstevel@tonic-gate 	int references; /* actually always 1 at the moment */
4600Sstevel@tonic-gate 	} SESS_CERT;
4610Sstevel@tonic-gate 
4620Sstevel@tonic-gate 
4630Sstevel@tonic-gate /*#define MAC_DEBUG	*/
4640Sstevel@tonic-gate 
4650Sstevel@tonic-gate /*#define ERR_DEBUG	*/
4660Sstevel@tonic-gate /*#define ABORT_DEBUG	*/
4670Sstevel@tonic-gate /*#define PKT_DEBUG 1   */
4680Sstevel@tonic-gate /*#define DES_DEBUG	*/
4690Sstevel@tonic-gate /*#define DES_OFB_DEBUG	*/
4700Sstevel@tonic-gate /*#define SSL_DEBUG	*/
4710Sstevel@tonic-gate /*#define RSA_DEBUG	*/
4720Sstevel@tonic-gate /*#define IDEA_DEBUG	*/
4730Sstevel@tonic-gate 
4740Sstevel@tonic-gate #define FP_ICC  (int (*)(const void *,const void *))
4750Sstevel@tonic-gate #define ssl_put_cipher_by_char(ssl,ciph,ptr) \
4760Sstevel@tonic-gate 		((ssl)->method->put_cipher_by_char((ciph),(ptr)))
4770Sstevel@tonic-gate #define ssl_get_cipher_by_char(ssl,ptr) \
4780Sstevel@tonic-gate 		((ssl)->method->get_cipher_by_char(ptr))
4790Sstevel@tonic-gate 
4800Sstevel@tonic-gate /* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff
4810Sstevel@tonic-gate  * It is a bit of a mess of functions, but hell, think of it as
4820Sstevel@tonic-gate  * an opaque structure :-) */
4830Sstevel@tonic-gate typedef struct ssl3_enc_method
4840Sstevel@tonic-gate 	{
4850Sstevel@tonic-gate 	int (*enc)(SSL *, int);
4860Sstevel@tonic-gate 	int (*mac)(SSL *, unsigned char *, int);
4870Sstevel@tonic-gate 	int (*setup_key_block)(SSL *);
4880Sstevel@tonic-gate 	int (*generate_master_secret)(SSL *, unsigned char *, unsigned char *, int);
4890Sstevel@tonic-gate 	int (*change_cipher_state)(SSL *, int);
4900Sstevel@tonic-gate 	int (*final_finish_mac)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char *, int, unsigned char *);
4910Sstevel@tonic-gate 	int finish_mac_length;
4920Sstevel@tonic-gate 	int (*cert_verify_mac)(SSL *, EVP_MD_CTX *, unsigned char *);
4930Sstevel@tonic-gate 	const char *client_finished_label;
4940Sstevel@tonic-gate 	int client_finished_label_len;
4950Sstevel@tonic-gate 	const char *server_finished_label;
4960Sstevel@tonic-gate 	int server_finished_label_len;
4970Sstevel@tonic-gate 	int (*alert_value)(int);
4980Sstevel@tonic-gate 	} SSL3_ENC_METHOD;
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate /* Used for holding the relevant compression methods loaded into SSL_CTX */
5010Sstevel@tonic-gate typedef struct ssl3_comp_st
5020Sstevel@tonic-gate 	{
5030Sstevel@tonic-gate 	int comp_id;	/* The identifier byte for this compression type */
5040Sstevel@tonic-gate 	char *name;	/* Text name used for the compression type */
5050Sstevel@tonic-gate 	COMP_METHOD *method; /* The method :-) */
5060Sstevel@tonic-gate 	} SSL3_COMP;
5070Sstevel@tonic-gate 
508*2139Sjp161948 extern SSL3_ENC_METHOD ssl3_undef_enc_method;
5090Sstevel@tonic-gate OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[];
5100Sstevel@tonic-gate OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[];
5110Sstevel@tonic-gate 
5120Sstevel@tonic-gate 
5130Sstevel@tonic-gate SSL_METHOD *ssl_bad_method(int ver);
5140Sstevel@tonic-gate SSL_METHOD *sslv2_base_method(void);
5150Sstevel@tonic-gate SSL_METHOD *sslv23_base_method(void);
5160Sstevel@tonic-gate SSL_METHOD *sslv3_base_method(void);
5170Sstevel@tonic-gate 
518*2139Sjp161948 extern SSL3_ENC_METHOD TLSv1_enc_data;
519*2139Sjp161948 extern SSL3_ENC_METHOD SSLv3_enc_data;
520*2139Sjp161948 extern SSL3_ENC_METHOD DTLSv1_enc_data;
521*2139Sjp161948 
522*2139Sjp161948 #define IMPLEMENT_tls1_meth_func(func_name, s_accept, s_connect, s_get_meth) \
523*2139Sjp161948 SSL_METHOD *func_name(void)  \
524*2139Sjp161948 	{ \
525*2139Sjp161948 	static SSL_METHOD func_name##_data= { \
526*2139Sjp161948 		TLS1_VERSION, \
527*2139Sjp161948 		tls1_new, \
528*2139Sjp161948 		tls1_clear, \
529*2139Sjp161948 		tls1_free, \
530*2139Sjp161948 		s_accept, \
531*2139Sjp161948 		s_connect, \
532*2139Sjp161948 		ssl3_read, \
533*2139Sjp161948 		ssl3_peek, \
534*2139Sjp161948 		ssl3_write, \
535*2139Sjp161948 		ssl3_shutdown, \
536*2139Sjp161948 		ssl3_renegotiate, \
537*2139Sjp161948 		ssl3_renegotiate_check, \
538*2139Sjp161948 		ssl3_get_message, \
539*2139Sjp161948 		ssl3_read_bytes, \
540*2139Sjp161948 		ssl3_write_bytes, \
541*2139Sjp161948 		ssl3_dispatch_alert, \
542*2139Sjp161948 		ssl3_ctrl, \
543*2139Sjp161948 		ssl3_ctx_ctrl, \
544*2139Sjp161948 		ssl3_get_cipher_by_char, \
545*2139Sjp161948 		ssl3_put_cipher_by_char, \
546*2139Sjp161948 		ssl3_pending, \
547*2139Sjp161948 		ssl3_num_ciphers, \
548*2139Sjp161948 		ssl3_get_cipher, \
549*2139Sjp161948 		s_get_meth, \
550*2139Sjp161948 		tls1_default_timeout, \
551*2139Sjp161948 		&TLSv1_enc_data, \
552*2139Sjp161948 		ssl_undefined_void_function, \
553*2139Sjp161948 		ssl3_callback_ctrl, \
554*2139Sjp161948 		ssl3_ctx_callback_ctrl, \
555*2139Sjp161948 	}; \
556*2139Sjp161948 	return &func_name##_data; \
557*2139Sjp161948 	}
558*2139Sjp161948 
559*2139Sjp161948 #define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect, s_get_meth) \
560*2139Sjp161948 SSL_METHOD *func_name(void)  \
561*2139Sjp161948 	{ \
562*2139Sjp161948 	static SSL_METHOD func_name##_data= { \
563*2139Sjp161948 		SSL3_VERSION, \
564*2139Sjp161948 		ssl3_new, \
565*2139Sjp161948 		ssl3_clear, \
566*2139Sjp161948 		ssl3_free, \
567*2139Sjp161948 		s_accept, \
568*2139Sjp161948 		s_connect, \
569*2139Sjp161948 		ssl3_read, \
570*2139Sjp161948 		ssl3_peek, \
571*2139Sjp161948 		ssl3_write, \
572*2139Sjp161948 		ssl3_shutdown, \
573*2139Sjp161948 		ssl3_renegotiate, \
574*2139Sjp161948 		ssl3_renegotiate_check, \
575*2139Sjp161948 		ssl3_get_message, \
576*2139Sjp161948 		ssl3_read_bytes, \
577*2139Sjp161948 		ssl3_write_bytes, \
578*2139Sjp161948 		ssl3_dispatch_alert, \
579*2139Sjp161948 		ssl3_ctrl, \
580*2139Sjp161948 		ssl3_ctx_ctrl, \
581*2139Sjp161948 		ssl3_get_cipher_by_char, \
582*2139Sjp161948 		ssl3_put_cipher_by_char, \
583*2139Sjp161948 		ssl3_pending, \
584*2139Sjp161948 		ssl3_num_ciphers, \
585*2139Sjp161948 		ssl3_get_cipher, \
586*2139Sjp161948 		s_get_meth, \
587*2139Sjp161948 		ssl3_default_timeout, \
588*2139Sjp161948 		&SSLv3_enc_data, \
589*2139Sjp161948 		ssl_undefined_void_function, \
590*2139Sjp161948 		ssl3_callback_ctrl, \
591*2139Sjp161948 		ssl3_ctx_callback_ctrl, \
592*2139Sjp161948 	}; \
593*2139Sjp161948 	return &func_name##_data; \
594*2139Sjp161948 	}
595*2139Sjp161948 
596*2139Sjp161948 #define IMPLEMENT_ssl23_meth_func(func_name, s_accept, s_connect, s_get_meth) \
597*2139Sjp161948 SSL_METHOD *func_name(void)  \
598*2139Sjp161948 	{ \
599*2139Sjp161948 	static SSL_METHOD func_name##_data= { \
600*2139Sjp161948 	TLS1_VERSION, \
601*2139Sjp161948 	tls1_new, \
602*2139Sjp161948 	tls1_clear, \
603*2139Sjp161948 	tls1_free, \
604*2139Sjp161948 	s_accept, \
605*2139Sjp161948 	s_connect, \
606*2139Sjp161948 	ssl23_read, \
607*2139Sjp161948 	ssl23_peek, \
608*2139Sjp161948 	ssl23_write, \
609*2139Sjp161948 	ssl_undefined_function, \
610*2139Sjp161948 	ssl_undefined_function, \
611*2139Sjp161948 	ssl_ok, \
612*2139Sjp161948 	ssl3_get_message, \
613*2139Sjp161948 	ssl3_read_bytes, \
614*2139Sjp161948 	ssl3_write_bytes, \
615*2139Sjp161948 	ssl3_dispatch_alert, \
616*2139Sjp161948 	ssl3_ctrl, \
617*2139Sjp161948 	ssl3_ctx_ctrl, \
618*2139Sjp161948 	ssl23_get_cipher_by_char, \
619*2139Sjp161948 	ssl23_put_cipher_by_char, \
620*2139Sjp161948 	ssl_undefined_const_function, \
621*2139Sjp161948 	ssl23_num_ciphers, \
622*2139Sjp161948 	ssl23_get_cipher, \
623*2139Sjp161948 	s_get_meth, \
624*2139Sjp161948 	ssl23_default_timeout, \
625*2139Sjp161948 	&ssl3_undef_enc_method, \
626*2139Sjp161948 	ssl_undefined_void_function, \
627*2139Sjp161948 	ssl3_callback_ctrl, \
628*2139Sjp161948 	ssl3_ctx_callback_ctrl, \
629*2139Sjp161948 	}; \
630*2139Sjp161948 	return &func_name##_data; \
631*2139Sjp161948 	}
632*2139Sjp161948 
633*2139Sjp161948 #define IMPLEMENT_ssl2_meth_func(func_name, s_accept, s_connect, s_get_meth) \
634*2139Sjp161948 SSL_METHOD *func_name(void)  \
635*2139Sjp161948 	{ \
636*2139Sjp161948 	static SSL_METHOD func_name##_data= { \
637*2139Sjp161948 		SSL2_VERSION, \
638*2139Sjp161948 		ssl2_new,	/* local */ \
639*2139Sjp161948 		ssl2_clear,	/* local */ \
640*2139Sjp161948 		ssl2_free,	/* local */ \
641*2139Sjp161948 		s_accept, \
642*2139Sjp161948 		s_connect, \
643*2139Sjp161948 		ssl2_read, \
644*2139Sjp161948 		ssl2_peek, \
645*2139Sjp161948 		ssl2_write, \
646*2139Sjp161948 		ssl2_shutdown, \
647*2139Sjp161948 		ssl_ok,	/* NULL - renegotiate */ \
648*2139Sjp161948 		ssl_ok,	/* NULL - check renegotiate */ \
649*2139Sjp161948 		NULL, /* NULL - ssl_get_message */ \
650*2139Sjp161948 		NULL, /* NULL - ssl_get_record */ \
651*2139Sjp161948 		NULL, /* NULL - ssl_write_bytes */ \
652*2139Sjp161948 		NULL, /* NULL - dispatch_alert */ \
653*2139Sjp161948 		ssl2_ctrl,	/* local */ \
654*2139Sjp161948 		ssl2_ctx_ctrl,	/* local */ \
655*2139Sjp161948 		ssl2_get_cipher_by_char, \
656*2139Sjp161948 		ssl2_put_cipher_by_char, \
657*2139Sjp161948 		ssl2_pending, \
658*2139Sjp161948 		ssl2_num_ciphers, \
659*2139Sjp161948 		ssl2_get_cipher, \
660*2139Sjp161948 		s_get_meth, \
661*2139Sjp161948 		ssl2_default_timeout, \
662*2139Sjp161948 		&ssl3_undef_enc_method, \
663*2139Sjp161948 		ssl_undefined_void_function, \
664*2139Sjp161948 		ssl2_callback_ctrl,	/* local */ \
665*2139Sjp161948 		ssl2_ctx_callback_ctrl,	/* local */ \
666*2139Sjp161948 	}; \
667*2139Sjp161948 	return &func_name##_data; \
668*2139Sjp161948 	}
669*2139Sjp161948 
670*2139Sjp161948 #define IMPLEMENT_dtls1_meth_func(func_name, s_accept, s_connect, s_get_meth) \
671*2139Sjp161948 SSL_METHOD *func_name(void)  \
672*2139Sjp161948 	{ \
673*2139Sjp161948 	static SSL_METHOD func_name##_data= { \
674*2139Sjp161948 		DTLS1_VERSION, \
675*2139Sjp161948 		dtls1_new, \
676*2139Sjp161948 		dtls1_clear, \
677*2139Sjp161948 		dtls1_free, \
678*2139Sjp161948 		s_accept, \
679*2139Sjp161948 		s_connect, \
680*2139Sjp161948 		ssl3_read, \
681*2139Sjp161948 		ssl3_peek, \
682*2139Sjp161948 		ssl3_write, \
683*2139Sjp161948 		ssl3_shutdown, \
684*2139Sjp161948 		ssl3_renegotiate, \
685*2139Sjp161948 		ssl3_renegotiate_check, \
686*2139Sjp161948 		dtls1_get_message, \
687*2139Sjp161948 		dtls1_read_bytes, \
688*2139Sjp161948 		dtls1_write_app_data_bytes, \
689*2139Sjp161948 		dtls1_dispatch_alert, \
690*2139Sjp161948 		ssl3_ctrl, \
691*2139Sjp161948 		ssl3_ctx_ctrl, \
692*2139Sjp161948 		ssl3_get_cipher_by_char, \
693*2139Sjp161948 		ssl3_put_cipher_by_char, \
694*2139Sjp161948 		ssl3_pending, \
695*2139Sjp161948 		ssl3_num_ciphers, \
696*2139Sjp161948 		ssl3_get_cipher, \
697*2139Sjp161948 		s_get_meth, \
698*2139Sjp161948 		dtls1_default_timeout, \
699*2139Sjp161948 		&DTLSv1_enc_data, \
700*2139Sjp161948 		ssl_undefined_void_function, \
701*2139Sjp161948 		ssl3_callback_ctrl, \
702*2139Sjp161948 		ssl3_ctx_callback_ctrl, \
703*2139Sjp161948 	}; \
704*2139Sjp161948 	return &func_name##_data; \
705*2139Sjp161948 	}
706*2139Sjp161948 
7070Sstevel@tonic-gate void ssl_clear_cipher_ctx(SSL *s);
7080Sstevel@tonic-gate int ssl_clear_bad_session(SSL *s);
7090Sstevel@tonic-gate CERT *ssl_cert_new(void);
7100Sstevel@tonic-gate CERT *ssl_cert_dup(CERT *cert);
7110Sstevel@tonic-gate int ssl_cert_inst(CERT **o);
7120Sstevel@tonic-gate void ssl_cert_free(CERT *c);
7130Sstevel@tonic-gate SESS_CERT *ssl_sess_cert_new(void);
7140Sstevel@tonic-gate void ssl_sess_cert_free(SESS_CERT *sc);
7150Sstevel@tonic-gate int ssl_set_peer_cert_type(SESS_CERT *c, int type);
7160Sstevel@tonic-gate int ssl_get_new_session(SSL *s, int session);
7170Sstevel@tonic-gate int ssl_get_prev_session(SSL *s, unsigned char *session,int len);
7180Sstevel@tonic-gate int ssl_cipher_id_cmp(const SSL_CIPHER *a,const SSL_CIPHER *b);
7190Sstevel@tonic-gate int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap,
7200Sstevel@tonic-gate 			const SSL_CIPHER * const *bp);
7210Sstevel@tonic-gate STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,
7220Sstevel@tonic-gate 					       STACK_OF(SSL_CIPHER) **skp);
723*2139Sjp161948 int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p,
724*2139Sjp161948                              int (*put_cb)(const SSL_CIPHER *, unsigned char *));
7250Sstevel@tonic-gate STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth,
7260Sstevel@tonic-gate 					     STACK_OF(SSL_CIPHER) **pref,
7270Sstevel@tonic-gate 					     STACK_OF(SSL_CIPHER) **sorted,
7280Sstevel@tonic-gate 					     const char *rule_str);
7290Sstevel@tonic-gate void ssl_update_cache(SSL *s, int mode);
730*2139Sjp161948 int ssl_cipher_get_evp(const SSL_SESSION *s,const EVP_CIPHER **enc,
731*2139Sjp161948 		       const EVP_MD **md,SSL_COMP **comp);
7320Sstevel@tonic-gate int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk);
7330Sstevel@tonic-gate int ssl_undefined_function(SSL *s);
734*2139Sjp161948 int ssl_undefined_void_function(void);
735*2139Sjp161948 int ssl_undefined_const_function(const SSL *s);
7360Sstevel@tonic-gate X509 *ssl_get_server_send_cert(SSL *);
7370Sstevel@tonic-gate EVP_PKEY *ssl_get_sign_pkey(SSL *,SSL_CIPHER *);
7380Sstevel@tonic-gate int ssl_cert_type(X509 *x,EVP_PKEY *pkey);
7390Sstevel@tonic-gate void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher);
7400Sstevel@tonic-gate STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s);
7410Sstevel@tonic-gate int ssl_verify_alarm_type(long type);
742*2139Sjp161948 void ssl_load_ciphers(void);
7430Sstevel@tonic-gate 
7440Sstevel@tonic-gate int ssl2_enc_init(SSL *s, int client);
7450Sstevel@tonic-gate int ssl2_generate_key_material(SSL *s);
7460Sstevel@tonic-gate void ssl2_enc(SSL *s,int send_data);
7470Sstevel@tonic-gate void ssl2_mac(SSL *s,unsigned char *mac,int send_data);
7480Sstevel@tonic-gate SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p);
7490Sstevel@tonic-gate int ssl2_put_cipher_by_char(const SSL_CIPHER *c,unsigned char *p);
7500Sstevel@tonic-gate int ssl2_part_read(SSL *s, unsigned long f, int i);
7510Sstevel@tonic-gate int ssl2_do_write(SSL *s);
752*2139Sjp161948 int ssl2_set_certificate(SSL *s, int type, int len, const unsigned char *data);
7530Sstevel@tonic-gate void ssl2_return_error(SSL *s,int reason);
7540Sstevel@tonic-gate void ssl2_write_error(SSL *s);
7550Sstevel@tonic-gate int ssl2_num_ciphers(void);
7560Sstevel@tonic-gate SSL_CIPHER *ssl2_get_cipher(unsigned int u);
7570Sstevel@tonic-gate int	ssl2_new(SSL *s);
7580Sstevel@tonic-gate void	ssl2_free(SSL *s);
7590Sstevel@tonic-gate int	ssl2_accept(SSL *s);
7600Sstevel@tonic-gate int	ssl2_connect(SSL *s);
7610Sstevel@tonic-gate int	ssl2_read(SSL *s, void *buf, int len);
7620Sstevel@tonic-gate int	ssl2_peek(SSL *s, void *buf, int len);
7630Sstevel@tonic-gate int	ssl2_write(SSL *s, const void *buf, int len);
7640Sstevel@tonic-gate int	ssl2_shutdown(SSL *s);
7650Sstevel@tonic-gate void	ssl2_clear(SSL *s);
7660Sstevel@tonic-gate long	ssl2_ctrl(SSL *s,int cmd, long larg, void *parg);
7670Sstevel@tonic-gate long	ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg);
768*2139Sjp161948 long	ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)(void));
769*2139Sjp161948 long	ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)(void));
770*2139Sjp161948 int	ssl2_pending(const SSL *s);
771*2139Sjp161948 long	ssl2_default_timeout(void );
7720Sstevel@tonic-gate 
7730Sstevel@tonic-gate SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
7740Sstevel@tonic-gate int ssl3_put_cipher_by_char(const SSL_CIPHER *c,unsigned char *p);
7750Sstevel@tonic-gate void ssl3_init_finished_mac(SSL *s);
7760Sstevel@tonic-gate int ssl3_send_server_certificate(SSL *s);
7770Sstevel@tonic-gate int ssl3_get_finished(SSL *s,int state_a,int state_b);
7780Sstevel@tonic-gate int ssl3_setup_key_block(SSL *s);
7790Sstevel@tonic-gate int ssl3_send_change_cipher_spec(SSL *s,int state_a,int state_b);
7800Sstevel@tonic-gate int ssl3_change_cipher_state(SSL *s,int which);
7810Sstevel@tonic-gate void ssl3_cleanup_key_block(SSL *s);
7820Sstevel@tonic-gate int ssl3_do_write(SSL *s,int type);
7830Sstevel@tonic-gate void ssl3_send_alert(SSL *s,int level, int desc);
7840Sstevel@tonic-gate int ssl3_generate_master_secret(SSL *s, unsigned char *out,
7850Sstevel@tonic-gate 	unsigned char *p, int len);
7860Sstevel@tonic-gate int ssl3_get_req_cert_type(SSL *s,unsigned char *p);
7870Sstevel@tonic-gate long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
7880Sstevel@tonic-gate int ssl3_send_finished(SSL *s, int a, int b, const char *sender,int slen);
7890Sstevel@tonic-gate int ssl3_num_ciphers(void);
7900Sstevel@tonic-gate SSL_CIPHER *ssl3_get_cipher(unsigned int u);
7910Sstevel@tonic-gate int ssl3_renegotiate(SSL *ssl);
7920Sstevel@tonic-gate int ssl3_renegotiate_check(SSL *ssl);
7930Sstevel@tonic-gate int ssl3_dispatch_alert(SSL *s);
7940Sstevel@tonic-gate int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
7950Sstevel@tonic-gate int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
7960Sstevel@tonic-gate int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1, EVP_MD_CTX *ctx2,
7970Sstevel@tonic-gate 	const char *sender, int slen,unsigned char *p);
7980Sstevel@tonic-gate int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p);
7990Sstevel@tonic-gate void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len);
8000Sstevel@tonic-gate int ssl3_enc(SSL *s, int send_data);
8010Sstevel@tonic-gate int ssl3_mac(SSL *ssl, unsigned char *md, int send_data);
8020Sstevel@tonic-gate unsigned long ssl3_output_cert_chain(SSL *s, X509 *x);
8030Sstevel@tonic-gate SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK_OF(SSL_CIPHER) *clnt,
8040Sstevel@tonic-gate 			       STACK_OF(SSL_CIPHER) *srvr);
8050Sstevel@tonic-gate int	ssl3_setup_buffers(SSL *s);
8060Sstevel@tonic-gate int	ssl3_new(SSL *s);
8070Sstevel@tonic-gate void	ssl3_free(SSL *s);
8080Sstevel@tonic-gate int	ssl3_accept(SSL *s);
8090Sstevel@tonic-gate int	ssl3_connect(SSL *s);
8100Sstevel@tonic-gate int	ssl3_read(SSL *s, void *buf, int len);
8110Sstevel@tonic-gate int	ssl3_peek(SSL *s, void *buf, int len);
8120Sstevel@tonic-gate int	ssl3_write(SSL *s, const void *buf, int len);
8130Sstevel@tonic-gate int	ssl3_shutdown(SSL *s);
8140Sstevel@tonic-gate void	ssl3_clear(SSL *s);
8150Sstevel@tonic-gate long	ssl3_ctrl(SSL *s,int cmd, long larg, void *parg);
8160Sstevel@tonic-gate long	ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg);
817*2139Sjp161948 long	ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)(void));
818*2139Sjp161948 long	ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)(void));
819*2139Sjp161948 int	ssl3_pending(const SSL *s);
820*2139Sjp161948 
821*2139Sjp161948 void ssl3_record_sequence_update(unsigned char *seq);
822*2139Sjp161948 int ssl3_do_change_cipher_spec(SSL *ssl);
823*2139Sjp161948 long ssl3_default_timeout(void );
824*2139Sjp161948 
825*2139Sjp161948 int ssl23_num_ciphers(void );
826*2139Sjp161948 SSL_CIPHER *ssl23_get_cipher(unsigned int u);
827*2139Sjp161948 int ssl23_read(SSL *s, void *buf, int len);
828*2139Sjp161948 int ssl23_peek(SSL *s, void *buf, int len);
829*2139Sjp161948 int ssl23_write(SSL *s, const void *buf, int len);
830*2139Sjp161948 int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p);
831*2139Sjp161948 SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p);
832*2139Sjp161948 long ssl23_default_timeout(void );
833*2139Sjp161948 
834*2139Sjp161948 long tls1_default_timeout(void);
835*2139Sjp161948 int dtls1_do_write(SSL *s,int type);
836*2139Sjp161948 int ssl3_read_n(SSL *s, int n, int max, int extend);
837*2139Sjp161948 int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
838*2139Sjp161948 int ssl3_do_compress(SSL *ssl);
839*2139Sjp161948 int ssl3_do_uncompress(SSL *ssl);
840*2139Sjp161948 int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
841*2139Sjp161948 	unsigned int len);
842*2139Sjp161948 unsigned char *dtls1_set_message_header(SSL *s,
843*2139Sjp161948 	unsigned char *p, unsigned char mt,	unsigned long len,
844*2139Sjp161948 	unsigned long frag_off, unsigned long frag_len);
845*2139Sjp161948 
846*2139Sjp161948 int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len);
847*2139Sjp161948 int dtls1_write_bytes(SSL *s, int type, const void *buf, int len);
848*2139Sjp161948 
849*2139Sjp161948 int dtls1_send_change_cipher_spec(SSL *s, int a, int b);
850*2139Sjp161948 int dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen);
851*2139Sjp161948 unsigned long dtls1_output_cert_chain(SSL *s, X509 *x);
852*2139Sjp161948 int dtls1_read_failed(SSL *s, int code);
853*2139Sjp161948 int dtls1_buffer_message(SSL *s, int ccs);
854*2139Sjp161948 int dtls1_retransmit_message(SSL *s, unsigned short seq,
855*2139Sjp161948 	unsigned long frag_off, int *found);
856*2139Sjp161948 void dtls1_clear_record_buffer(SSL *s);
857*2139Sjp161948 void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr);
858*2139Sjp161948 void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr);
859*2139Sjp161948 void dtls1_reset_seq_numbers(SSL *s, int rw);
860*2139Sjp161948 long dtls1_default_timeout(void);
861*2139Sjp161948 
862*2139Sjp161948 
863*2139Sjp161948 /* some client-only functions */
864*2139Sjp161948 int ssl3_client_hello(SSL *s);
865*2139Sjp161948 int ssl3_get_server_hello(SSL *s);
866*2139Sjp161948 int ssl3_get_certificate_request(SSL *s);
867*2139Sjp161948 int ssl3_get_server_done(SSL *s);
868*2139Sjp161948 int ssl3_send_client_verify(SSL *s);
869*2139Sjp161948 int ssl3_send_client_certificate(SSL *s);
870*2139Sjp161948 int ssl3_send_client_key_exchange(SSL *s);
871*2139Sjp161948 int ssl3_get_key_exchange(SSL *s);
872*2139Sjp161948 int ssl3_get_server_certificate(SSL *s);
873*2139Sjp161948 int ssl3_check_cert_and_algorithm(SSL *s);
874*2139Sjp161948 
875*2139Sjp161948 int dtls1_client_hello(SSL *s);
876*2139Sjp161948 int dtls1_send_client_certificate(SSL *s);
877*2139Sjp161948 int dtls1_send_client_key_exchange(SSL *s);
878*2139Sjp161948 int dtls1_send_client_verify(SSL *s);
879*2139Sjp161948 
880*2139Sjp161948 /* some server-only functions */
881*2139Sjp161948 int ssl3_get_client_hello(SSL *s);
882*2139Sjp161948 int ssl3_send_server_hello(SSL *s);
883*2139Sjp161948 int ssl3_send_hello_request(SSL *s);
884*2139Sjp161948 int ssl3_send_server_key_exchange(SSL *s);
885*2139Sjp161948 int ssl3_send_certificate_request(SSL *s);
886*2139Sjp161948 int ssl3_send_server_done(SSL *s);
887*2139Sjp161948 int ssl3_check_client_hello(SSL *s);
888*2139Sjp161948 int ssl3_get_client_certificate(SSL *s);
889*2139Sjp161948 int ssl3_get_client_key_exchange(SSL *s);
890*2139Sjp161948 int ssl3_get_cert_verify(SSL *s);
891*2139Sjp161948 
892*2139Sjp161948 int dtls1_send_hello_request(SSL *s);
893*2139Sjp161948 int dtls1_send_server_hello(SSL *s);
894*2139Sjp161948 int dtls1_send_server_certificate(SSL *s);
895*2139Sjp161948 int dtls1_send_server_key_exchange(SSL *s);
896*2139Sjp161948 int dtls1_send_certificate_request(SSL *s);
897*2139Sjp161948 int dtls1_send_server_done(SSL *s);
898*2139Sjp161948 
899*2139Sjp161948 
9000Sstevel@tonic-gate 
9010Sstevel@tonic-gate int ssl23_accept(SSL *s);
9020Sstevel@tonic-gate int ssl23_connect(SSL *s);
9030Sstevel@tonic-gate int ssl23_read_bytes(SSL *s, int n);
9040Sstevel@tonic-gate int ssl23_write_bytes(SSL *s);
9050Sstevel@tonic-gate 
9060Sstevel@tonic-gate int tls1_new(SSL *s);
9070Sstevel@tonic-gate void tls1_free(SSL *s);
9080Sstevel@tonic-gate void tls1_clear(SSL *s);
9090Sstevel@tonic-gate long tls1_ctrl(SSL *s,int cmd, long larg, void *parg);
910*2139Sjp161948 long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)(void));
9110Sstevel@tonic-gate SSL_METHOD *tlsv1_base_method(void );
9120Sstevel@tonic-gate 
913*2139Sjp161948 int dtls1_new(SSL *s);
914*2139Sjp161948 int	dtls1_accept(SSL *s);
915*2139Sjp161948 int	dtls1_connect(SSL *s);
916*2139Sjp161948 void dtls1_free(SSL *s);
917*2139Sjp161948 void dtls1_clear(SSL *s);
918*2139Sjp161948 long dtls1_ctrl(SSL *s,int cmd, long larg, void *parg);
919*2139Sjp161948 SSL_METHOD *dtlsv1_base_method(void );
920*2139Sjp161948 
921*2139Sjp161948 long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
922*2139Sjp161948 int dtls1_get_record(SSL *s);
923*2139Sjp161948 int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
924*2139Sjp161948 	unsigned int len, int create_empty_fragement);
925*2139Sjp161948 int dtls1_dispatch_alert(SSL *s);
926*2139Sjp161948 int dtls1_enc(SSL *s, int snd);
927*2139Sjp161948 
9280Sstevel@tonic-gate int ssl_init_wbio_buffer(SSL *s, int push);
9290Sstevel@tonic-gate void ssl_free_wbio_buffer(SSL *s);
9300Sstevel@tonic-gate 
9310Sstevel@tonic-gate int tls1_change_cipher_state(SSL *s, int which);
9320Sstevel@tonic-gate int tls1_setup_key_block(SSL *s);
9330Sstevel@tonic-gate int tls1_enc(SSL *s, int snd);
9340Sstevel@tonic-gate int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx,
9350Sstevel@tonic-gate 	const char *str, int slen, unsigned char *p);
9360Sstevel@tonic-gate int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p);
9370Sstevel@tonic-gate int tls1_mac(SSL *ssl, unsigned char *md, int snd);
9380Sstevel@tonic-gate int tls1_generate_master_secret(SSL *s, unsigned char *out,
9390Sstevel@tonic-gate 	unsigned char *p, int len);
9400Sstevel@tonic-gate int tls1_alert_code(int code);
9410Sstevel@tonic-gate int ssl3_alert_code(int code);
9420Sstevel@tonic-gate int ssl_ok(SSL *s);
9430Sstevel@tonic-gate 
944*2139Sjp161948 int check_srvr_ecc_cert_and_alg(X509 *x, SSL_CIPHER *cs);
945*2139Sjp161948 
9460Sstevel@tonic-gate SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n);
9470Sstevel@tonic-gate 
9480Sstevel@tonic-gate 
9490Sstevel@tonic-gate #endif
950