OpenVPN
mock_ssl_dependencies.c
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2002-2023 OpenVPN Inc <sales@openvpn.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2
12  * as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 /* Minimal set of mocked function/globals to get unit tests to
25  * compile that use the ssl_* files */
26 
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30 
31 #include "syshead.h"
32 
33 #include <setjmp.h>
34 #include <cmocka.h>
35 
36 
37 #include "ssl.h"
38 #include "ssl_verify.h"
39 
40 int
41 parse_line(const char *line, char **p, const int n, const char *file,
42  const int line_num, int msglevel, struct gc_arena *gc)
43 {
44  /* Dummy function to get the linker happy, should never be called */
45  assert_true(false);
46  return 0;
47 }
48 
49 
50 int
51 pem_password_callback(char *buf, int size, int rwflag, void *u)
52 {
53  return 0;
54 }
55 
56 void
57 cert_hash_remember(struct tls_session *session, const int cert_depth,
58  const struct buffer *cert_hash)
59 {
60  assert_false(true);
61 }
62 
64 verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depth)
65 {
66  return FAILURE;
67 }
result_t
result_t
Result of verification function.
Definition: ssl_verify_backend.h:35
parse_line
int parse_line(const char *line, char **p, const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)
Definition: mock_ssl_dependencies.c:41
verify_cert
result_t verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depth)
Definition: mock_ssl_dependencies.c:64
ssl_verify.h
cert_hash_remember
void cert_hash_remember(struct tls_session *session, const int cert_depth, const struct buffer *cert_hash)
Definition: mock_ssl_dependencies.c:57
buffer
Wrapper structure for dynamically allocated memory.
Definition: buffer.h:60
ssl.h
tls_session
Security parameter state of a single session within a VPN tunnel.
Definition: ssl_common.h:468
syshead.h
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
openvpn_x509_cert_t
X509 openvpn_x509_cert_t
Definition: openvpn-plugin.h:40
pem_password_callback
int pem_password_callback(char *buf, int size, int rwflag, void *u)
Callback to retrieve the user's password.
Definition: mock_ssl_dependencies.c:51
cert_hash
Structure containing the hash for a single certificate.
Definition: ssl_verify.h:54
config.h
session
Definition: keyingmaterialexporter.c:56
FAILURE
@ FAILURE
Definition: ssl_verify_backend.h:35