155714Skris/* ssl/ssl_locl.h */ 255714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 355714Skris * All rights reserved. 455714Skris * 555714Skris * This package is an SSL implementation written 655714Skris * by Eric Young (eay@cryptsoft.com). 755714Skris * The implementation was written so as to conform with Netscapes SSL. 8280304Sjkim * 955714Skris * This library is free for commercial and non-commercial use as long as 1055714Skris * the following conditions are aheared to. The following conditions 1155714Skris * apply to all code found in this distribution, be it the RC4, RSA, 1255714Skris * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1355714Skris * included with this distribution is covered by the same copyright terms 1455714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15280304Sjkim * 1655714Skris * Copyright remains Eric Young's, and as such any Copyright notices in 1755714Skris * the code are not to be removed. 1855714Skris * If this package is used in a product, Eric Young should be given attribution 1955714Skris * as the author of the parts of the library used. 2055714Skris * This can be in the form of a textual message at program startup or 2155714Skris * in documentation (online or textual) provided with the package. 22280304Sjkim * 2355714Skris * Redistribution and use in source and binary forms, with or without 2455714Skris * modification, are permitted provided that the following conditions 2555714Skris * are met: 2655714Skris * 1. Redistributions of source code must retain the copyright 2755714Skris * notice, this list of conditions and the following disclaimer. 2855714Skris * 2. Redistributions in binary form must reproduce the above copyright 2955714Skris * notice, this list of conditions and the following disclaimer in the 3055714Skris * documentation and/or other materials provided with the distribution. 3155714Skris * 3. All advertising materials mentioning features or use of this software 3255714Skris * must display the following acknowledgement: 3355714Skris * "This product includes cryptographic software written by 3455714Skris * Eric Young (eay@cryptsoft.com)" 3555714Skris * The word 'cryptographic' can be left out if the rouines from the library 3655714Skris * being used are not cryptographic related :-). 37280304Sjkim * 4. If you include any Windows specific code (or a derivative thereof) from 3855714Skris * the apps directory (application code) you must include an acknowledgement: 3955714Skris * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40280304Sjkim * 4155714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 4255714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4355714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4455714Skris * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4555714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 4655714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 4755714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4855714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 4955714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5055714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5155714Skris * SUCH DAMAGE. 52280304Sjkim * 5355714Skris * The licence and distribution terms for any publically available version or 5455714Skris * derivative of this code cannot be changed. i.e. this code cannot simply be 5555714Skris * copied and put under another distribution licence 5655714Skris * [including the GNU Public Licence.] 5755714Skris */ 5872613Skris/* ==================================================================== 59238405Sjkim * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. 6072613Skris * 6172613Skris * Redistribution and use in source and binary forms, with or without 6272613Skris * modification, are permitted provided that the following conditions 6372613Skris * are met: 6472613Skris * 6572613Skris * 1. Redistributions of source code must retain the above copyright 66280304Sjkim * notice, this list of conditions and the following disclaimer. 6772613Skris * 6872613Skris * 2. Redistributions in binary form must reproduce the above copyright 6972613Skris * notice, this list of conditions and the following disclaimer in 7072613Skris * the documentation and/or other materials provided with the 7172613Skris * distribution. 7272613Skris * 7372613Skris * 3. All advertising materials mentioning features or use of this 7472613Skris * software must display the following acknowledgment: 7572613Skris * "This product includes software developed by the OpenSSL Project 7672613Skris * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 7772613Skris * 7872613Skris * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 7972613Skris * endorse or promote products derived from this software without 8072613Skris * prior written permission. For written permission, please contact 8172613Skris * openssl-core@openssl.org. 8272613Skris * 8372613Skris * 5. Products derived from this software may not be called "OpenSSL" 8472613Skris * nor may "OpenSSL" appear in their names without prior written 8572613Skris * permission of the OpenSSL Project. 8672613Skris * 8772613Skris * 6. Redistributions of any form whatsoever must retain the following 8872613Skris * acknowledgment: 8972613Skris * "This product includes software developed by the OpenSSL Project 9072613Skris * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 9172613Skris * 9272613Skris * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 9372613Skris * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 9472613Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 9572613Skris * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 9672613Skris * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 9772613Skris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 9872613Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 9972613Skris * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 10072613Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 10172613Skris * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 10272613Skris * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 10372613Skris * OF THE POSSIBILITY OF SUCH DAMAGE. 10472613Skris * ==================================================================== 10572613Skris * 10672613Skris * This product includes cryptographic software written by Eric Young 10772613Skris * (eay@cryptsoft.com). This product includes software written by Tim 10872613Skris * Hudson (tjh@cryptsoft.com). 10972613Skris * 11072613Skris */ 111160814Ssimon/* ==================================================================== 112160814Ssimon * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 113280304Sjkim * ECC cipher suite support in OpenSSL originally developed by 114160814Ssimon * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. 115160814Ssimon */ 116238405Sjkim/* ==================================================================== 117238405Sjkim * Copyright 2005 Nokia. All rights reserved. 118238405Sjkim * 119238405Sjkim * The portions of the attached software ("Contribution") is developed by 120238405Sjkim * Nokia Corporation and is licensed pursuant to the OpenSSL open source 121238405Sjkim * license. 122238405Sjkim * 123238405Sjkim * The Contribution, originally written by Mika Kousa and Pasi Eronen of 124238405Sjkim * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites 125238405Sjkim * support (see RFC 4279) to OpenSSL. 126238405Sjkim * 127238405Sjkim * No patent licenses or other rights except those expressly stated in 128238405Sjkim * the OpenSSL open source license shall be deemed granted or received 129238405Sjkim * expressly, by implication, estoppel, or otherwise. 130238405Sjkim * 131238405Sjkim * No assurances are provided by Nokia that the Contribution does not 132238405Sjkim * infringe the patent or other intellectual property rights of any third 133238405Sjkim * party or that the license provides you with all the necessary rights 134238405Sjkim * to make use of the Contribution. 135238405Sjkim * 136238405Sjkim * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN 137238405Sjkim * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA 138238405Sjkim * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY 139238405Sjkim * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR 140238405Sjkim * OTHERWISE. 141238405Sjkim */ 14255714Skris 14355714Skris#ifndef HEADER_SSL_LOCL_H 144280304Sjkim# define HEADER_SSL_LOCL_H 145280304Sjkim# include <stdlib.h> 146280304Sjkim# include <time.h> 147280304Sjkim# include <string.h> 148280304Sjkim# include <errno.h> 14955714Skris 150280304Sjkim# include "e_os.h" 15155714Skris 152280304Sjkim# include <openssl/buffer.h> 153280304Sjkim# ifndef OPENSSL_NO_COMP 154280304Sjkim# include <openssl/comp.h> 155280304Sjkim# endif 156280304Sjkim# include <openssl/bio.h> 157280304Sjkim# include <openssl/stack.h> 158280304Sjkim# ifndef OPENSSL_NO_RSA 159280304Sjkim# include <openssl/rsa.h> 160280304Sjkim# endif 161280304Sjkim# ifndef OPENSSL_NO_DSA 162280304Sjkim# include <openssl/dsa.h> 163280304Sjkim# endif 164280304Sjkim# include <openssl/err.h> 165280304Sjkim# include <openssl/ssl.h> 166280304Sjkim# include <openssl/symhacks.h> 16755714Skris 168280304Sjkim# ifdef OPENSSL_BUILD_SHLIBSSL 169280304Sjkim# undef OPENSSL_EXTERN 170280304Sjkim# define OPENSSL_EXTERN OPENSSL_EXPORT 171280304Sjkim# endif 172109998Smarkm 173280304Sjkim# undef PKCS1_CHECK 17455714Skris 175280304Sjkim# define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ 176280304Sjkim l|=(((unsigned long)(*((c)++)))<< 8), \ 177280304Sjkim l|=(((unsigned long)(*((c)++)))<<16), \ 178280304Sjkim l|=(((unsigned long)(*((c)++)))<<24)) 17955714Skris 18055714Skris/* NOTE - c is not incremented as per c2l */ 181280304Sjkim# define c2ln(c,l1,l2,n) { \ 182280304Sjkim c+=n; \ 183280304Sjkim l1=l2=0; \ 184280304Sjkim switch (n) { \ 185280304Sjkim case 8: l2 =((unsigned long)(*(--(c))))<<24; \ 186280304Sjkim case 7: l2|=((unsigned long)(*(--(c))))<<16; \ 187280304Sjkim case 6: l2|=((unsigned long)(*(--(c))))<< 8; \ 188280304Sjkim case 5: l2|=((unsigned long)(*(--(c)))); \ 189280304Sjkim case 4: l1 =((unsigned long)(*(--(c))))<<24; \ 190280304Sjkim case 3: l1|=((unsigned long)(*(--(c))))<<16; \ 191280304Sjkim case 2: l1|=((unsigned long)(*(--(c))))<< 8; \ 192280304Sjkim case 1: l1|=((unsigned long)(*(--(c)))); \ 193280304Sjkim } \ 194280304Sjkim } 19555714Skris 196280304Sjkim# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ 197280304Sjkim *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ 198280304Sjkim *((c)++)=(unsigned char)(((l)>>16)&0xff), \ 199280304Sjkim *((c)++)=(unsigned char)(((l)>>24)&0xff)) 20055714Skris 201280304Sjkim# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \ 202280304Sjkim l|=((unsigned long)(*((c)++)))<<16, \ 203280304Sjkim l|=((unsigned long)(*((c)++)))<< 8, \ 204280304Sjkim l|=((unsigned long)(*((c)++)))) 20555714Skris 206280304Sjkim# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ 207280304Sjkim *((c)++)=(unsigned char)(((l)>>16)&0xff), \ 208280304Sjkim *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ 209280304Sjkim *((c)++)=(unsigned char)(((l) )&0xff)) 21055714Skris 211280304Sjkim# define l2n6(l,c) (*((c)++)=(unsigned char)(((l)>>40)&0xff), \ 212280304Sjkim *((c)++)=(unsigned char)(((l)>>32)&0xff), \ 213280304Sjkim *((c)++)=(unsigned char)(((l)>>24)&0xff), \ 214280304Sjkim *((c)++)=(unsigned char)(((l)>>16)&0xff), \ 215280304Sjkim *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ 216280304Sjkim *((c)++)=(unsigned char)(((l) )&0xff)) 217160814Ssimon 218280304Sjkim# define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \ 219280304Sjkim *((c)++)=(unsigned char)(((l)>>48)&0xff), \ 220280304Sjkim *((c)++)=(unsigned char)(((l)>>40)&0xff), \ 221280304Sjkim *((c)++)=(unsigned char)(((l)>>32)&0xff), \ 222280304Sjkim *((c)++)=(unsigned char)(((l)>>24)&0xff), \ 223280304Sjkim *((c)++)=(unsigned char)(((l)>>16)&0xff), \ 224280304Sjkim *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ 225280304Sjkim *((c)++)=(unsigned char)(((l) )&0xff)) 226246772Sjkim 227280304Sjkim# define n2l6(c,l) (l =((BN_ULLONG)(*((c)++)))<<40, \ 228280304Sjkim l|=((BN_ULLONG)(*((c)++)))<<32, \ 229280304Sjkim l|=((BN_ULLONG)(*((c)++)))<<24, \ 230280304Sjkim l|=((BN_ULLONG)(*((c)++)))<<16, \ 231280304Sjkim l|=((BN_ULLONG)(*((c)++)))<< 8, \ 232280304Sjkim l|=((BN_ULLONG)(*((c)++)))) 233160814Ssimon 23455714Skris/* NOTE - c is not incremented as per l2c */ 235280304Sjkim# define l2cn(l1,l2,c,n) { \ 236280304Sjkim c+=n; \ 237280304Sjkim switch (n) { \ 238280304Sjkim case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ 239280304Sjkim case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ 240280304Sjkim case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ 241280304Sjkim case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ 242280304Sjkim case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ 243280304Sjkim case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ 244280304Sjkim case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ 245280304Sjkim case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ 246280304Sjkim } \ 247280304Sjkim } 24855714Skris 249280304Sjkim# define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \ 250280304Sjkim (((unsigned int)(c[1])) )),c+=2) 251280304Sjkim# define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \ 252280304Sjkim c[1]=(unsigned char)(((s) )&0xff)),c+=2) 25355714Skris 254280304Sjkim# define n2l3(c,l) ((l =(((unsigned long)(c[0]))<<16)| \ 255280304Sjkim (((unsigned long)(c[1]))<< 8)| \ 256280304Sjkim (((unsigned long)(c[2])) )),c+=3) 25755714Skris 258280304Sjkim# define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \ 259280304Sjkim c[1]=(unsigned char)(((l)>> 8)&0xff), \ 260280304Sjkim c[2]=(unsigned char)(((l) )&0xff)),c+=3) 26155714Skris 26255714Skris/* LOCAL STUFF */ 26355714Skris 264280304Sjkim# define SSL_DECRYPT 0 265280304Sjkim# define SSL_ENCRYPT 1 26655714Skris 267280304Sjkim# define TWO_BYTE_BIT 0x80 268280304Sjkim# define SEC_ESC_BIT 0x40 269280304Sjkim# define TWO_BYTE_MASK 0x7fff 270280304Sjkim# define THREE_BYTE_MASK 0x3fff 27155714Skris 272280304Sjkim# define INC32(a) ((a)=((a)+1)&0xffffffffL) 273280304Sjkim# define DEC32(a) ((a)=((a)-1)&0xffffffffL) 274280304Sjkim# define MAX_MAC_SIZE 20 /* up from 16 for SSLv3 */ 27555714Skris 27659191Skris/* 27759191Skris * Define the Bitmasks for SSL_CIPHER.algorithms. 27859191Skris * This bits are used packed as dense as possible. If new methods/ciphers 27959191Skris * etc will be added, the bits a likely to change, so this information 28059191Skris * is for internal library use only, even though SSL_CIPHER.algorithms 28159191Skris * can be publicly accessed. 28259191Skris * Use the according functions for cipher management instead. 28359191Skris * 28459191Skris * The bit mask handling in the selection and sorting scheme in 28559191Skris * ssl_create_cipher_list() has only limited capabilities, reflecting 28659191Skris * that the different entities within are mutually exclusive: 28759191Skris * ONLY ONE BIT PER MASK CAN BE SET AT A TIME. 28859191Skris */ 289238405Sjkim 290238405Sjkim/* Bits for algorithm_mkey (key exchange algorithm) */ 291280304Sjkim/* RSA key exchange */ 292280304Sjkim# define SSL_kRSA 0x00000001L 293280304Sjkim/* DH cert, RSA CA cert */ 294280304Sjkim/* no such ciphersuites supported! */ 295280304Sjkim# define SSL_kDHr 0x00000002L 296280304Sjkim/* DH cert, DSA CA cert */ 297280304Sjkim/* no such ciphersuite supported! */ 298280304Sjkim# define SSL_kDHd 0x00000004L 299280304Sjkim/* tmp DH key no DH cert */ 300280304Sjkim# define SSL_kEDH 0x00000008L 301280304Sjkim/* Kerberos5 key exchange */ 302280304Sjkim# define SSL_kKRB5 0x00000010L 303280304Sjkim/* ECDH cert, RSA CA cert */ 304280304Sjkim# define SSL_kECDHr 0x00000020L 305280304Sjkim/* ECDH cert, ECDSA CA cert */ 306280304Sjkim# define SSL_kECDHe 0x00000040L 307280304Sjkim/* ephemeral ECDH */ 308280304Sjkim# define SSL_kEECDH 0x00000080L 309280304Sjkim/* PSK */ 310280304Sjkim# define SSL_kPSK 0x00000100L 311280304Sjkim/* GOST key exchange */ 312280304Sjkim# define SSL_kGOST 0x00000200L 313280304Sjkim/* SRP */ 314280304Sjkim# define SSL_kSRP 0x00000400L 31555714Skris 316238405Sjkim/* Bits for algorithm_auth (server authentication) */ 317280304Sjkim/* RSA auth */ 318280304Sjkim# define SSL_aRSA 0x00000001L 319280304Sjkim/* DSS auth */ 320280304Sjkim# define SSL_aDSS 0x00000002L 321280304Sjkim/* no auth (i.e. use ADH or AECDH) */ 322280304Sjkim# define SSL_aNULL 0x00000004L 323280304Sjkim/* Fixed DH auth (kDHd or kDHr) */ 324280304Sjkim/* no such ciphersuites supported! */ 325280304Sjkim# define SSL_aDH 0x00000008L 326280304Sjkim/* Fixed ECDH auth (kECDHe or kECDHr) */ 327280304Sjkim# define SSL_aECDH 0x00000010L 328280304Sjkim/* KRB5 auth */ 329280304Sjkim# define SSL_aKRB5 0x00000020L 330280304Sjkim/* ECDSA auth*/ 331280304Sjkim# define SSL_aECDSA 0x00000040L 332280304Sjkim/* PSK auth */ 333280304Sjkim# define SSL_aPSK 0x00000080L 334280304Sjkim/* GOST R 34.10-94 signature auth */ 335280304Sjkim# define SSL_aGOST94 0x00000100L 336280304Sjkim/* GOST R 34.10-2001 signature auth */ 337280304Sjkim# define SSL_aGOST01 0x00000200L 338280304Sjkim/* SRP auth */ 339280304Sjkim# define SSL_aSRP 0x00000400L 34055714Skris 341238405Sjkim/* Bits for algorithm_enc (symmetric encryption) */ 342280304Sjkim# define SSL_DES 0x00000001L 343280304Sjkim# define SSL_3DES 0x00000002L 344280304Sjkim# define SSL_RC4 0x00000004L 345280304Sjkim# define SSL_RC2 0x00000008L 346280304Sjkim# define SSL_IDEA 0x00000010L 347280304Sjkim# define SSL_eNULL 0x00000020L 348280304Sjkim# define SSL_AES128 0x00000040L 349280304Sjkim# define SSL_AES256 0x00000080L 350280304Sjkim# define SSL_CAMELLIA128 0x00000100L 351280304Sjkim# define SSL_CAMELLIA256 0x00000200L 352280304Sjkim# define SSL_eGOST2814789CNT 0x00000400L 353280304Sjkim# define SSL_SEED 0x00000800L 354280304Sjkim# define SSL_AES128GCM 0x00001000L 355280304Sjkim# define SSL_AES256GCM 0x00002000L 35655714Skris 357280304Sjkim# define SSL_AES (SSL_AES128|SSL_AES256|SSL_AES128GCM|SSL_AES256GCM) 358280304Sjkim# define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256) 35955714Skris 360238405Sjkim/* Bits for algorithm_mac (symmetric authentication) */ 361238405Sjkim 362280304Sjkim# define SSL_MD5 0x00000001L 363280304Sjkim# define SSL_SHA1 0x00000002L 364280304Sjkim# define SSL_GOST94 0x00000004L 365280304Sjkim# define SSL_GOST89MAC 0x00000008L 366280304Sjkim# define SSL_SHA256 0x00000010L 367280304Sjkim# define SSL_SHA384 0x00000020L 368238405Sjkim/* Not a real MAC, just an indication it is part of cipher */ 369280304Sjkim# define SSL_AEAD 0x00000040L 370238405Sjkim 371238405Sjkim/* Bits for algorithm_ssl (protocol version) */ 372280304Sjkim# define SSL_SSLV2 0x00000001UL 373280304Sjkim# define SSL_SSLV3 0x00000002UL 374280304Sjkim# define SSL_TLSV1 SSL_SSLV3/* for now */ 375280304Sjkim# define SSL_TLSV1_2 0x00000004UL 37659191Skris 377238405Sjkim/* Bits for algorithm2 (handshake digests and other extra flags) */ 378238405Sjkim 379280304Sjkim# define SSL_HANDSHAKE_MAC_MD5 0x10 380280304Sjkim# define SSL_HANDSHAKE_MAC_SHA 0x20 381280304Sjkim# define SSL_HANDSHAKE_MAC_GOST94 0x40 382280304Sjkim# define SSL_HANDSHAKE_MAC_SHA256 0x80 383280304Sjkim# define SSL_HANDSHAKE_MAC_SHA384 0x100 384280304Sjkim# define SSL_HANDSHAKE_MAC_DEFAULT (SSL_HANDSHAKE_MAC_MD5 | SSL_HANDSHAKE_MAC_SHA) 385238405Sjkim 386280304Sjkim/* 387280304Sjkim * When adding new digest in the ssl_ciph.c and increment SSM_MD_NUM_IDX make 388280304Sjkim * sure to update this constant too 389280304Sjkim */ 390280304Sjkim# define SSL_MAX_DIGEST 6 391238405Sjkim 392308200Sdelphij# define MAX_WARN_ALERT_COUNT 5 393308200Sdelphij 394280304Sjkim# define TLS1_PRF_DGST_MASK (0xff << TLS1_PRF_DGST_SHIFT) 395238405Sjkim 396280304Sjkim# define TLS1_PRF_DGST_SHIFT 10 397280304Sjkim# define TLS1_PRF_MD5 (SSL_HANDSHAKE_MAC_MD5 << TLS1_PRF_DGST_SHIFT) 398280304Sjkim# define TLS1_PRF_SHA1 (SSL_HANDSHAKE_MAC_SHA << TLS1_PRF_DGST_SHIFT) 399280304Sjkim# define TLS1_PRF_SHA256 (SSL_HANDSHAKE_MAC_SHA256 << TLS1_PRF_DGST_SHIFT) 400280304Sjkim# define TLS1_PRF_SHA384 (SSL_HANDSHAKE_MAC_SHA384 << TLS1_PRF_DGST_SHIFT) 401280304Sjkim# define TLS1_PRF_GOST94 (SSL_HANDSHAKE_MAC_GOST94 << TLS1_PRF_DGST_SHIFT) 402280304Sjkim# define TLS1_PRF (TLS1_PRF_MD5 | TLS1_PRF_SHA1) 403238405Sjkim 404280304Sjkim/* 405280304Sjkim * Stream MAC for GOST ciphersuites from cryptopro draft (currently this also 406280304Sjkim * goes into algorithm2) 407280304Sjkim */ 408280304Sjkim# define TLS1_STREAM_MAC 0x04 409238405Sjkim 41059191Skris/* 41159191Skris * Export and cipher strength information. For each cipher we have to decide 41259191Skris * whether it is exportable or not. This information is likely to change 41359191Skris * over time, since the export control rules are no static technical issue. 41459191Skris * 41559191Skris * Independent of the export flag the cipher strength is sorted into classes. 41659191Skris * SSL_EXP40 was denoting the 40bit US export limit of past times, which now 41759191Skris * is at 56bit (SSL_EXP56). If the exportable cipher class is going to change 41859191Skris * again (eg. to 64bit) the use of "SSL_EXP*" becomes blurred even more, 41959191Skris * since SSL_EXP64 could be similar to SSL_LOW. 42059191Skris * For this reason SSL_MICRO and SSL_MINI macros are included to widen the 42159191Skris * namespace of SSL_LOW-SSL_HIGH to lower values. As development of speed 42259191Skris * and ciphers goes, another extension to SSL_SUPER and/or SSL_ULTRA would 42359191Skris * be possible. 42459191Skris */ 425280304Sjkim# define SSL_EXP_MASK 0x00000003L 426280304Sjkim# define SSL_STRONG_MASK 0x000001fcL 427238405Sjkim 428280304Sjkim# define SSL_NOT_EXP 0x00000001L 429280304Sjkim# define SSL_EXPORT 0x00000002L 43059191Skris 431280304Sjkim# define SSL_STRONG_NONE 0x00000004L 432280304Sjkim# define SSL_EXP40 0x00000008L 433280304Sjkim# define SSL_MICRO (SSL_EXP40) 434280304Sjkim# define SSL_EXP56 0x00000010L 435280304Sjkim# define SSL_MINI (SSL_EXP56) 436280304Sjkim# define SSL_LOW 0x00000020L 437280304Sjkim# define SSL_MEDIUM 0x00000040L 438280304Sjkim# define SSL_HIGH 0x00000080L 439280304Sjkim# define SSL_FIPS 0x00000100L 440298999Sjkim# define SSL_NOT_DEFAULT 0x00000200L 44159191Skris 442298999Sjkim/* we have used 000003ff - 22 bits left to go */ 44359191Skris 444280304Sjkim/*- 44559191Skris * Macros to check the export status and cipher strength for export ciphers. 44659191Skris * Even though the macros for EXPORT and EXPORT40/56 have similar names, 44759191Skris * their meaning is different: 44859191Skris * *_EXPORT macros check the 'exportable' status. 44959191Skris * *_EXPORT40/56 macros are used to check whether a certain cipher strength 45059191Skris * is given. 45159191Skris * Since the SSL_IS_EXPORT* and SSL_EXPORT* macros depend on the correct 45259191Skris * algorithm structure element to be passed (algorithms, algo_strength) and no 45359191Skris * typechecking can be done as they are all of type unsigned long, their 45459191Skris * direct usage is discouraged. 45559191Skris * Use the SSL_C_* macros instead. 45659191Skris */ 457280304Sjkim# define SSL_IS_EXPORT(a) ((a)&SSL_EXPORT) 458280304Sjkim# define SSL_IS_EXPORT56(a) ((a)&SSL_EXP56) 459280304Sjkim# define SSL_IS_EXPORT40(a) ((a)&SSL_EXP40) 460280304Sjkim# define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algo_strength) 461280304Sjkim# define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algo_strength) 462280304Sjkim# define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algo_strength) 46359191Skris 464280304Sjkim# define SSL_EXPORT_KEYLENGTH(a,s) (SSL_IS_EXPORT40(s) ? 5 : \ 465280304Sjkim (a) == SSL_DES ? 8 : 7) 466280304Sjkim# define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024) 467280304Sjkim# define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithm_enc, \ 468280304Sjkim (c)->algo_strength) 469280304Sjkim# define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algo_strength) 47055714Skris 47155714Skris/* Mostly for SSLv3 */ 472280304Sjkim# define SSL_PKEY_RSA_ENC 0 473280304Sjkim# define SSL_PKEY_RSA_SIGN 1 474280304Sjkim# define SSL_PKEY_DSA_SIGN 2 475280304Sjkim# define SSL_PKEY_DH_RSA 3 476280304Sjkim# define SSL_PKEY_DH_DSA 4 477280304Sjkim# define SSL_PKEY_ECC 5 478280304Sjkim# define SSL_PKEY_GOST94 6 479280304Sjkim# define SSL_PKEY_GOST01 7 480280304Sjkim# define SSL_PKEY_NUM 8 48155714Skris 482280304Sjkim/*- 483280304Sjkim * SSL_kRSA <- RSA_ENC | (RSA_TMP & RSA_SIGN) | 484280304Sjkim * <- (EXPORT & (RSA_ENC | RSA_TMP) & RSA_SIGN) 48555714Skris * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN) 48655714Skris * SSL_kEDH <- RSA_ENC | RSA_SIGN | DSA_SIGN 48755714Skris * SSL_aRSA <- RSA_ENC | RSA_SIGN 48855714Skris * SSL_aDSS <- DSA_SIGN 48955714Skris */ 49055714Skris 491280304Sjkim/*- 492280304Sjkim#define CERT_INVALID 0 493280304Sjkim#define CERT_PUBLIC_KEY 1 494280304Sjkim#define CERT_PRIVATE_KEY 2 49555714Skris*/ 49655714Skris 497280304Sjkim# ifndef OPENSSL_NO_EC 498280304Sjkim/* 499280304Sjkim * From ECC-TLS draft, used in encoding the curve type in ECParameters 500160814Ssimon */ 501280304Sjkim# define EXPLICIT_PRIME_CURVE_TYPE 1 502280304Sjkim# define EXPLICIT_CHAR2_CURVE_TYPE 2 503280304Sjkim# define NAMED_CURVE_TYPE 3 504280304Sjkim# endif /* OPENSSL_NO_EC */ 505160814Ssimon 506280304Sjkimtypedef struct cert_pkey_st { 507280304Sjkim X509 *x509; 508280304Sjkim EVP_PKEY *privatekey; 509280304Sjkim /* Digest to use when signing */ 510280304Sjkim const EVP_MD *digest; 511280304Sjkim} CERT_PKEY; 51255714Skris 513280304Sjkimtypedef struct cert_st { 514280304Sjkim /* Current active set */ 515280304Sjkim /* 516280304Sjkim * ALWAYS points to an element of the pkeys array 517280304Sjkim * Probably it would make more sense to store 518280304Sjkim * an index, not a pointer. 519280304Sjkim */ 520280304Sjkim CERT_PKEY *key; 521280304Sjkim /* 522280304Sjkim * The following masks are for the key and auth algorithms that are 523280304Sjkim * supported by the certs below 524280304Sjkim */ 525280304Sjkim int valid; 526280304Sjkim unsigned long mask_k; 527280304Sjkim unsigned long mask_a; 528280304Sjkim unsigned long export_mask_k; 529280304Sjkim unsigned long export_mask_a; 530280304Sjkim# ifndef OPENSSL_NO_RSA 531280304Sjkim RSA *rsa_tmp; 532280304Sjkim RSA *(*rsa_tmp_cb) (SSL *ssl, int is_export, int keysize); 533280304Sjkim# endif 534280304Sjkim# ifndef OPENSSL_NO_DH 535280304Sjkim DH *dh_tmp; 536280304Sjkim DH *(*dh_tmp_cb) (SSL *ssl, int is_export, int keysize); 537280304Sjkim# endif 538280304Sjkim# ifndef OPENSSL_NO_ECDH 539280304Sjkim EC_KEY *ecdh_tmp; 540280304Sjkim /* Callback for generating ephemeral ECDH keys */ 541280304Sjkim EC_KEY *(*ecdh_tmp_cb) (SSL *ssl, int is_export, int keysize); 542280304Sjkim# endif 543280304Sjkim CERT_PKEY pkeys[SSL_PKEY_NUM]; 544280304Sjkim int references; /* >1 only if SSL_copy_session_id is used */ 545280304Sjkim} CERT; 54655714Skris 547280304Sjkimtypedef struct sess_cert_st { 548280304Sjkim STACK_OF(X509) *cert_chain; /* as received from peer (not for SSL2) */ 549280304Sjkim /* The 'peer_...' members are used only by clients. */ 550280304Sjkim int peer_cert_type; 551280304Sjkim CERT_PKEY *peer_key; /* points to an element of peer_pkeys (never 552280304Sjkim * NULL!) */ 553280304Sjkim CERT_PKEY peer_pkeys[SSL_PKEY_NUM]; 554280304Sjkim /* 555280304Sjkim * Obviously we don't have the private keys of these, so maybe we 556280304Sjkim * shouldn't even use the CERT_PKEY type here. 557280304Sjkim */ 558280304Sjkim# ifndef OPENSSL_NO_RSA 559280304Sjkim RSA *peer_rsa_tmp; /* not used for SSL 2 */ 560280304Sjkim# endif 561280304Sjkim# ifndef OPENSSL_NO_DH 562280304Sjkim DH *peer_dh_tmp; /* not used for SSL 2 */ 563280304Sjkim# endif 564280304Sjkim# ifndef OPENSSL_NO_ECDH 565280304Sjkim EC_KEY *peer_ecdh_tmp; 566280304Sjkim# endif 567280304Sjkim int references; /* actually always 1 at the moment */ 568280304Sjkim} SESS_CERT; 56955714Skris 570280304Sjkim/* 571280304Sjkim * #define MAC_DEBUG 572280304Sjkim */ 57355714Skris 574280304Sjkim/* 575280304Sjkim * #define ERR_DEBUG 576280304Sjkim */ 577280304Sjkim/* 578280304Sjkim * #define ABORT_DEBUG 579280304Sjkim */ 580280304Sjkim/* 581280304Sjkim * #define PKT_DEBUG 1 582280304Sjkim */ 583280304Sjkim/* 584280304Sjkim * #define DES_DEBUG 585280304Sjkim */ 586280304Sjkim/* 587280304Sjkim * #define DES_OFB_DEBUG 588280304Sjkim */ 589280304Sjkim/* 590280304Sjkim * #define SSL_DEBUG 591280304Sjkim */ 592280304Sjkim/* 593280304Sjkim * #define RSA_DEBUG 594280304Sjkim */ 595280304Sjkim/* 596280304Sjkim * #define IDEA_DEBUG 597280304Sjkim */ 59855714Skris 599280304Sjkim# define FP_ICC (int (*)(const void *,const void *)) 600280304Sjkim# define ssl_put_cipher_by_char(ssl,ciph,ptr) \ 601280304Sjkim ((ssl)->method->put_cipher_by_char((ciph),(ptr))) 602280304Sjkim# define ssl_get_cipher_by_char(ssl,ptr) \ 603280304Sjkim ((ssl)->method->get_cipher_by_char(ptr)) 60455714Skris 605280304Sjkim/* 606280304Sjkim * This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff It is a bit 607280304Sjkim * of a mess of functions, but hell, think of it as an opaque structure :-) 608280304Sjkim */ 609280304Sjkimtypedef struct ssl3_enc_method { 610280304Sjkim int (*enc) (SSL *, int); 611280304Sjkim int (*mac) (SSL *, unsigned char *, int); 612280304Sjkim int (*setup_key_block) (SSL *); 613280304Sjkim int (*generate_master_secret) (SSL *, unsigned char *, unsigned char *, 614280304Sjkim int); 615280304Sjkim int (*change_cipher_state) (SSL *, int); 616280304Sjkim int (*final_finish_mac) (SSL *, const char *, int, unsigned char *); 617280304Sjkim int finish_mac_length; 618280304Sjkim int (*cert_verify_mac) (SSL *, int, unsigned char *); 619280304Sjkim const char *client_finished_label; 620280304Sjkim int client_finished_label_len; 621280304Sjkim const char *server_finished_label; 622280304Sjkim int server_finished_label_len; 623280304Sjkim int (*alert_value) (int); 624280304Sjkim int (*export_keying_material) (SSL *, unsigned char *, size_t, 625280304Sjkim const char *, size_t, 626280304Sjkim const unsigned char *, size_t, 627280304Sjkim int use_context); 628280304Sjkim} SSL3_ENC_METHOD; 62955714Skris 630280304Sjkim# ifndef OPENSSL_NO_COMP 63155714Skris/* Used for holding the relevant compression methods loaded into SSL_CTX */ 632280304Sjkimtypedef struct ssl3_comp_st { 633280304Sjkim int comp_id; /* The identifier byte for this compression 634280304Sjkim * type */ 635280304Sjkim char *name; /* Text name used for the compression type */ 636280304Sjkim COMP_METHOD *method; /* The method :-) */ 637280304Sjkim} SSL3_COMP; 638280304Sjkim# endif 63955714Skris 640280304Sjkim# ifndef OPENSSL_NO_BUF_FREELISTS 641280304Sjkimtypedef struct ssl3_buf_freelist_st { 642280304Sjkim size_t chunklen; 643280304Sjkim unsigned int len; 644280304Sjkim struct ssl3_buf_freelist_entry_st *head; 645280304Sjkim} SSL3_BUF_FREELIST; 646238405Sjkim 647280304Sjkimtypedef struct ssl3_buf_freelist_entry_st { 648280304Sjkim struct ssl3_buf_freelist_entry_st *next; 649280304Sjkim} SSL3_BUF_FREELIST_ENTRY; 650280304Sjkim# endif 651238405Sjkim 652160814Ssimonextern SSL3_ENC_METHOD ssl3_undef_enc_method; 653238405SjkimOPENSSL_EXTERN const SSL_CIPHER ssl2_ciphers[]; 65455714SkrisOPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[]; 65555714Skris 65655714SkrisSSL_METHOD *ssl_bad_method(int ver); 65755714Skris 658160814Ssimonextern SSL3_ENC_METHOD TLSv1_enc_data; 659160814Ssimonextern SSL3_ENC_METHOD SSLv3_enc_data; 660160814Ssimonextern SSL3_ENC_METHOD DTLSv1_enc_data; 661160814Ssimon 662280304Sjkim# define SSL_IS_DTLS(s) (s->method->version == DTLS1_VERSION) 663260404Sdelphij 664280304Sjkim# define IMPLEMENT_tls_meth_func(version, func_name, s_accept, s_connect, \ 665280304Sjkim s_get_meth) \ 666238405Sjkimconst SSL_METHOD *func_name(void) \ 667280304Sjkim { \ 668280304Sjkim static const SSL_METHOD func_name##_data= { \ 669280304Sjkim version, \ 670280304Sjkim tls1_new, \ 671280304Sjkim tls1_clear, \ 672280304Sjkim tls1_free, \ 673280304Sjkim s_accept, \ 674280304Sjkim s_connect, \ 675280304Sjkim ssl3_read, \ 676280304Sjkim ssl3_peek, \ 677280304Sjkim ssl3_write, \ 678280304Sjkim ssl3_shutdown, \ 679280304Sjkim ssl3_renegotiate, \ 680280304Sjkim ssl3_renegotiate_check, \ 681280304Sjkim ssl3_get_message, \ 682280304Sjkim ssl3_read_bytes, \ 683280304Sjkim ssl3_write_bytes, \ 684280304Sjkim ssl3_dispatch_alert, \ 685280304Sjkim ssl3_ctrl, \ 686280304Sjkim ssl3_ctx_ctrl, \ 687280304Sjkim ssl3_get_cipher_by_char, \ 688280304Sjkim ssl3_put_cipher_by_char, \ 689280304Sjkim ssl3_pending, \ 690280304Sjkim ssl3_num_ciphers, \ 691280304Sjkim ssl3_get_cipher, \ 692280304Sjkim s_get_meth, \ 693280304Sjkim tls1_default_timeout, \ 694280304Sjkim &TLSv1_enc_data, \ 695280304Sjkim ssl_undefined_void_function, \ 696280304Sjkim ssl3_callback_ctrl, \ 697280304Sjkim ssl3_ctx_callback_ctrl, \ 698280304Sjkim }; \ 699280304Sjkim return &func_name##_data; \ 700280304Sjkim } 701160814Ssimon 702280304Sjkim# define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect, s_get_meth) \ 703238405Sjkimconst SSL_METHOD *func_name(void) \ 704280304Sjkim { \ 705280304Sjkim static const SSL_METHOD func_name##_data= { \ 706280304Sjkim SSL3_VERSION, \ 707280304Sjkim ssl3_new, \ 708280304Sjkim ssl3_clear, \ 709280304Sjkim ssl3_free, \ 710280304Sjkim s_accept, \ 711280304Sjkim s_connect, \ 712280304Sjkim ssl3_read, \ 713280304Sjkim ssl3_peek, \ 714280304Sjkim ssl3_write, \ 715280304Sjkim ssl3_shutdown, \ 716280304Sjkim ssl3_renegotiate, \ 717280304Sjkim ssl3_renegotiate_check, \ 718280304Sjkim ssl3_get_message, \ 719280304Sjkim ssl3_read_bytes, \ 720280304Sjkim ssl3_write_bytes, \ 721280304Sjkim ssl3_dispatch_alert, \ 722280304Sjkim ssl3_ctrl, \ 723280304Sjkim ssl3_ctx_ctrl, \ 724280304Sjkim ssl3_get_cipher_by_char, \ 725280304Sjkim ssl3_put_cipher_by_char, \ 726280304Sjkim ssl3_pending, \ 727280304Sjkim ssl3_num_ciphers, \ 728280304Sjkim ssl3_get_cipher, \ 729280304Sjkim s_get_meth, \ 730280304Sjkim ssl3_default_timeout, \ 731280304Sjkim &SSLv3_enc_data, \ 732280304Sjkim ssl_undefined_void_function, \ 733280304Sjkim ssl3_callback_ctrl, \ 734280304Sjkim ssl3_ctx_callback_ctrl, \ 735280304Sjkim }; \ 736280304Sjkim return &func_name##_data; \ 737280304Sjkim } 738160814Ssimon 739280304Sjkim# define IMPLEMENT_ssl23_meth_func(func_name, s_accept, s_connect, s_get_meth) \ 740238405Sjkimconst SSL_METHOD *func_name(void) \ 741280304Sjkim { \ 742280304Sjkim static const SSL_METHOD func_name##_data= { \ 743280304Sjkim TLS1_2_VERSION, \ 744280304Sjkim tls1_new, \ 745280304Sjkim tls1_clear, \ 746280304Sjkim tls1_free, \ 747280304Sjkim s_accept, \ 748280304Sjkim s_connect, \ 749280304Sjkim ssl23_read, \ 750280304Sjkim ssl23_peek, \ 751280304Sjkim ssl23_write, \ 752280304Sjkim ssl_undefined_function, \ 753280304Sjkim ssl_undefined_function, \ 754280304Sjkim ssl_ok, \ 755280304Sjkim ssl3_get_message, \ 756280304Sjkim ssl3_read_bytes, \ 757280304Sjkim ssl3_write_bytes, \ 758280304Sjkim ssl3_dispatch_alert, \ 759280304Sjkim ssl3_ctrl, \ 760280304Sjkim ssl3_ctx_ctrl, \ 761280304Sjkim ssl23_get_cipher_by_char, \ 762280304Sjkim ssl23_put_cipher_by_char, \ 763280304Sjkim ssl_undefined_const_function, \ 764280304Sjkim ssl23_num_ciphers, \ 765280304Sjkim ssl23_get_cipher, \ 766280304Sjkim s_get_meth, \ 767280304Sjkim ssl23_default_timeout, \ 768280304Sjkim &ssl3_undef_enc_method, \ 769280304Sjkim ssl_undefined_void_function, \ 770280304Sjkim ssl3_callback_ctrl, \ 771280304Sjkim ssl3_ctx_callback_ctrl, \ 772280304Sjkim }; \ 773280304Sjkim return &func_name##_data; \ 774280304Sjkim } 775160814Ssimon 776280304Sjkim# define IMPLEMENT_ssl2_meth_func(func_name, s_accept, s_connect, s_get_meth) \ 777238405Sjkimconst SSL_METHOD *func_name(void) \ 778280304Sjkim { \ 779280304Sjkim static const SSL_METHOD func_name##_data= { \ 780280304Sjkim SSL2_VERSION, \ 781280304Sjkim ssl2_new, /* local */ \ 782280304Sjkim ssl2_clear, /* local */ \ 783280304Sjkim ssl2_free, /* local */ \ 784280304Sjkim s_accept, \ 785280304Sjkim s_connect, \ 786280304Sjkim ssl2_read, \ 787280304Sjkim ssl2_peek, \ 788280304Sjkim ssl2_write, \ 789280304Sjkim ssl2_shutdown, \ 790280304Sjkim ssl_ok, /* NULL - renegotiate */ \ 791280304Sjkim ssl_ok, /* NULL - check renegotiate */ \ 792280304Sjkim NULL, /* NULL - ssl_get_message */ \ 793280304Sjkim NULL, /* NULL - ssl_get_record */ \ 794280304Sjkim NULL, /* NULL - ssl_write_bytes */ \ 795280304Sjkim NULL, /* NULL - dispatch_alert */ \ 796280304Sjkim ssl2_ctrl, /* local */ \ 797280304Sjkim ssl2_ctx_ctrl, /* local */ \ 798280304Sjkim ssl2_get_cipher_by_char, \ 799280304Sjkim ssl2_put_cipher_by_char, \ 800280304Sjkim ssl2_pending, \ 801280304Sjkim ssl2_num_ciphers, \ 802280304Sjkim ssl2_get_cipher, \ 803280304Sjkim s_get_meth, \ 804280304Sjkim ssl2_default_timeout, \ 805280304Sjkim &ssl3_undef_enc_method, \ 806280304Sjkim ssl_undefined_void_function, \ 807280304Sjkim ssl2_callback_ctrl, /* local */ \ 808280304Sjkim ssl2_ctx_callback_ctrl, /* local */ \ 809280304Sjkim }; \ 810280304Sjkim return &func_name##_data; \ 811280304Sjkim } 812160814Ssimon 813280304Sjkim# define IMPLEMENT_dtls1_meth_func(func_name, s_accept, s_connect, s_get_meth) \ 814238405Sjkimconst SSL_METHOD *func_name(void) \ 815280304Sjkim { \ 816280304Sjkim static const SSL_METHOD func_name##_data= { \ 817280304Sjkim DTLS1_VERSION, \ 818280304Sjkim dtls1_new, \ 819280304Sjkim dtls1_clear, \ 820280304Sjkim dtls1_free, \ 821280304Sjkim s_accept, \ 822280304Sjkim s_connect, \ 823280304Sjkim ssl3_read, \ 824280304Sjkim ssl3_peek, \ 825280304Sjkim ssl3_write, \ 826280304Sjkim dtls1_shutdown, \ 827280304Sjkim ssl3_renegotiate, \ 828280304Sjkim ssl3_renegotiate_check, \ 829280304Sjkim dtls1_get_message, \ 830280304Sjkim dtls1_read_bytes, \ 831280304Sjkim dtls1_write_app_data_bytes, \ 832280304Sjkim dtls1_dispatch_alert, \ 833280304Sjkim dtls1_ctrl, \ 834280304Sjkim ssl3_ctx_ctrl, \ 835280304Sjkim ssl3_get_cipher_by_char, \ 836280304Sjkim ssl3_put_cipher_by_char, \ 837280304Sjkim ssl3_pending, \ 838280304Sjkim ssl3_num_ciphers, \ 839280304Sjkim dtls1_get_cipher, \ 840280304Sjkim s_get_meth, \ 841280304Sjkim dtls1_default_timeout, \ 842280304Sjkim &DTLSv1_enc_data, \ 843280304Sjkim ssl_undefined_void_function, \ 844280304Sjkim ssl3_callback_ctrl, \ 845280304Sjkim ssl3_ctx_callback_ctrl, \ 846280304Sjkim }; \ 847280304Sjkim return &func_name##_data; \ 848280304Sjkim } 849160814Ssimon 850280304Sjkimstruct openssl_ssl_test_functions { 851280304Sjkim int (*p_ssl_init_wbio_buffer) (SSL *s, int push); 852280304Sjkim int (*p_ssl3_setup_buffers) (SSL *s); 853280304Sjkim int (*p_tls1_process_heartbeat) (SSL *s); 854280304Sjkim int (*p_dtls1_process_heartbeat) (SSL *s); 855280304Sjkim}; 856269686Sjkim 857280304Sjkim# ifndef OPENSSL_UNIT_TEST 858269686Sjkim 85955714Skrisvoid ssl_clear_cipher_ctx(SSL *s); 86055714Skrisint ssl_clear_bad_session(SSL *s); 86155714SkrisCERT *ssl_cert_new(void); 86255714SkrisCERT *ssl_cert_dup(CERT *cert); 86355714Skrisint ssl_cert_inst(CERT **o); 86455714Skrisvoid ssl_cert_free(CERT *c); 86555714SkrisSESS_CERT *ssl_sess_cert_new(void); 86655714Skrisvoid ssl_sess_cert_free(SESS_CERT *sc); 86755714Skrisint ssl_set_peer_cert_type(SESS_CERT *c, int type); 86855714Skrisint ssl_get_new_session(SSL *s, int session); 869280304Sjkimint ssl_get_prev_session(SSL *s, unsigned char *session, int len, 870280304Sjkim const unsigned char *limit); 871284285SjkimSSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket); 872280304Sjkimint ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b); 873280304SjkimDECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id); 874280304Sjkimint ssl_cipher_ptr_id_cmp(const SSL_CIPHER *const *ap, 875280304Sjkim const SSL_CIPHER *const *bp); 876280304SjkimSTACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, unsigned char *p, 877280304Sjkim int num, 878280304Sjkim STACK_OF(SSL_CIPHER) **skp); 879280304Sjkimint ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, 880280304Sjkim unsigned char *p, 881280304Sjkim int (*put_cb) (const SSL_CIPHER *, 882280304Sjkim unsigned char *)); 88359191SkrisSTACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth, 884280304Sjkim STACK_OF(SSL_CIPHER) **pref, 885280304Sjkim STACK_OF(SSL_CIPHER) **sorted, 886280304Sjkim const char *rule_str); 88755714Skrisvoid ssl_update_cache(SSL *s, int mode); 888280304Sjkimint ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, 889280304Sjkim const EVP_MD **md, int *mac_pkey_type, 890280304Sjkim int *mac_secret_size, SSL_COMP **comp); 891280304Sjkimint ssl_get_handshake_digest(int i, long *mask, const EVP_MD **md); 892280304Sjkimint ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk); 89355714Skrisint ssl_undefined_function(SSL *s); 894160814Ssimonint ssl_undefined_void_function(void); 895160814Ssimonint ssl_undefined_const_function(const SSL *s); 896246772SjkimCERT_PKEY *ssl_get_server_send_pkey(const SSL *s); 897246772SjkimX509 *ssl_get_server_send_cert(const SSL *); 898280304SjkimEVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *c, const EVP_MD **pmd); 899280304Sjkimint ssl_cert_type(X509 *x, EVP_PKEY *pkey); 900238405Sjkimvoid ssl_set_cert_masks(CERT *c, const SSL_CIPHER *cipher); 90155714SkrisSTACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s); 90255714Skrisint ssl_verify_alarm_type(long type); 903160814Ssimonvoid ssl_load_ciphers(void); 904264331Sjkimint ssl_fill_hello_random(SSL *s, int server, unsigned char *field, int len); 90555714Skris 90655714Skrisint ssl2_enc_init(SSL *s, int client); 907101615Snectarint ssl2_generate_key_material(SSL *s); 908280304Sjkimint ssl2_enc(SSL *s, int send_data); 909280304Sjkimvoid ssl2_mac(SSL *s, unsigned char *mac, int send_data); 910238405Sjkimconst SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p); 911280304Sjkimint ssl2_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); 91255714Skrisint ssl2_part_read(SSL *s, unsigned long f, int i); 91355714Skrisint ssl2_do_write(SSL *s); 914280304Sjkimint ssl2_set_certificate(SSL *s, int type, int len, 915280304Sjkim const unsigned char *data); 916280304Sjkimvoid ssl2_return_error(SSL *s, int reason); 91755714Skrisvoid ssl2_write_error(SSL *s); 91855714Skrisint ssl2_num_ciphers(void); 919238405Sjkimconst SSL_CIPHER *ssl2_get_cipher(unsigned int u); 920280304Sjkimint ssl2_new(SSL *s); 921280304Sjkimvoid ssl2_free(SSL *s); 922280304Sjkimint ssl2_accept(SSL *s); 923280304Sjkimint ssl2_connect(SSL *s); 924280304Sjkimint ssl2_read(SSL *s, void *buf, int len); 925280304Sjkimint ssl2_peek(SSL *s, void *buf, int len); 926280304Sjkimint ssl2_write(SSL *s, const void *buf, int len); 927280304Sjkimint ssl2_shutdown(SSL *s); 928280304Sjkimvoid ssl2_clear(SSL *s); 929280304Sjkimlong ssl2_ctrl(SSL *s, int cmd, long larg, void *parg); 930280304Sjkimlong ssl2_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg); 931280304Sjkimlong ssl2_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); 932280304Sjkimlong ssl2_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp) (void)); 933280304Sjkimint ssl2_pending(const SSL *s); 934280304Sjkimlong ssl2_default_timeout(void); 93555714Skris 936238405Sjkimconst SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); 937280304Sjkimint ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); 93855714Skrisvoid ssl3_init_finished_mac(SSL *s); 93955714Skrisint ssl3_send_server_certificate(SSL *s); 940194206Ssimonint ssl3_send_newsession_ticket(SSL *s); 941194206Ssimonint ssl3_send_cert_status(SSL *s); 942280304Sjkimint ssl3_get_finished(SSL *s, int state_a, int state_b); 94355714Skrisint ssl3_setup_key_block(SSL *s); 944280304Sjkimint ssl3_send_change_cipher_spec(SSL *s, int state_a, int state_b); 945280304Sjkimint ssl3_change_cipher_state(SSL *s, int which); 94655714Skrisvoid ssl3_cleanup_key_block(SSL *s); 947280304Sjkimint ssl3_do_write(SSL *s, int type); 948280304Sjkimint ssl3_send_alert(SSL *s, int level, int desc); 94955714Skrisint ssl3_generate_master_secret(SSL *s, unsigned char *out, 950280304Sjkim unsigned char *p, int len); 951280304Sjkimint ssl3_get_req_cert_type(SSL *s, unsigned char *p); 95255714Skrislong ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); 953280304Sjkimint ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen); 95455714Skrisint ssl3_num_ciphers(void); 955238405Sjkimconst SSL_CIPHER *ssl3_get_cipher(unsigned int u); 956280304Sjkimint ssl3_renegotiate(SSL *ssl); 957280304Sjkimint ssl3_renegotiate_check(SSL *ssl); 95855714Skrisint ssl3_dispatch_alert(SSL *s); 95972613Skrisint ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); 96055714Skrisint ssl3_write_bytes(SSL *s, int type, const void *buf, int len); 961280304Sjkimint ssl3_final_finish_mac(SSL *s, const char *sender, int slen, 962280304Sjkim unsigned char *p); 963238405Sjkimint ssl3_cert_verify_mac(SSL *s, int md_nid, unsigned char *p); 96455714Skrisvoid ssl3_finish_mac(SSL *s, const unsigned char *buf, int len); 96555714Skrisint ssl3_enc(SSL *s, int send_data); 966238405Sjkimint n_ssl3_mac(SSL *ssl, unsigned char *md, int send_data); 967238405Sjkimvoid ssl3_free_digest_list(SSL *s); 96855714Skrisunsigned long ssl3_output_cert_chain(SSL *s, X509 *x); 969280304SjkimSSL_CIPHER *ssl3_choose_cipher(SSL *ssl, STACK_OF(SSL_CIPHER) *clnt, 970280304Sjkim STACK_OF(SSL_CIPHER) *srvr); 971280304Sjkimint ssl3_setup_buffers(SSL *s); 972280304Sjkimint ssl3_setup_read_buffer(SSL *s); 973280304Sjkimint ssl3_setup_write_buffer(SSL *s); 974280304Sjkimint ssl3_release_read_buffer(SSL *s); 975280304Sjkimint ssl3_release_write_buffer(SSL *s); 976280304Sjkimint ssl3_digest_cached_records(SSL *s); 977280304Sjkimint ssl3_new(SSL *s); 978280304Sjkimvoid ssl3_free(SSL *s); 979280304Sjkimint ssl3_accept(SSL *s); 980280304Sjkimint ssl3_connect(SSL *s); 981280304Sjkimint ssl3_read(SSL *s, void *buf, int len); 982280304Sjkimint ssl3_peek(SSL *s, void *buf, int len); 983280304Sjkimint ssl3_write(SSL *s, const void *buf, int len); 984280304Sjkimint ssl3_shutdown(SSL *s); 985280304Sjkimvoid ssl3_clear(SSL *s); 986280304Sjkimlong ssl3_ctrl(SSL *s, int cmd, long larg, void *parg); 987280304Sjkimlong ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg); 988280304Sjkimlong ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); 989280304Sjkimlong ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp) (void)); 990280304Sjkimint ssl3_pending(const SSL *s); 99155714Skris 992160814Ssimonvoid ssl3_record_sequence_update(unsigned char *seq); 993160814Ssimonint ssl3_do_change_cipher_spec(SSL *ssl); 994280304Sjkimlong ssl3_default_timeout(void); 995160814Ssimon 996280304Sjkimint ssl23_num_ciphers(void); 997238405Sjkimconst SSL_CIPHER *ssl23_get_cipher(unsigned int u); 998160814Ssimonint ssl23_read(SSL *s, void *buf, int len); 999160814Ssimonint ssl23_peek(SSL *s, void *buf, int len); 1000160814Ssimonint ssl23_write(SSL *s, const void *buf, int len); 1001160814Ssimonint ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); 1002238405Sjkimconst SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p); 1003280304Sjkimlong ssl23_default_timeout(void); 1004160814Ssimon 1005160814Ssimonlong tls1_default_timeout(void); 1006280304Sjkimint dtls1_do_write(SSL *s, int type); 1007160814Ssimonint ssl3_read_n(SSL *s, int n, int max, int extend); 1008160814Ssimonint dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); 1009160814Ssimonint ssl3_do_compress(SSL *ssl); 1010160814Ssimonint ssl3_do_uncompress(SSL *ssl); 1011160814Ssimonint ssl3_write_pending(SSL *s, int type, const unsigned char *buf, 1012280304Sjkim unsigned int len); 1013280304Sjkimunsigned char *dtls1_set_message_header(SSL *s, 1014280304Sjkim unsigned char *p, unsigned char mt, 1015280304Sjkim unsigned long len, 1016280304Sjkim unsigned long frag_off, 1017280304Sjkim unsigned long frag_len); 1018160814Ssimon 1019160814Ssimonint dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len); 1020160814Ssimonint dtls1_write_bytes(SSL *s, int type, const void *buf, int len); 1021160814Ssimon 1022160814Ssimonint dtls1_send_change_cipher_spec(SSL *s, int a, int b); 1023160814Ssimonint dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen); 1024160814Ssimonunsigned long dtls1_output_cert_chain(SSL *s, X509 *x); 1025160814Ssimonint dtls1_read_failed(SSL *s, int code); 1026160814Ssimonint dtls1_buffer_message(SSL *s, int ccs); 1027280304Sjkimint dtls1_retransmit_message(SSL *s, unsigned short seq, 1028280304Sjkim unsigned long frag_off, int *found); 1029205128Ssimonint dtls1_get_queue_priority(unsigned short seq, int is_ccs); 1030205128Ssimonint dtls1_retransmit_buffered_messages(SSL *s); 1031306196Sjkimvoid dtls1_clear_received_buffer(SSL *s); 1032306196Sjkimvoid dtls1_clear_sent_buffer(SSL *s); 1033280304Sjkimvoid dtls1_get_message_header(unsigned char *data, 1034280304Sjkim struct hm_header_st *msg_hdr); 1035160814Ssimonvoid dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr); 1036160814Ssimonvoid dtls1_reset_seq_numbers(SSL *s, int rw); 1037160814Ssimonlong dtls1_default_timeout(void); 1038280304Sjkimstruct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft); 1039237657Sjkimint dtls1_check_timeout_num(SSL *s); 1040205128Ssimonint dtls1_handle_timeout(SSL *s); 1041238405Sjkimconst SSL_CIPHER *dtls1_get_cipher(unsigned int u); 1042205128Ssimonvoid dtls1_start_timer(SSL *s); 1043205128Ssimonvoid dtls1_stop_timer(SSL *s); 1044205128Ssimonint dtls1_is_timer_expired(SSL *s); 1045205128Ssimonvoid dtls1_double_timeout(SSL *s); 1046205128Ssimonint dtls1_send_newsession_ticket(SSL *s); 1047276864Sjkimunsigned int dtls1_min_mtu(SSL *s); 1048276864Sjkimunsigned int dtls1_link_min_mtu(void); 1049276864Sjkimvoid dtls1_hm_fragment_free(hm_fragment *frag); 1050160814Ssimon 1051160814Ssimon/* some client-only functions */ 1052160814Ssimonint ssl3_client_hello(SSL *s); 1053160814Ssimonint ssl3_get_server_hello(SSL *s); 1054160814Ssimonint ssl3_get_certificate_request(SSL *s); 1055194206Ssimonint ssl3_get_new_session_ticket(SSL *s); 1056194206Ssimonint ssl3_get_cert_status(SSL *s); 1057160814Ssimonint ssl3_get_server_done(SSL *s); 1058160814Ssimonint ssl3_send_client_verify(SSL *s); 1059238405Sjkimint ssl3_send_client_certificate(SSL *s); 1060194206Ssimonint ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); 1061160814Ssimonint ssl3_send_client_key_exchange(SSL *s); 1062160814Ssimonint ssl3_get_key_exchange(SSL *s); 1063160814Ssimonint ssl3_get_server_certificate(SSL *s); 1064160814Ssimonint ssl3_check_cert_and_algorithm(SSL *s); 1065280304Sjkim# ifndef OPENSSL_NO_TLSEXT 1066280304Sjkim# ifndef OPENSSL_NO_NEXTPROTONEG 1067238405Sjkimint ssl3_send_next_proto(SSL *s); 1068280304Sjkim# endif 1069280304Sjkim# endif 1070160814Ssimon 1071160814Ssimonint dtls1_client_hello(SSL *s); 1072160814Ssimonint dtls1_send_client_certificate(SSL *s); 1073160814Ssimonint dtls1_send_client_key_exchange(SSL *s); 1074160814Ssimonint dtls1_send_client_verify(SSL *s); 1075160814Ssimon 1076160814Ssimon/* some server-only functions */ 1077160814Ssimonint ssl3_get_client_hello(SSL *s); 1078160814Ssimonint ssl3_send_server_hello(SSL *s); 1079160814Ssimonint ssl3_send_hello_request(SSL *s); 1080160814Ssimonint ssl3_send_server_key_exchange(SSL *s); 1081160814Ssimonint ssl3_send_certificate_request(SSL *s); 1082160814Ssimonint ssl3_send_server_done(SSL *s); 1083160814Ssimonint ssl3_check_client_hello(SSL *s); 1084160814Ssimonint ssl3_get_client_certificate(SSL *s); 1085160814Ssimonint ssl3_get_client_key_exchange(SSL *s); 1086160814Ssimonint ssl3_get_cert_verify(SSL *s); 1087280304Sjkim# ifndef OPENSSL_NO_NEXTPROTONEG 1088238405Sjkimint ssl3_get_next_proto(SSL *s); 1089280304Sjkim# endif 1090160814Ssimon 1091160814Ssimonint dtls1_send_hello_request(SSL *s); 1092160814Ssimonint dtls1_send_server_hello(SSL *s); 1093160814Ssimonint dtls1_send_server_certificate(SSL *s); 1094160814Ssimonint dtls1_send_server_key_exchange(SSL *s); 1095160814Ssimonint dtls1_send_certificate_request(SSL *s); 1096160814Ssimonint dtls1_send_server_done(SSL *s); 1097160814Ssimon 109855714Skrisint ssl23_accept(SSL *s); 109955714Skrisint ssl23_connect(SSL *s); 110055714Skrisint ssl23_read_bytes(SSL *s, int n); 110155714Skrisint ssl23_write_bytes(SSL *s); 110255714Skris 110355714Skrisint tls1_new(SSL *s); 110455714Skrisvoid tls1_free(SSL *s); 110555714Skrisvoid tls1_clear(SSL *s); 1106280304Sjkimlong tls1_ctrl(SSL *s, int cmd, long larg, void *parg); 1107280304Sjkimlong tls1_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); 110855714Skris 1109160814Ssimonint dtls1_new(SSL *s); 1110280304Sjkimint dtls1_accept(SSL *s); 1111280304Sjkimint dtls1_connect(SSL *s); 1112160814Ssimonvoid dtls1_free(SSL *s); 1113160814Ssimonvoid dtls1_clear(SSL *s); 1114280304Sjkimlong dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); 1115238405Sjkimint dtls1_shutdown(SSL *s); 1116160814Ssimon 1117160814Ssimonlong dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); 1118160814Ssimonint dtls1_get_record(SSL *s); 1119160814Ssimonint do_dtls1_write(SSL *s, int type, const unsigned char *buf, 1120280304Sjkim unsigned int len, int create_empty_fragement); 1121160814Ssimonint dtls1_dispatch_alert(SSL *s); 1122160814Ssimonint dtls1_enc(SSL *s, int snd); 1123160814Ssimon 112455714Skrisint ssl_init_wbio_buffer(SSL *s, int push); 112555714Skrisvoid ssl_free_wbio_buffer(SSL *s); 112655714Skris 112755714Skrisint tls1_change_cipher_state(SSL *s, int which); 112855714Skrisint tls1_setup_key_block(SSL *s); 112955714Skrisint tls1_enc(SSL *s, int snd); 1130238405Sjkimint tls1_final_finish_mac(SSL *s, 1131280304Sjkim const char *str, int slen, unsigned char *p); 1132238405Sjkimint tls1_cert_verify_mac(SSL *s, int md_nid, unsigned char *p); 113355714Skrisint tls1_mac(SSL *ssl, unsigned char *md, int snd); 113455714Skrisint tls1_generate_master_secret(SSL *s, unsigned char *out, 1135280304Sjkim unsigned char *p, int len); 1136238405Sjkimint tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, 1137280304Sjkim const char *label, size_t llen, 1138280304Sjkim const unsigned char *p, size_t plen, 1139280304Sjkim int use_context); 114055714Skrisint tls1_alert_code(int code); 114155714Skrisint ssl3_alert_code(int code); 114255714Skrisint ssl_ok(SSL *s); 114355714Skris 1144280304Sjkim# ifndef OPENSSL_NO_ECDH 1145238405Sjkimint ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s); 1146280304Sjkim# endif 1147160814Ssimon 114855714SkrisSSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n); 114955714Skris 1150280304Sjkim# ifndef OPENSSL_NO_EC 1151238405Sjkimint tls1_ec_curve_id2nid(int curve_id); 1152238405Sjkimint tls1_ec_nid2curve_id(int nid); 1153280304Sjkim# endif /* OPENSSL_NO_EC */ 1154238405Sjkim 1155280304Sjkim# ifndef OPENSSL_NO_TLSEXT 1156280304Sjkimunsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, 1157280304Sjkim unsigned char *limit); 1158280304Sjkimunsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, 1159280304Sjkim unsigned char *limit); 1160280304Sjkimint ssl_parse_clienthello_tlsext(SSL *s, unsigned char **data, 1161291721Sjkim unsigned char *limit, int *al); 1162280304Sjkimint ssl_parse_serverhello_tlsext(SSL *s, unsigned char **data, 1163280304Sjkim unsigned char *d, int n, int *al); 1164194206Ssimonint ssl_prepare_clienthello_tlsext(SSL *s); 1165194206Ssimonint ssl_prepare_serverhello_tlsext(SSL *s); 1166246772Sjkimint ssl_check_clienthello_tlsext_early(SSL *s); 1167246772Sjkimint ssl_check_clienthello_tlsext_late(SSL *s); 1168194206Ssimonint ssl_check_serverhello_tlsext(SSL *s); 1169205128Ssimon 1170280304Sjkim# ifndef OPENSSL_NO_HEARTBEATS 1171238405Sjkimint tls1_heartbeat(SSL *s); 1172238405Sjkimint dtls1_heartbeat(SSL *s); 1173238405Sjkimint tls1_process_heartbeat(SSL *s); 1174238405Sjkimint dtls1_process_heartbeat(SSL *s); 1175280304Sjkim# endif 1176238405Sjkim 1177280304Sjkim# ifdef OPENSSL_NO_SHA256 1178280304Sjkim# define tlsext_tick_md EVP_sha1 1179280304Sjkim# else 1180280304Sjkim# define tlsext_tick_md EVP_sha256 1181280304Sjkim# endif 1182194206Ssimonint tls1_process_ticket(SSL *s, unsigned char *session_id, int len, 1183280304Sjkim const unsigned char *limit, SSL_SESSION **ret); 1184238405Sjkim 1185238405Sjkimint tls12_get_sigandhash(unsigned char *p, const EVP_PKEY *pk, 1186280304Sjkim const EVP_MD *md); 1187238405Sjkimint tls12_get_sigid(const EVP_PKEY *pk); 1188238405Sjkimconst EVP_MD *tls12_get_hash(unsigned char hash_alg); 1189238405Sjkim 1190280304Sjkim# endif 1191280304SjkimEVP_MD_CTX *ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md); 1192194206Ssimonvoid ssl_clear_hash_ctx(EVP_MD_CTX **hash); 1193205128Ssimonint ssl_add_serverhello_renegotiate_ext(SSL *s, unsigned char *p, int *len, 1194280304Sjkim int maxlen); 1195205128Ssimonint ssl_parse_serverhello_renegotiate_ext(SSL *s, unsigned char *d, int len, 1196280304Sjkim int *al); 1197205128Ssimonint ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, int *len, 1198280304Sjkim int maxlen); 1199205128Ssimonint ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len, 1200280304Sjkim int *al); 1201238405Sjkimlong ssl_get_algorithm2(SSL *s); 1202238405Sjkimint tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize); 1203238405Sjkimint tls12_get_req_sig_algs(SSL *s, unsigned char *p); 120455714Skris 1205280304Sjkimint ssl_add_clienthello_use_srtp_ext(SSL *s, unsigned char *p, int *len, 1206280304Sjkim int maxlen); 1207280304Sjkimint ssl_parse_clienthello_use_srtp_ext(SSL *s, unsigned char *d, int len, 1208280304Sjkim int *al); 1209280304Sjkimint ssl_add_serverhello_use_srtp_ext(SSL *s, unsigned char *p, int *len, 1210280304Sjkim int maxlen); 1211280304Sjkimint ssl_parse_serverhello_use_srtp_ext(SSL *s, unsigned char *d, int len, 1212280304Sjkim int *al); 1213238405Sjkim 1214246772Sjkim/* s3_cbc.c */ 1215280304Sjkimvoid ssl3_cbc_copy_mac(unsigned char *out, 1216280304Sjkim const SSL3_RECORD *rec, 1217280304Sjkim unsigned md_size, unsigned orig_len); 1218280304Sjkimint ssl3_cbc_remove_padding(const SSL *s, 1219280304Sjkim SSL3_RECORD *rec, 1220280304Sjkim unsigned block_size, unsigned mac_size); 1221280304Sjkimint tls1_cbc_remove_padding(const SSL *s, 1222280304Sjkim SSL3_RECORD *rec, 1223280304Sjkim unsigned block_size, unsigned mac_size); 1224246772Sjkimchar ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx); 1225291721Sjkimint ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, 1226291721Sjkim unsigned char *md_out, 1227291721Sjkim size_t *md_out_size, 1228291721Sjkim const unsigned char header[13], 1229291721Sjkim const unsigned char *data, 1230291721Sjkim size_t data_plus_mac_size, 1231291721Sjkim size_t data_plus_mac_plus_padding_size, 1232291721Sjkim const unsigned char *mac_secret, 1233291721Sjkim unsigned mac_secret_length, char is_sslv3); 1234246772Sjkim 1235280304Sjkimvoid tls_fips_digest_extra(const EVP_CIPHER_CTX *cipher_ctx, 1236280304Sjkim EVP_MD_CTX *mac_ctx, const unsigned char *data, 1237280304Sjkim size_t data_len, size_t orig_len); 1238246772Sjkim 1239269686Sjkimint srp_verify_server_param(SSL *s, int *al); 1240269686Sjkim 1241280304Sjkim# else 1242269686Sjkim 1243280304Sjkim# define ssl_init_wbio_buffer SSL_test_functions()->p_ssl_init_wbio_buffer 1244280304Sjkim# define ssl3_setup_buffers SSL_test_functions()->p_ssl3_setup_buffers 1245280304Sjkim# define tls1_process_heartbeat SSL_test_functions()->p_tls1_process_heartbeat 1246280304Sjkim# define dtls1_process_heartbeat SSL_test_functions()->p_dtls1_process_heartbeat 1247269686Sjkim 1248280304Sjkim# endif 124955714Skris#endif 1250