Skip to contentSkip to conversation

auth_token/tls_crypt: fix usage of md_valid()

PATCH Superseded Antonio Quartulli 2 participants 2 messages Feb 15, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 auth_token/tls_crypt: fix usage of md_valid()

With b39725cf ("Remove md_kt_t and change crypto API to use const char*") the logic for validating ciphers and md algorithms has been changed.

We should now *always* use md_valid() when validating a digest alg.

At the same time, add '!' (negation) when validating the digest algorithm in the tls-crypt code, in order to restore the proper logic.

Cc Arne Schwabe <[email protected]...>
Fixes b39725cf ("Remove md_kt_t and change crypto API to use const char*")
---
 src/openvpn/auth_token.c | 2 +-
 src/openvpn/tls_crypt.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
src/openvpn/auth_token.c +1 -1
index ceae68f6..10c9dde6 100644
@@ -38,7 +38,7 @@ auth_token_kt(void)
     kt.cipher = "none";
     kt.digest = "SHA256";
 
-    if (!kt.digest)
+    if (!md_valid(kt.digest))
     {
         msg(M_WARN, "ERROR: --tls-crypt requires HMAC-SHA-256 support.");
         return (struct key_type) { 0 };
src/openvpn/tls_crypt.c +1 -1
index 610168b0..aae2a917 100644
@@ -59,7 +59,7 @@ tls_crypt_kt(void)
         msg(M_WARN, "ERROR: --tls-crypt requires AES-256-CTR support.");
         return (struct key_type) { 0 };
     }
-    if (cipher_valid(kt.digest))
+    if (!md_valid(kt.digest))
     {
         msg(M_WARN, "ERROR: --tls-crypt requires HMAC-SHA-256 support.");
         return (struct key_type) { 0 };
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw

Am 15.02.22 um 11:26 schrieb Antonio Quartulli:

Quoted 5 lines

With b39725cf ("Remove md_kt_t and change crypto API to use const char*") the logic for validating ciphers and md algorithms has been changed.

We should now *always* use md_valid() when validating a digest alg.

Quoted 7 lines

At the same time, add '!' (negation) when validating the digest algorithm in the tls-crypt code, in order to restore the proper logic.

Cc Arne Schwabe <[email protected]...>
Fixes b39725cf ("Remove md_kt_t and change crypto API to use const char*")