]> git.ipfire.org Git - thirdparty/squid.git/blob - src/security/Context.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / security / Context.h
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_SRC_SECURITY_CONTEXT_H
10 #define SQUID_SRC_SECURITY_CONTEXT_H
11
12 #include "security/LockingPointer.h"
13
14 #if USE_OPENSSL
15 #if HAVE_OPENSSL_SSL_H
16 #include <openssl/ssl.h>
17 #endif
18
19 #elif USE_GNUTLS
20 #if HAVE_GNUTLS_GNUTLS_H
21 #include <gnutls/gnutls.h>
22 #endif
23 #endif
24
25 namespace Security {
26
27 /* IMPORTANT:
28 * Due to circular dependency issues between ssl/libsquidssl.la and
29 * security/libsecurity.la the code within src/ssl/ is restricted to
30 * only using Security::ContextPtr, it MUST NOT use ContextPointer
31 *
32 * Code outside of src/ssl/ should always use Security::ContextPointer
33 * when storing a reference to a context.
34 */
35 #if USE_OPENSSL
36 typedef SSL_CTX* ContextPtr;
37 CtoCpp1(SSL_CTX_free, SSL_CTX *);
38 typedef LockingPointer<SSL_CTX, SSL_CTX_free_cpp, CRYPTO_LOCK_SSL_CTX> ContextPointer;
39
40 #elif USE_GNUTLS
41 typedef gnutls_certificate_credentials_t ContextPtr;
42 CtoCpp1(gnutls_certificate_free_credentials, gnutls_certificate_credentials_t);
43 typedef Security::LockingPointer<struct gnutls_certificate_credentials_st, gnutls_certificate_free_credentials_cpp, -1> ContextPointer;
44
45 #else
46 // use void* so we can check against nullptr
47 typedef void* ContextPtr;
48 typedef Security::LockingPointer<void, nullptr, -1> ContextPointer;
49
50 #endif
51
52 } // namespace Security
53
54 #endif /* SQUID_SRC_SECURITY_CONTEXT_H */
55