-/* Set callbacks for a custom extension */
-static int custom_ext_set(custom_ext_methods *exts,
- unsigned int ext_type,
- custom_ext_parse_cb parse_cb,
- custom_ext_add_cb add_cb,
- void *arg)
- {
- custom_ext_method *meth;
- /* See if it is a supported internally */
- switch(ext_type)
- {
- case TLSEXT_TYPE_application_layer_protocol_negotiation:
- case TLSEXT_TYPE_ec_point_formats:
- case TLSEXT_TYPE_elliptic_curves:
- case TLSEXT_TYPE_heartbeat:
- case TLSEXT_TYPE_next_proto_neg:
- case TLSEXT_TYPE_padding:
- case TLSEXT_TYPE_renegotiate:
- case TLSEXT_TYPE_server_name:
- case TLSEXT_TYPE_session_ticket:
- case TLSEXT_TYPE_signature_algorithms:
- case TLSEXT_TYPE_srp:
- case TLSEXT_TYPE_status_request:
- case TLSEXT_TYPE_use_srtp:
-#ifdef TLSEXT_TYPE_opaque_prf_input
- case TLSEXT_TYPE_opaque_prf_input:
-#endif
-#ifdef TLSEXT_TYPE_encrypt_then_mac
- case TLSEXT_TYPE_encrypt_then_mac:
-#endif
- return 0;
- }
- /* Extension type must fit in 16 bits */
- if (ext_type > 0xffff)
- return 0;
- /* Search for duplicate */
- if (custom_ext_find(exts, ext_type))
- return 0;
- exts->meths = OPENSSL_realloc(exts->meths,
- (exts->meths_count + 1) * sizeof(custom_ext_method));
+/* Set callbacks for a custom extension. */
+static int custom_ext_meth_add(custom_ext_methods *exts,
+ unsigned int ext_type,
+ custom_ext_add_cb add_cb,
+ custom_ext_free_cb free_cb,
+ void *add_arg,
+ custom_ext_parse_cb parse_cb, void *parse_arg)
+{
+ custom_ext_method *meth;
+ /*
+ * Check application error: if add_cb is not set free_cb will never be
+ * called.
+ */
+ if (!add_cb && free_cb)
+ return 0;
+ /* Don't add if extension supported internally. */
+ if (SSL_extension_supported(ext_type))
+ return 0;
+ /* Extension type must fit in 16 bits */
+ if (ext_type > 0xffff)
+ return 0;
+ /* Search for duplicate */
+ if (custom_ext_find(exts, ext_type))
+ return 0;
+ exts->meths = OPENSSL_realloc(exts->meths,
+ (exts->meths_count +
+ 1) * sizeof(custom_ext_method));