Skip to contentSkip to conversation

Change in openvpn[master]: Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c

Openvpn-devel In review plaisthos (Code Review) 3 participants 6 messages Dec 7, 2023 – Dec 9, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1701971374000.I605394d4f3872a168d05bbbe52d90f6d48935865@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/470?usp=email

to review the following change.

Change subject: Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c
......................................................................

Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c

This allow these functions to be defined without having to include ssl.c/misc.c which pulls in a lot of more dependencies.

Change-Id I605394d4f3872a168d05bbbe52d90f6d48935865

---
M src/openvpn/misc.c
M src/openvpn/misc.h
M src/openvpn/ssl.c
M src/openvpn/ssl_backend.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_openssl.c
M src/openvpn/ssl_util.c
M src/openvpn/ssl_util.h

8 files changed, 211 insertions(+), 208 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/470/1

src/openvpn/misc.c +0 -20
index ce6e4fd..bce63ed 100644
@@ -773,26 +773,6 @@
     }
 }
 
-int
-get_num_elements(const char *string, char delimiter)
-{
-    int string_len = strlen(string);
-
-    ASSERT(0 != string_len);
-
-    int element_count = 1;
-    /* Get number of ciphers */
-    for (int i = 0; i < string_len; i++)
-    {
-        if (string[i] == delimiter)
-        {
-            element_count++;
-        }
-    }
-
-    return element_count;
-}
-
 struct buffer
 prepend_dir(const char *dir, const char *path, struct gc_arena *gc)
 {
src/openvpn/misc.h +0 -14
index b000b72..70a24dd 100644
@@ -193,20 +193,6 @@
 void output_peer_info_env(struct env_set *es, const char *peer_info);
 
 /**
- * Returns the occurrences of 'delimiter' in a string +1
- * This is typically used to find out the number elements in a
- * cipher string or similar that is separated by : like
- *
- *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
- *
- * @param string        the string to work on
- * @param delimiter     the delimiter to count, typically ':'
- * @return              occrrences of delimiter + 1
- */
-int
-get_num_elements(const char *string, char delimiter);
-
-/**
  * Prepend a directory to a path.
  */
 struct buffer
src/openvpn/ssl.c +0 -164

176 lines not on this page · raw message

src/openvpn/ssl_backend.h +0 -9
index 3854d59..b9466ce 100644
@@ -53,15 +53,6 @@
  */
 struct tls_session;
 
-/**
- * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
- *
- * @param cipher_name   Can be either OpenSSL or IANA cipher name
- * @return              tls_cipher_name_pair* if found, NULL otherwise
- */
-typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
-const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
-
 /*
  *
  * Functions implemented in ssl.c for use by the backend SSL library
src/openvpn/ssl_mbedtls.c +1 -0
index 9c9167d..cc88484 100644
@@ -44,6 +44,7 @@
 #include "mbedtls_compat.h"
 #include "pkcs11_backend.h"
 #include "ssl_common.h"
+#include "ssl_util.h"
 
 #include "ssl_verify_mbedtls.h"
 #include <mbedtls/debug.h>
src/openvpn/ssl_openssl.c +1 -0
index 82872bf..c30e6a9 100644
@@ -50,6 +50,7 @@
 #endif
 
 #include "ssl_verify_openssl.h"
+#include "ssl_util.h"
 
 #include <openssl/bn.h>
 #include <openssl/crypto.h>
src/openvpn/ssl_util.c +185 -0

188 lines not on this page · raw message

src/openvpn/ssl_util.h +24 -1
index 4c46f88..b3eaf9f 100644
@@ -66,4 +66,27 @@
  */
 const char *options_string_compat_lzo(const char *options, struct gc_arena *gc);
 
-#endif
+/**
+ * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
+ *
+ * @param cipher_name   Can be either OpenSSL or IANA cipher name
+ * @return              tls_cipher_name_pair* if found, NULL otherwise
+ */
+typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
+const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
+
+/**
+ * Returns the occurrences of 'delimiter' in a string +1
+ * This is typically used to find out the number elements in a
+ * cipher string or similar that is separated by : like
+ *
+ *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
+ *
+ * @param string        the string to work on
+ * @param delimiter     the delimiter to count, typically ':'
+ * @return              occrrences of delimiter + 1
+ */
+int
+get_num_elements(const char *string, char delimiter);
+
+#endif /* ifndef SSL_UTIL_H_ */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I605394d4f3872a168d05bbbe52d90f6d48935865
Gerrit-Change-Number: 470
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/470?usp=email )

Change subject: Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I605394d4f3872a168d05bbbe52d90f6d48935865
Gerrit-Change-Number: 470
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Fri, 08 Dec 2023 16:43:18 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

This allow these functions to be defined without having to include ssl.c/misc.c which pulls in a lot of more dependencies.

Change-Id I605394d4f3872a168d05bbbe52d90f6d48935865

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/470
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/misc.c +0 -20
index ce6e4fd..bce63ed 100644
@@ -773,26 +773,6 @@
     }
 }
 
-int
-get_num_elements(const char *string, char delimiter)
-{
-    int string_len = strlen(string);
-
-    ASSERT(0 != string_len);
-
-    int element_count = 1;
-    /* Get number of ciphers */
-    for (int i = 0; i < string_len; i++)
-    {
-        if (string[i] == delimiter)
-        {
-            element_count++;
-        }
-    }
-
-    return element_count;
-}
-
 struct buffer
 prepend_dir(const char *dir, const char *path, struct gc_arena *gc)
 {
src/openvpn/misc.h +0 -14
index b000b72..70a24dd 100644
@@ -193,20 +193,6 @@
 void output_peer_info_env(struct env_set *es, const char *peer_info);
 
 /**
- * Returns the occurrences of 'delimiter' in a string +1
- * This is typically used to find out the number elements in a
- * cipher string or similar that is separated by : like
- *
- *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
- *
- * @param string        the string to work on
- * @param delimiter     the delimiter to count, typically ':'
- * @return              occrrences of delimiter + 1
- */
-int
-get_num_elements(const char *string, char delimiter);
-
-/**
  * Prepend a directory to a path.
  */
 struct buffer
src/openvpn/ssl.c +0 -164

176 lines not on this page · raw message

src/openvpn/ssl_backend.h +0 -9
index 3854d59..b9466ce 100644
@@ -53,15 +53,6 @@
  */
 struct tls_session;
 
-/**
- * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
- *
- * @param cipher_name   Can be either OpenSSL or IANA cipher name
- * @return              tls_cipher_name_pair* if found, NULL otherwise
- */
-typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
-const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
-
 /*
  *
  * Functions implemented in ssl.c for use by the backend SSL library
src/openvpn/ssl_mbedtls.c +1 -0
index 9c9167d..cc88484 100644
@@ -44,6 +44,7 @@
 #include "mbedtls_compat.h"
 #include "pkcs11_backend.h"
 #include "ssl_common.h"
+#include "ssl_util.h"
 
 #include "ssl_verify_mbedtls.h"
 #include <mbedtls/debug.h>
src/openvpn/ssl_openssl.c +1 -0
index 82872bf..c30e6a9 100644
@@ -50,6 +50,7 @@
 #endif
 
 #include "ssl_verify_openssl.h"
+#include "ssl_util.h"
 
 #include <openssl/bn.h>
 #include <openssl/crypto.h>
src/openvpn/ssl_util.c +185 -0

188 lines not on this page · raw message

src/openvpn/ssl_util.h +24 -1
index 4c46f88..b3eaf9f 100644
@@ -66,4 +66,27 @@
  */
 const char *options_string_compat_lzo(const char *options, struct gc_arena *gc);
 
-#endif
+/**
+ * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
+ *
+ * @param cipher_name   Can be either OpenSSL or IANA cipher name
+ * @return              tls_cipher_name_pair* if found, NULL otherwise
+ */
+typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
+const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
+
+/**
+ * Returns the occurrences of 'delimiter' in a string +1
+ * This is typically used to find out the number elements in a
+ * cipher string or similar that is separated by : like
+ *
+ *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
+ *
+ * @param string        the string to work on
+ * @param delimiter     the delimiter to count, typically ':'
+ * @return              occrrences of delimiter + 1
+ */
+int
+get_num_elements(const char *string, char delimiter);
+
+#endif /* ifndef SSL_UTIL_H_ */
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c

"git show --color-moved=zebra" confirm that this is indeed only moving code around. "make check" still passes fine.

Your patch has been applied to the master branch.

commit 3094d8fb061c56ea73eda00c464fa81cdcd55c94

Author: Arne Schwabe
Date:   Fri Dec 8 18:33:46 2023 +0100
     Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg27726.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/470?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c
......................................................................

Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c

This allow these functions to be defined without having to include ssl.c/misc.c which pulls in a lot of more dependencies.

Change-Id I605394d4f3872a168d05bbbe52d90f6d48935865

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27726.html

---
M src/openvpn/misc.c
M src/openvpn/misc.h
M src/openvpn/ssl.c
M src/openvpn/ssl_backend.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_openssl.c
M src/openvpn/ssl_util.c
M src/openvpn/ssl_util.h

8 files changed, 211 insertions(+), 208 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/470/2

src/openvpn/misc.c +0 -20
index ce6e4fd..bce63ed 100644
@@ -773,26 +773,6 @@
     }
 }
 
-int
-get_num_elements(const char *string, char delimiter)
-{
-    int string_len = strlen(string);
-
-    ASSERT(0 != string_len);
-
-    int element_count = 1;
-    /* Get number of ciphers */
-    for (int i = 0; i < string_len; i++)
-    {
-        if (string[i] == delimiter)
-        {
-            element_count++;
-        }
-    }
-
-    return element_count;
-}
-
 struct buffer
 prepend_dir(const char *dir, const char *path, struct gc_arena *gc)
 {
src/openvpn/misc.h +0 -14
index b000b72..70a24dd 100644
@@ -193,20 +193,6 @@
 void output_peer_info_env(struct env_set *es, const char *peer_info);
 
 /**
- * Returns the occurrences of 'delimiter' in a string +1
- * This is typically used to find out the number elements in a
- * cipher string or similar that is separated by : like
- *
- *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
- *
- * @param string        the string to work on
- * @param delimiter     the delimiter to count, typically ':'
- * @return              occrrences of delimiter + 1
- */
-int
-get_num_elements(const char *string, char delimiter);
-
-/**
  * Prepend a directory to a path.
  */
 struct buffer
src/openvpn/ssl.c +0 -164

176 lines not on this page · raw message

src/openvpn/ssl_backend.h +0 -9
index 3854d59..b9466ce 100644
@@ -53,15 +53,6 @@
  */
 struct tls_session;
 
-/**
- * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
- *
- * @param cipher_name   Can be either OpenSSL or IANA cipher name
- * @return              tls_cipher_name_pair* if found, NULL otherwise
- */
-typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
-const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
-
 /*
  *
  * Functions implemented in ssl.c for use by the backend SSL library
src/openvpn/ssl_mbedtls.c +1 -0
index 9c9167d..cc88484 100644
@@ -44,6 +44,7 @@
 #include "mbedtls_compat.h"
 #include "pkcs11_backend.h"
 #include "ssl_common.h"
+#include "ssl_util.h"
 
 #include "ssl_verify_mbedtls.h"
 #include <mbedtls/debug.h>
src/openvpn/ssl_openssl.c +1 -0
index 82872bf..c30e6a9 100644
@@ -50,6 +50,7 @@
 #endif
 
 #include "ssl_verify_openssl.h"
+#include "ssl_util.h"
 
 #include <openssl/bn.h>
 #include <openssl/crypto.h>
src/openvpn/ssl_util.c +185 -0

188 lines not on this page · raw message

src/openvpn/ssl_util.h +24 -1
index 4c46f88..b3eaf9f 100644
@@ -66,4 +66,27 @@
  */
 const char *options_string_compat_lzo(const char *options, struct gc_arena *gc);
 
-#endif
+/**
+ * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
+ *
+ * @param cipher_name   Can be either OpenSSL or IANA cipher name
+ * @return              tls_cipher_name_pair* if found, NULL otherwise
+ */
+typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
+const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
+
+/**
+ * Returns the occurrences of 'delimiter' in a string +1
+ * This is typically used to find out the number elements in a
+ * cipher string or similar that is separated by : like
+ *
+ *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
+ *
+ * @param string        the string to work on
+ * @param delimiter     the delimiter to count, typically ':'
+ * @return              occrrences of delimiter + 1
+ */
+int
+get_num_elements(const char *string, char delimiter);
+
+#endif /* ifndef SSL_UTIL_H_ */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I605394d4f3872a168d05bbbe52d90f6d48935865
Gerrit-Change-Number: 470
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/470?usp=email )

Change subject: Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c
......................................................................

Move tls_get_cipher_name_pair and get_num_elements to ssl_utils.c

This allow these functions to be defined without having to include ssl.c/misc.c which pulls in a lot of more dependencies.

Change-Id I605394d4f3872a168d05bbbe52d90f6d48935865

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27726.html

---
M src/openvpn/misc.c
M src/openvpn/misc.h
M src/openvpn/ssl.c
M src/openvpn/ssl_backend.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_openssl.c
M src/openvpn/ssl_util.c
M src/openvpn/ssl_util.h

8 files changed, 211 insertions(+), 208 deletions(-)
src/openvpn/misc.c +0 -20
index ce6e4fd..bce63ed 100644
@@ -773,26 +773,6 @@
     }
 }
 
-int
-get_num_elements(const char *string, char delimiter)
-{
-    int string_len = strlen(string);
-
-    ASSERT(0 != string_len);
-
-    int element_count = 1;
-    /* Get number of ciphers */
-    for (int i = 0; i < string_len; i++)
-    {
-        if (string[i] == delimiter)
-        {
-            element_count++;
-        }
-    }
-
-    return element_count;
-}
-
 struct buffer
 prepend_dir(const char *dir, const char *path, struct gc_arena *gc)
 {
src/openvpn/misc.h +0 -14
index b000b72..70a24dd 100644
@@ -193,20 +193,6 @@
 void output_peer_info_env(struct env_set *es, const char *peer_info);
 
 /**
- * Returns the occurrences of 'delimiter' in a string +1
- * This is typically used to find out the number elements in a
- * cipher string or similar that is separated by : like
- *
- *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
- *
- * @param string        the string to work on
- * @param delimiter     the delimiter to count, typically ':'
- * @return              occrrences of delimiter + 1
- */
-int
-get_num_elements(const char *string, char delimiter);
-
-/**
  * Prepend a directory to a path.
  */
 struct buffer
src/openvpn/ssl.c +0 -164

176 lines not on this page · raw message

src/openvpn/ssl_backend.h +0 -9
index 3854d59..b9466ce 100644
@@ -53,15 +53,6 @@
  */
 struct tls_session;
 
-/**
- * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
- *
- * @param cipher_name   Can be either OpenSSL or IANA cipher name
- * @return              tls_cipher_name_pair* if found, NULL otherwise
- */
-typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
-const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
-
 /*
  *
  * Functions implemented in ssl.c for use by the backend SSL library
src/openvpn/ssl_mbedtls.c +1 -0
index 9c9167d..cc88484 100644
@@ -44,6 +44,7 @@
 #include "mbedtls_compat.h"
 #include "pkcs11_backend.h"
 #include "ssl_common.h"
+#include "ssl_util.h"
 
 #include "ssl_verify_mbedtls.h"
 #include <mbedtls/debug.h>
src/openvpn/ssl_openssl.c +1 -0
index 82872bf..c30e6a9 100644
@@ -50,6 +50,7 @@
 #endif
 
 #include "ssl_verify_openssl.h"
+#include "ssl_util.h"
 
 #include <openssl/bn.h>
 #include <openssl/crypto.h>
src/openvpn/ssl_util.c +185 -0

188 lines not on this page · raw message

src/openvpn/ssl_util.h +24 -1
index 4c46f88..b3eaf9f 100644
@@ -66,4 +66,27 @@
  */
 const char *options_string_compat_lzo(const char *options, struct gc_arena *gc);
 
-#endif
+/**
+ * Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name
+ *
+ * @param cipher_name   Can be either OpenSSL or IANA cipher name
+ * @return              tls_cipher_name_pair* if found, NULL otherwise
+ */
+typedef struct { const char *openssl_name; const char *iana_name; } tls_cipher_name_pair;
+const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
+
+/**
+ * Returns the occurrences of 'delimiter' in a string +1
+ * This is typically used to find out the number elements in a
+ * cipher string or similar that is separated by : like
+ *
+ *   X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1
+ *
+ * @param string        the string to work on
+ * @param delimiter     the delimiter to count, typically ':'
+ * @return              occrrences of delimiter + 1
+ */
+int
+get_num_elements(const char *string, char delimiter);
+
+#endif /* ifndef SSL_UTIL_H_ */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/470?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I605394d4f3872a168d05bbbe52d90f6d48935865
Gerrit-Change-Number: 470
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged