]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Skip encryption/decryption tests for WinZip AES if platform does not
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 14 Sep 2014 13:38:27 +0000 (22:38 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 14 Sep 2014 13:38:27 +0000 (22:38 +0900)
provide PBKDF2 functionarity.

libarchive/archive_write_set_format_zip.c
libarchive/test/test_read_format_zip_winzip_aes_large.c

index e604e1edceb7d19745065d266d0348d806213360..5a5ebdc01395f35f49b9a991ea58e35f74be27f5 100644 (file)
@@ -1619,8 +1619,10 @@ is_winzip_aes_encryption_supported(int encryption)
        }
        if (archive_random(salt, salt_len) != ARCHIVE_OK)
                return (0);
-       archive_pbkdf2_sha1("p", 1, salt, salt_len, 1000,
+       ret = archive_pbkdf2_sha1("p", 1, salt, salt_len, 1000,
            derived_key, key_len * 2 + 2);
+       if (ret != 0)
+               return (0);
 
        ret = archive_encrypto_aes_ctr_init(&cctx, derived_key, key_len);
        if (ret != 0)
index 6cff248400cc82194117437813173d33ef4e92cd..4027fc0eaf98f825c4e805eefeef4f0bee506668 100644 (file)
@@ -33,6 +33,20 @@ DEFINE_TEST(test_read_format_zip_winzip_aes256_large)
        struct archive *a;
        char buff[512];
 
+
+       /* Check if running system has cryptographic functionarity. */
+       assert((a = archive_write_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
+       if (ARCHIVE_OK != archive_write_set_options(a,
+                               "zip:encryption=aes256")) {
+               skipping("This system does not have cryptographic liberary");
+               archive_write_free(a);
+               return;
+       }
+       archive_write_free(a);
+
+
        extract_reference_file(refname);
 
        /*