mbed client on ethernet with LWIP

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by sandbox

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_ticket.h
mbedAustin 11:cada08fc8a70 3 *
mbedAustin 11:cada08fc8a70 4 * \brief TLS server ticket 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_TICKET_H
mbedAustin 11:cada08fc8a70 24 #define MBEDTLS_SSL_TICKET_H
mbedAustin 11:cada08fc8a70 25
mbedAustin 11:cada08fc8a70 26 /*
mbedAustin 11:cada08fc8a70 27 * This implementation of the session ticket callbacks includes key
mbedAustin 11:cada08fc8a70 28 * management, rotating the keys periodically in order to preserve forward
mbedAustin 11:cada08fc8a70 29 * secrecy, when MBEDTLS_HAVE_TIME is defined.
mbedAustin 11:cada08fc8a70 30 */
mbedAustin 11:cada08fc8a70 31
mbedAustin 11:cada08fc8a70 32 #include "ssl.h"
mbedAustin 11:cada08fc8a70 33 #include "cipher.h"
mbedAustin 11:cada08fc8a70 34
mbedAustin 11:cada08fc8a70 35 #if defined(MBEDTLS_THREADING_C)
mbedAustin 11:cada08fc8a70 36 #include "threading.h"
mbedAustin 11:cada08fc8a70 37 #endif
mbedAustin 11:cada08fc8a70 38
mbedAustin 11:cada08fc8a70 39 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 40 extern "C" {
mbedAustin 11:cada08fc8a70 41 #endif
mbedAustin 11:cada08fc8a70 42
mbedAustin 11:cada08fc8a70 43 /**
mbedAustin 11:cada08fc8a70 44 * \brief Information for session ticket protection
mbedAustin 11:cada08fc8a70 45 */
mbedAustin 11:cada08fc8a70 46 typedef struct
mbedAustin 11:cada08fc8a70 47 {
mbedAustin 11:cada08fc8a70 48 unsigned char name[4]; /*!< random key identifier */
mbedAustin 11:cada08fc8a70 49 uint32_t generation_time; /*!< key generation timestamp (seconds) */
mbedAustin 11:cada08fc8a70 50 mbedtls_cipher_context_t ctx; /*!< context for auth enc/decryption */
mbedAustin 11:cada08fc8a70 51 }
mbedAustin 11:cada08fc8a70 52 mbedtls_ssl_ticket_key;
mbedAustin 11:cada08fc8a70 53
mbedAustin 11:cada08fc8a70 54 /**
mbedAustin 11:cada08fc8a70 55 * \brief Context for session ticket handling functions
mbedAustin 11:cada08fc8a70 56 */
mbedAustin 11:cada08fc8a70 57 typedef struct
mbedAustin 11:cada08fc8a70 58 {
mbedAustin 11:cada08fc8a70 59 mbedtls_ssl_ticket_key keys[2]; /*!< ticket protection keys */
mbedAustin 11:cada08fc8a70 60 unsigned char active; /*!< index of the currently active key */
mbedAustin 11:cada08fc8a70 61
mbedAustin 11:cada08fc8a70 62 uint32_t ticket_lifetime; /*!< lifetime of tickets in seconds */
mbedAustin 11:cada08fc8a70 63
mbedAustin 11:cada08fc8a70 64 /** Callback for getting (pseudo-)random numbers */
mbedAustin 11:cada08fc8a70 65 int (*f_rng)(void *, unsigned char *, size_t);
mbedAustin 11:cada08fc8a70 66 void *p_rng; /*!< context for the RNG function */
mbedAustin 11:cada08fc8a70 67
mbedAustin 11:cada08fc8a70 68 #if defined(MBEDTLS_THREADING_C)
mbedAustin 11:cada08fc8a70 69 mbedtls_threading_mutex_t mutex;
mbedAustin 11:cada08fc8a70 70 #endif
mbedAustin 11:cada08fc8a70 71 }
mbedAustin 11:cada08fc8a70 72 mbedtls_ssl_ticket_context;
mbedAustin 11:cada08fc8a70 73
mbedAustin 11:cada08fc8a70 74 /**
mbedAustin 11:cada08fc8a70 75 * \brief Initialize a ticket context.
mbedAustin 11:cada08fc8a70 76 * (Just make it ready for mbedtls_ssl_ticket_setup()
mbedAustin 11:cada08fc8a70 77 * or mbedtls_ssl_ticket_free().)
mbedAustin 11:cada08fc8a70 78 *
mbedAustin 11:cada08fc8a70 79 * \param ctx Context to be initialized
mbedAustin 11:cada08fc8a70 80 */
mbedAustin 11:cada08fc8a70 81 void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx );
mbedAustin 11:cada08fc8a70 82
mbedAustin 11:cada08fc8a70 83 /**
mbedAustin 11:cada08fc8a70 84 * \brief Prepare context to be actually used
mbedAustin 11:cada08fc8a70 85 *
mbedAustin 11:cada08fc8a70 86 * \param ctx Context to be set up
mbedAustin 11:cada08fc8a70 87 * \param f_rng RNG callback function
mbedAustin 11:cada08fc8a70 88 * \param p_rng RNG callback context
mbedAustin 11:cada08fc8a70 89 * \param cipher AEAD cipher to use for ticket protection.
mbedAustin 11:cada08fc8a70 90 * Recommended value: MBEDTLS_CIPHER_AES_256_GCM.
mbedAustin 11:cada08fc8a70 91 * \param lifetime Tickets lifetime in seconds
mbedAustin 11:cada08fc8a70 92 * Recommended value: 86400 (one day).
mbedAustin 11:cada08fc8a70 93 *
mbedAustin 11:cada08fc8a70 94 * \note It is highly recommended to select a cipher that is at
mbedAustin 11:cada08fc8a70 95 * least as strong as the the strongest ciphersuite
mbedAustin 11:cada08fc8a70 96 * supported. Usually that means a 256-bit key.
mbedAustin 11:cada08fc8a70 97 *
mbedAustin 11:cada08fc8a70 98 * \note The lifetime of the keys is twice the lifetime of tickets.
mbedAustin 11:cada08fc8a70 99 * It is recommended to pick a reasonnable lifetime so as not
mbedAustin 11:cada08fc8a70 100 * to negate the benefits of forward secrecy.
mbedAustin 11:cada08fc8a70 101 *
mbedAustin 11:cada08fc8a70 102 * \return 0 if successful,
mbedAustin 11:cada08fc8a70 103 * or a specific MBEDTLS_ERR_XXX error code
mbedAustin 11:cada08fc8a70 104 */
mbedAustin 11:cada08fc8a70 105 int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx,
mbedAustin 11:cada08fc8a70 106 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
mbedAustin 11:cada08fc8a70 107 mbedtls_cipher_type_t cipher,
mbedAustin 11:cada08fc8a70 108 uint32_t lifetime );
mbedAustin 11:cada08fc8a70 109
mbedAustin 11:cada08fc8a70 110 /**
mbedAustin 11:cada08fc8a70 111 * \brief Implementation of the ticket write callback
mbedAustin 11:cada08fc8a70 112 *
mbedAustin 11:cada08fc8a70 113 * \note See \c mbedlts_ssl_ticket_write_t for description
mbedAustin 11:cada08fc8a70 114 */
mbedAustin 11:cada08fc8a70 115 mbedtls_ssl_ticket_write_t mbedtls_ssl_ticket_write;
mbedAustin 11:cada08fc8a70 116
mbedAustin 11:cada08fc8a70 117 /**
mbedAustin 11:cada08fc8a70 118 * \brief Implementation of the ticket parse callback
mbedAustin 11:cada08fc8a70 119 *
mbedAustin 11:cada08fc8a70 120 * \note See \c mbedlts_ssl_ticket_parse_t for description
mbedAustin 11:cada08fc8a70 121 */
mbedAustin 11:cada08fc8a70 122 mbedtls_ssl_ticket_parse_t mbedtls_ssl_ticket_parse;
mbedAustin 11:cada08fc8a70 123
mbedAustin 11:cada08fc8a70 124 /**
mbedAustin 11:cada08fc8a70 125 * \brief Free a context's content and zeroize it.
mbedAustin 11:cada08fc8a70 126 *
mbedAustin 11:cada08fc8a70 127 * \param ctx Context to be cleaned up
mbedAustin 11:cada08fc8a70 128 */
mbedAustin 11:cada08fc8a70 129 void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx );
mbedAustin 11:cada08fc8a70 130
mbedAustin 11:cada08fc8a70 131 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 132 }
mbedAustin 11:cada08fc8a70 133 #endif
mbedAustin 11:cada08fc8a70 134
mbedAustin 11:cada08fc8a70 135 #endif /* ssl_ticket.h */