00001 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 #if !defined(MBEDTLS_CONFIG_FILE) 00028 #include "config.h" 00029 #else 00030 #include MBEDTLS_CONFIG_FILE 00031 #endif 00032 00033 /* 00034 * This implementation of the session ticket callbacks includes key 00035 * management, rotating the keys periodically in order to preserve forward 00036 * secrecy, when MBEDTLS_HAVE_TIME is defined. 00037 */ 00038 00039 #include "ssl.h" 00040 #include "cipher.h" 00041 00042 #if defined(MBEDTLS_THREADING_C) 00043 #include "threading.h" 00044 #endif 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif 00049 00053 typedef struct 00054 { 00055 unsigned char name[4]; 00056 uint32_t generation_time; 00057 mbedtls_cipher_context_t ctx; 00058 } 00059 mbedtls_ssl_ticket_key; 00060 00064 typedef struct 00065 { 00066 mbedtls_ssl_ticket_key keys[2]; 00067 unsigned char active; 00069 uint32_t ticket_lifetime; 00072 int (*f_rng)(void *, unsigned char *, size_t); 00073 void *p_rng; 00075 #if defined(MBEDTLS_THREADING_C) 00076 mbedtls_threading_mutex_t mutex; 00077 #endif 00078 } 00079 mbedtls_ssl_ticket_context; 00080 00088 void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx ); 00089 00112 int mbedtls_ssl_ticket_setup( mbedtls_ssl_ticket_context *ctx, 00113 int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, 00114 mbedtls_cipher_type_t cipher, 00115 uint32_t lifetime ); 00116 00122 mbedtls_ssl_ticket_write_t mbedtls_ssl_ticket_write; 00123 00129 mbedtls_ssl_ticket_parse_t mbedtls_ssl_ticket_parse; 00130 00136 void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx ); 00137 00138 #ifdef __cplusplus 00139 } 00140 #endif 00141 00142 #endif /* ssl_ticket.h */