summaryrefslogtreecommitdiff
path: root/wsutil/rsa.h
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2017-04-26 07:33:25 +0200
committerMichael Mann <mmann78@netscape.net>2017-06-05 23:43:03 +0000
commit502cc61711173273ffb8be2cf895f5e79c3b47bc (patch)
tree53db680580f3ca6a56461908330b9a30218a1449 /wsutil/rsa.h
parent1b228df643121ab2fabde34226701b9cd92401be (diff)
downloadwireshark-502cc61711173273ffb8be2cf895f5e79c3b47bc.tar.gz
Move RSA key loading and decryption functions to wsutil
Loading PEM and PKCS#11 keys was being done in static functions in packet-ssl-utils.c. These were moved to wsutil, with prototypes in a new <wsutil/rsa.h> header. This adds gnutls as optional dependency to wsutil. The RSA decryption helper was also moved and is now provided in <wsutil/wsgcrypt.h>. This allows more dissectors to access this functionality. Change-Id: I6cfbbf5203f2881c82bad721747834ccd76e2033 Reviewed-on: https://code.wireshark.org/review/21941 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: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wsutil/rsa.h')
-rw-r--r--wsutil/rsa.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/wsutil/rsa.h b/wsutil/rsa.h
new file mode 100644
index 0000000000..dd5a9e316d
--- /dev/null
+++ b/wsutil/rsa.h
@@ -0,0 +1,55 @@
+/* rsa.h
+ *
+ * Functions for RSA private key reading and use
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2007 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __RSA_H__
+#define __RSA_H__
+
+#include "ws_symbol_export.h"
+#include "wsgcrypt.h"
+
+#ifdef HAVE_LIBGNUTLS
+#include <gnutls/abstract.h>
+WS_DLL_PUBLIC gcry_sexp_t rsa_privkey_to_sexp(gnutls_x509_privkey_t priv_key, char **err);
+
+/**
+ * Load an RSA private key from specified file
+ * @param fp the file that contain the key data
+ * @param [out] err error message upon failure; NULL upon success
+ * @return a pointer to the loaded key on success, or NULL upon failure
+ */
+WS_DLL_PUBLIC gnutls_x509_privkey_t rsa_load_pem_key(FILE* fp, char **err);
+
+/**
+ * Load a RSA private key from a PKCS#12 file (DER or PEM format)
+ * @param fp the file that contains the key data
+ * @param cert_passwd password to decrypt the PKCS#12 file
+ * @param [out] err error message upon failure; NULL upon success
+ * @return a pointer to the loaded key on success; NULL upon failure
+ */
+WS_DLL_PUBLIC gnutls_x509_privkey_t rsa_load_pkcs12(FILE* fp, const char *cert_passwd, char** err);
+#endif
+
+WS_DLL_PUBLIC void rsa_private_key_free(gpointer key);
+
+
+#endif /* __RSA_H__ */