summaryrefslogtreecommitdiff
path: root/libnm-core/crypto_nss.c
diff options
context:
space:
mode:
authorDan Winship <danw@redhat.com>2014-12-01 13:46:14 -0500
committerDan Winship <danw@redhat.com>2014-12-04 08:39:54 -0500
commit48ff21b5bc42daa8b6f72db8d82fd9b21fde842e (patch)
treea5601b1128c01119824a7ae8e8911a6cbd7cbdf0 /libnm-core/crypto_nss.c
parent34519eee136ef95666f77482315edde9d48250e5 (diff)
downloadNetworkManager-48ff21b5bc42daa8b6f72db8d82fd9b21fde842e.tar.gz
libnm-core: reimplement crypto_md5_hash() using GChecksum
Reimplement crypto_md5_hash() using GChecksum. Remove the gboolean return value and GError argument, since it cannot fail now.
Diffstat (limited to 'libnm-core/crypto_nss.c')
-rw-r--r--libnm-core/crypto_nss.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/libnm-core/crypto_nss.c b/libnm-core/crypto_nss.c
index 6ab935c3a2..4dd85f3bdc 100644
--- a/libnm-core/crypto_nss.c
+++ b/libnm-core/crypto_nss.c
@@ -72,61 +72,6 @@ crypto_init (GError **error)
return TRUE;
}
-gboolean
-crypto_md5_hash (const char *salt,
- const gsize salt_len,
- const char *password,
- gsize password_len,
- char *buffer,
- gsize buflen,
- GError **error)
-{
- PK11Context *ctx;
- int nkey = buflen;
- unsigned int digest_len;
- int count = 0;
- char digest[MD5_HASH_LEN];
- char *p = buffer;
-
- if (salt)
- g_return_val_if_fail (salt_len >= 8, FALSE);
-
- g_return_val_if_fail (password != NULL, FALSE);
- g_return_val_if_fail (password_len > 0, FALSE);
- g_return_val_if_fail (buffer != NULL, FALSE);
- g_return_val_if_fail (buflen > 0, FALSE);
-
- ctx = PK11_CreateDigestContext (SEC_OID_MD5);
- if (!ctx) {
- g_set_error (error, NM_CRYPTO_ERROR,
- NM_CRYPTO_ERROR_FAILED,
- _("Failed to initialize the MD5 context: %d."),
- PORT_GetError ());
- return FALSE;
- }
-
- while (nkey > 0) {
- int i = 0;
-
- PK11_DigestBegin (ctx);
- if (count++)
- PK11_DigestOp (ctx, (const unsigned char *) digest, digest_len);
- PK11_DigestOp (ctx, (const unsigned char *) password, password_len);
- if (salt)
- PK11_DigestOp (ctx, (const unsigned char *) salt, 8); /* Only use 8 bytes of salt */
- PK11_DigestFinal (ctx, (unsigned char *) digest, &digest_len, sizeof (digest));
-
- while (nkey && (i < digest_len)) {
- *(p++) = digest[i++];
- nkey--;
- }
- }
-
- memset (digest, 0, sizeof (digest));
- PK11_DestroyContext (ctx, PR_TRUE);
- return TRUE;
-}
-
char *
crypto_decrypt (const char *cipher,
int key_type,