]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
_gnutls_decrypt_pbes1_des_md5_data: ensure that encrypted data size is a multiple...
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 19 Jan 2017 08:20:28 +0000 (09:20 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 19 Jan 2017 08:22:57 +0000 (09:22 +0100)
That prevents incorrect data reaching nettle which has only
assertion checks (leading to an abort).

Issue found using oss-fuzz:
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=389

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
lib/x509/privkey_pkcs8_pbes1.c

index 933363d37cdb60c728654706b58a5a76a6edccd6..86ba2609f078a6b6db87b8e8e1a77eae28e7b8d3 100644 (file)
@@ -142,10 +142,14 @@ _gnutls_decrypt_pbes1_des_md5_data(const char *password,
        gnutls_datum_t dkey, d_iv;
        cipher_hd_st ch;
        uint8_t key[16];
+       const unsigned block_size = 8;
 
        if (enc_params->cipher != GNUTLS_CIPHER_DES_CBC)
                return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
 
+       if (encrypted_data->size % block_size != 0)
+               return gnutls_assert_val(GNUTLS_E_ILLEGAL_PARAMETER);
+
        /* generate the key
         */
        pbkdf1_md5(password, password_len, kdf_params->salt, kdf_params->iter_count, sizeof(key), key);