Delete some unneeded code
authorMatt Caswell <matt@openssl.org>
Wed, 28 Sep 2016 10:15:36 +0000 (11:15 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 29 Sep 2016 09:06:46 +0000 (10:06 +0100)
Some functions were being called from both code that used WPACKETs and code
that did not. Now that more code has been converted to use WPACKETs some of
that duplication can be removed.

Reviewed-by: Rich Salz <rsalz@openssl.org>
ssl/s3_lib.c
ssl/ssl_locl.h
ssl/t1_ext.c

index 2a4dc6d7a9ba8616c4da7c5ba7a45fa553d9e7d7..2115a7e0fa87e57663eaa2e617e705ce47a9e0c5 100644 (file)
@@ -3571,26 +3571,6 @@ const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
     return cp;
 }
 
-/*
- * Old version of the ssl3_put_cipher_by_char function used by code that has not
- * yet been converted to WPACKET yet. It will be deleted once WPACKET conversion
- * is complete.
- * TODO - DELETE ME
- */
-int ssl3_put_cipher_by_char_old(const SSL_CIPHER *c, unsigned char *p)
-{
-    long l;
-
-    if (p != NULL) {
-        l = c->id;
-        if ((l & 0xff000000) != 0x03000000)
-            return (0);
-        p[0] = ((unsigned char)(l >> 8L)) & 0xFF;
-        p[1] = ((unsigned char)(l)) & 0xFF;
-    }
-    return (2);
-}
-
 int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len)
 {
     if ((c->id & 0xff000000) != 0x03000000) {
index 1eddf9d8859ec77a11d32f43d5efb4d4ec3e3403..7dbff76eab828a72378ff44f14aa3258aa85dd2d 100644 (file)
@@ -1863,7 +1863,6 @@ __owur int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey);
 __owur EVP_PKEY *ssl_dh_to_pkey(DH *dh);
 
 __owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p);
-__owur int ssl3_put_cipher_by_char_old(const SSL_CIPHER *c, unsigned char *p);
 __owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt,
                                    size_t *len);
 int ssl3_init_finished_mac(SSL *s);
@@ -2117,8 +2116,6 @@ __owur int custom_ext_parse(SSL *s, int server,
                             unsigned int ext_type,
                             const unsigned char *ext_data, size_t ext_size,
                             int *al);
-__owur int custom_ext_add_old(SSL *s, int server, unsigned char **pret,
-                              unsigned char *limit, int *al);
 __owur int custom_ext_add(SSL *s, int server, WPACKET *pkt, int *al);
 
 __owur int custom_exts_copy(custom_ext_methods *dst,
index 099a0ae086349c504579122f8e2c89361175fb76..30b304669f80ce71b3024384360fc15c273ef937 100644 (file)
@@ -70,71 +70,6 @@ int custom_ext_parse(SSL *s, int server,
     return meth->parse_cb(s, ext_type, ext_data, ext_size, al, meth->parse_arg);
 }
 
-/*
- * Request custom extension data from the application and add to the return
- * buffer. This is the old style function signature prior to WPACKET. This is
- * here temporarily until the conversion to WPACKET is completed, i.e. it is
- * used by code that hasn't been converted yet.
- * TODO - REMOVE THIS FUNCTION
- */
-int custom_ext_add_old(SSL *s, int server,
-                       unsigned char **pret, unsigned char *limit, int *al)
-{
-    custom_ext_methods *exts = server ? &s->cert->srv_ext : &s->cert->cli_ext;
-    custom_ext_method *meth;
-    unsigned char *ret = *pret;
-    size_t i;
-
-    for (i = 0; i < exts->meths_count; i++) {
-        const unsigned char *out = NULL;
-        size_t outlen = 0;
-        meth = exts->meths + i;
-
-        if (server) {
-            /*
-             * For ServerHello only send extensions present in ClientHello.
-             */
-            if (!(meth->ext_flags & SSL_EXT_FLAG_RECEIVED))
-                continue;
-            /* If callback absent for server skip it */
-            if (!meth->add_cb)
-                continue;
-        }
-        if (meth->add_cb) {
-            int cb_retval = 0;
-            cb_retval = meth->add_cb(s, meth->ext_type,
-                                     &out, &outlen, al, meth->add_arg);
-            if (cb_retval < 0)
-                return 0;       /* error */
-            if (cb_retval == 0)
-                continue;       /* skip this extension */
-        }
-        if (4 > limit - ret || outlen > (size_t)(limit - ret - 4))
-            return 0;
-        s2n(meth->ext_type, ret);
-        s2n(outlen, ret);
-        if (outlen) {
-            memcpy(ret, out, outlen);
-            ret += outlen;
-        }
-        /*
-         * We can't send duplicates: code logic should prevent this.
-         */
-        OPENSSL_assert(!(meth->ext_flags & SSL_EXT_FLAG_SENT));
-        /*
-         * Indicate extension has been sent: this is both a sanity check to
-         * ensure we don't send duplicate extensions and indicates that it is
-         * not an error if the extension is present in ServerHello.
-         */
-        meth->ext_flags |= SSL_EXT_FLAG_SENT;
-        if (meth->free_cb)
-            meth->free_cb(s, meth->ext_type, out, meth->add_arg);
-    }
-    *pret = ret;
-    return 1;
-}
-
-
 /*
  * Request custom extension data from the application and add to the return
  * buffer.