Lines Matching +full:data +full:- +full:role

2  * Copyright 2014-2021 The OpenSSL Project Authors. All Rights Reserved.
39 if (add_cb_wrap->add_cb == NULL) in custom_ext_add_old_cb_wrap()
42 return add_cb_wrap->add_cb(s, ext_type, out, outlen, al, in custom_ext_add_old_cb_wrap()
43 add_cb_wrap->add_arg); in custom_ext_add_old_cb_wrap()
52 if (add_cb_wrap->free_cb == NULL) in custom_ext_free_old_cb_wrap()
55 add_cb_wrap->free_cb(s, ext_type, out, add_cb_wrap->add_arg); in custom_ext_free_old_cb_wrap()
67 if (parse_cb_wrap->parse_cb == NULL) in custom_ext_parse_old_cb_wrap()
70 return parse_cb_wrap->parse_cb(s, ext_type, in, inlen, al, in custom_ext_parse_old_cb_wrap()
71 parse_cb_wrap->parse_arg); in custom_ext_parse_old_cb_wrap()
75 * Find a custom extension from the list. The |role| param is there to
82 ENDPOINT role, unsigned int ext_type, in custom_ext_find() argument
86 custom_ext_method *meth = exts->meths; in custom_ext_find()
88 for (i = 0; i < exts->meths_count; i++, meth++) { in custom_ext_find()
89 if (ext_type == meth->ext_type in custom_ext_find()
90 && (role == ENDPOINT_BOTH || role == meth->role in custom_ext_find()
91 || meth->role == ENDPOINT_BOTH)) { in custom_ext_find()
106 custom_ext_method *meth = exts->meths; in custom_ext_init()
108 for (i = 0; i < exts->meths_count; i++, meth++) in custom_ext_init()
109 meth->ext_flags = 0; in custom_ext_init()
112 /* Pass received custom extension data to the application for parsing. */
118 custom_ext_methods *exts = &s->cert->custext; in custom_ext_parse()
120 ENDPOINT role = ENDPOINT_BOTH; in custom_ext_parse() local
123 role = s->server ? ENDPOINT_SERVER : ENDPOINT_CLIENT; in custom_ext_parse()
125 meth = custom_ext_find(exts, role, ext_type, NULL); in custom_ext_parse()
131 if (!extension_is_relevant(s, meth->context, context)) in custom_ext_parse()
141 if ((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0) { in custom_ext_parse()
154 meth->ext_flags |= SSL_EXT_FLAG_RECEIVED; in custom_ext_parse()
157 if (!meth->parse_cb) in custom_ext_parse()
160 if (meth->parse_cb(s, ext_type, context, ext_data, ext_size, x, chainidx, in custom_ext_parse()
161 &al, meth->parse_arg) <= 0) { in custom_ext_parse()
170 * Request custom extension data from the application and add to the return
176 custom_ext_methods *exts = &s->cert->custext; in custom_ext_add()
181 for (i = 0; i < exts->meths_count; i++) { in custom_ext_add()
185 meth = exts->meths + i; in custom_ext_add()
187 if (!should_add_extension(s, meth->context, context, maxversion)) in custom_ext_add()
196 if (!(meth->ext_flags & SSL_EXT_FLAG_RECEIVED)) in custom_ext_add()
200 * We skip it if the callback is absent - except for a ClientHello where in custom_ext_add()
203 if ((context & SSL_EXT_CLIENT_HELLO) == 0 && meth->add_cb == NULL) in custom_ext_add()
206 if (meth->add_cb != NULL) { in custom_ext_add()
207 int cb_retval = meth->add_cb(s, meth->ext_type, context, &out, in custom_ext_add()
209 meth->add_arg); in custom_ext_add()
219 if (!WPACKET_put_bytes_u16(pkt, meth->ext_type) in custom_ext_add()
223 if (meth->free_cb != NULL) in custom_ext_add()
224 meth->free_cb(s, meth->ext_type, context, out, meth->add_arg); in custom_ext_add()
232 if (!ossl_assert((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0)) { in custom_ext_add()
233 if (meth->free_cb != NULL) in custom_ext_add()
234 meth->free_cb(s, meth->ext_type, context, out, in custom_ext_add()
235 meth->add_arg); in custom_ext_add()
244 meth->ext_flags |= SSL_EXT_FLAG_SENT; in custom_ext_add()
246 if (meth->free_cb != NULL) in custom_ext_add()
247 meth->free_cb(s, meth->ext_type, context, out, meth->add_arg); in custom_ext_add()
257 custom_ext_method *methsrc = src->meths; in custom_exts_copy_flags()
259 for (i = 0; i < src->meths_count; i++, methsrc++) { in custom_exts_copy_flags()
260 custom_ext_method *methdst = custom_ext_find(dst, methsrc->role, in custom_exts_copy_flags()
261 methsrc->ext_type, NULL); in custom_exts_copy_flags()
266 methdst->ext_flags = methsrc->ext_flags; in custom_exts_copy_flags()
278 if (src->meths_count > 0) { in custom_exts_copy()
279 dst->meths = in custom_exts_copy()
280 OPENSSL_memdup(src->meths, in custom_exts_copy()
281 sizeof(*src->meths) * src->meths_count); in custom_exts_copy()
282 if (dst->meths == NULL) in custom_exts_copy()
284 dst->meths_count = src->meths_count; in custom_exts_copy()
286 for (i = 0; i < src->meths_count; i++) { in custom_exts_copy()
287 custom_ext_method *methsrc = src->meths + i; in custom_exts_copy()
288 custom_ext_method *methdst = dst->meths + i; in custom_exts_copy()
290 if (methsrc->add_cb != custom_ext_add_old_cb_wrap) in custom_exts_copy()
299 methdst->add_arg = NULL; in custom_exts_copy()
300 methdst->parse_arg = NULL; in custom_exts_copy()
304 methdst->add_arg = OPENSSL_memdup(methsrc->add_arg, in custom_exts_copy()
306 methdst->parse_arg = OPENSSL_memdup(methsrc->parse_arg, in custom_exts_copy()
309 if (methdst->add_arg == NULL || methdst->parse_arg == NULL) in custom_exts_copy()
327 for (i = 0, meth = exts->meths; i < exts->meths_count; i++, meth++) { in custom_exts_free()
328 if (meth->add_cb != custom_ext_add_old_cb_wrap) in custom_exts_free()
332 OPENSSL_free(meth->add_arg); in custom_exts_free()
333 OPENSSL_free(meth->parse_arg); in custom_exts_free()
335 OPENSSL_free(exts->meths); in custom_exts_free()
336 exts->meths = NULL; in custom_exts_free()
337 exts->meths_count = 0; in custom_exts_free()
343 return custom_ext_find(&ctx->cert->custext, ENDPOINT_CLIENT, ext_type, in SSL_CTX_has_client_custom_ext()
347 static int add_custom_ext_intern(SSL_CTX *ctx, ENDPOINT role, in add_custom_ext_intern() argument
356 custom_ext_methods *exts = &ctx->cert->custext; in add_custom_ext_intern()
369 * whilst simultaneously using the built-in SCT validation features, as in add_custom_ext_intern()
390 if (custom_ext_find(exts, role, ext_type, NULL)) in add_custom_ext_intern()
392 tmp = OPENSSL_realloc(exts->meths, in add_custom_ext_intern()
393 (exts->meths_count + 1) * sizeof(custom_ext_method)); in add_custom_ext_intern()
397 exts->meths = tmp; in add_custom_ext_intern()
398 meth = exts->meths + exts->meths_count; in add_custom_ext_intern()
400 meth->role = role; in add_custom_ext_intern()
401 meth->context = context; in add_custom_ext_intern()
402 meth->parse_cb = parse_cb; in add_custom_ext_intern()
403 meth->add_cb = add_cb; in add_custom_ext_intern()
404 meth->free_cb = free_cb; in add_custom_ext_intern()
405 meth->ext_type = ext_type; in add_custom_ext_intern()
406 meth->add_arg = add_arg; in add_custom_ext_intern()
407 meth->parse_arg = parse_arg; in add_custom_ext_intern()
408 exts->meths_count++; in add_custom_ext_intern()
412 static int add_old_custom_ext(SSL_CTX *ctx, ENDPOINT role, in add_old_custom_ext() argument
432 add_cb_wrap->add_arg = add_arg; in add_old_custom_ext()
433 add_cb_wrap->add_cb = add_cb; in add_old_custom_ext()
434 add_cb_wrap->free_cb = free_cb; in add_old_custom_ext()
435 parse_cb_wrap->parse_arg = parse_arg; in add_old_custom_ext()
436 parse_cb_wrap->parse_cb = parse_cb; in add_old_custom_ext()
438 ret = add_custom_ext_intern(ctx, role, ext_type, in add_old_custom_ext()