Mark SSL3_ENC_METHODs const and remove an unused one.

There's an undefined one not used anywhere. The others ought to be const.  Also
move the forward declaration to ssl.h so we don't have to use the struct name.

Change-Id: I76684cf65255535c677ec19154cac74317c289ba
Reviewed-on: https://boringssl-review.googlesource.com/2561
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index 0658947..39e228b 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -281,6 +281,7 @@
 typedef struct ssl_session_st SSL_SESSION;
 typedef struct tls_sigalgs_st TLS_SIGALGS;
 typedef struct ssl_conf_ctx_st SSL_CONF_CTX;
+typedef struct ssl3_enc_method SSL3_ENC_METHOD;
 
 DECLARE_STACK_OF(SSL_CIPHER)
 
@@ -344,7 +345,7 @@
 	int (*ssl_pending)(const SSL *s);
 	int (*num_ciphers)(void);
 	const SSL_CIPHER *(*get_cipher)(unsigned ncipher);
-	struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */
+	const SSL3_ENC_METHOD *ssl3_enc; /* Extra SSLv3/TLS stuff */
 	int (*ssl_version)(void);
 	long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)(void));
 	long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)(void));
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index c05cdb0..3f43bf2 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -77,7 +77,7 @@
 static int dtls1_handshake_write(SSL *s, enum should_add_to_finished_hash should_add_to_finished_hash);
 static void dtls1_add_to_finished_hash(SSL *s);
 
-SSL3_ENC_METHOD DTLSv1_enc_data={
+const SSL3_ENC_METHOD DTLSv1_enc_data = {
     	tls1_enc,
 	tls1_mac,
 	tls1_setup_key_block,
@@ -97,7 +97,7 @@
 	dtls1_add_to_finished_hash,
 	};
 
-SSL3_ENC_METHOD DTLSv1_2_enc_data={
+const SSL3_ENC_METHOD DTLSv1_2_enc_data = {
     	tls1_enc,
 	tls1_mac,
 	tls1_setup_key_block,
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index ad09cd2..0898ac3 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -924,7 +924,7 @@
 /* end of list */
 	};
 
-SSL3_ENC_METHOD SSLv3_enc_data={
+const SSL3_ENC_METHOD SSLv3_enc_data = {
 	ssl3_enc,
 	n_ssl3_mac,
 	ssl3_setup_key_block,
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 219cbf5..5a57a00 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -152,26 +152,6 @@
 
 #include "ssl_locl.h"
 
-SSL3_ENC_METHOD ssl3_undef_enc_method={
-	/* evil casts, but these functions are only called if there's a library bug */
-	(int (*)(SSL *,int))ssl_undefined_function,
-	(int (*)(SSL *, unsigned char *, int))ssl_undefined_function,
-	ssl_undefined_function,
-	(int (*)(SSL *, unsigned char *, unsigned char *, int))ssl_undefined_function,
-	(int (*)(SSL*, int))ssl_undefined_function,
-	(int (*)(SSL *,  const char*, int, unsigned char *))ssl_undefined_function,
-	0,	/* finish_mac_length */
-	(int (*)(SSL *, int, unsigned char *))ssl_undefined_function,
-	NULL,	/* client_finished_label */
-	0,	/* client_finished_label_len */
-	NULL,	/* server_finished_label */
-	0,	/* server_finished_label_len */
-	(int (*)(int))ssl_undefined_function,
-	(int (*)(SSL *, unsigned char *, size_t, const char *,
-		 size_t, const unsigned char *, size_t,
-		 int use_context)) ssl_undefined_function,
-	};
-
 /* Some error codes are special. Ensure the make_errors.go script
  * never regresses this. */
 OPENSSL_COMPILE_ASSERT(
diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h
index cf52bd1..00ba202 100644
--- a/ssl/ssl_locl.h
+++ b/ssl/ssl_locl.h
@@ -566,7 +566,7 @@
 /* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff
  * It is a bit of a mess of functions, but hell, think of it as
  * an opaque structure :-) */
-typedef struct ssl3_enc_method
+struct ssl3_enc_method
 	{
 	int (*enc)(SSL *, int);
 	int (*mac)(SSL *, unsigned char *, int);
@@ -595,7 +595,7 @@
 	int (*do_write)(SSL *s, enum should_add_to_finished_hash should_add_to_finished_hash);
 	/* Add the current handshake message to the finished hash. */
 	void (*add_to_finished_hash)(SSL *s);
-	} SSL3_ENC_METHOD;
+	};
 
 #define SSL_HM_HEADER_LENGTH(s)	s->method->ssl3_enc->hhlen
 #define ssl_handshake_start(s) \
@@ -634,16 +634,15 @@
 	};
 
 
-extern SSL3_ENC_METHOD ssl3_undef_enc_method;
 extern const SSL_CIPHER ssl3_ciphers[];
 
 
-extern SSL3_ENC_METHOD TLSv1_enc_data;
-extern SSL3_ENC_METHOD TLSv1_1_enc_data;
-extern SSL3_ENC_METHOD TLSv1_2_enc_data;
-extern SSL3_ENC_METHOD SSLv3_enc_data;
-extern SSL3_ENC_METHOD DTLSv1_enc_data;
-extern SSL3_ENC_METHOD DTLSv1_2_enc_data;
+extern const SSL3_ENC_METHOD TLSv1_enc_data;
+extern const SSL3_ENC_METHOD TLSv1_1_enc_data;
+extern const SSL3_ENC_METHOD TLSv1_2_enc_data;
+extern const SSL3_ENC_METHOD SSLv3_enc_data;
+extern const SSL3_ENC_METHOD DTLSv1_enc_data;
+extern const SSL3_ENC_METHOD DTLSv1_2_enc_data;
 
 #define IMPLEMENT_tls_meth_func(version, func_name, s_accept, s_connect, \
 				enc_data) \
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index dbaadf2..c8a4fea 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -124,7 +124,7 @@
 static int ssl_check_clienthello_tlsext(SSL *s);
 static int ssl_check_serverhello_tlsext(SSL *s);
 
-SSL3_ENC_METHOD TLSv1_enc_data={
+const SSL3_ENC_METHOD TLSv1_enc_data = {
 	tls1_enc,
 	tls1_mac,
 	tls1_setup_key_block,
@@ -144,7 +144,7 @@
 	ssl3_add_to_finished_hash,
 	};
 
-SSL3_ENC_METHOD TLSv1_1_enc_data={
+const SSL3_ENC_METHOD TLSv1_1_enc_data = {
 	tls1_enc,
 	tls1_mac,
 	tls1_setup_key_block,
@@ -164,7 +164,7 @@
 	ssl3_add_to_finished_hash,
 	};
 
-SSL3_ENC_METHOD TLSv1_2_enc_data={
+const SSL3_ENC_METHOD TLSv1_2_enc_data = {
 	tls1_enc,
 	tls1_mac,
 	tls1_setup_key_block,