aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/x509af
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-10-04 11:22:41 +0200
committerAnders Broman <a.broman58@gmail.com>2015-10-07 04:09:42 +0000
commit877fd03cbffa96bfb6c4c030ce9f8bade57cfc75 (patch)
tree4924dfcf05e8978e4e31e99fec97c806f33ad290 /asn1/x509af
parent40ff4ffee88977b2981e29cb4ad8658394c8442e (diff)
ssl-utils: load RSA keys based on their modulus+exponent
Load RSA private keys based on their public key instead of relying on the user to specify a valid address and port mapping. This is more reliable and prepares for simplification of the SSL Keys dialog. After this change, the "address" part of the UAT dialog will be ignored when loading the private key. The port+protocol mapping is still imported, but should probably be removed too. Change-Id: I4d7a2bfcf63d17e66e336ef770759f20510fc176 Reviewed-on: https://code.wireshark.org/review/10766 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'asn1/x509af')
-rw-r--r--asn1/x509af/packet-x509af-template.c21
-rw-r--r--asn1/x509af/x509af.cnf6
2 files changed, 27 insertions, 0 deletions
diff --git a/asn1/x509af/packet-x509af-template.c b/asn1/x509af/packet-x509af-template.c
index 21211401ff..c6941421d2 100644
--- a/asn1/x509af/packet-x509af-template.c
+++ b/asn1/x509af/packet-x509af-template.c
@@ -33,6 +33,9 @@
#include "packet-x509if.h"
#include "packet-x509sat.h"
#include "packet-ldap.h"
+#if defined(HAVE_LIBGNUTLS)
+#include <gnutls/gnutls.h>
+#endif
#define PNAME "X.509 Authentication Framework"
#define PSNAME "X509AF"
@@ -51,8 +54,26 @@ static int hf_x509af_extension_id = -1;
static gint ett_pkix_crl = -1;
#include "packet-x509af-ett.c"
static const char *algorithm_id;
+static void
+x509af_export_publickey(tvbuff_t *tvb, asn1_ctx_t *actx, int offset, int len);
#include "packet-x509af-fn.c"
+/* Exports the SubjectPublicKeyInfo structure as gnutls_datum_t.
+ * actx->private_data is assumed to be a gnutls_datum_t pointer which will be
+ * filled in if non-NULL. */
+static void
+x509af_export_publickey(tvbuff_t *tvb _U_, asn1_ctx_t *actx _U_, int offset _U_, int len _U_)
+{
+#if defined(HAVE_LIBGNUTLS)
+ gnutls_datum_t *subjectPublicKeyInfo = (gnutls_datum_t *)actx->private_data;
+ if (subjectPublicKeyInfo) {
+ subjectPublicKeyInfo->data = (guchar *) tvb_get_ptr(tvb, offset, len);
+ subjectPublicKeyInfo->size = len;
+ actx->private_data = NULL;
+ }
+#endif
+}
+
const char *x509af_get_last_algorithm_id(void) {
return algorithm_id;
}
diff --git a/asn1/x509af/x509af.cnf b/asn1/x509af/x509af.cnf
index de4d171348..5c98d6dbaf 100644
--- a/asn1/x509af/x509af.cnf
+++ b/asn1/x509af/x509af.cnf
@@ -81,6 +81,12 @@ CertificateList/signedCertificateList/revokedCertificates/_item/userCertificate
#.FN_BODY AlgorithmIdentifier/parameters
offset=call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL);
+#.FN_HDR SubjectPublicKeyInfo
+ int orig_offset = offset;
+#.FN_FTR SubjectPublicKeyInfo
+ x509af_export_publickey(tvb, actx, orig_offset, offset - orig_offset);
+#.END
+
#.FN_PARS Extension/extnId
FN_VARIANT = _str HF_INDEX = hf_x509af_extension_id VAL_PTR = &actx->external.direct_reference