diff options
| author | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2014-07-06 02:16:10 +0200 |
| commit | 33491bc4279481db8ae47213e34a6d695a0e8830 (patch) | |
| tree | 097d2b0fdff3fae6885381ae5e57a182cd8cbbba /libnm-util/crypto_nss.c | |
| parent | 59c3714a494c3b3765657c0551ad82842d98a7d2 (diff) | |
Imported Upstream version 0.9.10.0 upstream/0.9.10.0
Diffstat (limited to 'libnm-util/crypto_nss.c')
| -rw-r--r-- | libnm-util/crypto_nss.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/libnm-util/crypto_nss.c b/libnm-util/crypto_nss.c index 5a7aa30b..af3de666 100644 --- a/libnm-util/crypto_nss.c +++ b/libnm-util/crypto_nss.c @@ -161,6 +161,9 @@ crypto_decrypt (const char *cipher, } else if (!strcmp (cipher, CIPHER_DES_CBC)) { cipher_mech = CKM_DES_CBC_PAD; real_iv_len = 8; + } else if (!strcmp (cipher, CIPHER_AES_CBC)) { + cipher_mech = CKM_AES_CBC_PAD; + real_iv_len = 16; } else { g_set_error (error, NM_CRYPTO_ERROR, NM_CRYPTO_ERR_UNKNOWN_CIPHER, @@ -178,12 +181,6 @@ crypto_decrypt (const char *cipher, } output = g_malloc0 (data->len); - if (!output) { - g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_OUT_OF_MEMORY, - _("Not enough memory for decrypted key buffer.")); - return NULL; - } slot = PK11_GetBestSlot (cipher_mech, NULL); if (!slot) { @@ -326,6 +323,8 @@ crypto_encrypt (const char *cipher, if (!strcmp (cipher, CIPHER_DES_EDE3_CBC)) cipher_mech = CKM_DES3_CBC_PAD; + else if (!strcmp (cipher, CIPHER_AES_CBC)) + cipher_mech = CKM_AES_CBC_PAD; else { g_set_error (error, NM_CRYPTO_ERROR, NM_CRYPTO_ERR_UNKNOWN_CIPHER, @@ -346,12 +345,6 @@ crypto_encrypt (const char *cipher, padded_buf[data->len + i] = (guint8) (pad_len & 0xFF); output = g_malloc0 (output_len); - if (!output) { - g_set_error (error, NM_CRYPTO_ERROR, - NM_CRYPTO_ERR_OUT_OF_MEMORY, - _("Could not allocate memory for encrypting.")); - return NULL; - } slot = PK11_GetBestSlot (cipher_mech, NULL); if (!slot) { @@ -414,11 +407,8 @@ out: if (slot) PK11_FreeSlot (slot); - if (padded_buf) { - memset (padded_buf, 0, padded_buf_len); - g_free (padded_buf); - padded_buf = NULL; - } + memset (padded_buf, 0, padded_buf_len); + g_free (padded_buf); if (!success) { memset (output, 0, output_len); |