|
|
962144 |
From a1968db524e087a36a19a351b89bf6f1633819aa Mon Sep 17 00:00:00 2001
|
|
|
962144 |
From: minfrin <minfrin@users.noreply.github.com>
|
|
|
962144 |
Date: Tue, 5 Jan 2021 23:17:14 +0000
|
|
|
962144 |
Subject: [PATCH] Add support for digests detected from ECC certificates
|
|
|
962144 |
|
|
|
962144 |
Previously, the digest could be detected on RSA certificates only. This
|
|
|
962144 |
patch adds detection for ECC certificates.
|
|
|
962144 |
|
|
|
962144 |
[ bvanassche: changed _htmap2 into a two-dimensional array and renamed _htmap2
|
|
|
962144 |
back to _htmap ]
|
|
|
962144 |
---
|
|
|
962144 |
snmplib/snmp_openssl.c | 60 +++++++++++++++++++++++++++++++++++-------
|
|
|
962144 |
1 file changed, 50 insertions(+), 10 deletions(-)
|
|
|
962144 |
|
|
|
962144 |
diff --git a/snmplib/snmp_openssl.c b/snmplib/snmp_openssl.c
|
|
|
962144 |
index c092a007a..432cb5c27 100644
|
|
|
962144 |
--- a/snmplib/snmp_openssl.c
|
|
|
962144 |
+++ b/snmplib/snmp_openssl.c
|
|
|
962144 |
@@ -521,18 +521,54 @@ netsnmp_openssl_cert_dump_extensions(X509 *ocert)
|
|
|
962144 |
}
|
|
|
962144 |
}
|
|
|
962144 |
|
|
|
962144 |
-static int _htmap[NS_HASH_MAX + 1] = {
|
|
|
962144 |
- 0, NID_md5WithRSAEncryption, NID_sha1WithRSAEncryption,
|
|
|
962144 |
- NID_sha224WithRSAEncryption, NID_sha256WithRSAEncryption,
|
|
|
962144 |
- NID_sha384WithRSAEncryption, NID_sha512WithRSAEncryption };
|
|
|
962144 |
+static const struct {
|
|
|
962144 |
+ uint16_t nid;
|
|
|
962144 |
+ uint16_t ht;
|
|
|
962144 |
+} _htmap[] = {
|
|
|
962144 |
+ { 0, NS_HASH_NONE },
|
|
|
962144 |
+#ifdef NID_md5WithRSAEncryption
|
|
|
962144 |
+ { NID_md5WithRSAEncryption, NS_HASH_MD5 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_sha1WithRSAEncryption
|
|
|
962144 |
+ { NID_sha1WithRSAEncryption, NS_HASH_SHA1 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_ecdsa_with_SHA1
|
|
|
962144 |
+ { NID_ecdsa_with_SHA1, NS_HASH_SHA1 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_sha224WithRSAEncryption
|
|
|
962144 |
+ { NID_sha224WithRSAEncryption, NS_HASH_SHA224 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_ecdsa_with_SHA224
|
|
|
962144 |
+ { NID_ecdsa_with_SHA224, NS_HASH_SHA224 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_sha256WithRSAEncryption
|
|
|
962144 |
+ { NID_sha256WithRSAEncryption, NS_HASH_SHA256 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_ecdsa_with_SHA256
|
|
|
962144 |
+ { NID_ecdsa_with_SHA256, NS_HASH_SHA256 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_sha384WithRSAEncryption
|
|
|
962144 |
+ { NID_sha384WithRSAEncryption, NS_HASH_SHA384 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_ecdsa_with_SHA384
|
|
|
962144 |
+ { NID_ecdsa_with_SHA384, NS_HASH_SHA384 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_sha512WithRSAEncryption
|
|
|
962144 |
+ { NID_sha512WithRSAEncryption, NS_HASH_SHA512 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+#ifdef NID_ecdsa_with_SHA512
|
|
|
962144 |
+ { NID_ecdsa_with_SHA512, NS_HASH_SHA512 },
|
|
|
962144 |
+#endif
|
|
|
962144 |
+};
|
|
|
962144 |
|
|
|
962144 |
int
|
|
|
962144 |
_nid2ht(int nid)
|
|
|
962144 |
{
|
|
|
962144 |
int i;
|
|
|
962144 |
- for (i=1; i<= NS_HASH_MAX; ++i) {
|
|
|
962144 |
- if (nid == _htmap[i])
|
|
|
962144 |
- return i;
|
|
|
962144 |
+
|
|
|
962144 |
+ for (i = 0; i < sizeof(_htmap) / sizeof(_htmap[0]); i++) {
|
|
|
962144 |
+ if (_htmap[i].nid == nid)
|
|
|
962144 |
+ return _htmap[i].ht;
|
|
|
962144 |
}
|
|
|
962144 |
return 0;
|
|
|
962144 |
}
|
|
|
962144 |
@@ -541,9 +577,13 @@ _nid2ht(int nid)
|
|
|
962144 |
int
|
|
|
962144 |
_ht2nid(int ht)
|
|
|
962144 |
{
|
|
|
962144 |
- if ((ht < 0) || (ht > NS_HASH_MAX))
|
|
|
962144 |
- return 0;
|
|
|
962144 |
- return _htmap[ht];
|
|
|
962144 |
+ int i;
|
|
|
962144 |
+
|
|
|
962144 |
+ for (i = 0; i < sizeof(_htmap) / sizeof(_htmap[0]); i++) {
|
|
|
962144 |
+ if (_htmap[i].ht == ht)
|
|
|
962144 |
+ return _htmap[i].nid;
|
|
|
962144 |
+ }
|
|
|
962144 |
+ return 0;
|
|
|
962144 |
}
|
|
|
962144 |
#endif /* NETSNMP_FEATURE_REMOVE_OPENSSL_HT2NID */
|
|
|
962144 |
|
|
|
962144 |
|