mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 /**
markrad 0:cdf462088d13 2 * \file ssl_cookie.h
markrad 0:cdf462088d13 3 *
markrad 0:cdf462088d13 4 * \brief DTLS cookie callbacks implementation
markrad 0:cdf462088d13 5 *
markrad 0:cdf462088d13 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 7 * SPDX-License-Identifier: Apache-2.0
markrad 0:cdf462088d13 8 *
markrad 0:cdf462088d13 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
markrad 0:cdf462088d13 10 * not use this file except in compliance with the License.
markrad 0:cdf462088d13 11 * You may obtain a copy of the License at
markrad 0:cdf462088d13 12 *
markrad 0:cdf462088d13 13 * http://www.apache.org/licenses/LICENSE-2.0
markrad 0:cdf462088d13 14 *
markrad 0:cdf462088d13 15 * Unless required by applicable law or agreed to in writing, software
markrad 0:cdf462088d13 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
markrad 0:cdf462088d13 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
markrad 0:cdf462088d13 18 * See the License for the specific language governing permissions and
markrad 0:cdf462088d13 19 * limitations under the License.
markrad 0:cdf462088d13 20 *
markrad 0:cdf462088d13 21 * This file is part of mbed TLS (https://tls.mbed.org)
markrad 0:cdf462088d13 22 */
markrad 0:cdf462088d13 23 #ifndef MBEDTLS_SSL_COOKIE_H
markrad 0:cdf462088d13 24 #define MBEDTLS_SSL_COOKIE_H
markrad 0:cdf462088d13 25
markrad 0:cdf462088d13 26 #include "ssl.h"
markrad 0:cdf462088d13 27
markrad 0:cdf462088d13 28 #if defined(MBEDTLS_THREADING_C)
markrad 0:cdf462088d13 29 #include "threading.h"
markrad 0:cdf462088d13 30 #endif
markrad 0:cdf462088d13 31
markrad 0:cdf462088d13 32 /**
markrad 0:cdf462088d13 33 * \name SECTION: Module settings
markrad 0:cdf462088d13 34 *
markrad 0:cdf462088d13 35 * The configuration options you can set for this module are in this section.
markrad 0:cdf462088d13 36 * Either change them in config.h or define them on the compiler command line.
markrad 0:cdf462088d13 37 * \{
markrad 0:cdf462088d13 38 */
markrad 0:cdf462088d13 39 #ifndef MBEDTLS_SSL_COOKIE_TIMEOUT
markrad 0:cdf462088d13 40 #define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */
markrad 0:cdf462088d13 41 #endif
markrad 0:cdf462088d13 42
markrad 0:cdf462088d13 43 /* \} name SECTION: Module settings */
markrad 0:cdf462088d13 44
markrad 0:cdf462088d13 45 #ifdef __cplusplus
markrad 0:cdf462088d13 46 extern "C" {
markrad 0:cdf462088d13 47 #endif
markrad 0:cdf462088d13 48
markrad 0:cdf462088d13 49 /**
markrad 0:cdf462088d13 50 * \brief Context for the default cookie functions.
markrad 0:cdf462088d13 51 */
markrad 0:cdf462088d13 52 typedef struct
markrad 0:cdf462088d13 53 {
markrad 0:cdf462088d13 54 mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */
markrad 0:cdf462088d13 55 #if !defined(MBEDTLS_HAVE_TIME)
markrad 0:cdf462088d13 56 unsigned long serial; /*!< serial number for expiration */
markrad 0:cdf462088d13 57 #endif
markrad 0:cdf462088d13 58 unsigned long timeout; /*!< timeout delay, in seconds if HAVE_TIME,
markrad 0:cdf462088d13 59 or in number of tickets issued */
markrad 0:cdf462088d13 60
markrad 0:cdf462088d13 61 #if defined(MBEDTLS_THREADING_C)
markrad 0:cdf462088d13 62 mbedtls_threading_mutex_t mutex;
markrad 0:cdf462088d13 63 #endif
markrad 0:cdf462088d13 64 } mbedtls_ssl_cookie_ctx;
markrad 0:cdf462088d13 65
markrad 0:cdf462088d13 66 /**
markrad 0:cdf462088d13 67 * \brief Initialize cookie context
markrad 0:cdf462088d13 68 */
markrad 0:cdf462088d13 69 void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx );
markrad 0:cdf462088d13 70
markrad 0:cdf462088d13 71 /**
markrad 0:cdf462088d13 72 * \brief Setup cookie context (generate keys)
markrad 0:cdf462088d13 73 */
markrad 0:cdf462088d13 74 int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx,
markrad 0:cdf462088d13 75 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 76 void *p_rng );
markrad 0:cdf462088d13 77
markrad 0:cdf462088d13 78 /**
markrad 0:cdf462088d13 79 * \brief Set expiration delay for cookies
markrad 0:cdf462088d13 80 * (Default MBEDTLS_SSL_COOKIE_TIMEOUT)
markrad 0:cdf462088d13 81 *
markrad 0:cdf462088d13 82 * \param ctx Cookie contex
markrad 0:cdf462088d13 83 * \param delay Delay, in seconds if HAVE_TIME, or in number of cookies
markrad 0:cdf462088d13 84 * issued in the meantime.
markrad 0:cdf462088d13 85 * 0 to disable expiration (NOT recommended)
markrad 0:cdf462088d13 86 */
markrad 0:cdf462088d13 87 void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay );
markrad 0:cdf462088d13 88
markrad 0:cdf462088d13 89 /**
markrad 0:cdf462088d13 90 * \brief Free cookie context
markrad 0:cdf462088d13 91 */
markrad 0:cdf462088d13 92 void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx );
markrad 0:cdf462088d13 93
markrad 0:cdf462088d13 94 /**
markrad 0:cdf462088d13 95 * \brief Generate cookie, see \c mbedtls_ssl_cookie_write_t
markrad 0:cdf462088d13 96 */
markrad 0:cdf462088d13 97 mbedtls_ssl_cookie_write_t mbedtls_ssl_cookie_write;
markrad 0:cdf462088d13 98
markrad 0:cdf462088d13 99 /**
markrad 0:cdf462088d13 100 * \brief Verify cookie, see \c mbedtls_ssl_cookie_write_t
markrad 0:cdf462088d13 101 */
markrad 0:cdf462088d13 102 mbedtls_ssl_cookie_check_t mbedtls_ssl_cookie_check;
markrad 0:cdf462088d13 103
markrad 0:cdf462088d13 104 #ifdef __cplusplus
markrad 0:cdf462088d13 105 }
markrad 0:cdf462088d13 106 #endif
markrad 0:cdf462088d13 107
markrad 0:cdf462088d13 108 #endif /* ssl_cookie.h */