/* Custom extension utility functions */
-#include <assert.h>
#include <openssl/ct.h>
#include "../ssl_locl.h"
+#include "internal/cryptlib.h"
#include "statem_locl.h"
typedef struct {
custom_ext_parse_cb_wrap *parse_cb_wrap =
(custom_ext_parse_cb_wrap *)parse_arg;
+ if (parse_cb_wrap->parse_cb == NULL)
+ return 1;
+
return parse_cb_wrap->parse_cb(s, ext_type, in, inlen, al,
parse_cb_wrap->parse_arg);
}
if ((context & (SSL_EXT_TLS1_2_SERVER_HELLO
| SSL_EXT_TLS1_3_SERVER_HELLO
- | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS)) != 0) {
- /*
- * For ServerHello/EncryptedExtensions only send extensions present
- * in ClientHello.
- */
+ | SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS
+ | SSL_EXT_TLS1_3_CERTIFICATE
+ | SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST)) != 0) {
+ /* Only send extensions present in ClientHello. */
if (!(meth->ext_flags & SSL_EXT_FLAG_RECEIVED))
continue;
}
/*
* We can't send duplicates: code logic should prevent this.
*/
- assert((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0);
+ if (!ossl_assert((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0)) {
+ *al = SSL_AD_INTERNAL_ERROR;
+ return 0;
+ }
/*
* Indicate extension has been sent: this is both a sanity check to
* ensure we don't send duplicate extensions and indicates that it
return 1;
}
+/* Copy the flags from src to dst for any extensions that exist in both */
+int custom_exts_copy_flags(custom_ext_methods *dst,
+ const custom_ext_methods *src)
+{
+ size_t i;
+ custom_ext_method *methsrc = src->meths;
+
+ for (i = 0; i < src->meths_count; i++, methsrc++) {
+ custom_ext_method *methdst = custom_ext_find(dst, methsrc->role,
+ methsrc->ext_type, NULL);
+
+ if (methdst == NULL)
+ continue;
+
+ methdst->ext_flags = methsrc->ext_flags;
+ }
+
+ return 1;
+}
+
/* Copy table of custom extensions */
int custom_exts_copy(custom_ext_methods *dst, const custom_ext_methods *src)
{
parse_cb_wrap->parse_arg = parse_arg;
parse_cb_wrap->parse_cb = parse_cb;
- /*
- * TODO(TLS1.3): Is it possible with the old API to add custom exts for both
- * client and server for the same type in the same SSL_CTX? We don't handle
- * that yet.
- */
ret = add_custom_ext_intern(ctx, role, ext_type,
context,
custom_ext_add_old_cb_wrap,