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 /* 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 00047 typedef struct 00048 { 00049 unsigned char name[4]; 00050 uint32_t generation_time; 00051 mbedtls_cipher_context_t ctx; 00052 } 00053 mbedtls_ssl_ticket_key; 00054 00058 typedef struct 00059 { 00060 mbedtls_ssl_ticket_key keys[2]; 00061 unsigned char active; 00063 uint32_t ticket_lifetime; 00066 int (*f_rng)(void *, unsigned char *, size_t); 00067 void *p_rng; 00069 #if defined(MBEDTLS_THREADING_C) 00070 mbedtls_threading_mutex_t mutex; 00071 #endif 00072 } 00073 mbedtls_ssl_ticket_context; 00074 00082 void mbedtls_ssl_ticket_init( mbedtls_ssl_ticket_context *ctx ); 00083 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 00116 mbedtls_ssl_ticket_write_t mbedtls_ssl_ticket_write; 00117 00123 mbedtls_ssl_ticket_parse_t mbedtls_ssl_ticket_parse; 00124 00130 void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx ); 00131 00132 #ifdef __cplusplus 00133 } 00134 #endif 00135 00136 #endif /* ssl_ticket.h */