summaryrefslogtreecommitdiff
path: root/libnm-util/crypto.h
diff options
context:
space:
mode:
authorTambet Ingo <tambet@gmail.com>2008-05-19 07:43:13 +0000
committerTambet Ingo <tambet@gmail.com>2008-05-19 07:43:13 +0000
commit40a69f986cdd173493ed9bbb74aefd67eca592a4 (patch)
tree1bf423a486aec39c94484c5cdf1e69690f5895a2 /libnm-util/crypto.h
parent192fe93b3a7d312860d079567515dc7e8571e172 (diff)
downloadNetworkManager-40a69f986cdd173493ed9bbb74aefd67eca592a4.tar.gz
2008-05-15 Tambet Ingo <tambet@gmail.com>
Move crypto functions from nm-applet to libnm-util. * libnm-util/nm-setting-8021x.c (nm_setting_802_1x_set_ca_cert) (nm_setting_802_1x_set_client_cert) (nm_setting_802_1x_set_phase2_ca_cert) (nm_setting_802_1x_set_phase2_client_cert) (nm_setting_802_1x_set_private_key) (nm_setting_802_1x_set_phase2_private_key): Implement. Given a certificate file (or private key and it's password), read the certificate data. * libnm-util/crypto_nss.c: * libnm-util/crypto_gnutls.c: * libnm-util/crypto.[ch]: Move here from nm-applet. * configure.in: Check for NSS and gnutls here (moved here from nm-applet). * system-settings/plugins/ifcfg-suse/parser.c (read_wpa_eap_settings): Imlement WPA-EAP configuration reading from sysconfig. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3673 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-util/crypto.h')
-rw-r--r--libnm-util/crypto.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/libnm-util/crypto.h b/libnm-util/crypto.h
new file mode 100644
index 0000000000..d970ce1326
--- /dev/null
+++ b/libnm-util/crypto.h
@@ -0,0 +1,92 @@
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw@redhat.com>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2007 Red Hat, Inc.
+ */
+
+#include <glib.h>
+
+#define MD5_HASH_LEN 20
+#define CIPHER_DES_EDE3_CBC "DES-EDE3-CBC"
+#define CIPHER_DES_CBC "DES-CBC"
+
+enum {
+ NM_CRYPTO_ERR_NONE = 0,
+ NM_CRYPTO_ERR_CANT_READ_FILE,
+ NM_CRYPTO_ERR_PEM_FORMAT_INVALID,
+ NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
+ NM_CRYPTO_ERR_DECODE_FAILED,
+ NM_CRYPTO_ERR_OUT_OF_MEMORY,
+ NM_CRYPTO_ERR_UNKNOWN_KEY_TYPE,
+ NM_CRYPTO_ERR_UNKNOWN_CIPHER,
+ NM_CRYPTO_ERR_RAW_IV_INVALID,
+ NM_CRYPTO_ERR_MD5_INIT_FAILED,
+ NM_CRYPTO_ERR_CIPHER_INIT_FAILED,
+ NM_CRYPTO_ERR_CIPHER_SET_KEY_FAILED,
+ NM_CRYPTO_ERR_CIPHER_SET_IV_FAILED,
+ NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
+};
+
+enum {
+ NM_CRYPTO_KEY_TYPE_UNKNOWN = 0,
+ NM_CRYPTO_KEY_TYPE_RSA,
+ NM_CRYPTO_KEY_TYPE_DSA,
+};
+
+
+#define NM_CRYPTO_ERROR nm_crypto_error_quark ()
+GQuark nm_crypto_error_quark (void);
+
+gboolean crypto_init (GError **error);
+
+void crypto_deinit (void);
+
+GByteArray * crypto_get_private_key (const char *file,
+ const char *password,
+ guint32 *out_key_type,
+ GError **error);
+
+GByteArray * crypto_load_and_verify_certificate (const char *file,
+ GError **error);
+
+/* Internal utils API bits for crypto providers */
+
+gboolean crypto_md5_hash (const char *salt,
+ const gsize salt_len,
+ const char *password,
+ gsize password_len,
+ char *buffer,
+ gsize buflen,
+ GError **error);
+
+char * crypto_decrypt (const char *cipher,
+ int key_type,
+ const char *data,
+ gsize data_len,
+ const char *iv,
+ const gsize iv_len,
+ const char *key,
+ const gsize key_len,
+ gsize *out_len,
+ GError **error);
+
+gboolean crypto_verify_cert (const unsigned char *data,
+ gsize len,
+ GError **error);
+
+