aboutsummaryrefslogtreecommitdiff
path: root/src/openvpn/ssl_util.h
diff options
context:
space:
mode:
authorArne Schwabe2021-02-26 12:10:12 +0100
committerGert Doering2021-03-10 10:40:18 +0100
commit88664aba69a8aab0e600200c445024fbaf7bab80 (patch)
tree478a70d33e1d3b3971a82422cd4060803c6a9a8d /src/openvpn/ssl_util.h
parent53229047a259b2edb9034802a33fe27636675ff9 (diff)
downloadopenvpn-88664aba69a8aab0e600200c445024fbaf7bab80.zip
openvpn-88664aba69a8aab0e600200c445024fbaf7bab80.tar.gz
Refactor extract_var_peer_info into standalone function and add ssl_util.c
Our "natural" place for this function would be ssl.c but ssl.c has a lot of dependencies on all kinds of other compilation units so including ssl.c into unit tests is near impossible currently. Instead create a new file ssl_util.c that holds small utility functions like this one. Patch v2: add newline add the end of sll_util.h and ssl_util.c Patch v3: Refactor/clean up the function even more as suggested by Gert. Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Lev Stipakov <lstipakov@gmail.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210226111012.21269-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21585.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src/openvpn/ssl_util.h')
-rw-r--r--src/openvpn/ssl_util.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/openvpn/ssl_util.h b/src/openvpn/ssl_util.h
new file mode 100644
index 0000000..bc2ae30
--- /dev/null
+++ b/src/openvpn/ssl_util.h
@@ -0,0 +1,49 @@
+/*
+ * OpenVPN -- An application to securely tunnel IP networks
+ * over a single TCP/UDP port, with support for SSL/TLS-based
+ * session authentication and key exchange,
+ * packet encryption, packet authentication, and
+ * packet compression.
+ *
+ * Copyright (C) 2002-2020 OpenVPN Inc <sales@openvpn.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/**
+ * @file SSL utility function. This file (and its .c file) is designed to
+ * to be included in units/etc without pulling in a lot of dependencies
+ */
+
+#ifndef SSL_UTIL_H_
+#define SSL_UTIL_H_
+
+#include "buffer.h"
+
+/**
+ * Extracts a variable from peer info, the returned string will be allocated
+ * using the supplied gc_arena
+ *
+ * @param peer_info The peer's peer_info
+ * @param var The variable *including* =, e.g. IV_CIPHERS=
+ *
+ * @return The content of the variable as NULL terminated string or NULL if the
+ * variable cannot be found.
+ */
+char *
+extract_var_peer_info(const char *peer_info,
+ const char *var,
+ struct gc_arena *gc);
+
+#endif