BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
ssl_ticket.h
Go to the documentation of this file.
00001 /** 00002 * \file ssl_ticket.h 00003 * 00004 * \brief TLS server ticket callbacks implementation 00005 */ 00006 /* 00007 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00008 * SPDX-License-Identifier: Apache-2.0 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00011 * not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00018 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 * 00022 * This file is part of mbed TLS (https://tls.mbed.org) 00023 */ 00024 #ifndef MBEDTLS_SSL_TICKET_H 00025 #define MBEDTLS_SSL_TICKET_H 00026 00027 /* 00028 * This implementation of the session ticket callbacks includes key 00029 * management, rotating the keys periodically in order to preserve forward 00030 * secrecy, when MBEDTLS_HAVE_TIME is defined. 00031 */ 00032 00033 #include "ssl.h" 00034 #include "cipher.h" 00035 00036 #if defined(MBEDTLS_THREADING_C) 00037 #include "threading.h" 00038 #endif 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /** 00045 * \brief Information for session ticket protection 00046 */ 00047 typedef struct 00048 { 00049 unsigned char name[4]; /*!< random key identifier */ 00050 uint32_t generation_time ; /*!< key generation timestamp (seconds) */ 00051 mbedtls_cipher_context_t ctx ; /*!< context for auth enc/decryption */ 00052 } 00053 mbedtls_ssl_ticket_key; 00054 00055 /** 00056 * \brief Context for session ticket handling functions 00057 */ 00058 typedef struct 00059 { 00060 mbedtls_ssl_ticket_key keys[2]; /*!< ticket protection keys */ 00061 unsigned char active ; /*!< index of the currently active key */ 00062 00063 uint32_t ticket_lifetime ; /*!< lifetime of tickets in seconds */ 00064 00065 /** Callback for getting (pseudo-)random numbers */ 00066 int (*f_rng)(void *, unsigned char *, size_t); 00067 void *p_rng ; /*!< context for the RNG function */ 00068 00069 #if defined(MBEDTLS_THREADING_C) 00070 mbedtls_threading_mutex_t mutex; 00071 #endif 00072 } 00073 mbedtls_ssl_ticket_context; 00074 00075 /** 00076 * \brief Initialize a ticket context. 00077 * (Just make it ready for mbedtls_ssl_ticket_setup() 00078 * or mbedtls_ssl_ticket_free().) 00079 * 00080 * \param ctx Context to be initialized 00081 */ 00082 void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx ); 00083 00084 /** 00085 * \brief Prepare context to be actually used 00086 * 00087 * \param ctx Context to be set up 00088 * \param f_rng RNG callback function 00089 * \param p_rng RNG callback context 00090 * \param cipher AEAD cipher to use for ticket protection. 00091 * Recommended value: MBEDTLS_CIPHER_AES_256_GCM. 00092 * \param lifetime Tickets lifetime in seconds 00093 * Recommended value: 86400 (one day). 00094 * 00095 * \note It is highly recommended to select a cipher that is at 00096 * least as strong as the the strongest ciphersuite 00097 * supported. Usually that means a 256-bit key. 00098 * 00099 * \note The lifetime of the keys is twice the lifetime of tickets. 00100 * It is recommended to pick a reasonnable lifetime so as not 00101 * to negate the benefits of forward secrecy. 00102 * 00103 * \return 0 if successful, 00104 * or a specific MBEDTLS_ERR_XXX error code 00105 */ 00106 int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx, 00107 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, 00108 mbedtls_cipher_type_t cipher, 00109 uint32_t lifetime ); 00110 00111 /** 00112 * \brief Implementation of the ticket write callback 00113 * 00114 * \note See \c mbedlts_ssl_ticket_write_t for description 00115 */ 00116 mbedtls_ssl_ticket_write_t mbedtls_ssl_ticket_write; 00117 00118 /** 00119 * \brief Implementation of the ticket parse callback 00120 * 00121 * \note See \c mbedlts_ssl_ticket_parse_t for description 00122 */ 00123 mbedtls_ssl_ticket_parse_t mbedtls_ssl_ticket_parse; 00124 00125 /** 00126 * \brief Free a context's content and zeroize it. 00127 * 00128 * \param ctx Context to be cleaned up 00129 */ 00130 void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx ); 00131 00132 #ifdef __cplusplus 00133 } 00134 #endif 00135 00136 #endif /* ssl_ticket.h */
Generated on Tue Jul 12 2022 12:22:22 by
