blob: 7db00c2f897073806b0efc5a56cc6b6e9d3d6070 [file] [log] [blame]
Manuel Pégourié-Gonnard232edd42014-07-23 16:56:27 +02001/**
2 * \file ssl_cookie.h
3 *
4 * \brief DTLS cookie callbacks implementation
5 *
6 * Copyright (C) 2014, Brainspark B.V.
7 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27#ifndef POLARSSL_SSL_COOKIE_H
28#define POLARSSL_SSL_COOKIE_H
29
30#include "ssl.h"
31
32/**
33 * \name SECTION: Module settings
34 *
35 * The configuration options you can set for this module are in this section.
36 * Either change them in config.h or define them on the compiler command line.
37 * \{
38 */
39
40/* \} name SECTION: Module settings */
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/**
47 * \brief Context for the default cookie functions.
48 */
49typedef struct
50{
Manuel Pégourié-Gonnarde9030812014-07-23 21:29:11 +020051 md_context_t hmac_ctx; /*!< context for the HMAC portion */
52#if !defined(POLARSSL_HAVE_TIME)
53 unsigned long serial; /*!< serial number for expiration */
54#endif
Manuel Pégourié-Gonnard232edd42014-07-23 16:56:27 +020055} ssl_cookie_ctx;
56
57/**
58 * \brief Initialize cookie context
59 */
60void ssl_cookie_init( ssl_cookie_ctx *ctx );
61
62/**
63 * \brief Setup cookie context (generate keys)
64 */
65int ssl_cookie_setup( ssl_cookie_ctx *ctx,
66 int (*f_rng)(void *, unsigned char *, size_t),
67 void *p_rng );
68
69/**
70 * \brief Free cookie context
71 */
72void ssl_cookie_free( ssl_cookie_ctx *ctx );
73
74/**
75 * \brief Generate cookie, see \c ssl_cookie_write_t
76 */
77ssl_cookie_write_t ssl_cookie_write;
78
79/**
80 * \brief Verify cookie, see \c ssl_cookie_write_t
81 */
82ssl_cookie_check_t ssl_cookie_check;
83
84#ifdef __cplusplus
85}
86#endif
87
88#endif /* ssl_cookie.h */