1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Dan Williams <dcbw@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA.
21 * Copyright 2007 - 2014 Red Hat, Inc.
27 #include "nm-default.h"
29 #define MD5_HASH_LEN 20
30 #define CIPHER_DES_EDE3_CBC "DES-EDE3-CBC"
31 #define CIPHER_DES_CBC "DES-CBC"
32 #define CIPHER_AES_CBC "AES-128-CBC"
35 NM_CRYPTO_KEY_TYPE_UNKNOWN = 0,
36 NM_CRYPTO_KEY_TYPE_RSA,
37 NM_CRYPTO_KEY_TYPE_DSA
41 NM_CRYPTO_FILE_FORMAT_UNKNOWN = 0,
42 NM_CRYPTO_FILE_FORMAT_X509,
43 NM_CRYPTO_FILE_FORMAT_RAW_KEY,
44 NM_CRYPTO_FILE_FORMAT_PKCS12
47 gboolean crypto_init (GError **error);
49 GByteArray *crypto_decrypt_openssl_private_key_data (const guint8 *data,
52 NMCryptoKeyType *out_key_type,
55 GByteArray *crypto_decrypt_openssl_private_key (const char *file,
57 NMCryptoKeyType *out_key_type,
60 GByteArray *crypto_load_and_verify_certificate (const char *file,
61 NMCryptoFileFormat *out_file_format,
64 gboolean crypto_is_pkcs12_file (const char *file, GError **error);
66 gboolean crypto_is_pkcs12_data (const guint8 *data, gsize len, GError **error);
68 NMCryptoFileFormat crypto_verify_private_key_data (const guint8 *data,
71 gboolean *out_is_encrypted,
74 NMCryptoFileFormat crypto_verify_private_key (const char *file,
76 gboolean *out_is_encrypted,
79 /* Internal utils API bits for crypto providers */
81 void crypto_md5_hash (const char *salt,
88 char *crypto_make_des_aes_key (const char *cipher,
95 char * crypto_decrypt (const char *cipher,
106 char * crypto_encrypt (const char *cipher,
116 gboolean crypto_randomize (void *buffer, gsize buffer_len, GError **error);
118 NMCryptoFileFormat crypto_verify_cert (const guint8 *data,
122 gboolean crypto_verify_pkcs12 (const guint8 *data,
124 const char *password,
127 gboolean crypto_verify_pkcs8 (const guint8 *data,
129 gboolean is_encrypted,
130 const char *password,
133 #endif /* __CRYPTO_H__ */