]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
auth_token/tls_crypt: fix usage of md_valid()
authorAntonio Quartulli <a@unstable.cc>
Tue, 15 Feb 2022 12:31:57 +0000 (13:31 +0100)
committerGert Doering <gert@greenie.muc.de>
Wed, 16 Feb 2022 07:46:37 +0000 (08:46 +0100)
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 <arne@rfc2549.org>
Fixes: b39725cf ("Remove md_kt_t and change crypto API to use const char*")
Reported-by: Richard T Bonhomme <tincantech@protonmail.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220215123157.10615-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23793.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/auth_token.c
src/openvpn/crypto_backend.h
src/openvpn/tls_crypt.c

index ceae68f69517262fa025df4329e89c31c013fbe5..10c9dde6c521d824cb6b5ac4f59375677e4449a1 100644 (file)
@@ -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 };
index abf1b876c9d29ac2e5672d386af48218c74f80b6..6d89b9e5ae614b7bb60b16736865d09590c50ea2 100644 (file)
@@ -520,8 +520,7 @@ static inline bool md_defined(const char* mdname)
  *
  * @param digest        Name of the digest to verify, e.g. \c MD5).
  *
- * @return              A statically allocated structure containing parameters
- *                      for the given message digest.
+ * @return              Whether a digest of the given name is available
  */
 bool md_valid(const char *digest);
 
index 610168b0a335d2203277d0f0e25397858c8c891b..aae2a9170432cb47ed032c69ea0a6aee379f21d7 100644 (file)
@@ -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 };