Moved s3_pkt.c, s23_pkt.c and d1_pkt.c into the record layer.
authorMatt Caswell <matt@openssl.org>
Mon, 2 Feb 2015 10:38:12 +0000 (10:38 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 26 Mar 2015 15:01:59 +0000 (15:01 +0000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/Makefile
ssl/record/d1_pkt.c [moved from ssl/d1_pkt.c with 99% similarity]
ssl/record/rec_layer.h
ssl/record/s23_pkt.c [moved from ssl/s23_pkt.c with 99% similarity]
ssl/record/s3_pkt.c [moved from ssl/s3_pkt.c with 99% similarity]
ssl/ssl_locl.h

index b212084c8a213ede015239486802a6bf7250b477..a2fb87dbfd019873b7fbec5ccac43643a900af9b 100644 (file)
@@ -21,11 +21,11 @@ APPS=
 LIB=$(TOP)/libssl.a
 SHARED_LIB= libssl$(SHLIB_EXT)
 LIBSRC=        \
 LIB=$(TOP)/libssl.a
 SHARED_LIB= libssl$(SHLIB_EXT)
 LIBSRC=        \
-       s3_meth.c   s3_srvr.c s3_clnt.c  s3_lib.c  s3_enc.c s3_pkt.c s3_both.c s3_cbc.c \
+       s3_meth.c   s3_srvr.c s3_clnt.c  s3_lib.c  s3_enc.c record/s3_pkt.c s3_both.c s3_cbc.c \
        s3_msg.c \
        s3_msg.c \
-       s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
+       s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c record/s23_pkt.c \
        t1_meth.c   t1_srvr.c t1_clnt.c  t1_lib.c  t1_enc.c t1_ext.c \
        t1_meth.c   t1_srvr.c t1_clnt.c  t1_lib.c  t1_enc.c t1_ext.c \
-       d1_meth.c   d1_srvr.c d1_clnt.c  d1_lib.c  d1_pkt.c d1_msg.c \
+       d1_meth.c   d1_srvr.c d1_clnt.c  d1_lib.c  record/d1_pkt.c d1_msg.c \
        d1_both.c d1_srtp.c \
        ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
        ssl_ciph.c ssl_stat.c ssl_rsa.c \
        d1_both.c d1_srtp.c \
        ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
        ssl_ciph.c ssl_stat.c ssl_rsa.c \
@@ -33,11 +33,11 @@ LIBSRC=     \
        bio_ssl.c ssl_err.c kssl.c t1_reneg.c tls_srp.c t1_trce.c ssl_utst.c \
        record/ssl3_buffer.c record/ssl3_record.c
 LIBOBJ= \
        bio_ssl.c ssl_err.c kssl.c t1_reneg.c tls_srp.c t1_trce.c ssl_utst.c \
        record/ssl3_buffer.c record/ssl3_record.c
 LIBOBJ= \
-       s3_meth.o  s3_srvr.o  s3_clnt.o  s3_lib.o  s3_enc.o s3_pkt.o s3_both.o s3_cbc.o \
+       s3_meth.o  s3_srvr.o  s3_clnt.o  s3_lib.o  s3_enc.o record/s3_pkt.o s3_both.o s3_cbc.o \
        s3_msg.o \
        s3_msg.o \
-       s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o \
+       s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o record/s23_pkt.o \
        t1_meth.o   t1_srvr.o t1_clnt.o  t1_lib.o  t1_enc.o t1_ext.o \
        t1_meth.o   t1_srvr.o t1_clnt.o  t1_lib.o  t1_enc.o t1_ext.o \
-       d1_meth.o   d1_srvr.o d1_clnt.o  d1_lib.o  d1_pkt.o d1_msg.o \
+       d1_meth.o   d1_srvr.o d1_clnt.o  d1_lib.o  record/d1_pkt.o d1_msg.o \
        d1_both.o d1_srtp.o\
        ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \
        ssl_ciph.o ssl_stat.o ssl_rsa.o \
        d1_both.o d1_srtp.o\
        ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \
        ssl_ciph.o ssl_stat.o ssl_rsa.o \
similarity index 99%
rename from ssl/d1_pkt.c
rename to ssl/record/d1_pkt.c
index d82e0d58273357e5c0b0a5abe7330422b1ec7787..e85e94dd749efe60e198649c22584fdfc186fabf 100644 (file)
 #include <stdio.h>
 #include <errno.h>
 #define USE_SOCKETS
 #include <stdio.h>
 #include <errno.h>
 #define USE_SOCKETS
-#include "ssl_locl.h"
+#include "../ssl_locl.h"
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 #include <openssl/pqueue.h>
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 #include <openssl/pqueue.h>
index 3f63fac82e729c651b361db205ecaa9e7e2a017c..e8dd3ff1f186f1391854f4bfc8a41202f5f5b45d 100644 (file)
 
 #include "../ssl_locl.h"
 
 
 #include "../ssl_locl.h"
 
+typedef struct dtls1_bitmap_st {
+    unsigned long map;          /* track 32 packets on 32-bit systems and 64
+                                 * - on 64-bit systems */
+    unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit
+                                   * value in big-endian encoding */
+} DTLS1_BITMAP;
+
+
+typedef struct record_pqueue_st {
+    unsigned short epoch;
+    pqueue q;
+} record_pqueue;
+
 typedef struct record_layer_st {
     /* The parent SSL structure */
     SSL *s;
 typedef struct record_layer_st {
     /* The parent SSL structure */
     SSL *s;
@@ -136,3 +149,27 @@ typedef struct record_layer_st {
 #define RECORD_LAYER_get_wbuf(rl)               (&(rl)->wbuf)
 #define RECORD_LAYER_get_rrec(rl)               (&(rl)->rrec)
 #define RECORD_LAYER_get_wrec(rl)               (&(rl)->wrec)
 #define RECORD_LAYER_get_wbuf(rl)               (&(rl)->wbuf)
 #define RECORD_LAYER_get_rrec(rl)               (&(rl)->rrec)
 #define RECORD_LAYER_get_wrec(rl)               (&(rl)->wrec)
+
+__owur int ssl23_read_bytes(SSL *s, int n);
+__owur int ssl23_write_bytes(SSL *s);
+__owur int ssl3_read_n(SSL *s, int n, int max, int extend);
+__owur int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
+__owur int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
+                         unsigned int len, int create_empty_fragment);
+__owur int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
+                       unsigned int len);
+__owur int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
+__owur int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
+int dtls1_write_bytes(SSL *s, int type, const void *buf, int len);
+__owur int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
+                   unsigned int len, int create_empty_fragement);
+int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap);
+void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap);
+DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr,
+                                      unsigned int *is_next_epoch);
+int dtls1_process_buffered_records(SSL *s);
+int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue);
+int dtls1_buffer_record(SSL *s, record_pqueue *q,
+                               unsigned char *priority);
+void dtls1_reset_seq_numbers(SSL *s, int rw);
+
similarity index 99%
rename from ssl/s23_pkt.c
rename to ssl/record/s23_pkt.c
index efc8647841bf21db77dd94608e55605988854d3c..e3a91554fd8257a088a87f00804aa3fb14168419 100644 (file)
@@ -59,7 +59,7 @@
 #include <stdio.h>
 #include <errno.h>
 #define USE_SOCKETS
 #include <stdio.h>
 #include <errno.h>
 #define USE_SOCKETS
-#include "ssl_locl.h"
+#include "../ssl_locl.h"
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 
similarity index 99%
rename from ssl/s3_pkt.c
rename to ssl/record/s3_pkt.c
index 16a6db42ccd016335c8111f688194d74fe88e249..b9d057530192cc3a2927f847de835e1f43d71c91 100644 (file)
 #include <limits.h>
 #include <errno.h>
 #define USE_SOCKETS
 #include <limits.h>
 #include <errno.h>
 #define USE_SOCKETS
-#include "ssl_locl.h"
+#include "../ssl_locl.h"
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 #include <openssl/rand.h>
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 #include <openssl/rand.h>
index e6f2c67b7fb35af3c72317d0f5650b7be9b7944d..e0dd259788c524bb1b9457f4017d7d344c9ad38a 100644 (file)
@@ -1376,13 +1376,6 @@ typedef struct ssl3_state_st {
 /* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */
 #  define DTLS1_MAX_MTU_OVERHEAD                   48
 
 /* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */
 #  define DTLS1_MAX_MTU_OVERHEAD                   48
 
-typedef struct dtls1_bitmap_st {
-    unsigned long map;          /* track 32 packets on 32-bit systems and 64
-                                 * - on 64-bit systems */
-    unsigned char max_seq_num[8]; /* max record number seen so far, 64-bit
-                                   * value in big-endian encoding */
-} DTLS1_BITMAP;
-
 struct dtls1_retransmit_state {
     EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
     EVP_MD_CTX *write_hash;     /* used for mac generation */
 struct dtls1_retransmit_state {
     EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */
     EVP_MD_CTX *write_hash;     /* used for mac generation */
@@ -1419,11 +1412,6 @@ struct dtls1_timeout_st {
     unsigned int num_alerts;
 };
 
     unsigned int num_alerts;
 };
 
-typedef struct record_pqueue_st {
-    unsigned short epoch;
-    pqueue q;
-} record_pqueue;
-
 typedef struct hm_fragment_st {
     struct hm_header_st msg_header;
     unsigned char *fragment;
 typedef struct hm_fragment_st {
     struct hm_header_st msg_header;
     unsigned char *fragment;
@@ -2089,8 +2077,6 @@ __owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u);
 int ssl3_renegotiate(SSL *ssl);
 int ssl3_renegotiate_check(SSL *ssl);
 __owur int ssl3_dispatch_alert(SSL *s);
 int ssl3_renegotiate(SSL *ssl);
 int ssl3_renegotiate_check(SSL *ssl);
 __owur int ssl3_dispatch_alert(SSL *s);
-__owur int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
-__owur int ssl3_write_bytes(SSL *s, int type, const void *buf, int len);
 __owur int ssl3_final_finish_mac(SSL *s, const char *sender, int slen,
                           unsigned char *p);
 __owur int ssl3_cert_verify_mac(SSL *s, int md_nid, unsigned char *p);
 __owur int ssl3_final_finish_mac(SSL *s, const char *sender, int slen,
                           unsigned char *p);
 __owur int ssl3_cert_verify_mac(SSL *s, int md_nid, unsigned char *p);
@@ -2135,12 +2121,6 @@ __owur int ssl_allow_compression(SSL *s);
 
 __owur long tls1_default_timeout(void);
 __owur int dtls1_do_write(SSL *s, int type);
 
 __owur long tls1_default_timeout(void);
 __owur int dtls1_do_write(SSL *s, int type);
-__owur int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
-                         unsigned int len, int create_empty_fragment);
-__owur int ssl3_read_n(SSL *s, int n, int max, int extend);
-__owur int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
-__owur int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
-                       unsigned int len);
 void dtls1_set_message_header(SSL *s,
                               unsigned char *p, unsigned char mt,
                               unsigned long len,
 void dtls1_set_message_header(SSL *s,
                               unsigned char *p, unsigned char mt,
                               unsigned long len,
@@ -2162,7 +2142,6 @@ void dtls1_clear_record_buffer(SSL *s);
 void dtls1_get_message_header(unsigned char *data,
                               struct hm_header_st *msg_hdr);
 void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr);
 void dtls1_get_message_header(unsigned char *data,
                               struct hm_header_st *msg_hdr);
 void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr);
-void dtls1_reset_seq_numbers(SSL *s, int rw);
 __owur long dtls1_default_timeout(void);
 __owur struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft);
 __owur int dtls1_check_timeout_num(SSL *s);
 __owur long dtls1_default_timeout(void);
 __owur struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft);
 __owur int dtls1_check_timeout_num(SSL *s);
@@ -2176,14 +2155,6 @@ __owur int dtls1_send_newsession_ticket(SSL *s);
 __owur unsigned int dtls1_min_mtu(SSL *s);
 __owur unsigned int dtls1_link_min_mtu(void);
 void dtls1_hm_fragment_free(hm_fragment *frag);
 __owur unsigned int dtls1_min_mtu(SSL *s);
 __owur unsigned int dtls1_link_min_mtu(void);
 void dtls1_hm_fragment_free(hm_fragment *frag);
-int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap);
-void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap);
-DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr,
-                                      unsigned int *is_next_epoch);
-int dtls1_process_buffered_records(SSL *s);
-int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue);
-int dtls1_buffer_record(SSL *s, record_pqueue *q,
-                               unsigned char *priority);
 
 /* some client-only functions */
 __owur int ssl3_client_hello(SSL *s);
 
 /* some client-only functions */
 __owur int ssl3_client_hello(SSL *s);
@@ -2223,8 +2194,6 @@ __owur int ssl3_get_next_proto(SSL *s);
 
 __owur int ssl23_accept(SSL *s);
 __owur int ssl23_connect(SSL *s);
 
 __owur int ssl23_accept(SSL *s);
 __owur int ssl23_connect(SSL *s);
-__owur int ssl23_read_bytes(SSL *s, int n);
-__owur int ssl23_write_bytes(SSL *s);
 
 __owur int tls1_new(SSL *s);
 void tls1_free(SSL *s);
 
 __owur int tls1_new(SSL *s);
 void tls1_free(SSL *s);
@@ -2241,8 +2210,6 @@ long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg);
 __owur int dtls1_shutdown(SSL *s);
 
 __owur long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
 __owur int dtls1_shutdown(SSL *s);
 
 __owur long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
-__owur int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
-                   unsigned int len, int create_empty_fragement);
 __owur int dtls1_dispatch_alert(SSL *s);
 
 __owur int ssl_init_wbio_buffer(SSL *s, int push);
 __owur int dtls1_dispatch_alert(SSL *s);
 
 __owur int ssl_init_wbio_buffer(SSL *s, int push);