Mbed TLS v4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ssl_ticket.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  */
10 #ifndef MBEDTLS_SSL_TICKET_H
11 #define MBEDTLS_SSL_TICKET_H
12 #include "mbedtls/private_access.h"
13 
14 #include "mbedtls/build_info.h"
15 
16 /*
17  * This implementation of the session ticket callbacks includes key
18  * management, rotating the keys periodically in order to preserve forward
19  * secrecy, when MBEDTLS_HAVE_TIME is defined.
20  */
21 
22 #include "mbedtls/ssl.h"
23 
24 #if defined(MBEDTLS_HAVE_TIME)
25 #include "mbedtls/platform_time.h"
26 #endif
27 
28 #include "psa/crypto.h"
29 
30 #if defined(MBEDTLS_THREADING_C)
31 #include "mbedtls/threading.h"
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define MBEDTLS_SSL_TICKET_MAX_KEY_BYTES 32
39 #define MBEDTLS_SSL_TICKET_KEY_NAME_BYTES 4
44 typedef struct mbedtls_ssl_ticket_key {
45  unsigned char MBEDTLS_PRIVATE(name)[MBEDTLS_SSL_TICKET_KEY_NAME_BYTES];
47 #if defined(MBEDTLS_HAVE_TIME)
48  mbedtls_time_t MBEDTLS_PRIVATE(generation_time);
49 #endif
50 
53  uint32_t MBEDTLS_PRIVATE(lifetime);
54  mbedtls_svc_key_id_t MBEDTLS_PRIVATE(key);
55  psa_algorithm_t MBEDTLS_PRIVATE(alg);
56  psa_key_type_t MBEDTLS_PRIVATE(key_type);
57  size_t MBEDTLS_PRIVATE(key_bits);
58 }
60 
65  mbedtls_ssl_ticket_key MBEDTLS_PRIVATE(keys)[2];
66  unsigned char MBEDTLS_PRIVATE(active);
68  uint32_t MBEDTLS_PRIVATE(ticket_lifetime);
72 #if defined(MBEDTLS_THREADING_C)
73  mbedtls_threading_mutex_t MBEDTLS_PRIVATE(mutex);
74 #endif
75 }
77 
86 
115  psa_algorithm_t alg, psa_key_type_t key_type, psa_key_bits_t key_bits,
116  uint32_t lifetime);
117 
157  const unsigned char *name, size_t nlength,
158  const unsigned char *k, size_t klength,
159  uint32_t lifetime);
160 
167 
174 
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* ssl_ticket.h */
int mbedtls_ssl_ticket_parse_t(void *p_ticket, mbedtls_ssl_session *session, unsigned char *buf, size_t len)
Callback type: parse and load session ticket.
Definition: ssl.h:2549
struct mbedtls_ssl_ticket_key mbedtls_ssl_ticket_key
Information for session ticket protection.
#define MBEDTLS_SSL_TICKET_KEY_NAME_BYTES
Definition: ssl_ticket.h:39
uint16_t psa_key_bits_t
Platform Security Architecture cryptography module.
void mbedtls_ssl_ticket_init(mbedtls_ssl_ticket_context *ctx)
Initialize a ticket context. (Just make it ready for mbedtls_ssl_ticket_setup() or mbedtls_ssl_ticket...
int mbedtls_ssl_ticket_rotate(mbedtls_ssl_ticket_context *ctx, const unsigned char *name, size_t nlength, const unsigned char *k, size_t klength, uint32_t lifetime)
Rotate session ticket encryption key to new specified key. Provides for external control of session t...
int mbedtls_ssl_ticket_setup(mbedtls_ssl_ticket_context *ctx, psa_algorithm_t alg, psa_key_type_t key_type, psa_key_bits_t key_bits, uint32_t lifetime)
Prepare context to be actually used.
Threading abstraction layer.
mbedtls_ssl_ticket_parse_t mbedtls_ssl_ticket_parse
Implementation of the ticket parse callback.
Definition: ssl_ticket.h:173
MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t
Definition: platform_time.h:23
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:127
Build-time configuration info.
mbedtls_ssl_ticket_write_t mbedtls_ssl_ticket_write
Implementation of the ticket write callback.
Definition: ssl_ticket.h:166
struct mbedtls_ssl_ticket_context mbedtls_ssl_ticket_context
Context for session ticket handling functions.
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:71
Information for session ticket protection.
Definition: ssl_ticket.h:44
SSL/TLS functions.
int mbedtls_ssl_ticket_write_t(void *p_ticket, const mbedtls_ssl_session *session, unsigned char *start, const unsigned char *end, size_t *tlen, uint32_t *lifetime)
Callback type: generate and write session ticket.
Definition: ssl.h:2519
Mbed TLS Platform time abstraction.
void mbedtls_ssl_ticket_free(mbedtls_ssl_ticket_context *ctx)
Free a context's content and zeroize it.
Context for session ticket handling functions.
Definition: ssl_ticket.h:64