X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=ssl%2Ft1_ext.c;h=30b304669f80ce71b3024384360fc15c273ef937;hb=229185e668514e17bce9b22c38303e3cc3c9eb7a;hp=1ccd4c8b15595d5673e1fc3f97a5675cd55cf8cd;hpb=2c7b4dbc1af9cfae4e4afd7c4a07db95a1133a6a;p=openssl.git diff --git a/ssl/t1_ext.c b/ssl/t1_ext.c index 1ccd4c8b15..30b304669f 100644 --- a/ssl/t1_ext.c +++ b/ssl/t1_ext.c @@ -70,76 +70,11 @@ 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 PACKETW. This is - * here temporarily until the conversion to PACKETW 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. */ -int custom_ext_add(SSL *s, int server, PACKETW *pkt, int *al) +int custom_ext_add(SSL *s, int server, WPACKET *pkt, int *al) { custom_ext_methods *exts = server ? &s->cert->srv_ext : &s->cert->cli_ext; custom_ext_method *meth; @@ -148,7 +83,6 @@ int custom_ext_add(SSL *s, int server, PACKETW *pkt, int *al) for (i = 0; i < exts->meths_count; i++) { const unsigned char *out = NULL; size_t outlen = 0; - PACKETW spkt; meth = exts->meths + i; @@ -172,10 +106,10 @@ int custom_ext_add(SSL *s, int server, PACKETW *pkt, int *al) continue; /* skip this extension */ } - if (!PACKETW_put_bytes(pkt, meth->ext_type, 2) - || !PACKETW_get_sub_packet_len(pkt, &spkt, 2) - || (outlen > 0 && !PACKETW_memcpy(&spkt, out, outlen)) - || !PACKETW_close(&spkt)) { + if (!WPACKET_put_bytes_u16(pkt, meth->ext_type) + || !WPACKET_start_sub_packet_u16(pkt) + || (outlen > 0 && !WPACKET_memcpy(pkt, out, outlen)) + || !WPACKET_close(pkt)) { *al = SSL_AD_INTERNAL_ERROR; return 0; }