Mbed OS Reference
Loading...
Searching...
No Matches
ssl_cookie.h
Go to the documentation of this file.
1/**
2 * \file ssl_cookie.h
3 *
4 * \brief DTLS cookie callbacks implementation
5 */
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22#ifndef MBEDTLS_SSL_COOKIE_H
23#define MBEDTLS_SSL_COOKIE_H
24
25#if !defined(MBEDTLS_CONFIG_FILE)
26#include "mbedtls/config.h"
27#else
28#include MBEDTLS_CONFIG_FILE
29#endif
30
31#include "mbedtls/ssl.h"
32
33#if defined(MBEDTLS_THREADING_C)
34#include "mbedtls/threading.h"
35#endif
36
37/**
38 * \ingroup mbedtls_ssl_module
39 * \{
40 */
41
42/**
43 * \name SECTION: Module settings
44 *
45 * The configuration options you can set for this module are in this section.
46 * Either change them in config.h or define them on the compiler command line.
47 * \{
48 */
49#ifndef MBEDTLS_SSL_COOKIE_TIMEOUT
50#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */
51#endif
52
53/** \} name SECTION: Module settings */
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59/**
60 * \brief Context for the default cookie functions.
61 */
63{
64 mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */
65#if !defined(MBEDTLS_HAVE_TIME)
66 unsigned long serial; /*!< serial number for expiration */
67#endif
68 unsigned long timeout; /*!< timeout delay, in seconds if HAVE_TIME,
69 or in number of tickets issued */
70
71#if defined(MBEDTLS_THREADING_C)
72 mbedtls_threading_mutex_t mutex;
73#endif
75
76/**
77 * \brief Initialize cookie context
78 */
80
81/**
82 * \brief Setup cookie context (generate keys)
83 */
85 int (*f_rng)(void *, unsigned char *, size_t),
86 void *p_rng );
87
88/**
89 * \brief Set expiration delay for cookies
90 * (Default MBEDTLS_SSL_COOKIE_TIMEOUT)
91 *
92 * \param ctx Cookie contex
93 * \param delay Delay, in seconds if HAVE_TIME, or in number of cookies
94 * issued in the meantime.
95 * 0 to disable expiration (NOT recommended)
96 */
98
99/**
100 * \brief Free cookie context
101 */
103
104/**
105 * \brief Generate cookie, see \c mbedtls_ssl_cookie_write_t
106 */
108
109/**
110 * \brief Verify cookie, see \c mbedtls_ssl_cookie_write_t
111 */
113
114#ifdef __cplusplus
115}
116#endif
117
118/// \}
119
120#endif /* ssl_cookie.h */
Configuration options (set of defines)
int mbedtls_ssl_cookie_write_t(void *ctx, unsigned char **p, unsigned char *end, const unsigned char *info, size_t ilen)
Callback type: generate a cookie.
Definition: ssl.h:2210
int mbedtls_ssl_cookie_check_t(void *ctx, const unsigned char *cookie, size_t clen, const unsigned char *info, size_t ilen)
Callback type: verify a cookie.
Definition: ssl.h:2227
SSL/TLS functions.
The generic message-digest context.
Definition: md.h:98
Threading abstraction layer.