mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

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