1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/libcrypto/inc/include/openssl/dtls1.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,211 @@
1.4 +/* ssl/dtls1.h */
1.5 +/*
1.6 + * DTLS implementation written by Nagendra Modadugu
1.7 + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
1.8 + */
1.9 +/* ====================================================================
1.10 + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
1.11 + *
1.12 + * Redistribution and use in source and binary forms, with or without
1.13 + * modification, are permitted provided that the following conditions
1.14 + * are met:
1.15 + *
1.16 + * 1. Redistributions of source code must retain the above copyright
1.17 + * notice, this list of conditions and the following disclaimer.
1.18 + *
1.19 + * 2. Redistributions in binary form must reproduce the above copyright
1.20 + * notice, this list of conditions and the following disclaimer in
1.21 + * the documentation and/or other materials provided with the
1.22 + * distribution.
1.23 + *
1.24 + * 3. All advertising materials mentioning features or use of this
1.25 + * software must display the following acknowledgment:
1.26 + * "This product includes software developed by the OpenSSL Project
1.27 + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
1.28 + *
1.29 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
1.30 + * endorse or promote products derived from this software without
1.31 + * prior written permission. For written permission, please contact
1.32 + * openssl-core@OpenSSL.org.
1.33 + *
1.34 + * 5. Products derived from this software may not be called "OpenSSL"
1.35 + * nor may "OpenSSL" appear in their names without prior written
1.36 + * permission of the OpenSSL Project.
1.37 + *
1.38 + * 6. Redistributions of any form whatsoever must retain the following
1.39 + * acknowledgment:
1.40 + * "This product includes software developed by the OpenSSL Project
1.41 + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
1.42 + *
1.43 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
1.44 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.45 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1.46 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
1.47 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1.48 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1.49 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1.50 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.51 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.52 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.53 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1.54 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1.55 + * ====================================================================
1.56 + *
1.57 + * This product includes cryptographic software written by Eric Young
1.58 + * (eay@cryptsoft.com). This product includes software written by Tim
1.59 + * Hudson (tjh@cryptsoft.com).
1.60 + *
1.61 + */
1.62 +
1.63 +#ifndef HEADER_DTLS1_H
1.64 +#define HEADER_DTLS1_H
1.65 +
1.66 +#include <openssl/buffer.h>
1.67 +#include <openssl/pqueue.h>
1.68 +
1.69 +#ifdef __cplusplus
1.70 +extern "C" {
1.71 +#endif
1.72 +
1.73 +#define DTLS1_VERSION 0xFEFF
1.74 +#define DTLS1_BAD_VER 0x0100
1.75 +
1.76 +#define DTLS1_AD_MISSING_HANDSHAKE_MESSAGE 110
1.77 +
1.78 +/* lengths of messages */
1.79 +#define DTLS1_COOKIE_LENGTH 32
1.80 +
1.81 +#define DTLS1_RT_HEADER_LENGTH 13
1.82 +
1.83 +#define DTLS1_HM_HEADER_LENGTH 12
1.84 +
1.85 +#define DTLS1_HM_BAD_FRAGMENT -2
1.86 +#define DTLS1_HM_FRAGMENT_RETRY -3
1.87 +
1.88 +#define DTLS1_CCS_HEADER_LENGTH 1
1.89 +
1.90 +#define DTLS1_AL_HEADER_LENGTH 7
1.91 +
1.92 +
1.93 +typedef struct dtls1_bitmap_st
1.94 + {
1.95 + PQ_64BIT map;
1.96 + unsigned long length; /* sizeof the bitmap in bits */
1.97 + PQ_64BIT max_seq_num; /* max record number seen so far */
1.98 + } DTLS1_BITMAP;
1.99 +
1.100 +struct hm_header_st
1.101 + {
1.102 + unsigned char type;
1.103 + unsigned long msg_len;
1.104 + unsigned short seq;
1.105 + unsigned long frag_off;
1.106 + unsigned long frag_len;
1.107 + unsigned int is_ccs;
1.108 + };
1.109 +
1.110 +struct ccs_header_st
1.111 + {
1.112 + unsigned char type;
1.113 + unsigned short seq;
1.114 + };
1.115 +
1.116 +struct dtls1_timeout_st
1.117 + {
1.118 + /* Number of read timeouts so far */
1.119 + unsigned int read_timeouts;
1.120 +
1.121 + /* Number of write timeouts so far */
1.122 + unsigned int write_timeouts;
1.123 +
1.124 + /* Number of alerts received so far */
1.125 + unsigned int num_alerts;
1.126 + };
1.127 +
1.128 +typedef struct record_pqueue_st
1.129 + {
1.130 + unsigned short epoch;
1.131 + pqueue q;
1.132 + } record_pqueue;
1.133 +
1.134 +typedef struct hm_fragment_st
1.135 + {
1.136 + struct hm_header_st msg_header;
1.137 + unsigned char *fragment;
1.138 + } hm_fragment;
1.139 +
1.140 +typedef struct dtls1_state_st
1.141 + {
1.142 + unsigned int send_cookie;
1.143 + unsigned char cookie[DTLS1_COOKIE_LENGTH];
1.144 + unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];
1.145 + unsigned int cookie_len;
1.146 +
1.147 + /*
1.148 + * The current data and handshake epoch. This is initially
1.149 + * undefined, and starts at zero once the initial handshake is
1.150 + * completed
1.151 + */
1.152 + unsigned short r_epoch;
1.153 + unsigned short w_epoch;
1.154 +
1.155 + /* records being received in the current epoch */
1.156 + DTLS1_BITMAP bitmap;
1.157 +
1.158 + /* renegotiation starts a new set of sequence numbers */
1.159 + DTLS1_BITMAP next_bitmap;
1.160 +
1.161 + /* handshake message numbers */
1.162 + unsigned short handshake_write_seq;
1.163 + unsigned short next_handshake_write_seq;
1.164 +
1.165 + unsigned short handshake_read_seq;
1.166 +
1.167 + /* Received handshake records (processed and unprocessed) */
1.168 + record_pqueue unprocessed_rcds;
1.169 + record_pqueue processed_rcds;
1.170 +
1.171 + /* Buffered handshake messages */
1.172 + pqueue buffered_messages;
1.173 +
1.174 + /* Buffered (sent) handshake records */
1.175 + pqueue sent_messages;
1.176 +
1.177 + unsigned int mtu; /* max wire packet size */
1.178 +
1.179 + struct hm_header_st w_msg_hdr;
1.180 + struct hm_header_st r_msg_hdr;
1.181 +
1.182 + struct dtls1_timeout_st timeout;
1.183 +
1.184 + /* storage for Alert/Handshake protocol data received but not
1.185 + * yet processed by ssl3_read_bytes: */
1.186 + unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];
1.187 + unsigned int alert_fragment_len;
1.188 + unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];
1.189 + unsigned int handshake_fragment_len;
1.190 +
1.191 + unsigned int retransmitting;
1.192 +
1.193 + } DTLS1_STATE;
1.194 +
1.195 +typedef struct dtls1_record_data_st
1.196 + {
1.197 + unsigned char *packet;
1.198 + unsigned int packet_length;
1.199 + SSL3_BUFFER rbuf;
1.200 + SSL3_RECORD rrec;
1.201 + } DTLS1_RECORD_DATA;
1.202 +
1.203 +
1.204 +/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */
1.205 +#define DTLS1_TMO_READ_COUNT 2
1.206 +#define DTLS1_TMO_WRITE_COUNT 2
1.207 +
1.208 +#define DTLS1_TMO_ALERT_COUNT 12
1.209 +
1.210 +#ifdef __cplusplus
1.211 +}
1.212 +#endif
1.213 +#endif
1.214 +