charon-nm: Set local address to %any so IPv6 may be used as outer address
[strongswan.git] / src / libtls / tls_cache.h
1 /*
2 * Copyright (C) 2011 Martin Willi
3 * Copyright (C) 2011 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup tls_cache tls_cache
18 * @{ @ingroup libtls
19 */
20
21 #ifndef TLS_CACHE_H_
22 #define TLS_CACHE_H_
23
24 typedef struct tls_cache_t tls_cache_t;
25
26 #include "tls_crypto.h"
27
28 /**
29 * TLS session cache facility.
30 */
31 struct tls_cache_t {
32
33 /**
34 * Create a new TLS session entry.
35 *
36 * @param session session identifier
37 * @param id identity the session is bound to
38 * @param master TLS master secret
39 * @param suite TLS cipher suite of the session
40 */
41 void (*create)(tls_cache_t *this, chunk_t session, identification_t *id,
42 chunk_t master, tls_cipher_suite_t suite);
43
44 /**
45 * Look up a TLS session entry.
46 *
47 * @param session session ID to find
48 * @param id identity the session is bound to
49 * @param master gets allocated master secret, if session found
50 * @return TLS suite of session, 0 if none found
51 */
52 tls_cipher_suite_t (*lookup)(tls_cache_t *this, chunk_t session,
53 identification_t *id, chunk_t* master);
54
55 /**
56 * Check if we have a session for a given identity.
57 *
58 * @param id identity to check
59 * @return allocated session ID, or chunk_empty
60 */
61 chunk_t (*check)(tls_cache_t *this, identification_t *id);
62
63 /**
64 * Destroy a tls_cache_t.
65 */
66 void (*destroy)(tls_cache_t *this);
67 };
68
69 /**
70 * Create a tls_cache instance.
71 *
72 * @param max_sessions maximum number of sessions to store
73 * @param max_age maximum age of a session, in seconds
74 * @return tls cache
75 */
76 tls_cache_t *tls_cache_create(u_int max_sessions, u_int max_age);
77
78 #endif /** TLS_CACHE_H_ @}*/