/src/freeradius-server/src/lib/tls/utils.h
Line | Count | Source |
1 | | #pragma once |
2 | | /* |
3 | | * This program is free software; you can redistribute it and/or modify |
4 | | * it under the terms of the GNU General Public License as published by |
5 | | * the Free Software Foundation; either version 2 of the License, or |
6 | | * (at your option) any later version. |
7 | | * |
8 | | * This program is distributed in the hope that it will be useful, |
9 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | | * GNU General Public License for more details. |
12 | | * |
13 | | * You should have received a copy of the GNU General Public License |
14 | | * along with this program; if not, write to the Free Software |
15 | | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
16 | | */ |
17 | | #ifdef WITH_TLS |
18 | | /** |
19 | | * $Id: 3f9241efff4b6c98cd7a9465aa651d5bc2dd8761 $ |
20 | | * |
21 | | * @file lib/tls/utils.h |
22 | | * @brief Miscellaneous TLS utility functions |
23 | | * |
24 | | * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org) |
25 | | */ |
26 | | RCSIDH(utils_h, "$Id: 3f9241efff4b6c98cd7a9465aa651d5bc2dd8761 $") |
27 | | |
28 | | #include "openssl_user_macros.h" |
29 | | |
30 | | #include <openssl/ssl.h> |
31 | | |
32 | | #include <freeradius-devel/util/time.h> |
33 | | #include <freeradius-devel/server/request.h> |
34 | | |
35 | | #ifdef __cplusplus |
36 | | extern "C" { |
37 | | #endif |
38 | | |
39 | | /* |
40 | | * OpenSSL 4.0 returns const extensions and extension objects, which |
41 | | * OpenSSL 3.x functions won't accept. |
42 | | */ |
43 | | #if OPENSSL_VERSION_NUMBER >= 0x40000000L |
44 | | # define FR_OPENSSL_X509_CONST const |
45 | | #else |
46 | | # define FR_OPENSSL_X509_CONST |
47 | | #endif |
48 | | |
49 | | /** Return the length of an ASN1_STRING's data |
50 | | * |
51 | | * The data is not NUL terminated, so always use this length with ASN1_STRING_get0_data(). |
52 | | */ |
53 | | static inline size_t fr_tls_asn1_string_length(ASN1_STRING const *s) |
54 | 0 | { |
55 | | #if OPENSSL_VERSION_NUMBER >= 0x40100000L |
56 | | return ASN1_STRING_get_length(s); |
57 | | #else |
58 | 0 | return (size_t)ASN1_STRING_length(s); |
59 | 0 | #endif |
60 | 0 | } Unexecuted instantiation: cert.c:fr_tls_asn1_string_length Unexecuted instantiation: conf.c:fr_tls_asn1_string_length Unexecuted instantiation: ctx.c:fr_tls_asn1_string_length Unexecuted instantiation: pairs.c:fr_tls_asn1_string_length Unexecuted instantiation: strerror.c:fr_tls_asn1_string_length Unexecuted instantiation: utils.c:fr_tls_asn1_string_length |
61 | | |
62 | | char const *fr_tls_utils_x509_pkey_type(X509 *cert); |
63 | | |
64 | | int fr_tls_utils_keyblock_size_get(request_t *request, SSL *ssl); |
65 | | |
66 | | int fr_tls_utils_asn1time_to_epoch(time_t *out, ASN1_TIME const *asn1); |
67 | | |
68 | | int fr_utils_get_private_key_password(char *buf, int size, UNUSED int rwflag, void *u); |
69 | | |
70 | | #ifdef __cplusplus |
71 | | } |
72 | | #endif |
73 | | #endif /* WITH_TLS */ |