1*0Sstevel@tonic-gate /* ssl/ssl3.h */ 2*0Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3*0Sstevel@tonic-gate * All rights reserved. 4*0Sstevel@tonic-gate * 5*0Sstevel@tonic-gate * This package is an SSL implementation written 6*0Sstevel@tonic-gate * by Eric Young (eay@cryptsoft.com). 7*0Sstevel@tonic-gate * The implementation was written so as to conform with Netscapes SSL. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * This library is free for commercial and non-commercial use as long as 10*0Sstevel@tonic-gate * the following conditions are aheared to. The following conditions 11*0Sstevel@tonic-gate * apply to all code found in this distribution, be it the RC4, RSA, 12*0Sstevel@tonic-gate * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13*0Sstevel@tonic-gate * included with this distribution is covered by the same copyright terms 14*0Sstevel@tonic-gate * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15*0Sstevel@tonic-gate * 16*0Sstevel@tonic-gate * Copyright remains Eric Young's, and as such any Copyright notices in 17*0Sstevel@tonic-gate * the code are not to be removed. 18*0Sstevel@tonic-gate * If this package is used in a product, Eric Young should be given attribution 19*0Sstevel@tonic-gate * as the author of the parts of the library used. 20*0Sstevel@tonic-gate * This can be in the form of a textual message at program startup or 21*0Sstevel@tonic-gate * in documentation (online or textual) provided with the package. 22*0Sstevel@tonic-gate * 23*0Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 24*0Sstevel@tonic-gate * modification, are permitted provided that the following conditions 25*0Sstevel@tonic-gate * are met: 26*0Sstevel@tonic-gate * 1. Redistributions of source code must retain the copyright 27*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 28*0Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 29*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 30*0Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 31*0Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 32*0Sstevel@tonic-gate * must display the following acknowledgement: 33*0Sstevel@tonic-gate * "This product includes cryptographic software written by 34*0Sstevel@tonic-gate * Eric Young (eay@cryptsoft.com)" 35*0Sstevel@tonic-gate * The word 'cryptographic' can be left out if the rouines from the library 36*0Sstevel@tonic-gate * being used are not cryptographic related :-). 37*0Sstevel@tonic-gate * 4. If you include any Windows specific code (or a derivative thereof) from 38*0Sstevel@tonic-gate * the apps directory (application code) you must include an acknowledgement: 39*0Sstevel@tonic-gate * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40*0Sstevel@tonic-gate * 41*0Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42*0Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43*0Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44*0Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45*0Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46*0Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47*0Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48*0Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49*0Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50*0Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51*0Sstevel@tonic-gate * SUCH DAMAGE. 52*0Sstevel@tonic-gate * 53*0Sstevel@tonic-gate * The licence and distribution terms for any publically available version or 54*0Sstevel@tonic-gate * derivative of this code cannot be changed. i.e. this code cannot simply be 55*0Sstevel@tonic-gate * copied and put under another distribution licence 56*0Sstevel@tonic-gate * [including the GNU Public Licence.] 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate /* ==================================================================== 59*0Sstevel@tonic-gate * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 60*0Sstevel@tonic-gate * 61*0Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 62*0Sstevel@tonic-gate * modification, are permitted provided that the following conditions 63*0Sstevel@tonic-gate * are met: 64*0Sstevel@tonic-gate * 65*0Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 66*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 67*0Sstevel@tonic-gate * 68*0Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 69*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in 70*0Sstevel@tonic-gate * the documentation and/or other materials provided with the 71*0Sstevel@tonic-gate * distribution. 72*0Sstevel@tonic-gate * 73*0Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this 74*0Sstevel@tonic-gate * software must display the following acknowledgment: 75*0Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project 76*0Sstevel@tonic-gate * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 77*0Sstevel@tonic-gate * 78*0Sstevel@tonic-gate * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 79*0Sstevel@tonic-gate * endorse or promote products derived from this software without 80*0Sstevel@tonic-gate * prior written permission. For written permission, please contact 81*0Sstevel@tonic-gate * openssl-core@openssl.org. 82*0Sstevel@tonic-gate * 83*0Sstevel@tonic-gate * 5. Products derived from this software may not be called "OpenSSL" 84*0Sstevel@tonic-gate * nor may "OpenSSL" appear in their names without prior written 85*0Sstevel@tonic-gate * permission of the OpenSSL Project. 86*0Sstevel@tonic-gate * 87*0Sstevel@tonic-gate * 6. Redistributions of any form whatsoever must retain the following 88*0Sstevel@tonic-gate * acknowledgment: 89*0Sstevel@tonic-gate * "This product includes software developed by the OpenSSL Project 90*0Sstevel@tonic-gate * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 91*0Sstevel@tonic-gate * 92*0Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 93*0Sstevel@tonic-gate * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 94*0Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 95*0Sstevel@tonic-gate * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 96*0Sstevel@tonic-gate * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 97*0Sstevel@tonic-gate * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 98*0Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 99*0Sstevel@tonic-gate * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 100*0Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 101*0Sstevel@tonic-gate * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 102*0Sstevel@tonic-gate * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 103*0Sstevel@tonic-gate * OF THE POSSIBILITY OF SUCH DAMAGE. 104*0Sstevel@tonic-gate * ==================================================================== 105*0Sstevel@tonic-gate * 106*0Sstevel@tonic-gate * This product includes cryptographic software written by Eric Young 107*0Sstevel@tonic-gate * (eay@cryptsoft.com). This product includes software written by Tim 108*0Sstevel@tonic-gate * Hudson (tjh@cryptsoft.com). 109*0Sstevel@tonic-gate * 110*0Sstevel@tonic-gate */ 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate #ifndef HEADER_SSL3_H 113*0Sstevel@tonic-gate #define HEADER_SSL3_H 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate #ifndef OPENSSL_NO_COMP 116*0Sstevel@tonic-gate #include <openssl/comp.h> 117*0Sstevel@tonic-gate #endif 118*0Sstevel@tonic-gate #include <openssl/buffer.h> 119*0Sstevel@tonic-gate #include <openssl/evp.h> 120*0Sstevel@tonic-gate #include <openssl/ssl.h> 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate #ifdef __cplusplus 123*0Sstevel@tonic-gate extern "C" { 124*0Sstevel@tonic-gate #endif 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate #define SSL3_CK_RSA_NULL_MD5 0x03000001 127*0Sstevel@tonic-gate #define SSL3_CK_RSA_NULL_SHA 0x03000002 128*0Sstevel@tonic-gate #define SSL3_CK_RSA_RC4_40_MD5 0x03000003 129*0Sstevel@tonic-gate #define SSL3_CK_RSA_RC4_128_MD5 0x03000004 130*0Sstevel@tonic-gate #define SSL3_CK_RSA_RC4_128_SHA 0x03000005 131*0Sstevel@tonic-gate #define SSL3_CK_RSA_RC2_40_MD5 0x03000006 132*0Sstevel@tonic-gate #define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 133*0Sstevel@tonic-gate #define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 134*0Sstevel@tonic-gate #define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 135*0Sstevel@tonic-gate #define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate #define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B 138*0Sstevel@tonic-gate #define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C 139*0Sstevel@tonic-gate #define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D 140*0Sstevel@tonic-gate #define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E 141*0Sstevel@tonic-gate #define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F 142*0Sstevel@tonic-gate #define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate #define SSL3_CK_EDH_DSS_DES_40_CBC_SHA 0x03000011 145*0Sstevel@tonic-gate #define SSL3_CK_EDH_DSS_DES_64_CBC_SHA 0x03000012 146*0Sstevel@tonic-gate #define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA 0x03000013 147*0Sstevel@tonic-gate #define SSL3_CK_EDH_RSA_DES_40_CBC_SHA 0x03000014 148*0Sstevel@tonic-gate #define SSL3_CK_EDH_RSA_DES_64_CBC_SHA 0x03000015 149*0Sstevel@tonic-gate #define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA 0x03000016 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate #define SSL3_CK_ADH_RC4_40_MD5 0x03000017 152*0Sstevel@tonic-gate #define SSL3_CK_ADH_RC4_128_MD5 0x03000018 153*0Sstevel@tonic-gate #define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 154*0Sstevel@tonic-gate #define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A 155*0Sstevel@tonic-gate #define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate #define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C 158*0Sstevel@tonic-gate #define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D 159*0Sstevel@tonic-gate #if 0 /* Because it clashes with KRB5, is never used any more, and is safe 160*0Sstevel@tonic-gate to remove according to David Hopwood <david.hopwood@zetnet.co.uk> 161*0Sstevel@tonic-gate of the ietf-tls list */ 162*0Sstevel@tonic-gate #define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E 163*0Sstevel@tonic-gate #endif 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate /* VRS Additional Kerberos5 entries 166*0Sstevel@tonic-gate */ 167*0Sstevel@tonic-gate #define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E 168*0Sstevel@tonic-gate #define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F 169*0Sstevel@tonic-gate #define SSL3_CK_KRB5_RC4_128_SHA 0x03000020 170*0Sstevel@tonic-gate #define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021 171*0Sstevel@tonic-gate #define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022 172*0Sstevel@tonic-gate #define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023 173*0Sstevel@tonic-gate #define SSL3_CK_KRB5_RC4_128_MD5 0x03000024 174*0Sstevel@tonic-gate #define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate #define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026 177*0Sstevel@tonic-gate #define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027 178*0Sstevel@tonic-gate #define SSL3_CK_KRB5_RC4_40_SHA 0x03000028 179*0Sstevel@tonic-gate #define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029 180*0Sstevel@tonic-gate #define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A 181*0Sstevel@tonic-gate #define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate #define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" 184*0Sstevel@tonic-gate #define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" 185*0Sstevel@tonic-gate #define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" 186*0Sstevel@tonic-gate #define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" 187*0Sstevel@tonic-gate #define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" 188*0Sstevel@tonic-gate #define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" 189*0Sstevel@tonic-gate #define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" 190*0Sstevel@tonic-gate #define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" 191*0Sstevel@tonic-gate #define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" 192*0Sstevel@tonic-gate #define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gate #define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" 195*0Sstevel@tonic-gate #define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" 196*0Sstevel@tonic-gate #define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" 197*0Sstevel@tonic-gate #define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" 198*0Sstevel@tonic-gate #define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" 199*0Sstevel@tonic-gate #define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate #define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" 202*0Sstevel@tonic-gate #define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" 203*0Sstevel@tonic-gate #define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" 204*0Sstevel@tonic-gate #define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" 205*0Sstevel@tonic-gate #define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" 206*0Sstevel@tonic-gate #define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" 207*0Sstevel@tonic-gate 208*0Sstevel@tonic-gate #define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" 209*0Sstevel@tonic-gate #define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" 210*0Sstevel@tonic-gate #define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" 211*0Sstevel@tonic-gate #define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" 212*0Sstevel@tonic-gate #define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate #define SSL3_TXT_FZA_DMS_NULL_SHA "FZA-NULL-SHA" 215*0Sstevel@tonic-gate #define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" 216*0Sstevel@tonic-gate #define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" 219*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" 220*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA" 221*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA" 222*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" 223*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" 224*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5" 225*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5" 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" 228*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA" 229*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA" 230*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" 231*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5" 232*0Sstevel@tonic-gate #define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5" 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate #define SSL3_SSL_SESSION_ID_LENGTH 32 235*0Sstevel@tonic-gate #define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gate #define SSL3_MASTER_SECRET_SIZE 48 238*0Sstevel@tonic-gate #define SSL3_RANDOM_SIZE 32 239*0Sstevel@tonic-gate #define SSL3_SESSION_ID_SIZE 32 240*0Sstevel@tonic-gate #define SSL3_RT_HEADER_LENGTH 5 241*0Sstevel@tonic-gate 242*0Sstevel@tonic-gate /* Due to MS stuffing up, this can change.... */ 243*0Sstevel@tonic-gate #if defined(OPENSSL_SYS_WIN16) || \ 244*0Sstevel@tonic-gate (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)) 245*0Sstevel@tonic-gate #define SSL3_RT_MAX_EXTRA (14000) 246*0Sstevel@tonic-gate #else 247*0Sstevel@tonic-gate #define SSL3_RT_MAX_EXTRA (16384) 248*0Sstevel@tonic-gate #endif 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate #define SSL3_RT_MAX_PLAIN_LENGTH 16384 251*0Sstevel@tonic-gate #define SSL3_RT_MAX_COMPRESSED_LENGTH (1024+SSL3_RT_MAX_PLAIN_LENGTH) 252*0Sstevel@tonic-gate #define SSL3_RT_MAX_ENCRYPTED_LENGTH (1024+SSL3_RT_MAX_COMPRESSED_LENGTH) 253*0Sstevel@tonic-gate #define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) 254*0Sstevel@tonic-gate #define SSL3_RT_MAX_DATA_SIZE (1024*1024) 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate #define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" 257*0Sstevel@tonic-gate #define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate #define SSL3_VERSION 0x0300 260*0Sstevel@tonic-gate #define SSL3_VERSION_MAJOR 0x03 261*0Sstevel@tonic-gate #define SSL3_VERSION_MINOR 0x00 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gate #define SSL3_RT_CHANGE_CIPHER_SPEC 20 264*0Sstevel@tonic-gate #define SSL3_RT_ALERT 21 265*0Sstevel@tonic-gate #define SSL3_RT_HANDSHAKE 22 266*0Sstevel@tonic-gate #define SSL3_RT_APPLICATION_DATA 23 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gate #define SSL3_AL_WARNING 1 269*0Sstevel@tonic-gate #define SSL3_AL_FATAL 2 270*0Sstevel@tonic-gate 271*0Sstevel@tonic-gate #define SSL3_AD_CLOSE_NOTIFY 0 272*0Sstevel@tonic-gate #define SSL3_AD_UNEXPECTED_MESSAGE 10 /* fatal */ 273*0Sstevel@tonic-gate #define SSL3_AD_BAD_RECORD_MAC 20 /* fatal */ 274*0Sstevel@tonic-gate #define SSL3_AD_DECOMPRESSION_FAILURE 30 /* fatal */ 275*0Sstevel@tonic-gate #define SSL3_AD_HANDSHAKE_FAILURE 40 /* fatal */ 276*0Sstevel@tonic-gate #define SSL3_AD_NO_CERTIFICATE 41 277*0Sstevel@tonic-gate #define SSL3_AD_BAD_CERTIFICATE 42 278*0Sstevel@tonic-gate #define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 279*0Sstevel@tonic-gate #define SSL3_AD_CERTIFICATE_REVOKED 44 280*0Sstevel@tonic-gate #define SSL3_AD_CERTIFICATE_EXPIRED 45 281*0Sstevel@tonic-gate #define SSL3_AD_CERTIFICATE_UNKNOWN 46 282*0Sstevel@tonic-gate #define SSL3_AD_ILLEGAL_PARAMETER 47 /* fatal */ 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate typedef struct ssl3_record_st 285*0Sstevel@tonic-gate { 286*0Sstevel@tonic-gate /*r */ int type; /* type of record */ 287*0Sstevel@tonic-gate /*rw*/ unsigned int length; /* How many bytes available */ 288*0Sstevel@tonic-gate /*r */ unsigned int off; /* read/write offset into 'buf' */ 289*0Sstevel@tonic-gate /*rw*/ unsigned char *data; /* pointer to the record data */ 290*0Sstevel@tonic-gate /*rw*/ unsigned char *input; /* where the decode bytes are */ 291*0Sstevel@tonic-gate /*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ 292*0Sstevel@tonic-gate } SSL3_RECORD; 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate typedef struct ssl3_buffer_st 295*0Sstevel@tonic-gate { 296*0Sstevel@tonic-gate unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, 297*0Sstevel@tonic-gate * see ssl3_setup_buffers() */ 298*0Sstevel@tonic-gate size_t len; /* buffer size */ 299*0Sstevel@tonic-gate int offset; /* where to 'copy from' */ 300*0Sstevel@tonic-gate int left; /* how many bytes left */ 301*0Sstevel@tonic-gate } SSL3_BUFFER; 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gate #define SSL3_CT_RSA_SIGN 1 304*0Sstevel@tonic-gate #define SSL3_CT_DSS_SIGN 2 305*0Sstevel@tonic-gate #define SSL3_CT_RSA_FIXED_DH 3 306*0Sstevel@tonic-gate #define SSL3_CT_DSS_FIXED_DH 4 307*0Sstevel@tonic-gate #define SSL3_CT_RSA_EPHEMERAL_DH 5 308*0Sstevel@tonic-gate #define SSL3_CT_DSS_EPHEMERAL_DH 6 309*0Sstevel@tonic-gate #define SSL3_CT_FORTEZZA_DMS 20 310*0Sstevel@tonic-gate #define SSL3_CT_NUMBER 7 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gate #define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 313*0Sstevel@tonic-gate #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 314*0Sstevel@tonic-gate #define SSL3_FLAGS_POP_BUFFER 0x0004 315*0Sstevel@tonic-gate #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gate typedef struct ssl3_state_st 318*0Sstevel@tonic-gate { 319*0Sstevel@tonic-gate long flags; 320*0Sstevel@tonic-gate int delay_buf_pop_ret; 321*0Sstevel@tonic-gate 322*0Sstevel@tonic-gate unsigned char read_sequence[8]; 323*0Sstevel@tonic-gate unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; 324*0Sstevel@tonic-gate unsigned char write_sequence[8]; 325*0Sstevel@tonic-gate unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate unsigned char server_random[SSL3_RANDOM_SIZE]; 328*0Sstevel@tonic-gate unsigned char client_random[SSL3_RANDOM_SIZE]; 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate /* flags for countermeasure against known-IV weakness */ 331*0Sstevel@tonic-gate int need_empty_fragments; 332*0Sstevel@tonic-gate int empty_fragment_done; 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate SSL3_BUFFER rbuf; /* read IO goes into here */ 335*0Sstevel@tonic-gate SSL3_BUFFER wbuf; /* write IO goes into here */ 336*0Sstevel@tonic-gate 337*0Sstevel@tonic-gate SSL3_RECORD rrec; /* each decoded record goes in here */ 338*0Sstevel@tonic-gate SSL3_RECORD wrec; /* goes out from here */ 339*0Sstevel@tonic-gate 340*0Sstevel@tonic-gate /* storage for Alert/Handshake protocol data received but not 341*0Sstevel@tonic-gate * yet processed by ssl3_read_bytes: */ 342*0Sstevel@tonic-gate unsigned char alert_fragment[2]; 343*0Sstevel@tonic-gate unsigned int alert_fragment_len; 344*0Sstevel@tonic-gate unsigned char handshake_fragment[4]; 345*0Sstevel@tonic-gate unsigned int handshake_fragment_len; 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate /* partial write - check the numbers match */ 348*0Sstevel@tonic-gate unsigned int wnum; /* number of bytes sent so far */ 349*0Sstevel@tonic-gate int wpend_tot; /* number bytes written */ 350*0Sstevel@tonic-gate int wpend_type; 351*0Sstevel@tonic-gate int wpend_ret; /* number of bytes submitted */ 352*0Sstevel@tonic-gate const unsigned char *wpend_buf; 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate /* used during startup, digest all incoming/outgoing packets */ 355*0Sstevel@tonic-gate EVP_MD_CTX finish_dgst1; 356*0Sstevel@tonic-gate EVP_MD_CTX finish_dgst2; 357*0Sstevel@tonic-gate 358*0Sstevel@tonic-gate /* this is set whenerver we see a change_cipher_spec message 359*0Sstevel@tonic-gate * come in when we are not looking for one */ 360*0Sstevel@tonic-gate int change_cipher_spec; 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gate int warn_alert; 363*0Sstevel@tonic-gate int fatal_alert; 364*0Sstevel@tonic-gate /* we allow one fatal and one warning alert to be outstanding, 365*0Sstevel@tonic-gate * send close alert via the warning alert */ 366*0Sstevel@tonic-gate int alert_dispatch; 367*0Sstevel@tonic-gate unsigned char send_alert[2]; 368*0Sstevel@tonic-gate 369*0Sstevel@tonic-gate /* This flag is set when we should renegotiate ASAP, basically when 370*0Sstevel@tonic-gate * there is no more data in the read or write buffers */ 371*0Sstevel@tonic-gate int renegotiate; 372*0Sstevel@tonic-gate int total_renegotiations; 373*0Sstevel@tonic-gate int num_renegotiations; 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate int in_read_app_data; 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gate struct { 378*0Sstevel@tonic-gate /* actually only needs to be 16+20 */ 379*0Sstevel@tonic-gate unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2]; 380*0Sstevel@tonic-gate 381*0Sstevel@tonic-gate /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ 382*0Sstevel@tonic-gate unsigned char finish_md[EVP_MAX_MD_SIZE*2]; 383*0Sstevel@tonic-gate int finish_md_len; 384*0Sstevel@tonic-gate unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2]; 385*0Sstevel@tonic-gate int peer_finish_md_len; 386*0Sstevel@tonic-gate 387*0Sstevel@tonic-gate unsigned long message_size; 388*0Sstevel@tonic-gate int message_type; 389*0Sstevel@tonic-gate 390*0Sstevel@tonic-gate /* used to hold the new cipher we are going to use */ 391*0Sstevel@tonic-gate SSL_CIPHER *new_cipher; 392*0Sstevel@tonic-gate #ifndef OPENSSL_NO_DH 393*0Sstevel@tonic-gate DH *dh; 394*0Sstevel@tonic-gate #endif 395*0Sstevel@tonic-gate /* used when SSL_ST_FLUSH_DATA is entered */ 396*0Sstevel@tonic-gate int next_state; 397*0Sstevel@tonic-gate 398*0Sstevel@tonic-gate int reuse_message; 399*0Sstevel@tonic-gate 400*0Sstevel@tonic-gate /* used for certificate requests */ 401*0Sstevel@tonic-gate int cert_req; 402*0Sstevel@tonic-gate int ctype_num; 403*0Sstevel@tonic-gate char ctype[SSL3_CT_NUMBER]; 404*0Sstevel@tonic-gate STACK_OF(X509_NAME) *ca_names; 405*0Sstevel@tonic-gate 406*0Sstevel@tonic-gate int use_rsa_tmp; 407*0Sstevel@tonic-gate 408*0Sstevel@tonic-gate int key_block_length; 409*0Sstevel@tonic-gate unsigned char *key_block; 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gate const EVP_CIPHER *new_sym_enc; 412*0Sstevel@tonic-gate const EVP_MD *new_hash; 413*0Sstevel@tonic-gate #ifndef OPENSSL_NO_COMP 414*0Sstevel@tonic-gate const SSL_COMP *new_compression; 415*0Sstevel@tonic-gate #else 416*0Sstevel@tonic-gate char *new_compression; 417*0Sstevel@tonic-gate #endif 418*0Sstevel@tonic-gate int cert_request; 419*0Sstevel@tonic-gate } tmp; 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate } SSL3_STATE; 422*0Sstevel@tonic-gate 423*0Sstevel@tonic-gate /* SSLv3 */ 424*0Sstevel@tonic-gate /*client */ 425*0Sstevel@tonic-gate /* extra state */ 426*0Sstevel@tonic-gate #define SSL3_ST_CW_FLUSH (0x100|SSL_ST_CONNECT) 427*0Sstevel@tonic-gate /* write to server */ 428*0Sstevel@tonic-gate #define SSL3_ST_CW_CLNT_HELLO_A (0x110|SSL_ST_CONNECT) 429*0Sstevel@tonic-gate #define SSL3_ST_CW_CLNT_HELLO_B (0x111|SSL_ST_CONNECT) 430*0Sstevel@tonic-gate /* read from server */ 431*0Sstevel@tonic-gate #define SSL3_ST_CR_SRVR_HELLO_A (0x120|SSL_ST_CONNECT) 432*0Sstevel@tonic-gate #define SSL3_ST_CR_SRVR_HELLO_B (0x121|SSL_ST_CONNECT) 433*0Sstevel@tonic-gate #define SSL3_ST_CR_CERT_A (0x130|SSL_ST_CONNECT) 434*0Sstevel@tonic-gate #define SSL3_ST_CR_CERT_B (0x131|SSL_ST_CONNECT) 435*0Sstevel@tonic-gate #define SSL3_ST_CR_KEY_EXCH_A (0x140|SSL_ST_CONNECT) 436*0Sstevel@tonic-gate #define SSL3_ST_CR_KEY_EXCH_B (0x141|SSL_ST_CONNECT) 437*0Sstevel@tonic-gate #define SSL3_ST_CR_CERT_REQ_A (0x150|SSL_ST_CONNECT) 438*0Sstevel@tonic-gate #define SSL3_ST_CR_CERT_REQ_B (0x151|SSL_ST_CONNECT) 439*0Sstevel@tonic-gate #define SSL3_ST_CR_SRVR_DONE_A (0x160|SSL_ST_CONNECT) 440*0Sstevel@tonic-gate #define SSL3_ST_CR_SRVR_DONE_B (0x161|SSL_ST_CONNECT) 441*0Sstevel@tonic-gate /* write to server */ 442*0Sstevel@tonic-gate #define SSL3_ST_CW_CERT_A (0x170|SSL_ST_CONNECT) 443*0Sstevel@tonic-gate #define SSL3_ST_CW_CERT_B (0x171|SSL_ST_CONNECT) 444*0Sstevel@tonic-gate #define SSL3_ST_CW_CERT_C (0x172|SSL_ST_CONNECT) 445*0Sstevel@tonic-gate #define SSL3_ST_CW_CERT_D (0x173|SSL_ST_CONNECT) 446*0Sstevel@tonic-gate #define SSL3_ST_CW_KEY_EXCH_A (0x180|SSL_ST_CONNECT) 447*0Sstevel@tonic-gate #define SSL3_ST_CW_KEY_EXCH_B (0x181|SSL_ST_CONNECT) 448*0Sstevel@tonic-gate #define SSL3_ST_CW_CERT_VRFY_A (0x190|SSL_ST_CONNECT) 449*0Sstevel@tonic-gate #define SSL3_ST_CW_CERT_VRFY_B (0x191|SSL_ST_CONNECT) 450*0Sstevel@tonic-gate #define SSL3_ST_CW_CHANGE_A (0x1A0|SSL_ST_CONNECT) 451*0Sstevel@tonic-gate #define SSL3_ST_CW_CHANGE_B (0x1A1|SSL_ST_CONNECT) 452*0Sstevel@tonic-gate #define SSL3_ST_CW_FINISHED_A (0x1B0|SSL_ST_CONNECT) 453*0Sstevel@tonic-gate #define SSL3_ST_CW_FINISHED_B (0x1B1|SSL_ST_CONNECT) 454*0Sstevel@tonic-gate /* read from server */ 455*0Sstevel@tonic-gate #define SSL3_ST_CR_CHANGE_A (0x1C0|SSL_ST_CONNECT) 456*0Sstevel@tonic-gate #define SSL3_ST_CR_CHANGE_B (0x1C1|SSL_ST_CONNECT) 457*0Sstevel@tonic-gate #define SSL3_ST_CR_FINISHED_A (0x1D0|SSL_ST_CONNECT) 458*0Sstevel@tonic-gate #define SSL3_ST_CR_FINISHED_B (0x1D1|SSL_ST_CONNECT) 459*0Sstevel@tonic-gate 460*0Sstevel@tonic-gate /* server */ 461*0Sstevel@tonic-gate /* extra state */ 462*0Sstevel@tonic-gate #define SSL3_ST_SW_FLUSH (0x100|SSL_ST_ACCEPT) 463*0Sstevel@tonic-gate /* read from client */ 464*0Sstevel@tonic-gate /* Do not change the number values, they do matter */ 465*0Sstevel@tonic-gate #define SSL3_ST_SR_CLNT_HELLO_A (0x110|SSL_ST_ACCEPT) 466*0Sstevel@tonic-gate #define SSL3_ST_SR_CLNT_HELLO_B (0x111|SSL_ST_ACCEPT) 467*0Sstevel@tonic-gate #define SSL3_ST_SR_CLNT_HELLO_C (0x112|SSL_ST_ACCEPT) 468*0Sstevel@tonic-gate /* write to client */ 469*0Sstevel@tonic-gate #define SSL3_ST_SW_HELLO_REQ_A (0x120|SSL_ST_ACCEPT) 470*0Sstevel@tonic-gate #define SSL3_ST_SW_HELLO_REQ_B (0x121|SSL_ST_ACCEPT) 471*0Sstevel@tonic-gate #define SSL3_ST_SW_HELLO_REQ_C (0x122|SSL_ST_ACCEPT) 472*0Sstevel@tonic-gate #define SSL3_ST_SW_SRVR_HELLO_A (0x130|SSL_ST_ACCEPT) 473*0Sstevel@tonic-gate #define SSL3_ST_SW_SRVR_HELLO_B (0x131|SSL_ST_ACCEPT) 474*0Sstevel@tonic-gate #define SSL3_ST_SW_CERT_A (0x140|SSL_ST_ACCEPT) 475*0Sstevel@tonic-gate #define SSL3_ST_SW_CERT_B (0x141|SSL_ST_ACCEPT) 476*0Sstevel@tonic-gate #define SSL3_ST_SW_KEY_EXCH_A (0x150|SSL_ST_ACCEPT) 477*0Sstevel@tonic-gate #define SSL3_ST_SW_KEY_EXCH_B (0x151|SSL_ST_ACCEPT) 478*0Sstevel@tonic-gate #define SSL3_ST_SW_CERT_REQ_A (0x160|SSL_ST_ACCEPT) 479*0Sstevel@tonic-gate #define SSL3_ST_SW_CERT_REQ_B (0x161|SSL_ST_ACCEPT) 480*0Sstevel@tonic-gate #define SSL3_ST_SW_SRVR_DONE_A (0x170|SSL_ST_ACCEPT) 481*0Sstevel@tonic-gate #define SSL3_ST_SW_SRVR_DONE_B (0x171|SSL_ST_ACCEPT) 482*0Sstevel@tonic-gate /* read from client */ 483*0Sstevel@tonic-gate #define SSL3_ST_SR_CERT_A (0x180|SSL_ST_ACCEPT) 484*0Sstevel@tonic-gate #define SSL3_ST_SR_CERT_B (0x181|SSL_ST_ACCEPT) 485*0Sstevel@tonic-gate #define SSL3_ST_SR_KEY_EXCH_A (0x190|SSL_ST_ACCEPT) 486*0Sstevel@tonic-gate #define SSL3_ST_SR_KEY_EXCH_B (0x191|SSL_ST_ACCEPT) 487*0Sstevel@tonic-gate #define SSL3_ST_SR_CERT_VRFY_A (0x1A0|SSL_ST_ACCEPT) 488*0Sstevel@tonic-gate #define SSL3_ST_SR_CERT_VRFY_B (0x1A1|SSL_ST_ACCEPT) 489*0Sstevel@tonic-gate #define SSL3_ST_SR_CHANGE_A (0x1B0|SSL_ST_ACCEPT) 490*0Sstevel@tonic-gate #define SSL3_ST_SR_CHANGE_B (0x1B1|SSL_ST_ACCEPT) 491*0Sstevel@tonic-gate #define SSL3_ST_SR_FINISHED_A (0x1C0|SSL_ST_ACCEPT) 492*0Sstevel@tonic-gate #define SSL3_ST_SR_FINISHED_B (0x1C1|SSL_ST_ACCEPT) 493*0Sstevel@tonic-gate /* write to client */ 494*0Sstevel@tonic-gate #define SSL3_ST_SW_CHANGE_A (0x1D0|SSL_ST_ACCEPT) 495*0Sstevel@tonic-gate #define SSL3_ST_SW_CHANGE_B (0x1D1|SSL_ST_ACCEPT) 496*0Sstevel@tonic-gate #define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) 497*0Sstevel@tonic-gate #define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) 498*0Sstevel@tonic-gate 499*0Sstevel@tonic-gate #define SSL3_MT_HELLO_REQUEST 0 500*0Sstevel@tonic-gate #define SSL3_MT_CLIENT_HELLO 1 501*0Sstevel@tonic-gate #define SSL3_MT_SERVER_HELLO 2 502*0Sstevel@tonic-gate #define SSL3_MT_CERTIFICATE 11 503*0Sstevel@tonic-gate #define SSL3_MT_SERVER_KEY_EXCHANGE 12 504*0Sstevel@tonic-gate #define SSL3_MT_CERTIFICATE_REQUEST 13 505*0Sstevel@tonic-gate #define SSL3_MT_SERVER_DONE 14 506*0Sstevel@tonic-gate #define SSL3_MT_CERTIFICATE_VERIFY 15 507*0Sstevel@tonic-gate #define SSL3_MT_CLIENT_KEY_EXCHANGE 16 508*0Sstevel@tonic-gate #define SSL3_MT_FINISHED 20 509*0Sstevel@tonic-gate 510*0Sstevel@tonic-gate #define SSL3_MT_CCS 1 511*0Sstevel@tonic-gate 512*0Sstevel@tonic-gate /* These are used when changing over to a new cipher */ 513*0Sstevel@tonic-gate #define SSL3_CC_READ 0x01 514*0Sstevel@tonic-gate #define SSL3_CC_WRITE 0x02 515*0Sstevel@tonic-gate #define SSL3_CC_CLIENT 0x10 516*0Sstevel@tonic-gate #define SSL3_CC_SERVER 0x20 517*0Sstevel@tonic-gate #define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) 518*0Sstevel@tonic-gate #define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) 519*0Sstevel@tonic-gate #define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) 520*0Sstevel@tonic-gate #define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) 521*0Sstevel@tonic-gate 522*0Sstevel@tonic-gate #ifdef __cplusplus 523*0Sstevel@tonic-gate } 524*0Sstevel@tonic-gate #endif 525*0Sstevel@tonic-gate #endif 526*0Sstevel@tonic-gate 527