]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Detect encrypted archive entries (ZIP, RAR, 7Zip)
authorKonrad Kleine <konrad.wilhelm.kleine@gmail.com>
Mon, 1 Jul 2013 15:12:24 +0000 (17:12 +0200)
committerKonrad Kleine <konrad.wilhelm.kleine@gmail.com>
Tue, 17 Sep 2013 15:17:39 +0000 (17:17 +0200)
With this change you can detect if an archive entry is encrypted. The
archive formats covered with this change are: ZIP, RAR, and 7zip. Other
formats can be added quite simply by looking at the already supported
formats. For all the already supported formats we have tests that check
if:

* an archive entries's data is encryped (data test)
* an archive entries's metadata is encrypted (header test)
* one file is encrypted while another is not (partially test)

These new functions are introduced.

int archive_read_format_capabilities(struct archive*)

Returns a bitmask of capabilities that are supported by the archive
format reader. If the reader has no special capabilities,
ARCHIVE_READ_FORMAT_CAPS_NONE is returned; otherwise 0 is returned.

You can call this function even before reading the first header from
an archive.

Return Values:
* ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
The reader supports detection of encrypted data.
* ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA
The reader supports detection of encrypted metadata (e.g.
filename, modification time, size, etc.)
* ARCHIVE_READ_FORMAT_CAPS_NONE
None of the above capabilities. If this value is returned, this
doesn't mean that the format itself doesn't support any type of
encryption it simply means that the reader is not capable of
detecting it.

int archive_read_has_encrypted_entries(struct archive *)

Returns "true" (non-zero) if the archive contains at least one
encrypted entry, no matter which encryption type (data or metadata)
is used; otherwise 0 is returned.

You should only call this function after reading the first header
from an archive.

NOTE: I'm not sure that this function will stay in for long.

int archive_entry_is_data_encrypted(struct archive_entry*)

Returns "true" (non-zero) if the archive entry's data is encrypted;
otherwise 0 is returned. You can call this function after calling
archive_read_next_header().

int archive_entry_is_metadata_encrypted(struct archive_entry*)

Returns "true" (non-zero) if the archive entry's metadata is
encrypted; otherwise 0 is returned. You can call this function after
calling archive_read_next_header().

int archive_entry_is_encrypted(struct archive_entry*)

Returns "true" (non-zero) if either the archive entry's data and/or
it's metadata is encrypted; otherwise 0 is returned. You can call
this function after calling archive_read_next_header().

If you use archive_read_format_capabilities() in combination with one of
the archive_entry_is_[data|metadata]_encrypted() functions, you can be
sure that you've encountered an encrypted entry. This allows you to
react differently depending on libarchive's return codes. For instance,
you might want to skip encrypted files from being extracted until
decryption support has been implemented.

Here's how I generated the 7zip test files:
-------------------------------------------

With header encrpytion (-mhe=on):

    $ rm -f test_read_format_7zip_encryption_header.7z
    $ echo "foo" > bar.txt && 7z a -mhe=on -p12345678 \
    test_read_format_7zip_encryption_header.7z bar.txt

    $ uuencode test_read_format_7zip_encryption_header.7z \
    test_read_format_7zip_encryption_header.7z > \
    test_read_format_7zip_encryption_header.7z.uu

Without header encrpytion (-mhe=off):

    $ rm -f test_read_format_7zip_encryption.7z
    $ echo "foo" > bar.txt && 7z a -mhe=off -p12345678 \
    test_read_format_7zip_encryption.7z bar.txt

    $ uuencode test_read_format_7zip_encryption.7z \
    test_read_format_7zip_encryption.7z > \
    test_read_format_7zip_encryption.7z.uu

Partially encrypted archive:

$ rm -f test_read_format_7zip_encryption_partially.7z
$ echo "foo" > bar_unencrypted.txt && 7z a \
test_read_format_7zip_encryption_partially.7z bar_unencrypted.txt
$ echo "foo" > bar_encrypted.txt && 7z a -mhe=off -p12345678 \
test_read_format_7zip_encryption_partially.7z bar_encrypted.txt

$ uuencode test_read_format_7zip_encryption_partially.7z \
test_read_format_7zip_encryption_partially.7z > \
test_read_format_7zip_encryption_partially.7z.uu

Here's how I generated the RAR test files:
------------------------------------------

These are the files we can will add to the archives:

    echo "data of foo.txt" > foo.txt
    echo "data of bar.txt" > bar.txt

 With header encrpytion (-hp):

    rm -f test_read_format_rar_encryption_header.rar
    rar a -hp12345678 test_read_format_rar_encryption_header.rar \
    foo.txt bar.txt

    uuencode test_read_format_rar_encryption_header.rar \
    test_read_format_rar_encryption_header.rar > \
    test_read_format_rar_encryption_header.rar.uu

Without header encrpytion (-p):

    rm -f test_read_format_rar_encryption_data.rar
    rar a -p12345678 test_read_format_rar_encryption_data.rar \
    foo.txt bar.txt

    uuencode test_read_format_rar_encryption_data.rar \
    test_read_format_rar_encryption_data.rar > \
    test_read_format_rar_encryption_data.rar.uu

Partially encrypted archive (-p on "foo.txt" and no password on "bar.txt"):

    rm -f test_read_format_rar_encryption_partially.rar
    rar a -p12345678 test_read_format_rar_encryption_partially.rar foo.txt
    rar a test_read_format_rar_encryption_partially.rar bar.txt

    uuencode test_read_format_rar_encryption_partially.rar \
    test_read_format_rar_encryption_partially.rar > \
    test_read_format_rar_encryption_partially.rar.uu

Here's how I generated the ZIP test files:
------------------------------------------

This is how I've created the test files:

These are the files we will add to the archives:
  On Windows:
    echo "data of foo.txt" > foo.txt
    echo "data of bar.txt" > bar.txt

For the creation of the Zip archives I've used the
PKZIP Command Line Add-On available from here:

http://comm.pkware.com/pkzip-cli-download.html

With header (aka central directory) encrpytion (-cd):

  On Windows:
    del /F test_read_format_zip_encryption_header.zip
    pkzipc.exe -add -cryptalgorithm=AES,256 -passphrase=12345678 -cd test_read_format_zip_encryption_header.zip foo.txt bar.txt

  On Linux:
    uuencode test_read_format_zip_encryption_header.zip \
    test_read_format_zip_encryption_header.zip > \
    test_read_format_zip_encryption_header.zip.uu

Without header encrpytion:

  On Windows:
    del /F test_read_format_zip_encryption_data.zip
    pkzipc.exe -add -cryptalgorithm=AES,256 -passphrase=12345678 test_read_format_zip_encryption_data.zip foo.txt bar.txt

  On Linux:
    uuencode test_read_format_zip_encryption_data.zip \
    test_read_format_zip_encryption_data.zip > \
    test_read_format_zip_encryption_data.zip.uu

Partially encrypted archive ("foo.txt" is encrypted and "bar.txt" is not):

  On Windows:
    del /F test_read_format_zip_encryption_partially.zip
    pkzipc.exe -add -cryptalgorithm=AES,256 -passphrase=12345678 test_read_format_zip_encryption_partially.zip foo.txt
    pkzipc.exe -add test_read_format_zip_encryption_partially.zip bar.txt

  On Linux:
    uuencode test_read_format_zip_encryption_partially.zip \
    test_read_format_zip_encryption_partially.zip > \
    test_read_format_zip_encryption_partially.zip.uu

96 files changed:
libarchive/archive.h
libarchive/archive_entry.c
libarchive/archive_entry.h
libarchive/archive_entry_private.h
libarchive/archive_read.c
libarchive/archive_read_private.h
libarchive/archive_read_support_format_7zip.c
libarchive/archive_read_support_format_ar.c
libarchive/archive_read_support_format_cab.c
libarchive/archive_read_support_format_cpio.c
libarchive/archive_read_support_format_empty.c
libarchive/archive_read_support_format_iso9660.c
libarchive/archive_read_support_format_lha.c
libarchive/archive_read_support_format_mtree.c
libarchive/archive_read_support_format_rar.c
libarchive/archive_read_support_format_raw.c
libarchive/archive_read_support_format_tar.c
libarchive/archive_read_support_format_xar.c
libarchive/archive_read_support_format_zip.c
libarchive/test/CMakeLists.txt
libarchive/test/test_read_format_7zip.c
libarchive/test/test_read_format_7zip_encryption.7z.uu [new file with mode: 0644]
libarchive/test/test_read_format_7zip_encryption_data.c [new file with mode: 0644]
libarchive/test/test_read_format_7zip_encryption_header.7z.uu [new file with mode: 0644]
libarchive/test/test_read_format_7zip_encryption_header.c [new file with mode: 0644]
libarchive/test/test_read_format_7zip_encryption_partially.7z.uu [new file with mode: 0644]
libarchive/test/test_read_format_7zip_encryption_partially.c [new file with mode: 0644]
libarchive/test/test_read_format_ar.c
libarchive/test/test_read_format_cab.c
libarchive/test/test_read_format_cab_filename.c
libarchive/test/test_read_format_cpio_afio.c
libarchive/test/test_read_format_cpio_bin.c
libarchive/test/test_read_format_cpio_bin_Z.c
libarchive/test/test_read_format_cpio_bin_be.c
libarchive/test/test_read_format_cpio_bin_bz2.c
libarchive/test/test_read_format_cpio_bin_gz.c
libarchive/test/test_read_format_cpio_bin_lzip.c
libarchive/test/test_read_format_cpio_bin_lzma.c
libarchive/test/test_read_format_cpio_bin_xz.c
libarchive/test/test_read_format_cpio_filename.c
libarchive/test/test_read_format_cpio_odc.c
libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c
libarchive/test/test_read_format_cpio_svr4_gzip.c
libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c
libarchive/test/test_read_format_cpio_svr4c_Z.c
libarchive/test/test_read_format_empty.c
libarchive/test/test_read_format_gtar_filename.c
libarchive/test/test_read_format_gtar_gz.c
libarchive/test/test_read_format_gtar_lzma.c
libarchive/test/test_read_format_gtar_sparse.c
libarchive/test/test_read_format_iso_Z.c
libarchive/test/test_read_format_iso_multi_extent.c
libarchive/test/test_read_format_iso_xorriso.c
libarchive/test/test_read_format_isojoliet_bz2.c
libarchive/test/test_read_format_isojoliet_long.c
libarchive/test/test_read_format_isojoliet_rr.c
libarchive/test/test_read_format_isojoliet_versioned.c
libarchive/test/test_read_format_isorr_bz2.c
libarchive/test/test_read_format_isorr_ce.c
libarchive/test/test_read_format_isorr_new_bz2.c
libarchive/test/test_read_format_isorr_rr_moved.c
libarchive/test/test_read_format_isozisofs_bz2.c
libarchive/test/test_read_format_lha.c
libarchive/test/test_read_format_lha_filename.c
libarchive/test/test_read_format_mtree.c
libarchive/test/test_read_format_pax_bz2.c
libarchive/test/test_read_format_rar.c
libarchive/test/test_read_format_rar_encryption_data.c [new file with mode: 0644]
libarchive/test/test_read_format_rar_encryption_data.rar.uu [new file with mode: 0644]
libarchive/test/test_read_format_rar_encryption_header.c [new file with mode: 0644]
libarchive/test/test_read_format_rar_encryption_header.rar.uu [new file with mode: 0644]
libarchive/test/test_read_format_rar_encryption_partially.c [new file with mode: 0644]
libarchive/test/test_read_format_rar_encryption_partially.rar.uu [new file with mode: 0644]
libarchive/test/test_read_format_raw.c
libarchive/test/test_read_format_tar.c
libarchive/test/test_read_format_tar_empty_filename.c
libarchive/test/test_read_format_tar_empty_pax.c
libarchive/test/test_read_format_tar_filename.c
libarchive/test/test_read_format_tbz.c
libarchive/test/test_read_format_tgz.c
libarchive/test/test_read_format_tlz.c
libarchive/test/test_read_format_txz.c
libarchive/test/test_read_format_tz.c
libarchive/test/test_read_format_ustar_filename.c
libarchive/test/test_read_format_xar.c
libarchive/test/test_read_format_zip.c
libarchive/test/test_read_format_zip_comment_stored.c
libarchive/test/test_read_format_zip_encryption_data.c [new file with mode: 0644]
libarchive/test/test_read_format_zip_encryption_data.zip.uu [new file with mode: 0644]
libarchive/test/test_read_format_zip_encryption_header.c [new file with mode: 0644]
libarchive/test/test_read_format_zip_encryption_header.zip.uu [new file with mode: 0644]
libarchive/test/test_read_format_zip_encryption_partially.c [new file with mode: 0644]
libarchive/test/test_read_format_zip_encryption_partially.zip.uu [new file with mode: 0644]
libarchive/test/test_read_format_zip_filename.c
libarchive/test/test_read_format_zip_mac_metadata.c
libarchive/test/test_read_format_zip_sfx.c

index 5281440306caa9669963daf3708f1c9222e26e46..0d3ed8f40beb9f57079aec6a3cad733d8ef2077f 100644 (file)
@@ -285,6 +285,18 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1,
 #define        ARCHIVE_FORMAT_RAR                      0xD0000
 #define        ARCHIVE_FORMAT_7ZIP                     0xE0000
 
+/*
+ * Codes returned by archive_read_format_capabilities().
+ *
+ * This list can be extended with values between 0 and 0xffff.
+ * The original purpose of this list was to let different archive
+ * format readers expose their general capabilities in terms of
+ * encryption.
+ */
+#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0)  /* reader can detect encrypted data */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1)  /* reader can detect encryptable metadata (pathname, mtime, etc.) */
+
 /*-
  * Basic outline for reading an archive:
  *   1) Ask archive_read_new for an archive reader object.
@@ -466,6 +478,15 @@ __LA_DECL int archive_read_next_header2(struct archive *,
  */
 __LA_DECL __LA_INT64_T          archive_read_header_position(struct archive *);
 
+/* Returns "true" (non-zero) if the archive contains encrypted entries; otherwise 0 is returned. */
+__LA_DECL int           archive_read_has_encrypted_entries(struct archive *);
+
+/*
+ * Returns a bitmask of capabilities that are supported by the archive format reader.
+ * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
+ */
+__LA_DECL int           archive_read_format_capabilities(struct archive *);
+
 /* Read data from the body of an entry.  Similar to read(2). */
 __LA_DECL __LA_SSIZE_T          archive_read_data(struct archive *,
                                    void *, size_t);
index 386e51d473e8712292d1be99fb16df8cef3a4665..101e61f1e6d461101573557f595ba1ebca1a68ad 100644 (file)
@@ -201,6 +201,10 @@ archive_entry_clone(struct archive_entry *entry)
        entry2->ae_set = entry->ae_set;
        archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname);
 
+       /* Copy encryption status */
+       entry2->is_data_encrypted = entry->is_data_encrypted;
+       entry2->is_metadata_encrypted = entry->is_metadata_encrypted;
+       
        /* Copy ACL data over. */
        archive_acl_copy(&entry2->acl, &entry->acl);
 
@@ -695,6 +699,25 @@ _archive_entry_uname_l(struct archive_entry *entry,
        return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc));
 }
 
+int
+archive_entry_is_data_encrypted(struct archive_entry *entry)
+{
+       return (entry && entry->is_data_encrypted);
+}
+
+int
+archive_entry_is_metadata_encrypted(struct archive_entry *entry)
+{
+       return (entry && entry->is_metadata_encrypted);
+}
+
+int
+archive_entry_is_encrypted(struct archive_entry *entry)
+{
+       return (entry && (entry->is_data_encrypted 
+                                       || entry->is_metadata_encrypted));
+}
+
 /*
  * Functions to set archive_entry properties.
  */
@@ -1216,6 +1239,22 @@ archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name)
        return (0);
 }
 
+void
+archive_entry_set_is_data_encrypted(struct archive_entry *entry, char encrypted)
+{
+    if (entry) {
+        entry->is_data_encrypted = encrypted;
+    }
+}
+
+void
+archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char encrypted)
+{
+    if (entry) {
+        entry->is_metadata_encrypted = encrypted;
+    }
+}
+
 int
 _archive_entry_copy_uname_l(struct archive_entry *entry,
     const char *name, size_t len, struct archive_string_conv *sc)
index a9050652e6a4e38fb25f3313f89365f88d0a68f4..ebd85d9796d196ccd731e46fa3e77cbbaa5e01b6 100644 (file)
@@ -235,6 +235,9 @@ __LA_DECL const wchar_t     *archive_entry_symlink_w(struct archive_entry *);
 __LA_DECL __LA_INT64_T  archive_entry_uid(struct archive_entry *);
 __LA_DECL const char   *archive_entry_uname(struct archive_entry *);
 __LA_DECL const wchar_t        *archive_entry_uname_w(struct archive_entry *);
+__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);
+__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);
+__LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
 
 /*
  * Set fields in an archive_entry.
@@ -306,6 +309,8 @@ __LA_DECL void      archive_entry_set_uname(struct archive_entry *, const char *);
 __LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *);
 __LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
 __LA_DECL int  archive_entry_update_uname_utf8(struct archive_entry *, const char *);
+__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char encrypted);
+__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char encrypted);
 /*
  * Routines to bulk copy fields to/from a platform-native "struct
  * stat."  Libarchive used to just store a struct stat inside of each
index e3547c3e318723ba77ef01e5bf99de974a73ea59..74b50da6bd1accd1fa1dc4a344aae3c748306059 100644 (file)
@@ -154,6 +154,9 @@ struct archive_entry {
        /* Not used within libarchive; useful for some clients. */
        struct archive_mstring ae_sourcepath;   /* Path this entry is sourced from. */
 
+       char is_data_encrypted;
+       char is_metadata_encrypted;
+       
        void *mac_metadata;
        size_t mac_metadata_size;
 
index 048c316c52d43b0fcaaf6927c1176d1479133fef..77293837d25265c5ecc602bee3b13dc9d30e2173 100644 (file)
@@ -746,6 +746,31 @@ archive_read_header_position(struct archive *_a)
        return (a->header_position);
 }
 
+/* Returns "true" (non-zero) if the archive contains encrypted entries; otherwise 0 is returned. */
+int
+archive_read_has_encrypted_entries(struct archive *_a)
+{
+       struct archive_read *a = (struct archive_read *)_a;
+       if (a && a->format && a->format->has_encrypted_entries) {
+               return (a->format->has_encrypted_entries)(a);
+       }
+       return 0;
+}
+
+/*
+ * Returns a bitmask of capabilities that are supported by the archive format reader.
+ * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
+ */
+int
+archive_read_format_capabilities(struct archive *_a)
+{
+       struct archive_read *a = (struct archive_read *)_a;
+       if (a && a->format && a->format->format_capabilties) {
+               return (a->format->format_capabilties)(a);
+       }
+       return ARCHIVE_READ_FORMAT_CAPS_NONE;
+}
+
 /*
  * Read data from an archive entry, using a read(2)-style interface.
  * This is a convenience routine that just calls
@@ -1094,7 +1119,9 @@ __archive_read_register_format(struct archive_read *a,
     int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
     int (*read_data_skip)(struct archive_read *),
     int64_t (*seek_data)(struct archive_read *, int64_t, int),
-    int (*cleanup)(struct archive_read *))
+    int (*cleanup)(struct archive_read *),
+    int (*format_capabilities)(struct archive_read *),
+    int (*has_encrypted_entries)(struct archive_read *))
 {
        int i, number_slots;
 
@@ -1117,6 +1144,8 @@ __archive_read_register_format(struct archive_read *a,
                        a->formats[i].cleanup = cleanup;
                        a->formats[i].data = format_data;
                        a->formats[i].name = name;
+                       a->formats[i].format_capabilties = format_capabilities;
+                       a->formats[i].has_encrypted_entries = has_encrypted_entries;
                        return (ARCHIVE_OK);
                }
        }
index 8a6c859a8a1431f974657409e99435afe0dfda47..0dc0c776ceebcc42971374d69f8b19f387f2b0ca 100644 (file)
@@ -207,6 +207,8 @@ struct archive_read {
                int     (*read_data_skip)(struct archive_read *);
                int64_t (*seek_data)(struct archive_read *, int64_t, int);
                int     (*cleanup)(struct archive_read *);
+               int     (*format_capabilties)(struct archive_read *);
+               int     (*has_encrypted_entries)(struct archive_read *);
        }       formats[16];
        struct archive_format_descriptor        *format; /* Active format. */
 
@@ -226,7 +228,9 @@ int __archive_read_register_format(struct archive_read *a,
            int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
            int (*read_data_skip)(struct archive_read *),
            int64_t (*seek_data)(struct archive_read *, int64_t, int),
-           int (*cleanup)(struct archive_read *));
+           int (*cleanup)(struct archive_read *),
+           int (*format_capabilities)(struct archive_read *),
+           int (*has_encrypted_entries)(struct archive_read *));
 
 int __archive_read_get_bidder(struct archive_read *a,
     struct archive_read_filter_bidder **bidder);
index 194b8d51c96aa72e0c4430335ba57287417ef750..c8284792cdf25668e085b038db3fac4e4a4ecce1 100644 (file)
@@ -69,7 +69,11 @@ __FBSDID("$FreeBSD$");
 #define _7Z_BZ2                0x040202
 #define _7Z_PPMD       0x030401
 #define _7Z_DELTA      0x03
-#define _7Z_CRYPTO     0x06F10701
+#define _7Z_CRYPTO_MAIN_ZIP                    0x06F10101 /* Main Zip crypto algo */
+#define _7Z_CRYPTO_RAR_29                      0x06F10303 /* Rar29 AES-128 + (modified SHA-1) */
+#define _7Z_CRYPTO_AES_256_SHA_256     0x06F10701 /* AES-256 + SHA-256 */
+
+
 #define _7Z_X86                0x03030103
 #define _7Z_X86_BCJ2   0x0303011B
 #define _7Z_POWERPC    0x03030205
@@ -322,8 +326,13 @@ struct _7zip {
        struct archive_string_conv *sconv;
 
        char                     format_name[64];
+       
+       /* Custom value that is non-zero if this archive contains encrypted entries. */
+       char has_encrypted_entries;
 };
 
+static int     archive_read_format_7zip_has_encrypted_entries(struct archive_read *);
+static int     archive_read_support_format_7zip_capabilities(struct archive_read *a);
 static int     archive_read_format_7zip_bid(struct archive_read *, int);
 static int     archive_read_format_7zip_cleanup(struct archive_read *);
 static int     archive_read_format_7zip_read_data(struct archive_read *,
@@ -410,13 +419,36 @@ archive_read_support_format_7zip(struct archive *_a)
            archive_read_format_7zip_read_data,
            archive_read_format_7zip_read_data_skip,
            NULL,
-           archive_read_format_7zip_cleanup);
+           archive_read_format_7zip_cleanup,
+           archive_read_support_format_7zip_capabilities,
+           archive_read_format_7zip_has_encrypted_entries);
 
        if (r != ARCHIVE_OK)
                free(zip);
        return (ARCHIVE_OK);
 }
 
+static int
+archive_read_support_format_7zip_capabilities(struct archive_read * a)
+{
+       (void)a; /* UNUSED */
+       return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA |
+                       ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+
+static int
+archive_read_format_7zip_has_encrypted_entries(struct archive_read *_a)
+{
+       if (_a && _a->format) {
+               struct _7zip * zip = (struct _7zip *)_a->format->data;
+               if (zip && zip->has_encrypted_entries) {
+                       return 1;
+               }
+       }
+       return 0;
+}
+
 static int
 archive_read_format_7zip_bid(struct archive_read *a, int best_bid)
 {
@@ -568,6 +600,8 @@ archive_read_format_7zip_read_header(struct archive_read *a,
        struct _7zip *zip = (struct _7zip *)a->format->data;
        struct _7zip_entry *zip_entry;
        int r, ret = ARCHIVE_OK;
+       struct _7z_folder *folder = 0;
+       uint64_t fidx = 0;
 
        a->archive.archive_format = ARCHIVE_FORMAT_7ZIP;
        if (a->archive.archive_format_name == NULL)
@@ -603,6 +637,25 @@ archive_read_format_7zip_read_header(struct archive_read *a,
                if (zip->sconv == NULL)
                        return (ARCHIVE_FATAL);
        }
+       
+       /* Figure out if the entry is encrypted by looking at the folder
+          that is associated to the current 7zip entry. If the folder
+          has a coder with a _7Z_CRYPTO codec then the folder is encrypted.
+          Hence the entry must also be encrypted. */
+       if (zip_entry && zip_entry->folderIndex < zip->si.ci.numFolders) {
+               folder = &(zip->si.ci.folders[zip_entry->folderIndex]);
+               for (fidx=0; folder && fidx<folder->numCoders; fidx++) {
+                       switch(folder->coders[fidx].codec) {
+                               case _7Z_CRYPTO_MAIN_ZIP:
+                               case _7Z_CRYPTO_RAR_29:
+                               case _7Z_CRYPTO_AES_256_SHA_256: {
+                                       archive_entry_set_is_data_encrypted(entry, 1);
+                                       zip->has_encrypted_entries = 1;
+                                       break;
+                               }
+                       }
+               }
+       }
 
        if (archive_entry_copy_pathname_l(entry,
            (const char *)zip_entry->utf16name,
@@ -1203,6 +1256,17 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
                archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
                    "Unexpected codec ID: %lX", zip->codec);
                return (ARCHIVE_FAILED);
+       case _7Z_CRYPTO_MAIN_ZIP:
+       case _7Z_CRYPTO_RAR_29:
+       case _7Z_CRYPTO_AES_256_SHA_256:
+               if (a->entry) {
+                       archive_entry_set_is_metadata_encrypted(a->entry, 1);
+                       archive_entry_set_is_data_encrypted(a->entry, 1);
+                       zip->has_encrypted_entries = 1;
+               }
+               archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+                   "Crypto codec not supported yet (ID: 0x%lX)", zip->codec);
+               return (ARCHIVE_FAILED);
        default:
                archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
                    "Unknown codec ID: %lX", zip->codec);
@@ -2755,6 +2819,7 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip,
        zip->header_crc32 = 0;
        zip->header_is_encoded = 0;
        zip->header_is_being_read = 1;
+       zip->has_encrypted_entries = 0;
        check_header_crc = 1;
 
        if ((p = header_bytes(a, 1)) == NULL) {
@@ -3235,15 +3300,28 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder,
         * Check coder types.
         */
        for (i = 0; i < folder->numCoders; i++) {
-               if (folder->coders[i].codec == _7Z_CRYPTO) {
-                       archive_set_error(&(a->archive),
-                           ARCHIVE_ERRNO_MISC,
-                           "The %s is encrypted, "
-                           "but currently not supported", cname);
-                       return (ARCHIVE_FATAL);
+               switch(folder->coders[i].codec) {
+                       case _7Z_CRYPTO_MAIN_ZIP:
+                       case _7Z_CRYPTO_RAR_29:
+                       case _7Z_CRYPTO_AES_256_SHA_256: {
+                               /* For entry that is associated with this folder, mark
+                                  it as encrypted (data+metadata). */
+                               zip->has_encrypted_entries = 1;
+                               if (a->entry) {
+                                       archive_entry_set_is_data_encrypted(a->entry, 1);
+                                       archive_entry_set_is_metadata_encrypted(a->entry, 1);
+                               }
+                               archive_set_error(&(a->archive),
+                                       ARCHIVE_ERRNO_MISC,
+                                       "The %s is encrypted, "
+                                       "but currently not supported", cname);
+                               return (ARCHIVE_FATAL);
+                       }
+                       case _7Z_X86_BCJ2: {
+                               found_bcj2++;
+                               break;
+                       }
                }
-               if (folder->coders[i].codec == _7Z_X86_BCJ2)
-                       found_bcj2++;
        }
        if ((folder->numCoders > 2 && !found_bcj2) || found_bcj2 > 1) {
                archive_set_error(&(a->archive),
index 40be18c0cce24d62ce0eb0a50b8fd11303f5e20d..82756c976e365e97d467ca9aeb7ed758a945f921 100644 (file)
@@ -122,7 +122,9 @@ archive_read_support_format_ar(struct archive *_a)
            archive_read_format_ar_read_data,
            archive_read_format_ar_skip,
            NULL,
-           archive_read_format_ar_cleanup);
+           archive_read_format_ar_cleanup,
+           NULL,
+           NULL);
 
        if (r != ARCHIVE_OK) {
                free(ar);
index 3c9f94ca6ba3b18050fef490b2b167ce4b58cc38..fc70684afa04feed1dbaef4eda7def7fb1cbf8d4 100644 (file)
@@ -383,7 +383,9 @@ archive_read_support_format_cab(struct archive *_a)
            archive_read_format_cab_read_data,
            archive_read_format_cab_read_data_skip,
            NULL,
-           archive_read_format_cab_cleanup);
+           archive_read_format_cab_cleanup,
+           NULL,
+           NULL);
 
        if (r != ARCHIVE_OK)
                free(cab);
index 819f4a4f531e89ff8e5d219b02d8ccd3c0687907..0b6968980bedb1243811fb6fe4de56188c80c94b 100644 (file)
@@ -243,7 +243,9 @@ archive_read_support_format_cpio(struct archive *_a)
            archive_read_format_cpio_read_data,
            archive_read_format_cpio_skip,
            NULL,
-           archive_read_format_cpio_cleanup);
+           archive_read_format_cpio_cleanup,
+           NULL,
+           NULL);
 
        if (r != ARCHIVE_OK)
                free(cpio);
index 3660738209754d884bec0e04d6029ccf98ba9cc7..c641eb9b150e9ee548e64408252b6fced9b06e2c 100644 (file)
@@ -54,6 +54,8 @@ archive_read_support_format_empty(struct archive *_a)
            archive_read_format_empty_read_data,
            NULL,
            NULL,
+           NULL,
+           NULL,
            NULL);
 
        return (r);
index 914bc71dfed546710f9d512abd8ec2b0986a05d2..86d07fecbb5ead771cde7f1806b84d33f9049286 100644 (file)
@@ -478,7 +478,9 @@ archive_read_support_format_iso9660(struct archive *_a)
            archive_read_format_iso9660_read_data,
            archive_read_format_iso9660_read_data_skip,
            NULL,
-           archive_read_format_iso9660_cleanup);
+           archive_read_format_iso9660_cleanup,
+           NULL,
+           NULL);
 
        if (r != ARCHIVE_OK) {
                free(iso9660);
index f702949fb8c1ec593c55b5dda02da37e66961654..b88731afa8c608378a6b85ea59b48b06e7c820b0 100644 (file)
@@ -320,7 +320,9 @@ archive_read_support_format_lha(struct archive *_a)
            archive_read_format_lha_read_data,
            archive_read_format_lha_read_data_skip,
            NULL,
-           archive_read_format_lha_cleanup);
+           archive_read_format_lha_cleanup,
+           NULL,
+           NULL);
 
        if (r != ARCHIVE_OK)
                free(lha);
index c4e7021a869bbe9ce5d0ce4df6210f4763810dde..e10ef4f96994dee7347b696de6950da40c54d78d 100644 (file)
@@ -205,7 +205,7 @@ archive_read_support_format_mtree(struct archive *_a)
        mtree->fd = -1;
 
        r = __archive_read_register_format(a, mtree, "mtree",
-           mtree_bid, NULL, read_header, read_data, skip, NULL, cleanup);
+           mtree_bid, NULL, read_header, read_data, skip, NULL, cleanup, NULL, NULL);
 
        if (r != ARCHIVE_OK)
                free(mtree);
index 99c57a0fc0ebb3e0b977489a6d5ed609922d3922..88195a94f8418354cd3ac4a8c9481fc598d1de1b 100644 (file)
@@ -304,8 +304,15 @@ struct rar
     ssize_t             avail_in;
     const unsigned char *next_in;
   } br;
+  
+  /*
+   * Custom field to denote that this archive contains encrypted entries
+   */
+  char has_encrypted_entries;
 };
 
+static int archive_read_support_format_rar_capabilities(struct archive_read *);
+static int archive_read_format_rar_has_encrypted_entries(struct archive_read *);
 static int archive_read_format_rar_bid(struct archive_read *, int);
 static int archive_read_format_rar_options(struct archive_read *,
     const char *, const char *);
@@ -655,13 +662,36 @@ archive_read_support_format_rar(struct archive *_a)
                                      archive_read_format_rar_read_data,
                                      archive_read_format_rar_read_data_skip,
                                      archive_read_format_rar_seek_data,
-                                     archive_read_format_rar_cleanup);
+                                     archive_read_format_rar_cleanup,
+                                     archive_read_support_format_rar_capabilities,
+                                     archive_read_format_rar_has_encrypted_entries);
 
   if (r != ARCHIVE_OK)
     free(rar);
   return (r);
 }
 
+static int
+archive_read_support_format_rar_capabilities(struct archive_read * a)
+{
+       (void)a; /* UNUSED */
+       return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
+                       | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+static int
+archive_read_format_rar_has_encrypted_entries(struct archive_read *_a)
+{
+       if (_a && _a->format) {
+               struct rar * rar = (struct rar *)_a->format->data;
+               if (rar && rar->has_encrypted_entries) {
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+
 static int
 archive_read_format_rar_bid(struct archive_read *a, int best_bid)
 {
@@ -857,9 +887,14 @@ archive_read_format_rar_read_header(struct archive_read *a,
                             sizeof(rar->reserved2));
       }
 
+      /* Main header is password encrytped, so we cannot read any
+         file names or any other info about files from the header. */
       if (rar->main_flags & MHD_PASSWORD)
       {
-        archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+        archive_entry_set_is_metadata_encrypted(entry, 1);
+        archive_entry_set_is_data_encrypted(entry, 1);
+        rar->has_encrypted_entries = 1;
+         archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                           "RAR encryption support unavailable.");
         return (ARCHIVE_FATAL);
       }
@@ -1290,9 +1325,14 @@ read_header(struct archive_read *a, struct archive_entry *entry,
 
   if (rar->file_flags & FHD_PASSWORD)
   {
+       archive_entry_set_is_data_encrypted(entry, 1);
+       rar->has_encrypted_entries = 1;
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                       "RAR encryption support unavailable.");
-    return (ARCHIVE_FATAL);
+    /* Since it is only the data part itself that is encrypted we can at least
+       extract information about the currently processed entry and don't need
+       to return ARCHIVE_FATAL here. */
+    /*return (ARCHIVE_FATAL);*/
   }
 
   if (rar->file_flags & FHD_LARGE)
index 843497878a368cf1574dcc4d2a74d2cbf32a487b..efa2c6a33c7e8b2dd23fb4b6e38138c17df3bf67 100644 (file)
@@ -78,7 +78,9 @@ archive_read_support_format_raw(struct archive *_a)
            archive_read_format_raw_read_data,
            archive_read_format_raw_read_data_skip,
            NULL,
-           archive_read_format_raw_cleanup);
+           archive_read_format_raw_cleanup,
+           NULL,
+           NULL);
        if (r != ARCHIVE_OK)
                free(info);
        return (r);
index 95960a2c1833c532eb238b44a5a4d8fca997d64c..603ea3f9787826fb170cd785983aba1a242d1018 100644 (file)
@@ -254,7 +254,9 @@ archive_read_support_format_tar(struct archive *_a)
            archive_read_format_tar_read_data,
            archive_read_format_tar_skip,
            NULL,
-           archive_read_format_tar_cleanup);
+           archive_read_format_tar_cleanup,
+           NULL,
+           NULL);
 
        if (r != ARCHIVE_OK)
                free(tar);
index 6a9e1923be6937d99c3f45b27a1c5f833cd4d550..b0f5352212a8fc0b6ded91f59a433f9844cf487f 100644 (file)
@@ -468,7 +468,9 @@ archive_read_support_format_xar(struct archive *_a)
            xar_read_data,
            xar_read_data_skip,
            NULL,
-           xar_cleanup);
+           xar_cleanup,
+           NULL,
+           NULL);
        if (r != ARCHIVE_OK)
                free(xar);
        return (r);
index 84e545e0f56c5181f730e91e6eb28e93da828439..6a77dd7e77b13ebe6d250478f220aa52da18f307 100644 (file)
@@ -74,9 +74,11 @@ struct zip {
        int64_t                 end_of_central_directory_offset;
        int64_t                 central_directory_offset;
        size_t                  central_directory_size;
-       size_t                  central_directory_entries;
+       size_t                  central_directory_entries_total;
+       size_t                  central_directory_entries_on_this_disk;
        char                    have_central_directory;
        int64_t                 offset;
+       char                    has_encrypted_entries;
 
        /* List of entries (seekable Zip only) */
        size_t                  entries_remaining;
@@ -120,10 +122,16 @@ struct zip {
 };
 
 #define ZIP_LENGTH_AT_END      8
-#define ZIP_ENCRYPTED          (1<<0)  
-#define ZIP_STRONG_ENCRYPTED   (1<<6)  
-#define ZIP_UTF8_NAME          (1<<11) 
-
+#define ZIP_ENCRYPTED  (1<<0)
+#define ZIP_STRONG_ENCRYPTED   (1<<6)
+/* See "7.2 Single Password Symmetric Encryption Method"
+   in http://www.pkware.com/documents/casestudies/APPNOTE.TXT */
+#define ZIP_CENTRAL_DIRECTORY_ENCRYPTED        (1<<13) 
+#define ZIP_UTF8_NAME  (1<<11) 
+
+static int     archive_read_format_zip_has_encrypted_entries(struct archive_read *);
+static int     archive_read_support_format_zip_capabilities_seekable(struct archive_read *a);
+static int     archive_read_support_format_zip_capabilities_streamable(struct archive_read *a);
 static int     archive_read_format_zip_streamable_bid(struct archive_read *,
                    int);
 static int     archive_read_format_zip_seekable_bid(struct archive_read *,
@@ -182,7 +190,9 @@ archive_read_support_format_zip_streamable(struct archive *_a)
            archive_read_format_zip_read_data,
            archive_read_format_zip_read_data_skip,
            NULL,
-           archive_read_format_zip_cleanup);
+           archive_read_format_zip_cleanup,
+           archive_read_support_format_zip_capabilities_streamable,
+           archive_read_format_zip_has_encrypted_entries);
 
        if (r != ARCHIVE_OK)
                free(zip);
@@ -216,13 +226,42 @@ archive_read_support_format_zip_seekable(struct archive *_a)
            archive_read_format_zip_read_data,
            archive_read_format_zip_read_data_skip,
            NULL,
-           archive_read_format_zip_cleanup);
+           archive_read_format_zip_cleanup,
+           archive_read_support_format_zip_capabilities_seekable,
+           archive_read_format_zip_has_encrypted_entries);
 
        if (r != ARCHIVE_OK)
                free(zip);
        return (ARCHIVE_OK);
 }
 
+static int
+archive_read_support_format_zip_capabilities_seekable(struct archive_read * a)
+{
+       (void)a; /* UNUSED */
+       return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+static int
+archive_read_support_format_zip_capabilities_streamable(struct archive_read * a)
+{
+       (void)a; /* UNUSED */
+       return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+
+static int
+archive_read_format_zip_has_encrypted_entries(struct archive_read *_a)
+{
+       if (_a && _a->format) {
+               struct zip * zip = (struct zip *)_a->format->data;
+               if (zip && zip->has_encrypted_entries) {
+                       return 1;
+               }
+       }
+       return 0;
+}
+
 int
 archive_read_support_format_zip(struct archive *a)
 {
@@ -307,18 +346,20 @@ archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
                if (!found)
                        return 0;
        }
-
+    
        /* Since we've already done the hard work of finding the
           end of central directory record, let's save the important
           information. */
-       zip->central_directory_entries = archive_le16dec(p + 10);
+       zip->central_directory_entries_on_this_disk = archive_le16dec(p + 8);
+       zip->central_directory_entries_total = archive_le16dec(p + 10);
        zip->central_directory_size = archive_le32dec(p + 12);
        zip->central_directory_offset = archive_le32dec(p + 16);
        zip->end_of_central_directory_offset = filesize;
-
+       
        /* Just one volume, so central dir must all be on this volume. */
-       if (zip->central_directory_entries != archive_le16dec(p + 8))
+       if (zip->central_directory_entries_total != zip->central_directory_entries_on_this_disk) {
                return 0;
+       }
        /* Central directory can't extend beyond end of this file. */
        if (zip->central_directory_offset +
            (int64_t)zip->central_directory_size > filesize)
@@ -435,9 +476,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
        __archive_rb_tree_init(&zip->tree, &rb_ops);
        __archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops);
 
-       zip->zip_entries = calloc(zip->central_directory_entries,
+       zip->zip_entries = calloc(zip->central_directory_entries_total,
                                sizeof(struct zip_entry));
-       for (i = 0; i < zip->central_directory_entries; ++i) {
+       for (i = 0; i < zip->central_directory_entries_total; ++i) {
                struct zip_entry *zip_entry = &zip->zip_entries[i];
                size_t filename_length, extra_length, comment_length;
                uint32_t external_attributes;
@@ -455,6 +496,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
                zip_entry->system = p[5];
                /* version_required = archive_le16dec(p + 6); */
                zip_entry->flags = archive_le16dec(p + 8);
+               if (zip_entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)){
+                       zip->has_encrypted_entries = 1;
+               }
                zip_entry->compression = (char)archive_le16dec(p + 10);
                zip_entry->mtime = zip_time(p + 12);
                zip_entry->crc32 = archive_le32dec(p + 16);
@@ -468,7 +512,7 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
                external_attributes = archive_le32dec(p + 38);
                zip_entry->local_header_offset =
                    archive_le32dec(p + 42) + correction;
-
+               
                /* If we can't guess the mode, leave it zero here;
                   when we read the local file header we might get
                   more information. */
@@ -520,7 +564,6 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
                        __archive_rb_tree_insert_node(&zip->tree,
                            &zip_entry->node);
                }
-
                /* We don't read the filename until we get to the
                   local file header.  Reading it here would speed up
                   table-of-contents operations (removing the need to
@@ -700,7 +743,7 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a,
 
        if (zip->zip_entries == NULL) {
                r = slurp_central_directory(a, zip);
-               zip->entries_remaining = zip->central_directory_entries;
+               zip->entries_remaining = zip->central_directory_entries_total;
                if (r != ARCHIVE_OK)
                        return r;
                /* Get first entry whose local header offset is lower than
@@ -716,7 +759,7 @@ archive_read_format_zip_seekable_read_header(struct archive_read *a,
        if (zip->entries_remaining <= 0 || zip->entry == NULL)
                return ARCHIVE_EOF;
        --zip->entries_remaining;
-
+       
        if (zip->entry->rsrcname.s)
                rsrc = (struct zip_entry *)__archive_rb_tree_find_node(
                    &zip->tree_rsrc, zip->entry->rsrcname.s);
@@ -989,6 +1032,16 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
        version = p[4];
        zip_entry->system = p[5];
        zip_entry->flags = archive_le16dec(p + 6);
+       if (zip_entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
+               zip->has_encrypted_entries = 1;
+               archive_entry_set_is_data_encrypted(entry, 1);
+               if (zip_entry->flags & ZIP_CENTRAL_DIRECTORY_ENCRYPTED &&
+                       zip_entry->flags & ZIP_ENCRYPTED &&
+                       zip_entry->flags & ZIP_STRONG_ENCRYPTED) {
+                       archive_entry_set_is_metadata_encrypted(entry, 1);
+                       return ARCHIVE_FATAL;
+        }
+       }       
        zip_entry->compression = (char)archive_le16dec(p + 8);
        zip_entry->mtime = zip_time(p + 10);
        local_crc32 = archive_le32dec(p + 14);
@@ -1211,6 +1264,7 @@ archive_read_format_zip_read_data(struct archive_read *a,
                return (ARCHIVE_EOF);
 
        if (zip->entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
+               zip->has_encrypted_entries = 1;
                archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                    "Encrypted file is unsupported");
                return (ARCHIVE_FAILED);
@@ -1602,9 +1656,9 @@ archive_read_format_zip_cleanup(struct archive_read *a)
        if (zip->stream_valid)
                inflateEnd(&zip->stream);
 #endif
-       if (zip->zip_entries && zip->central_directory_entries) {
+       if (zip->zip_entries && zip->central_directory_entries_total) {
                unsigned i;
-               for (i = 0; i < zip->central_directory_entries; i++)
+               for (i = 0; i < zip->central_directory_entries_total; i++)
                        archive_string_free(&(zip->zip_entries[i].rsrcname));
        }
        free(zip->zip_entries);
index dadea4c6917afa69ecebb5cb894745378f34dd9a..dc36cc89755799e89b9510eb8d31c8795dfd427b 100644 (file)
@@ -87,6 +87,9 @@ IF(ENABLE_TEST)
     test_read_filter_program_signature.c
     test_read_filter_uudecode.c
     test_read_format_7zip.c
+    test_read_format_7zip_encryption_data.c
+    test_read_format_7zip_encryption_partially.c
+    test_read_format_7zip_encryption_header.c
     test_read_format_ar.c
     test_read_format_cab.c
     test_read_format_cab_filename.c
@@ -127,6 +130,9 @@ IF(ENABLE_TEST)
     test_read_format_mtree.c
     test_read_format_pax_bz2.c
     test_read_format_rar.c
+    test_read_format_rar_encryption_data.c
+    test_read_format_rar_encryption_partially.c
+    test_read_format_rar_encryption_header.c
     test_read_format_raw.c
     test_read_format_tar.c
     test_read_format_tar_empty_pax.c
@@ -141,6 +147,9 @@ IF(ENABLE_TEST)
     test_read_format_xar.c
     test_read_format_zip.c
     test_read_format_zip_comment_stored.c
+    test_read_format_zip_encryption_data.c
+    test_read_format_zip_encryption_partially.c
+    test_read_format_zip_encryption_header.c
     test_read_format_zip_filename.c
     test_read_format_zip_mac_metadata.c
     test_read_format_zip_sfx.c
index 62657a82165a9b0c32acce24212937a710919552..eb79852c38dcc66808103596265532a6989de1fe 100644 (file)
@@ -50,6 +50,8 @@ test_copy()
        assertEqualString("file1", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(60, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(60, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "    ", 4);
 
@@ -122,6 +124,8 @@ test_empty_file()
        assertEqualString("empty", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualInt(1, archive_file_count(a));
 
@@ -161,6 +165,8 @@ test_plain_header(const char *refname)
        assertEqualString("file1", archive_entry_pathname(ae));
        assertEqualInt(1322058763, archive_entry_mtime(ae));
        assertEqualInt(2844, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(sizeof(buff), archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "The libarchive distribution ", 28);
 
@@ -202,6 +208,8 @@ test_extract_all_files(const char *refname)
        assertEqualString("dir1/file1", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(13, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(13, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\n", 13);
 
@@ -211,6 +219,8 @@ test_extract_all_files(const char *refname)
        assertEqualString("file2", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(26, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(26, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\n", 26);
 
@@ -220,6 +230,8 @@ test_extract_all_files(const char *refname)
        assertEqualString("file3", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(39, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(39, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\n", 39);
 
@@ -229,6 +241,8 @@ test_extract_all_files(const char *refname)
        assertEqualString("file4", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(52, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(52, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff,
            "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52);
@@ -238,6 +252,8 @@ test_extract_all_files(const char *refname)
        assertEqualInt((AE_IFDIR | 0755), archive_entry_mode(ae));
        assertEqualString("dir1/", archive_entry_pathname(ae));
        assertEqualInt(2764801, archive_entry_mtime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualInt(5, archive_file_count(a));
 
@@ -277,6 +293,8 @@ test_extract_last_file(const char *refname)
        assertEqualString("dir1/file1", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(13, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file2. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -284,6 +302,8 @@ test_extract_last_file(const char *refname)
        assertEqualString("file2", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(26, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file3. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -291,6 +311,8 @@ test_extract_last_file(const char *refname)
        assertEqualString("file3", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(39, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file4. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -298,6 +320,8 @@ test_extract_last_file(const char *refname)
        assertEqualString("file4", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(52, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(52, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff,
            "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52);
@@ -307,6 +331,8 @@ test_extract_last_file(const char *refname)
        assertEqualInt((AE_IFDIR | 0755), archive_entry_mode(ae));
        assertEqualString("dir1/", archive_entry_pathname(ae));
        assertEqualInt(2764801, archive_entry_mtime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualInt(5, archive_file_count(a));
 
@@ -347,6 +373,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("dir1/file1", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(13, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(13, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\n", 13);
 
@@ -356,6 +384,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("file2", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(26, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(26, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\n", 26);
 
@@ -365,6 +395,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("file3", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(39, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(39, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\n", 39);
 
@@ -374,6 +406,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("file4", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(52, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(52, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff,
            "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52);
@@ -384,6 +418,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("dir1/zfile1", archive_entry_pathname(ae));
        assertEqualInt(5184001, archive_entry_mtime(ae));
        assertEqualInt(13, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(13, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\n", 13);
 
@@ -393,6 +429,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("zfile2", archive_entry_pathname(ae));
        assertEqualInt(5184001, archive_entry_mtime(ae));
        assertEqualInt(26, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(26, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\n", 26);
 
@@ -402,6 +440,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("zfile3", archive_entry_pathname(ae));
        assertEqualInt(5184001, archive_entry_mtime(ae));
        assertEqualInt(39, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(39, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\n", 39);
 
@@ -411,6 +451,8 @@ test_extract_all_files2(const char *refname)
        assertEqualString("zfile4", archive_entry_pathname(ae));
        assertEqualInt(5184001, archive_entry_mtime(ae));
        assertEqualInt(52, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(52, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff,
            "aaaaaaaaaaaa\nbbbbbbbbbbbb\ncccccccccccc\ndddddddddddd\n", 52);
@@ -420,6 +462,8 @@ test_extract_all_files2(const char *refname)
        assertEqualInt((AE_IFDIR | 0755), archive_entry_mode(ae));
        assertEqualString("dir1/", archive_entry_pathname(ae));
        assertEqualInt(2764801, archive_entry_mtime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualInt(9, archive_file_count(a));
 
@@ -460,6 +504,8 @@ test_delta_lzma(const char *refname)
        assertEqualString("file1", archive_entry_pathname(ae));
        assertEqualInt(172802, archive_entry_mtime(ae));
        assertEqualInt(27627, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        remaining = (size_t)archive_entry_size(ae);
        while (remaining) {
                if (remaining < sizeof(buff))
@@ -514,6 +560,8 @@ test_bcj(const char *refname)
        assertEqualString("x86exe", archive_entry_pathname(ae));
        assertEqualInt(172802, archive_entry_mtime(ae));
        assertEqualInt(27328, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        remaining = (size_t)archive_entry_size(ae);
        while (remaining) {
                if (remaining < sizeof(buff))
@@ -569,6 +617,8 @@ test_ppmd()
        assertEqualString("ppmd_test.txt", archive_entry_pathname(ae));
        assertEqualInt(1322464589, archive_entry_mtime(ae));
        assertEqualInt(102400, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        remaining = (size_t)archive_entry_size(ae);
        while (remaining) {
                if (remaining < sizeof(buff))
@@ -619,6 +669,8 @@ test_symname()
        assertEqualString("file1", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(32, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(32, archive_read_data(a, buff, sizeof(buff)));
        assertEqualMem(buff, "hellohellohello\nhellohellohello\n", 32);
 
@@ -628,6 +680,8 @@ test_symname()
        assertEqualString("symlinkfile", archive_entry_pathname(ae));
        assertEqualString("file1", archive_entry_symlink(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualInt(2, archive_file_count(a));
 
diff --git a/libarchive/test/test_read_format_7zip_encryption.7z.uu b/libarchive/test/test_read_format_7zip_encryption.7z.uu
new file mode 100644 (file)
index 0000000..5122679
--- /dev/null
@@ -0,0 +1,7 @@
+begin 664 test_read_format_7zip_encryption.7z
+M-WJ\KR<<``."K^J($`````````!A`````````%C_;&JY#8C0K"UKHUJ[Y37?
+MT4'9`00&``$)$``'"P$``B0&\0<!"E,'V61M9)J_#M4C`P$!!5T```$``0`,
+M"`0`"`H!J&4R?@``!0$1$0!B`&$`<@`N`'0`>`!T````%`H!``"&-JAYL,X!
+*%08!`""`M($`````
+`
+end
diff --git a/libarchive/test/test_read_format_7zip_encryption_data.c b/libarchive/test/test_read_format_7zip_encryption_data.c
new file mode 100644 (file)
index 0000000..4820da7
--- /dev/null
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD");
+
+DEFINE_TEST(test_read_format_7zip_encryption_data)
+{
+       /* This file is password protected (encrypted) with AES-256. The headers
+          are NOT encrypted. Password is "12345678". */
+       const char *refname = "test_read_format_7zip_encryption.7z";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, 
+               archive_read_open_filename(a, refname, 10240));
+
+       /* Verify encrypted file "bar.txt". */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae));
+       assertEqualString("bar.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379073980, archive_entry_mtime(ae));
+       assertEqualInt(4, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+
+       assertEqualInt(1, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_7ZIP, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
diff --git a/libarchive/test/test_read_format_7zip_encryption_header.7z.uu b/libarchive/test/test_read_format_7zip_encryption_header.7z.uu
new file mode 100644 (file)
index 0000000..cdabd24
--- /dev/null
@@ -0,0 +1,8 @@
+begin 664 test_read_format_7zip_encryption_header.7z
+M-WJ\KR<<``-1(7)]@``````````F`````````!I:QVF.6KJ?=[:U9:-!,8A0
+MB6O0&LG!?DD:R_'07!.!NV;/LY)*FIFWXUI[)=TPG&";5C%<HF+_9E78TWJ!
+M5Q=ZF(.88]0Y3<U4PI>*%S+LERGW+.D%XK*'>5.FQ>74JN]"%`5%TTQ[@L^#
+MZVV`LJT"<VY^#I<U<O#)7:DEX*#)1,]DQA<&$`$)<``'"P$``20&\0<!"E,'
+23QKRY44=+M(,80H!^V/0)@``
+`
+end
diff --git a/libarchive/test/test_read_format_7zip_encryption_header.c b/libarchive/test/test_read_format_7zip_encryption_header.c
new file mode 100644 (file)
index 0000000..54054c8
--- /dev/null
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD");
+
+
+DEFINE_TEST(test_read_format_7zip_encryption_header)
+{
+       /* This file is password protected (encrypted) with AES-256. The headers
+          ARE encrypted. Password is "12345678". */
+       const char *refname = "test_read_format_7zip_encryption_header.7z";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK,
+           archive_read_open_filename(a, refname, 10240));
+
+       /* Verify regular file but with encrypted headers
+          as a consequence, all meta information is invalid. */
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
+       
+       assertEqualInt(0, archive_entry_mode(ae));
+       assertEqualString(NULL, archive_entry_pathname(ae));
+       assertEqualInt(0, archive_entry_mtime(ae));
+       assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(1, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+
+       assertEqualInt(1, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_7ZIP, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
diff --git a/libarchive/test/test_read_format_7zip_encryption_partially.7z.uu b/libarchive/test/test_read_format_7zip_encryption_partially.7z.uu
new file mode 100644 (file)
index 0000000..ad98dce
--- /dev/null
@@ -0,0 +1,8 @@
+begin 664 test_read_format_7zip_encryption_partially.7z
+M-WJ\KR<<``-.Y/D@G``````````B`````````)D0(6<`,QOL%````&2Q`&1E
+M$MIXH*@X+XD>61@``($S!ZXQF+DAMZ?L<`,6_>V19<3;V2;&..`F/OY`DLGI
+MB?L"X_1-'%<>!(3'6&[GTF&K$I`20KWW0T2OU80/'3WLJ@2\\?YH6A7J\T["
+M5JH6Y6_..SN-L'T>$^";VM@^(Y(^]N\E588GW68QK>M[C@$[AM@/<+RH]Q!&
+J"GI1?FZ````7!A@!"8"$``<+`0`!(P,!`05=`!````R`N@H!F[7,7```
+`
+end
diff --git a/libarchive/test/test_read_format_7zip_encryption_partially.c b/libarchive/test/test_read_format_7zip_encryption_partially.c
new file mode 100644 (file)
index 0000000..31252fc
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD");
+
+DEFINE_TEST(test_read_format_7zip_encryption_partially)
+{
+       /* This file is password protected (encrypted) with AES-256. The headers
+          are NOT encrypted. Password is "12345678". It contains one encrypted
+          and one unencrypted file. */
+       const char *refname = "test_read_format_7zip_encryption_partially.7z";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK,
+           archive_read_open_filename(a, refname, 10240));
+
+       /* Verify regular unencrypted file1. */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae));
+       assertEqualString("bar_unencrypted.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379079541, archive_entry_mtime(ae));    
+       assertEqualInt(4, archive_entry_size(ae));
+       assertEqualInt(0, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 0, archive_read_has_encrypted_entries(a));
+       assertEqualInt(4, archive_read_data(a, buff, sizeof(buff)));
+       
+       /* Verify regular encrypted file2. */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae));
+       assertEqualString("bar_encrypted.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379079565, archive_entry_mtime(ae));
+       assertEqualInt(4, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+
+       assertEqualInt(2, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_7ZIP, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
index e70d1ae552bf181c4b53e14e12000dac52451fe6..55e8b318f96a540205df925e7a71ff1710ab4431 100644 (file)
@@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_ar)
        assertEqualInt(0, archive_entry_uid(ae));
        assertEqualInt(0, archive_entry_gid(ae));
        assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* First Entry */
        assertA(0 == archive_read_next_header(a, &ae));
@@ -59,6 +61,8 @@ DEFINE_TEST(test_read_format_ar)
        assert(8 == archive_entry_size(ae));
        assertA(8 == archive_read_data(a, buff, 10));
        assertEqualMem(buff, "55667788", 8);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Second Entry */
        assertA(0 == archive_read_next_header(a, &ae));
@@ -69,6 +73,8 @@ DEFINE_TEST(test_read_format_ar)
        assert(4 == archive_entry_size(ae));
        assertA(4 == archive_read_data(a, buff, 10));
        assertEqualMem(buff, "3333", 4);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Third Entry */
        assertA(0 == archive_read_next_header(a, &ae));
index e09d46d238358d11c98ca535578b34a92165e15d..8b77d898e5a058efc41d4030a8bd9c8214133ec2 100644 (file)
@@ -204,6 +204,8 @@ verify(const char *refname, enum comp_type comp)
        assertEqualInt(0, archive_entry_uid(ae));
        assertEqualInt(0, archive_entry_gid(ae));
        assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        if (comp != STORE) {
                /* Verify regular zero.
@@ -215,6 +217,8 @@ verify(const char *refname, enum comp_type comp)
                assertEqualString("zero", archive_entry_pathname(ae));
                assertEqualInt(0, archive_entry_uid(ae));
                assertEqualInt(0, archive_entry_gid(ae));
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
                assertEqualInt(33000, archive_entry_size(ae));
                for (s = 0; s + sizeof(buff) < 33000; s+= sizeof(buff)) {
                        ssize_t rsize = archive_read_data(a, buff, sizeof(buff));
@@ -236,6 +240,8 @@ verify(const char *refname, enum comp_type comp)
        assertEqualString("dir1/file1", archive_entry_pathname(ae));
        assertEqualInt(0, archive_entry_uid(ae));
        assertEqualInt(0, archive_entry_gid(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(file1_size, archive_entry_size(ae));
        assertEqualInt(file1_size, archive_read_data(a, buff, file1_size));
        assertEqualMem(buff, file1, file1_size);
@@ -246,6 +252,8 @@ verify(const char *refname, enum comp_type comp)
        assertEqualString("dir2/file2", archive_entry_pathname(ae));
        assertEqualInt(0, archive_entry_uid(ae));
        assertEqualInt(0, archive_entry_gid(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(file2_size, archive_entry_size(ae));
        assertEqualInt(file2_size, archive_read_data(a, buff, file2_size));
        assertEqualMem(buff, file2, file2_size);
@@ -295,11 +303,17 @@ verify2(const char *refname, enum comp_type comp)
 
        /* Verify regular empty. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        if (comp != STORE) {
                assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        }
        /* Verify regular file1. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file2. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -349,14 +363,22 @@ verify3(const char *refname, enum comp_type comp)
 
        /* Verify regular empty. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        if (comp != STORE) {
                assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        }
        /* Verify regular file1. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file2. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
index f148590ff508a5a0e18965230a32f98c850a5f71..885f750a07365000e51147970651fc128ed7eb0e 100644 (file)
@@ -58,6 +58,8 @@ test_read_format_cab_filename_CP932_eucJP(const char *refname)
            "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb4\xc1\xbb\xfa\x2e\x74\x78\x74",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -65,6 +67,8 @@ test_read_format_cab_filename_CP932_eucJP(const char *refname)
            "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb0\xec\xcd\xf7\xc9\xbd\x2e\x74\x78\x74",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -122,6 +126,8 @@ test_read_format_cab_filename_CP932_UTF8(const char *refname)
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
 #endif
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -139,6 +145,8 @@ test_read_format_cab_filename_CP932_UTF8(const char *refname)
            archive_entry_pathname(ae));
 #endif
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
index db6003f95a603b7f6e941cb27e32da043032b431..f5c4a3d273797a098356bf9e1750327b78eb0d2c 100644 (file)
@@ -98,6 +98,8 @@ DEFINE_TEST(test_read_format_cpio_afio)
         */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualInt(17, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE);
        assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX);
        /*
@@ -107,6 +109,8 @@ DEFINE_TEST(test_read_format_cpio_afio)
        assertEqualInt(17, archive_entry_size(ae));
        if (uid_size() > 4)
                assertEqualInt(65536, archive_entry_uid(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE);
        assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_AFIO_LARGE);
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
index e65cb9b3870c86f99d9bb4ff40bc5435781e5526..26980d7a57f85bd089a03c59318a83ff5707becb 100644 (file)
@@ -52,6 +52,8 @@ DEFINE_TEST(test_read_format_cpio_bin)
        assertEqualIntA(a, 0, archive_read_open_memory(a, archive, sizeof(archive)));
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
        assertEqualInt(1, archive_file_count(a));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
        assertEqualIntA(a, ARCHIVE_FORMAT_CPIO_BIN_LE, archive_format(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
index 8aca71f2476db64a58216729c1b52a35c8d15591..d6c515065f3533bc2da270b718632d3d48170385 100644 (file)
@@ -51,6 +51,8 @@ DEFINE_TEST(test_read_format_cpio_bin_Z)
        failure("archive_format_name(a)=\"%s\"",
            archive_format_name(a));
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index dfd664c9a4d2a0644f19fbf11c90ed6c4b57ec03..c114b50959a2d4efa0c64b465843f5aa117bad00 100644 (file)
@@ -44,6 +44,8 @@ DEFINE_TEST(test_read_format_cpio_bin_be)
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
        assertEqualInt(archive_entry_uid(ae), 1000);
        assertEqualInt(archive_entry_gid(ae), 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_BE);
index 8afbbcd1ebc1d0cef6f2a6aa77bbb505c21193e1..58637b3a1880c482d9c995e10c074aaf4e8cd061 100644 (file)
@@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_cpio_bin_bz2)
        assertEqualIntA(a, ARCHIVE_OK,
            archive_read_open_memory(a, archive, sizeof(archive)));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assert(archive_filter_code(a, 0) == ARCHIVE_FILTER_BZIP2);
        assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
index 98f53578e12930c900d1a28a78fda897ef1c4dc1..5aa8beb54e7bf9d51308e4401411c24ce7bbce80 100644 (file)
@@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_cpio_bin_gz)
        assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualInt(archive_filter_code(a, 0),
            ARCHIVE_FILTER_GZIP);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
index 4e3fb58722fefc49503c996133752b5027fecf8e..2f98b0084cf56a460ab78ae9806b0d52bc8494a3 100644 (file)
@@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_cpio_bin_lzip)
        assertEqualIntA(a, ARCHIVE_OK,
            archive_read_open_memory(a, archive, sizeof(archive)));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZIP);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
index cca19ffa7786a25c2abedc8a59727ca58927e327..2b61542bfa6a04c0d22775829d4adc4fb75d9770 100644 (file)
@@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_cpio_bin_lzma)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 2b5e6143ca5a71934d9545ed3688dab3e0d053b5..11546cc1c44c53f842212d1a178d144725df0abb 100644 (file)
@@ -64,6 +64,8 @@ DEFINE_TEST(test_read_format_cpio_bin_xz)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_XZ);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index d0c7c7afafffb68d6c8288dc2ed080734f6c7ad2..fc73c7dddcd57e0f462d9ccfc345d1d928b80d97 100644 (file)
@@ -57,11 +57,15 @@ test_read_format_cpio_filename_eucJP_UTF8(const char *refname)
        assertEqualString("\xe6\xbc\xa2\xe5\xad\x97.txt",
            archive_entry_pathname(ae));
        assertEqualInt(8, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xe8\xa1\xa8.txt", archive_entry_pathname(ae));
        assertEqualInt(4, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
index c608bf045a506f5644996dcaf55adf8c97d7b25f..ca22a836ba3b090461f4798839c42f3fa0d58874 100644 (file)
@@ -57,6 +57,8 @@ DEFINE_TEST(test_read_format_cpio_odc)
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
        assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE);
        assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index d069da39eb74702fd8abb9bb9c954c332dd91375..7a01ee3d297b2037777be51361d6d834e30610e9 100644 (file)
@@ -112,6 +112,8 @@ DEFINE_TEST(test_read_format_cpio_svr4_bzip2_rpm)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("./etc/file3", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify the end-of-archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
index 9b96234644ce72c5b43e772d0173c4b27c7c5ad0..0874be92c6d90e159c9a99ed7bfb01434c5ddc69 100644 (file)
@@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_cpio_svr4_gzip)
            ARCHIVE_FILTER_GZIP);
        assertEqualInt(archive_format(a),
            ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index eccde65ad53cc8fb5e7a255861a570fab0bbb1e5..3e6ae3146dbeb813f61f2edc2d98ab7c4714e910 100644 (file)
@@ -112,6 +112,8 @@ DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("./etc/file3", archive_entry_pathname(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify the end-of-archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
index c33cd07ef83c4ca016fae05532aad91a9f0f5811..cc4ded5fe3c2688b3f5569d045f15a57a62765e4 100644 (file)
@@ -51,6 +51,8 @@ DEFINE_TEST(test_read_format_cpio_svr4c_Z)
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS);
        failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_CRC);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index c27d57ad5a820f6608aac44d3eea31edb8a2dc7b..63a5e560820987a655862af5da6dfd79c512235b 100644 (file)
@@ -38,6 +38,8 @@ DEFINE_TEST(test_read_format_empty)
        assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
        assertA(archive_filter_code(a, 0) == ARCHIVE_FILTER_NONE);
        assertA(archive_format(a) == ARCHIVE_FORMAT_EMPTY);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 4b2a88c1ee0bc867b7fab7c2ebf7036338388480..64dc222edcdf6e81c7a7858853d80e6881083e67 100644 (file)
@@ -62,6 +62,8 @@ test_read_format_gtar_filename_eucJP_UTF8(const char *refname)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xe8\xa1\xa8.txt", archive_entry_pathname(ae));
        assertEqualInt(4, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
index 8d60de00754f6ae441013585e9c110eef47d6316..7d5576eff1d54866c15e220f069d8d330b99ca71 100644 (file)
@@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_gtar_gz)
        assertEqualInt(archive_filter_code(a, 0),
            ARCHIVE_FILTER_GZIP);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 5dfbb2c227f22f9a8437f4252fd8848887f13393..8b66ef321c6d88b93afb4adae3346d804e1e674b 100644 (file)
@@ -66,6 +66,8 @@ DEFINE_TEST(test_read_format_gtar_lzma)
            archive_read_next_header(a, &ae));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
 finish:
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
index 9a3511e9cc6a83ee8f649a4b2c3073f59f91a586..a7542314bebf071b58474660def90b616450e18d 100644 (file)
@@ -200,6 +200,8 @@ verify_archive_file(const char *name, struct archive_contents *ac)
                }
                failure("Name mismatch in archive %s", name);
                assertEqualString(ac->filename, archive_entry_pathname(ae));
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
                expect = *cts++;
                while (0 == (err = archive_read_data_block(a,
index 551e0cf3431c9d481b294b0f02288334982317e0..74f2181e21b1f1358457b18ce13b729751fdd516 100644 (file)
@@ -47,6 +47,8 @@ test1(void)
        assertEqualInt(archive_filter_code(a, 0),
            ARCHIVE_FILTER_COMPRESS);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
@@ -88,6 +90,8 @@ test2(void)
        assertEqualInt(archive_filter_code(a, 0),
            ARCHIVE_FILTER_COMPRESS);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 63b5cf7abb5d88dbc4f2372dce45444180ec07b0..54b0c600fc88704209349d20871b6c233ccc825e 100644 (file)
@@ -73,6 +73,8 @@ DEFINE_TEST(test_read_format_iso_multi_extent)
                        assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
                        assertEqualInt(1, archive_entry_uid(ae));
                        assertEqualInt(2, archive_entry_gid(ae));
+                       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+                       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
                } else {
                        failure("Saw a file that shouldn't have been there");
                        assertEqualString(archive_entry_pathname(ae), "");
index 13502605a2ba63810eec4a4ce1cb19ad15f5ad33..8303c6bf6ab56436805634efcd0b076d398f46ce 100644 (file)
@@ -86,6 +86,9 @@ DEFINE_TEST(test_read_format_iso_xorriso)
        for (i = 0; i < 10; ++i) {
                assertEqualInt(0, archive_read_next_header(a, &ae));
 
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+               
                if (strcmp(".", archive_entry_pathname(ae)) == 0) {
                        /* '.' root directory. */
                        assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
index 36239d121feae46d19ab77fc08d8833e2d325e5b..8f35d3f17cc40dd13b1256ba73630d51b2d0a1a2 100644 (file)
@@ -83,6 +83,8 @@ DEFINE_TEST(test_read_format_isojoliet_bz2)
        assertEqualIntA(a, ARCHIVE_EOF,
            archive_read_data_block(a, &p, &size, &offset));
        assertEqualInt((int)size, 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A directory. */
        assertEqualInt(0, archive_read_next_header(a, &ae));
@@ -91,6 +93,8 @@ DEFINE_TEST(test_read_format_isojoliet_bz2)
        assertEqualInt(2048, archive_entry_size(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(86401, archive_entry_atime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A regular file with two names ("hardlink" gets returned
         * first, so it's not marked as a hardlink). */
@@ -121,6 +125,8 @@ DEFINE_TEST(test_read_format_isojoliet_bz2)
        assertEqualInt(0, archive_entry_size(ae));
        assertEqualInt(172802, archive_entry_mtime(ae));
        assertEqualInt(172802, archive_entry_atime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
index 06f3f4fee488f3b2e4d35f05396cdd03a16c30d9..aad54e330f2ba265e54b774190c34d3c9ae832ac 100644 (file)
@@ -91,6 +91,8 @@ DEFINE_TEST(test_read_format_isojoliet_long)
        assertEqualIntA(a, ARCHIVE_EOF,
            archive_read_data_block(a, &p, &size, &offset));
        assertEqualInt((int)size, 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A directory. */
        pathname[100] = 'd';
@@ -103,6 +105,8 @@ DEFINE_TEST(test_read_format_isojoliet_long)
        assertEqualInt(2048, archive_entry_size(ae));
        assertEqualInt(86401, archive_entry_mtime(ae));
        assertEqualInt(86401, archive_entry_atime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A regular file with two names (pathname gets returned
         * first, so it's not marked as a hardlink). */
@@ -119,6 +123,8 @@ DEFINE_TEST(test_read_format_isojoliet_long)
        assertEqualInt(6, (int)size);
        assertEqualInt(0, offset);
        assertEqualMem(p, "hello\n", 6);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Second name for the same regular file (this happens to be
         * returned second, so does get marked as a hardlink). */
@@ -127,6 +133,8 @@ DEFINE_TEST(test_read_format_isojoliet_long)
        assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
        assertEqualString("hardlink", archive_entry_hardlink(ae));
        assert(!archive_entry_size_is_set(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
index ebf1b92d97f5ddb5ea0e79eb93ceb9ee48da21b9..b5562f9193464f88d835bf4f9705ff7d26e3bf0a 100644 (file)
@@ -83,6 +83,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr)
        assertEqualIntA(a, ARCHIVE_EOF,
            archive_read_data_block(a, &p, &size, &offset));
        assertEqualInt((int)size, 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A directory. */
        assertEqualInt(0, archive_read_next_header(a, &ae));
@@ -94,6 +96,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr)
        assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
        assertEqualInt(1, archive_entry_uid(ae));
        assertEqualInt(2, archive_entry_gid(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A regular file with two names ("hardlink" gets returned
         * first, so it's not marked as a hardlink). */
@@ -116,6 +120,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr)
        assertEqualInt(2, archive_entry_nlink(ae));
        assertEqualInt(1, archive_entry_uid(ae));
        assertEqualInt(2, archive_entry_gid(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Second name for the same regular file (this happens to be
         * returned second, so does get marked as a hardlink). */
@@ -132,6 +138,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr)
        assertEqualInt(2, archive_entry_nlink(ae));
        assertEqualInt(1, archive_entry_uid(ae));
        assertEqualInt(2, archive_entry_gid(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A symlink to the regular file. */
        assertEqualInt(0, archive_read_next_header(a, &ae));
@@ -145,6 +153,8 @@ DEFINE_TEST(test_read_format_isojoliet_rr)
        assertEqualInt(1, archive_entry_nlink(ae));
        assertEqualInt(1, archive_entry_uid(ae));
        assertEqualInt(2, archive_entry_gid(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
index 8fa974b9806f669d6cf904c99afb477112c0fd35..1b38f118c38d9c9cc31937bfaf072f9ed47bcf4d 100644 (file)
@@ -58,6 +58,8 @@ DEFINE_TEST(test_read_format_isojoliet_versioned)
        assertEqualInt(0, archive_read_next_header(a, &ae));
        assertEqualString("test", archive_entry_pathname(ae));
        assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* A regular file which is called test.txt and has
         * ;1 appended to it because apparently Nero always
@@ -69,6 +71,8 @@ DEFINE_TEST(test_read_format_isojoliet_versioned)
        assertEqualString("test/test.txt",
            archive_entry_pathname(ae));
        assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
index 1c16f3cb1ef7fc0edafd28ec7cbced8370c462ad..4c0e792f04cedb757635363af634573d57fb900c 100644 (file)
@@ -73,6 +73,9 @@ DEFINE_TEST(test_read_format_isorr_bz2)
         * verify that each one is what we expect. */
        for (i = 0; i < 10; ++i) {
                assertEqualInt(0, archive_read_next_header(a, &ae));
+               
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
                if (strcmp(".", archive_entry_pathname(ae)) == 0) {
                        /* '.' root directory. */
index c198643486643b8e20d7289519d4d8264265cef0..d0c1c5b63fa007b8f23347eec12b68c41ba85581 100644 (file)
@@ -109,6 +109,9 @@ DEFINE_TEST(test_read_format_isorr_ce)
         * verify that each one is what we expect. */
        for (i = 0; i < 8; ++i) {
                assertEqualInt(0, archive_read_next_header(a, &ae));
+               
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
                if (strcmp(".", archive_entry_pathname(ae)) == 0) {
                        /* '.' root directory. */
index 96fb0589340c409b3d19f9eda7403ccf5dc2cf59..f5c21410f230538866756b6e13136177b21795e0 100644 (file)
@@ -74,6 +74,9 @@ DEFINE_TEST(test_read_format_isorr_new_bz2)
         * verify that each one is what we expect. */
        for (i = 0; i < 10; ++i) {
                assertEqualInt(0, archive_read_next_header(a, &ae));
+               
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
                if (strcmp(".", archive_entry_pathname(ae)) == 0) {
                        /* '.' root directory. */
index 57e7e1f85951bb635d3420063b23fe4ff1ac5678..db9c736955d57a562482a340ba3852aaaaa8e3a5 100644 (file)
@@ -80,6 +80,9 @@ DEFINE_TEST(test_read_format_isorr_rr_moved)
        for (i = 0; i < 13; ++i) {
                assertEqualInt(0, archive_read_next_header(a, &ae));
 
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+               
                if (strcmp(".", archive_entry_pathname(ae)) == 0) {
                        /* '.' root directory. */
                        assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
index 50ad32c70b015390fd88d5a898d208df7b672507..4c12fa14c77a5dbdf0660ff8337fe1014f9817cd 100644 (file)
@@ -73,6 +73,9 @@ DEFINE_TEST(test_read_format_isozisofs_bz2)
        for (i = 0; i < 8; ++i) {
                assertEqualInt(0, archive_read_next_header(a, &ae));
 
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+               
                if (strcmp(".", archive_entry_pathname(ae)) == 0) {
                        /* '.' root directory. */
                        assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
index 36c5d080340a1a9c3caa03961f2ba885a9a7a1f4..7f443394b45615ca25cb429745f68f50e86b42bc 100644 (file)
@@ -169,6 +169,8 @@ verify(const char *refname, int posix)
        assertEqualIntA(a, ARCHIVE_EOF,
            archive_read_data_block(a, &pv, &s, &o));
        assertEqualInt(s, 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify directory2.  */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -181,6 +183,8 @@ verify(const char *refname, int posix)
        assertEqualIntA(a, ARCHIVE_EOF,
            archive_read_data_block(a, &pv, &s, &o));
        assertEqualInt(s, 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        if (posix) {
                /* Verify symbolic link file1. */
@@ -192,6 +196,8 @@ verify(const char *refname, int posix)
                assertEqualInt(uid, archive_entry_uid(ae));
                assertEqualInt(gid, archive_entry_gid(ae));
                assertEqualInt(0, archive_entry_size(ae));
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
                /* Verify symbolic link file2. */
                assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -202,6 +208,8 @@ verify(const char *refname, int posix)
                assertEqualInt(uid, archive_entry_uid(ae));
                assertEqualInt(gid, archive_entry_gid(ae));
                assertEqualInt(0, archive_entry_size(ae));
+               assertEqualInt(archive_entry_is_encrypted(ae), 0);
+               assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        }
 
        /* Verify regular file1. */
@@ -214,6 +222,8 @@ verify(const char *refname, int posix)
        assertEqualInt(file1_size, archive_entry_size(ae));
        assertEqualInt(file1_size, archive_read_data(a, buff, file1_size));
        assertEqualMem(buff, file1, file1_size);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file2. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -228,6 +238,8 @@ verify(const char *refname, int posix)
        assertEqualInt(file2_size, archive_entry_size(ae));
        assertEqualInt(file2_size, archive_read_data(a, buff, file2_size));
        assertEqualMem(buff, file2, file2_size);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify the number of files read. */
        if (posix) {
@@ -245,6 +257,10 @@ verify(const char *refname, int posix)
        } else {
                assertEqualInt(4, archive_file_count(a));
        }
+       
+       /* Verify encryption status */
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify archive format. */
        assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
index 67b6f3643843863cbaadc3f4743a7bb30ccb0883..1c068193589eca30bd7883f99edc7f31b93834ed 100644 (file)
@@ -68,12 +68,15 @@ test_read_format_lha_filename_CP932_eucJP(const char *refname)
        assertEqualString("\xB4\xC1\xBB\xFA\x2E\x74\x78\x74",
            archive_entry_pathname(ae));
        assertEqualInt(8, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xC9\xBD\x2E\x74\x78\x74", archive_entry_pathname(ae));
        assertEqualInt(4, archive_entry_size(ae));
-
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
index efedc415eb6dc8b8645adae69be60f1b2eb8ee31..3a02c4410035e7e5bb076457df0566556014adca 100644 (file)
@@ -76,63 +76,97 @@ test_read_format_mtree1(void)
        assertEqualInt(archive_entry_size(ae), 3);
        assertEqualInt(3, archive_read_data(a, buff, 3));
        assertEqualMem(buff, "hi\n", 3);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir");
        assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir/file with space");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "file with space");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3a");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3a/indir3a");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/fullindir2");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/indir2");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3b");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3b/indir3b");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "notindir");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/emptyfile");
        assertEqualInt(archive_entry_size(ae), 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/smallfile");
        assertEqualInt(archive_entry_size(ae), 1);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* TODO: Mtree reader should probably return ARCHIVE_WARN for this. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/toosmallfile");
        assertEqualInt(archive_entry_size(ae), -1);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/bigfile");
        assertEqualInt(archive_entry_size(ae), max_int64);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/toobigfile");
        /* Size in mtree is max_int64 + 1; should return max_int64. */
        assertEqualInt(archive_entry_size(ae), max_int64);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/veryoldfile");
@@ -143,12 +177,16 @@ test_read_format_mtree1(void)
        /* Simply asserting min_time - 1 > 0 breaks with some compiler optimizations. */
        t = min_time - 1;
        assert(t > 0);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* toooldfile is 1 sec older, which should overflow and get returned
         * with the same value. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/toooldfile");
        assertEqualInt(archive_entry_mtime(ae), min_time);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualInt(19, archive_file_count(a));
@@ -176,6 +214,8 @@ test_read_format_mtree2(void)
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE);
        assertEqualString(archive_entry_pathname(ae), "d");
        assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualInt(1, archive_file_count(a));
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
@@ -210,12 +250,18 @@ test_read_format_mtree3(void)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "a");
        assertEqualInt(archive_entry_filetype(ae), AE_IFREG);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "b");
        assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "c");
        assertEqualInt(archive_entry_filetype(ae), AE_IFREG);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualInt(3, archive_file_count(a));
@@ -255,23 +301,35 @@ DEFINE_TEST(test_read_format_mtree_filenames_only)
        assertEqualIntA(a, ARCHIVE_OK,
            archive_read_open_memory(a, archive, sizeof(archive)));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
-       assertEqualString(archive_entry_pathname(ae), "./a");
+       assertEqualString(archive_entry_pathname(ae), "./a");   
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./b");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./c");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./d");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./e");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./f");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0444);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualInt(6, archive_file_count(a));
@@ -313,16 +371,22 @@ DEFINE_TEST(test_read_format_mtree_nochange)
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
        assertEqualInt(archive_entry_mtime(ae), 123);
        assertEqualInt(archive_entry_size(ae), 5);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./b");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
        assertEqualInt(archive_entry_mtime(ae), 234);
        assertEqualInt(archive_entry_size(ae), 6);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./c");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
        assertEqualInt(archive_entry_mtime(ae), 345);
        assertEqualInt(archive_entry_size(ae), 7);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualInt(3, archive_file_count(a));
@@ -351,6 +415,8 @@ DEFINE_TEST(test_read_format_mtree_nochange)
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
        assertEqualInt(archive_entry_mtime(ae), 234);
        assertEqualInt(archive_entry_size(ae), 6);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "./c");
 #if !defined(_WIN32) || defined(__CYGWIN__)
@@ -358,6 +424,8 @@ DEFINE_TEST(test_read_format_mtree_nochange)
 #endif
        assert(archive_entry_mtime(ae) != 345);
        assertEqualInt(archive_entry_size(ae), 7);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualInt(3, archive_file_count(a));
@@ -399,41 +467,65 @@ DEFINE_TEST(test_read_format_mtree_nomagic_v1_form)
        assertEqualInt(archive_entry_size(ae), 3);
        assertEqualInt(3, archive_read_data(a, buff, 3));
        assertEqualMem(buff, "hi\n", 3);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir");
        assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir/file with space");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "file with space");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3a");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3a/indir3a");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/fullindir2");
        assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/indir2");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3b");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "dir2/dir3b/indir3b");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "notindir");
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualInt(12, archive_file_count(a));
index 48717fbd60e5fd89f31aa2b8ea2b452df090bbe3..f26b04ed5a59ea5885f624d13052c3780c66fef5 100644 (file)
@@ -60,6 +60,8 @@ DEFINE_TEST(test_read_format_pax_bz2)
        assertEqualInt(1, archive_file_count(a));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_BZIP2);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a,ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index dc234e05f7f797c12ff58b4b1dcfe351cc2cee38..e4e57f6add52f51826ecf5be995ebaf93c2fd38f 100644 (file)
@@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_rar_basic)
   assertEqualInt(33188, archive_entry_mode(ae));
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Second header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -64,6 +66,8 @@ DEFINE_TEST(test_read_format_rar_basic)
   assertEqualInt(41471, archive_entry_mode(ae));
   assertEqualString("test.txt", archive_entry_symlink(ae));
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Third header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -75,6 +79,8 @@ DEFINE_TEST(test_read_format_rar_basic)
   assertEqualInt(33188, archive_entry_mode(ae));
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Fourth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -84,6 +90,8 @@ DEFINE_TEST(test_read_format_rar_basic)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Fifth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -93,6 +101,8 @@ DEFINE_TEST(test_read_format_rar_basic)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -126,6 +136,8 @@ DEFINE_TEST(test_read_format_rar_subblock)
   assertEqualInt(33188, archive_entry_mode(ae));
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -159,6 +171,8 @@ DEFINE_TEST(test_read_format_rar_noeof)
   assertEqualInt(33188, archive_entry_mode(ae));
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -227,6 +241,8 @@ DEFINE_TEST(test_read_format_rar_unicode_UTF8)
   assertEqualInt(33188, archive_entry_mode(ae));
   assertEqualIntA(a, 5, archive_read_data(a, buff, 5));
   assertEqualMem(buff, test_txt, 5);
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Third header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -273,6 +289,8 @@ DEFINE_TEST(test_read_format_rar_unicode_UTF8)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(41453, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /* Sixth header */
@@ -283,6 +301,8 @@ DEFINE_TEST(test_read_format_rar_unicode_UTF8)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(16, archive_entry_size(ae));
   assertEqualInt(33204, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 16, archive_read_data(a, buff, sizeof(buff)));
 
   /* Test EOF */
@@ -328,6 +348,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Second header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -338,6 +360,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(5, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(5 == archive_read_data(a, buff, 5));
   assertEqualMem(buff, test_txt, 5);
 
@@ -349,6 +373,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Fourth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -356,6 +382,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Fifth header, which has a symbolic-link name in multi-byte characters. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -368,6 +396,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(41453, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /* Sixth header */
@@ -378,6 +408,8 @@ DEFINE_TEST(test_read_format_rar_unicode_CP932)
   assertA((int)archive_entry_mtime(ae));
   assertEqualInt(16, archive_entry_size(ae));
   assertEqualInt(33204, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 16, archive_read_data(a, buff, sizeof(buff)));
 
   /* Test EOF */
@@ -416,6 +448,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file1_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file1_size == archive_read_data(a, file1_buff, file1_size));
   assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1],
                  file1_test_txt, sizeof(file1_test_txt) - 1);
@@ -428,6 +462,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(41471, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae));
   assertEqualIntA(a, 0, archive_read_data(a, file1_buff, 30));
 
@@ -439,6 +475,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file2_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file2_size == archive_read_data(a, file2_buff, file2_size));
   assertEqualMem(&file2_buff[file2_size + 1 - sizeof(file2_test_txt)],
                  file2_test_txt, sizeof(file2_test_txt) - 1);
@@ -452,6 +490,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file1_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file1_size == archive_read_data(a, file1_buff, file1_size));
   assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1],
                  file1_test_txt, sizeof(file1_test_txt) - 1);
@@ -464,6 +504,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Sixth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -473,6 +515,8 @@ DEFINE_TEST(test_read_format_rar_compress_normal)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -507,6 +551,8 @@ DEFINE_TEST(test_read_format_rar_multi_lzss_blocks)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   while (offset + (int)sizeof(buff) < size)
   {
     assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff)));
@@ -551,6 +597,8 @@ DEFINE_TEST(test_read_format_rar_compress_best)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file1_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file1_size == archive_read_data(a, file1_buff, file1_size));
   assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1],
                  file1_test_txt, sizeof(file1_test_txt) - 1);
@@ -563,6 +611,8 @@ DEFINE_TEST(test_read_format_rar_compress_best)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(41471, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae));
   assertEqualIntA(a, 0, archive_read_data(a, file1_buff, 30));
 
@@ -574,6 +624,8 @@ DEFINE_TEST(test_read_format_rar_compress_best)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file2_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file2_size == archive_read_data(a, file2_buff, file2_size));
   assertEqualMem(&file2_buff[file2_size + 1 - sizeof(file2_test_txt)],
                  file2_test_txt, sizeof(file2_test_txt) - 1);
@@ -587,6 +639,8 @@ DEFINE_TEST(test_read_format_rar_compress_best)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file1_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file1_size == archive_read_data(a, file1_buff, file1_size));
   assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1],
                  file1_test_txt, sizeof(file1_test_txt) - 1);
@@ -599,6 +653,8 @@ DEFINE_TEST(test_read_format_rar_compress_best)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Sixth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -608,6 +664,8 @@ DEFINE_TEST(test_read_format_rar_compress_best)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -643,6 +701,8 @@ DEFINE_TEST(test_read_format_rar_ppmd_lzss_conversion)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   while (offset + (int)sizeof(buff) < size)
   {
     assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff)));
@@ -692,6 +752,8 @@ DEFINE_TEST(test_read_format_rar_binary)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file1_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file1_size == archive_read_data(a, file1_buff, file1_size));
   assertEqualMem(&file1_buff[file1_size - sizeof(file1_test_txt) + 1],
                  file1_test_txt, sizeof(file1_test_txt) - 1);
@@ -704,6 +766,8 @@ DEFINE_TEST(test_read_format_rar_binary)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file2_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file2_size == archive_read_data(a, file2_buff, file2_size));
   assertEqualMem(&file2_buff[file2_size + 1 - sizeof(file2_test_txt)],
                  file2_test_txt, sizeof(file2_test_txt) - 1);
@@ -738,6 +802,8 @@ DEFINE_TEST(test_read_format_rar_windows)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(16, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
 
@@ -749,6 +815,8 @@ DEFINE_TEST(test_read_format_rar_windows)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(16, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
 
@@ -760,6 +828,8 @@ DEFINE_TEST(test_read_format_rar_windows)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(sizeof(buff), archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff)));
 
   /* Fourth header. */
@@ -770,6 +840,8 @@ DEFINE_TEST(test_read_format_rar_windows)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Fifth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -779,6 +851,8 @@ DEFINE_TEST(test_read_format_rar_windows)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -828,6 +902,8 @@ DEFINE_TEST(test_read_format_rar_multivolume)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file1_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   while (offset + (int)sizeof(buff) < file1_size)
   {
     assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff)));
@@ -845,6 +921,8 @@ DEFINE_TEST(test_read_format_rar_multivolume)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file2_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file2_size == archive_read_data(a, file2_buff, file2_size));
   assertEqualMem(&file2_buff[file2_size - sizeof(file2_test_txt) + 1],
                  file2_test_txt, sizeof(file2_test_txt) - 1);
@@ -857,6 +935,8 @@ DEFINE_TEST(test_read_format_rar_multivolume)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(41471, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae));
   assertEqualIntA(a, 0, archive_read_data(a, file2_buff, 30));
 
@@ -868,6 +948,8 @@ DEFINE_TEST(test_read_format_rar_multivolume)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file3_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file3_size == archive_read_data(a, file3_buff, file3_size));
   assertEqualMem(&file3_buff[file3_size + 1 - sizeof(file3_test_txt)],
                  file3_test_txt, sizeof(file3_test_txt) - 1);
@@ -881,6 +963,8 @@ DEFINE_TEST(test_read_format_rar_multivolume)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file2_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file2_size == archive_read_data(a, file2_buff, file2_size));
   assertEqualMem(&file2_buff[file2_size - sizeof(file2_test_txt) + 1],
                  file2_test_txt, sizeof(file2_test_txt) - 1);
@@ -893,6 +977,8 @@ DEFINE_TEST(test_read_format_rar_multivolume)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Seventh header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -902,6 +988,8 @@ DEFINE_TEST(test_read_format_rar_multivolume)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -941,6 +1029,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file1_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Second header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -950,6 +1040,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file2_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Third header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -959,6 +1051,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(41471, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualString("LibarchiveAddingTest.html", archive_entry_symlink(ae));
 
   /* Fourth header. */
@@ -969,6 +1063,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file3_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Fifth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -979,6 +1075,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file2_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Sixth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -988,6 +1086,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Seventh header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -997,6 +1097,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -1028,6 +1130,8 @@ DEFINE_TEST(test_read_format_rar_sfx)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(16, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
 
@@ -1039,6 +1143,8 @@ DEFINE_TEST(test_read_format_rar_sfx)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(sizeof(buff), archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(sizeof(buff) == archive_read_data(a, buff, sizeof(buff)));
 
   /* Third header. */
@@ -1049,6 +1155,8 @@ DEFINE_TEST(test_read_format_rar_sfx)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(16, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(size == archive_read_data(a, buff, size));
   assertEqualMem(buff, test_txt, size);
 
@@ -1060,6 +1168,8 @@ DEFINE_TEST(test_read_format_rar_sfx)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Fifth header. */
   assertA(0 == archive_read_next_header(a, &ae));
@@ -1069,6 +1179,8 @@ DEFINE_TEST(test_read_format_rar_sfx)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -1109,6 +1221,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_stored_file)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertA(file_size == archive_read_data(a, file_buff, file_size));
   assertEqualMem(&file_buff[file_size - sizeof(file_test_txt) + 1],
                  file_test_txt, sizeof(file_test_txt) - 1);
@@ -1147,6 +1261,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_stored_file_skip)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertA(1 == archive_read_next_header(a, &ae));
@@ -1193,6 +1309,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_seek_data)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Seek to the end minus 64 bytes */
   assertA(file_size - (int)sizeof(buff) ==
@@ -1331,6 +1449,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_seek_multiple_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Attempt to read past end of file */
   assertEqualInt(file_size, archive_seek_data(a, 0, SEEK_END));
@@ -1379,6 +1499,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_seek_multiple_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(file_size, archive_entry_size(ae));
   assertEqualInt(33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Attempt to read past end of file */
   assertEqualInt(file_size, archive_seek_data(a, 0, SEEK_END));
@@ -1523,6 +1645,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualIntA(a, 20111, archive_entry_size(ae));
   assertEqualIntA(a, 33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   test_read_format_rar_multivolume_uncompressed_files_helper(a);
 
@@ -1786,6 +1910,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualIntA(a, 20111, archive_entry_size(ae));
   assertEqualIntA(a, 33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   test_read_format_rar_multivolume_uncompressed_files_helper(a);
 
@@ -2169,6 +2295,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualIntA(a, 20111, archive_entry_size(ae));
   assertEqualIntA(a, 33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   test_read_format_rar_multivolume_uncompressed_files_helper(a);
 
@@ -2432,6 +2560,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualIntA(a, 20111, archive_entry_size(ae));
   assertEqualIntA(a, 33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   test_read_format_rar_multivolume_uncompressed_files_helper(a);
 
@@ -2815,6 +2945,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualIntA(a, 20111, archive_entry_size(ae));
   assertEqualIntA(a, 33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   test_read_format_rar_multivolume_uncompressed_files_helper(a);
 
@@ -3078,6 +3210,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualIntA(a, 20111, archive_entry_size(ae));
   assertEqualIntA(a, 33188, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   test_read_format_rar_multivolume_uncompressed_files_helper(a);
 
@@ -3462,6 +3596,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertEqualInt(41471, archive_entry_mode(ae));
   assertEqualString("testsubdir/LibarchiveAddingTest.html",
     archive_entry_symlink(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /*
@@ -3476,6 +3612,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertEqualInt(41471, archive_entry_mode(ae));
   assertEqualString("testsubdir/LibarchiveAddingTest2.html",
     archive_entry_symlink(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /*
@@ -3490,6 +3628,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertEqualInt(41471, archive_entry_mode(ae));
   assertEqualString("testdir/LibarchiveAddingTest.html",
     archive_entry_symlink(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /*
@@ -3504,6 +3644,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertEqualInt(41471, archive_entry_mode(ae));
   assertEqualString("testdir/LibarchiveAddingTest2.html",
     archive_entry_symlink(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /*
@@ -3518,6 +3660,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertEqualInt(41471, archive_entry_mode(ae));
   assertEqualString("testdir/testsubdir/LibarchiveAddingTest.html",
     archive_entry_symlink(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /*
@@ -3532,6 +3676,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertEqualInt(41471, archive_entry_mode(ae));
   assertEqualString("testdir/testsubdir/LibarchiveAddingTest2.html",
     archive_entry_symlink(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /*
@@ -3544,6 +3690,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /*
    * Fourteenth header.
@@ -3555,6 +3703,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /*
    * Fifteenth header.
@@ -3566,6 +3716,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /*
    * Sixteenth header.
@@ -3577,6 +3729,8 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertA((int)archive_entry_atime(ae));
   assertEqualInt(0, archive_entry_size(ae));
   assertEqualInt(16877, archive_entry_mode(ae));
+  assertEqualInt(archive_entry_is_encrypted(ae), 0);
+  assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
   /* Test EOF */
   assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
diff --git a/libarchive/test/test_read_format_rar_encryption_data.c b/libarchive/test/test_read_format_rar_encryption_data.c
new file mode 100644 (file)
index 0000000..14de888
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_rar_encryption_data)
+{
+       /* This file is password protected (encrypted). The headers
+          are NOT encrypted. Password is "12345678". */
+       const char *refname = "test_read_format_rar_encryption_data.rar";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, 
+               archive_read_open_filename(a, refname, 10240));
+
+       /* Verify encrypted file "foo.txt" */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae));
+       assertEqualString("foo.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379403430, archive_entry_mtime(ae));
+       assertEqualInt(16, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+       
+       /* Verify encrypted file "bar.txt" */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae));
+       assertEqualString("bar.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379403432, archive_entry_mtime(ae));
+       assertEqualInt(16, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+       
+       assertEqualInt(2, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_RAR, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
diff --git a/libarchive/test/test_read_format_rar_encryption_data.rar.uu b/libarchive/test/test_read_format_rar_encryption_data.rar.uu
new file mode 100644 (file)
index 0000000..793e237
--- /dev/null
@@ -0,0 +1,8 @@
+begin 664 test_read_format_rar_encryption_data.rar
+M4F%R(1H'`,^0<P``#0````````!=_'0DA"\`(````!`````#7(:MIJ5,,4,=
+M,P<`M($``&9O;RYT>'1/`[S9UA9,WT5`&I*2B-\5*XZ>SW"Y0.C)1^;.UK]$
+MXK@UJ)SH93<!!T5T)(0O`"`````0`````[[BD,VF3#%#'3,'`+2!``!B87(N
+M='AT3P.\V=863-]P='I(B8@/9EM]Y0:Y<AZH)57XRC<!H^WT\13S(V31H<0]
+%>P!`!P``
+`
+end
diff --git a/libarchive/test/test_read_format_rar_encryption_header.c b/libarchive/test/test_read_format_rar_encryption_header.c
new file mode 100644 (file)
index 0000000..71de49d
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_rar_encryption_header)
+{
+       /* This file is password protected (encrypted) with AES-256. The headers
+          ARE encrypted. Password is "12345678". */
+       const char *refname = "test_read_format_rar_encryption_header.rar";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK,
+           archive_read_open_filename(a, refname, 10240));
+
+       /* Verify regular file but with encrypted headers
+          as a consequence, all meta information is invalid. */
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
+       
+       assertEqualInt(0, archive_entry_mode(ae));
+       assertEqualString(NULL, archive_entry_pathname(ae));
+       assertEqualInt(0, archive_entry_mtime(ae));
+       assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(1, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+
+       assertEqualInt(1, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_RAR, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_format_rar_encryption_header.rar.uu b/libarchive/test/test_read_format_rar_encryption_header.rar.uu
new file mode 100644 (file)
index 0000000..5bd48d7
--- /dev/null
@@ -0,0 +1,8 @@
+begin 664 test_read_format_rar_encryption_header.rar
+M4F%R(1H'`,Z9<X``#0````````#C+JMDIUQVC(1'0@#+RLR?%V>1EQMQ=@1S
+M,[$:0Y\;'G8_C0D%2L":*;.B*LM0!,!.2!RBU?+`DTN9KXD\<4RGSC<K5.$U
+M5ZP^2+6",C4`Q^N*MW0)<$U,XRZK9*=<=HRJEM_P8GIN:*4ZDP<>+#KCC:\R
+M$)P&_/D2I'(4,7$^#2[\,Y"D.2T$@B1#J-Z$]R6_*($W7+!JH\,(XH,'C7FC
+H@B,\$1>+CX-=`-%F3C6%I^,NJV2G7':,JF?4KS:6=TAK%$V=]2+N^@``
+`
+end
diff --git a/libarchive/test/test_read_format_rar_encryption_partially.c b/libarchive/test/test_read_format_rar_encryption_partially.c
new file mode 100644 (file)
index 0000000..3b13103
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_rar_encryption_partially)
+{
+       /* This file contains one file that is encrypted (foo.txt, password=12345678)
+          and one file that is not encrypted (bar.txt) The header is not encrypted
+          on this file. */
+       const char *refname = "test_read_format_rar_encryption_partially.rar";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK,
+           archive_read_open_filename(a, refname, 10240));
+
+       /* Verify encrypted file "foo.txt". */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae));
+       assertEqualString("foo.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379403430, archive_entry_mtime(ae));    
+       assertEqualInt(16, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+       
+       /* Verify unencrypted file "bar.txt". */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0664), archive_entry_mode(ae));
+       assertEqualString("bar.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379403432, archive_entry_mtime(ae));
+       assertEqualInt(16, archive_entry_size(ae));
+       assertEqualInt(0, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(16, archive_read_data(a, buff, sizeof(buff)));
+
+       assertEqualInt(2, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_RAR, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_format_rar_encryption_partially.rar.uu b/libarchive/test/test_read_format_rar_encryption_partially.rar.uu
new file mode 100644 (file)
index 0000000..0c9727f
--- /dev/null
@@ -0,0 +1,7 @@
+begin 664 test_read_format_rar_encryption_partially.rar
+M4F%R(1H'`,^0<P``#0````````"7.G0DA"\`(````!`````#7(:MIJ5,,4,=
+M,P<`M($``&9O;RYT>'2>C_^E6-T51TBV:OLN/8KJ<5S5/Y4G6N&PG<5GX;P=
+MF_YJK^@\`3\09C!T((`G`!P````0`````[[BD,VF3#%#'3,'`+2!``!B87(N
+F='AT#!#)/HRW]%5!"GXA#4D)<!^>_]J&++4FP^?OH,0]>P!`!P``
+`
+end
index a23b9c55a74923299ee1410512e86e9d306c68c1..ed130bf5070d29578c78ef3ba9e3c4661ca567ae 100644 (file)
@@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_raw)
        assert(!archive_entry_atime_is_set(ae));
        assert(!archive_entry_ctime_is_set(ae));
        assert(!archive_entry_mtime_is_set(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(4, archive_read_data(a, buff, 32));
        assertEqualMem(buff, "foo\n", 4);
 
@@ -74,6 +76,8 @@ DEFINE_TEST(test_read_format_raw)
        /* First (and only!) Entry */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("data", archive_entry_pathname(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        /* Most fields should be unset (unknown) */
        assert(!archive_entry_size_is_set(ae));
        assert(!archive_entry_atime_is_set(ae));
index 8273e753065868411a8546d3e7dbaeb138eba2f5..aa0735b827bc771cbbe087e3a62a717eab2f2841 100644 (file)
@@ -74,6 +74,8 @@ static void verifyEmpty(void)
        assertEqualString(archive_filter_name(a, 0), "none");
        failure("512 zero bytes should be recognized as a tar archive.");
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
@@ -439,6 +441,8 @@ static void verify(unsigned char *d, size_t s,
        assertA(0 == archive_read_next_header(a, &ae));
        assertEqualInt(archive_filter_code(a, 0), compression);
        assertEqualInt(archive_format(a), format);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify the only entry. */
        f(ae);
index d7c8105a4262c7acf3804c7b9db574a6a4a21112..ec047834ef6cfc7d760674ac44092c80ddd29851 100644 (file)
@@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_tar_empty_filename)
        assertEqualInt(0, archive_entry_gid(ae));
        assertEqualString("wheel", archive_entry_gname(ae));
        assertEqualInt(040775, archive_entry_mode(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify the end-of-archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
index c6b5741ec37cef5ec5db31388fcc93da1e3eae58..fcdc48e352d35ae33d46f9bbb4fc3dc6cd9747db 100644 (file)
@@ -49,6 +49,8 @@ DEFINE_TEST(test_read_format_tar_empty_pax)
        assertEqualIntA(a, ARCHIVE_OK,
            archive_read_open_filename(a, refname, 10240));
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(ARCHIVE_FILTER_COMPRESS, archive_filter_code(a, 0));
        assertEqualInt(ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE, archive_format(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
index ee2bf81dec945817daa061a3a3422f533976aaab..e50880a833191f8498e5a28aa6baae57bd7f7716 100644 (file)
@@ -80,12 +80,16 @@ test_read_format_tar_filename_KOI8R_CP866(const char *refname)
        assertEqualString("\x8f\x90\x88\x82\x85\x92",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular second file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -123,6 +127,8 @@ next_test:
        assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /*
         * Verify regular second file.
@@ -132,6 +138,8 @@ next_test:
        assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -179,13 +187,20 @@ test_read_format_tar_filename_KOI8R_UTF8(const char *refname)
        assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
+       /* Verify encryption status */
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -194,6 +209,10 @@ test_read_format_tar_filename_KOI8R_UTF8(const char *refname)
        assertEqualIntA(a, ARCHIVE_FILTER_COMPRESS, archive_filter_code(a, 0));
        assertEqualIntA(a, ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE,
            archive_format(a));
+       
+       /* Verify encryption status */
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Close the archive. */
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
@@ -220,6 +239,10 @@ test_read_format_tar_filename_KOI8R_UTF8(const char *refname)
        assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       
+       /* Verify encryption status */
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /*
         * Verify regular second file.
@@ -286,12 +309,16 @@ test_read_format_tar_filename_KOI8R_CP1251(const char *refname)
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular second file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -328,6 +355,8 @@ next_test:
        assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /*
         * Verify regular second file.
@@ -336,6 +365,8 @@ next_test:
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
index 475c558eefc510d84e5916f794ff8e35dbe9fd93..3047051041c88f28f1321a0a42b2d19c23882e82 100644 (file)
@@ -53,6 +53,8 @@ DEFINE_TEST(test_read_format_tbz)
        assertEqualInt(1, archive_file_count(a));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_BZIP2);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 60985a0d9f8c6400a78a809a00f2b3827b02555c..3294c318b0744683e12b650af1997a595abe6590 100644 (file)
@@ -54,6 +54,8 @@ DEFINE_TEST(test_read_format_tgz)
        assertEqualInt(archive_filter_code(a, 0),
            ARCHIVE_FILTER_GZIP);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK,archive_read_free(a));
 }
index 2a058d03971bb4f8e67ad752c9987fc8247e5080..f7c4b06c5ea15b7bbd2f24d9b14acfe66b930bb0 100644 (file)
@@ -56,6 +56,8 @@ DEFINE_TEST(test_read_format_tlz)
        assertEqualInt(1, archive_file_count(a));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_LZMA);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 6672ad2f08645ff6d8e2f93b303acc9f704ee255..d570465377e3e7cfe25215011b38e318d2f831dc 100644 (file)
@@ -59,6 +59,8 @@ DEFINE_TEST(test_read_format_txz)
        assertEqualInt(1, archive_file_count(a));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_XZ);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 60d8a4e61514ae93ed84b827dec947d86cdfad61..d2240dbae0edd639c446fbdd5b101f2b692702d3 100644 (file)
@@ -51,6 +51,8 @@ DEFINE_TEST(test_read_format_tz)
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_COMPRESS);
        failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index f2e577d0a3b9f666b4c207028244bc3e8a32f119..b32047f5edff59dec0ea9da4524181472c7f6f6c 100644 (file)
@@ -57,12 +57,16 @@ test_read_format_ustar_filename_eucJP_UTF8(const char *refname)
        assertEqualString("\xe6\xbc\xa2\xe5\xad\x97.txt",
            archive_entry_pathname(ae));
        assertEqualInt(8, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xe8\xa1\xa8.txt", archive_entry_pathname(ae));
        assertEqualInt(4, archive_entry_size(ae));
-
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+       
 
        /* End of archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -108,13 +112,17 @@ test_read_format_ustar_filename_CP866_KOI8R(const char *refname)
        assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xd2\xc9\xd7\xc5\xd4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
-
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
+       
 
        /* End of archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -159,12 +167,16 @@ test_read_format_ustar_filename_CP866_UTF8(const char *refname)
        assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -211,12 +223,16 @@ test_read_format_ustar_filename_KOI8R_CP866(const char *refname)
        assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\x8f\x90\x88\x82\x85\x92",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -262,12 +278,16 @@ test_read_format_ustar_filename_KOI8R_UTF8(const char *refname)
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -313,11 +333,15 @@ test_read_format_ustar_filename_eucJP_CP932(const char *refname)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\x8a\xbf\x8e\x9a.txt", archive_entry_pathname(ae));
        assertEqualInt(8, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\x95\x5c.txt", archive_entry_pathname(ae));
        assertEqualInt(4, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -364,12 +388,16 @@ test_read_format_ustar_filename_CP866_CP1251(const char *refname)
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -416,12 +444,16 @@ test_read_format_ustar_filename_CP866_CP1251_win(const char *refname)
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -467,12 +499,16 @@ test_read_format_ustar_filename_KOI8R_CP1251(const char *refname)
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
index f2de1e0139452202cbc8eb3ed999ab74a15f02ae..e6bc3511babc9de4302d5a6c679b1cf8b89415a2 100644 (file)
@@ -663,6 +663,8 @@ static void verify(unsigned char *d, size_t s,
        assertA(0 == archive_read_next_header(a, &ae));
        assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE);
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR);
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        /* Verify the only entry. */
        f1(a, ae);
        if (f2) {
index 7f3568157b5bfcb2735206da752c6a6092ed1577..7df25ec2b343ed75dcbfe5f7cdfb8b9c3190bee0 100644 (file)
@@ -52,6 +52,8 @@ verify_basic(struct archive *a, int seek_checks)
        assertEqualInt(0, archive_entry_size(ae));
        if (seek_checks)
                assertEqualInt(AE_IFDIR | 0755, archive_entry_mode(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualIntA(a, ARCHIVE_EOF,
            archive_read_data_block(a, &pv, &s, &o));
        assertEqualInt((int)s, 0);
@@ -62,6 +64,8 @@ verify_basic(struct archive *a, int seek_checks)
        if (seek_checks)
                assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
        assertEqualInt(18, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        failure("archive_read_data() returns number of bytes read");
        if (libz_enabled) {
                assertEqualInt(18, archive_read_data(a, buff, 19));
@@ -76,6 +80,8 @@ verify_basic(struct archive *a, int seek_checks)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("file2", archive_entry_pathname(ae));
        assertEqualInt(1179605932, archive_entry_mtime(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        if (seek_checks) {
                assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
                assertEqualInt(64, archive_entry_size_is_set(ae));
@@ -144,6 +150,8 @@ verify_info_zip_ux(struct archive *a, int seek_checks)
        assertEqualString("file1", archive_entry_pathname(ae));
        assertEqualInt(1300668680, archive_entry_mtime(ae));
        assertEqualInt(18, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        if (seek_checks)
                assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
        failure("zip reader should read Info-ZIP New Unix Extra Field");
@@ -208,6 +216,8 @@ verify_extract_length_at_end(struct archive *a, int seek_checks)
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualString("hello.txt", archive_entry_pathname(ae));
        if (seek_checks) {
                assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
@@ -278,12 +288,16 @@ test_symlink(void)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("file", archive_entry_pathname(ae));
        assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("symlink", archive_entry_pathname(ae));
        assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
        assertEqualInt(0, archive_entry_size(ae));
        assertEqualString("file", archive_entry_symlink(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
index 5394cebc0507ce934348ba4edc8e126ad09d6301..5d7014d9d4256101a53ab0c372e0c570b5ab092a 100644 (file)
@@ -48,15 +48,21 @@ verify(const char *refname)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("file0", archive_entry_pathname(ae));
        assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("build.sh", archive_entry_pathname(ae));
        assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
        assertEqualInt(23, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 }
 
 DEFINE_TEST(test_read_format_zip_comment_stored)
diff --git a/libarchive/test/test_read_format_zip_encryption_data.c b/libarchive/test/test_read_format_zip_encryption_data.c
new file mode 100644 (file)
index 0000000..c4585a1
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_zip_encryption_data)
+{
+       /* This file is password protected (encrypted). The headers
+          are NOT encrypted. Password is "12345678". */
+       const char *refname = "test_read_format_zip_encryption_data.zip";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, 
+               archive_read_open_filename(a, refname, 10240));
+
+       /* Verify encrypted file "bar.txt" */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae));
+       assertEqualString("bar.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379416406, archive_entry_mtime(ae));
+       assertEqualInt(20, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, sizeof(buff)));
+       
+       /* Verify encrypted file "foo.txt" */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae));
+       assertEqualString("foo.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379416400, archive_entry_mtime(ae));
+       assertEqualInt(20, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, sizeof(buff)));
+       
+       assertEqualInt(2, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
diff --git a/libarchive/test/test_read_format_zip_encryption_data.zip.uu b/libarchive/test/test_read_format_zip_encryption_data.zip.uu
new file mode 100644 (file)
index 0000000..d419e7d
--- /dev/null
@@ -0,0 +1,25 @@
+begin 664 test_read_format_zip_encryption_data.zip
+M4$L#!#,`00```*UI,4/H*IFA5@$``!0````'````8F%R+G1X=!``2#/PIQFT
+M*F$4U*$#L8[-?B`!```#`!!F``$!`)``[SL/J;#"+JV#-X^_<G4LZ9N0-"3T
+M?USM"E4Q6?[!.3S$^RX>V7R?(/NINR^)*Z@-<WE<\6H)%,>`+PM+G'_/G,@=
+MOQI>T\*I"7FDH^[+/([/S3(S=2JR^B1VT7NV=\PU*ILZ(S-9P@#K>HTK<9$X
+MG?3>):QUHT4^7JY*;B_X.,6FCSB0]-;K-:!W"\9#7%JT`````(``I>M3N%RW
+MKHT3'HV+V7'\SG*),5W`7P-"J01^*X5F-K&;`\FXL%S[!!"J1<JN'$\SDV">
+M?4B:)(8&4)C/_^4!TF+`7W`%52=)VJ9U?3H,W@"9S8062TGSY_<:.\=X_SCC
+M<D],6[)[W+M>1?,I!IE@=&J39?KX5+0Y\Y`;^.[MR@]TB?WG-.D/]RONSJ(6
+MMAL3^^^V;)?](;*EA#%$TN]?2U!+`P0S`$$```"J:3%#_\P&4E8!```4````
+M!P```&9O;RYT>'00`(N<JIJ)9,DL4<)ZS:,$M6,@`0```P`09@`!`0"0`.\[
+M#ZFPPBZM@S>/OW)U+.F;D#0D]']<[0I5,5G^P3D\Q/LN'ME\GR#[J;LOB2NH
+M#7-Y7/%J"13'@"\+2YQ_SYS(';\:7M/"J0EYI*/NRSR.S\TR,W4JLOHD=M%[
+MMG?,-2J;.B,S6<(`ZWJ-*W&1.)WTWB6L=:-%/EZN2FXO^#C%IH\XD/36ZS6@
+M=PO&0UQ:M`````"``".OX15'_!K.OGAW6+M]C;[G8@26,FBSB&/46Q@#[301
+M`"51%C)3[11_TP#)7O_6`&/F?FGG]G9;W.L$"<T.,(68%F[9I1ZTS]>;H2&[
+ML$PNS#NDG9Q@BFL$`&S?<RKIF$0-.V![PIJ.+"5GW)3L;JWCD>S3;,D#OS#%
+MZ>O6I=M41I^&XX"JLTTKLW]*B=+>(C]+6]H**#DX_EJ;9BBY;,=02P$"0``S
+M`$$```"M:3%#Z"J9H58!```4````!P`T```````!`"``````````8F%R+G1X
+M=`H`(````````0`8`".@Q.V6L\X!(Z#$[9:SS@$CH,3MEK/.`1<`#``"`!!F
+M``$!``````!02P$"0``S`$$```"J:3%#_\P&4E8!```4````!P`T```````!
+M`"````![`0``9F]O+G1X=`H`(````````0`8`"4C6.F6L\X!)2-8Z9:SS@$E
+M(UCIEK/.`1<`#``"`!!F``$!``````!02P4&``````(``@#2````]@(`````
+`
+end
diff --git a/libarchive/test/test_read_format_zip_encryption_header.c b/libarchive/test/test_read_format_zip_encryption_header.c
new file mode 100644 (file)
index 0000000..5776db8
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_zip_encryption_header)
+{
+       /* This file is password protected (encrypted) with AES-256. The headers
+          ARE encrypted. Password is "12345678". */
+       const char *refname = "test_read_format_zip_encryption_header.zip";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK,
+           archive_read_open_filename(a, refname, 10240));
+
+       /* Verify regular file but with encrypted headers
+          as a consequence, all meta information is invalid. */
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
+       
+       assertEqualInt(0, archive_entry_mode(ae));
+       assertEqualString(NULL, archive_entry_pathname(ae));
+       assertEqualInt(0, archive_entry_mtime(ae));
+       assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(1, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FATAL, archive_read_data(a, buff, sizeof(buff)));
+
+       assertEqualInt(1, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_format_zip_encryption_header.zip.uu b/libarchive/test/test_read_format_zip_encryption_header.zip.uu
new file mode 100644 (file)
index 0000000..8ba23d3
--- /dev/null
@@ -0,0 +1,32 @@
+begin 664 test_read_format_zip_encryption_header.zip
+M4$L#!#,`02``````````````5@$````````!````,1``X3'*9,%K7_13)[I3
+MUO.*N2`!```#`!!F``$!`)``M'BJYI=VD<MB76[?O3IDTVM#',YK$L&:DX!C
+ML%00Q:QRCM/8%XJ.8''-JI$Z*\!\`]%-[F'4"G01L1E]L[ST_7"*)/_/9VO1
+MLKUI\AFKFUK@M89K)2HI3-"XGZN4SSBEZ&\F@R?>ZMXC4&]B1)Q%WJ/M`8VS
+M%S*.0\5[MJ34[W"H8*AO==S@TG'S'J'3A;8C`````(``4-?ZX*L^`*0786KZ
+ME7<\#%<[_`^#/MO"P\3FX5`^9`Q%(S:FDO98B*C`BC%'XQ0*X"FMO8[@3'S@
+MX(JO5(Q:8-&AM8(OPBY40\O!"%Z5'>I\/<_(AA-%)*TBI6YT6!WEM7L,-"W(
+M/GE:7T.B39$3C.W)X2`A=KV-UB4C7<C^OV&:"B?Y]DU=W2*(SFV=8Q]D\Q*W
+M%B9E>I?6B-!F<"?VLE!+`P0S`$$@`````````````%8!`````````0```#(0
+M`%(U7N:0Z+,VS3SNJBRE_=`@`0```P`09@`!`0"0`+1XJN:7=I'+8EUNW[TZ
+M9--K0QS.:Q+!FI.`8[!4$,6L<H[3V!>*CF!QS:J1.BO`?`/13>YAU`IT$;$9
+M?;.\]/UPBB3_SV=KT;*]:?(9JYM:X+6&:R4J*4S0N)^KE,\XI>AO)H,GWNK>
+M(U!O8D2<1=ZC[0&-LQ<RCD/%>[:DU.]PJ&"H;W7<X-)Q\QZATX6V(P````"`
+M`&O$^CTH9KN(X?(:`+,T7:PMJ"E"?LTSG9^$P881P?4X"%AG>CYF;:)G.8S3
+M%AT<])L+^"37+I@-S&ALBA\_10'AM,+6C"RP!FEV@VW1"2PDL->Q5HL*M[X(
+M];^?-43F%4=UMP/U>8<DO/W\7,S2S5MSP96Y5"C'I3MST([/-X3(VZQ.XNGM
+M>3:C4K&OM*'&=DS[_V!*YK9X(6G9R,]GJ\\0`!A&@I%F4R!H=;RQSVWL,/D@
+M`0```P`09@`!`0"0`+1XJN:7=I'+8EUNW[TZ9--K0QS.:Q+!FI.`8[!4$,6L
+M<H[3V!>*CF!QS:J1.BO`?`/13>YAU`IT$;$9?;.\]/UPBB3_SV=KT;*]:?(9
+MJYM:X+6&:R4J*4S0N)^KE,\XI>AO)H,GWNK>(U!O8D2<1=ZC[0&-LQ<RCD/%
+M>[:DU.]PJ&"H;W7<X-)Q\QZATX6V(P````"``(/(E'//(-;AFW-I#4'M.C!+
+MWZ-\VREA15;E6=_G,KY#<1*,3$U0:B#`]\N[&'P`IT9>A2^EL1N!T3'%DP<<
+MXY=DJB$8LS8KERBNN[I*X]M"?A<Q))<H]YV`F<GNWHI#Z].M5&6VM)!B&&/1
+M&15"]OG@91-531!<@R6L;"PIU/R)H]QUVXIM$G9<!+J]4N0\+SL(Q,5?)."!
+MY-^!/U`V$I@O%ZUMU2755&HDUS$*:?33>\FYX"B`IP_XMQ-.*H3#`XY.,-K%
+M0`Z%4:U*W#IM_DBOP-$^?R<8,!%#Z6F1`?;Z:=LG6@'C+#0I[]^+E$0'L5!+
+M!@9,`````````$``/@```````````````````````@````````"F`0``````
+M`.H"````````"`"F`0```````-(`````````$&8``0$``0`$``"$P.)02P8'
+F`````)`$`````````0```%!+!08```````#__Z8!``#J`@``````
+`
+end
diff --git a/libarchive/test/test_read_format_zip_encryption_partially.c b/libarchive/test/test_read_format_zip_encryption_partially.c
new file mode 100644 (file)
index 0000000..330497a
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2013 Konrad Kleine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_read_format_zip_encryption_partially)
+{
+       /* This file contains one file that is encrypted (foo.txt, password=12345678)
+          and one file that is not encrypted (bar.txt) The header is not encrypted
+          on this file. */
+       const char *refname = "test_read_format_zip_encryption_partially.zip";
+       struct archive_entry *ae;
+       struct archive *a;
+       char buff[128];
+
+       extract_reference_file(refname);
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+       assertEqualIntA(a, ARCHIVE_OK,
+           archive_read_open_filename(a, refname, 10240));
+
+       /* Verify unencrypted file "bar.txt". */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae));
+       assertEqualString("bar.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379416406, archive_entry_mtime(ae));    
+       assertEqualInt(20, archive_entry_size(ae));
+       assertEqualInt(0, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(20, archive_read_data(a, buff, sizeof(buff)));
+       
+       /* Verify encrypted file "foo.txt". */
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt((AE_IFREG | 0666), archive_entry_mode(ae));
+       assertEqualString("foo.txt", archive_entry_pathname(ae));
+       assertEqualInt(1379416400, archive_entry_mtime(ae));
+       assertEqualInt(20, archive_entry_size(ae));
+       assertEqualInt(1, archive_entry_is_data_encrypted(ae));
+       assertEqualInt(0, archive_entry_is_metadata_encrypted(ae));
+       assertEqualIntA(a, 1, archive_read_has_encrypted_entries(a));
+       assertEqualInt(ARCHIVE_FAILED, archive_read_data(a, buff, sizeof(buff)));
+
+       assertEqualInt(2, archive_file_count(a));
+
+       /* End of archive. */
+       assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+       /* Verify archive format. */
+       assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
+       assertEqualIntA(a, ARCHIVE_FORMAT_ZIP, archive_format(a));
+
+       /* Close the archive. */
+       assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_read_format_zip_encryption_partially.zip.uu b/libarchive/test/test_read_format_zip_encryption_partially.zip.uu
new file mode 100644 (file)
index 0000000..ac19d31
--- /dev/null
@@ -0,0 +1,18 @@
+begin 664 test_read_format_zip_encryption_partially.zip
+M4$L#!`H``````*UI,4/H*IFA%````!0````'````8F%R+G1X=")D871A(&]F
+M(&)A<BYT>'0B(`T*4$L#!#,`00```*II,4/_S`925@$``!0````'````9F]O
+M+G1X=!``=<L("9.V+5=*CU"'8S([NR`!```#`!!F``$!`)``!P:=O$!^8J-1
+M-@AD4Y2P=)46_!+9\&&2@AT.;]YT2\]U=17;:L*_:G6/FYR"S@WYW%.=]]$I
+MS2"'F_V9+Y4:]4I%FDN+;.6^6W]S536;D2\QBJ_[R9C.57TI'M?VD82"MHPQ
+MD&P>Y31BJ>9'GG$*/<^F6_&OGLZO5E%/W5NJ591,`8BB:/5/7M)AK8/IJ0=@
+M`````(``QS1<"+$&V4,T_.3PQ&HBEXWEA;,\<!Z8TZ4KQ#:]J=>K(U'9+L4P
+M=:(P%7DH*U7(2#M.IB;M\7X??Y!F]%PMN<#((2`+)9A+<(W[1K0X@&5:`QJV
+MQ:NR:QT5U'+D!K^/_N*M>SJ-)-^@^N6]4VD&Z@L#X(!-7@-6#-G3WV`1:PL"
+M!4FWNU]+#`:$,2UI5U`@#@BY.)#$HP6(2<B2@W^UO%!+`0)```H``````*UI
+M,4/H*IFA%````!0````'`"0```````$`(`````````!B87(N='AT"@`@````
+M```!`!@`(Z#$[9:SS@$CH,3MEK/.`2.@Q.V6L\X!4$L!`D``,P!!````JFDQ
+M0__,!E)6`0``%`````<`-````````0`@````.0```&9O;RYT>'0*`"``````
+M``$`&``E(UCIEK/.`24C6.F6L\X!)2-8Z9:SS@$7``P``@`09@`!`0``````
+64$L%!@`````"``(`P@```+0!````````
+`
+end
index 21b6160275d5701879c6aa1bcd8e0b8d411de659..4b9730f977d0477713d589ab4d64684be37cbf3a 100644 (file)
@@ -58,6 +58,8 @@ test_read_format_zip_filename_CP932_eucJP(const char *refname)
            "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb0\xec\xcd\xf7\xc9\xbd\x2e\x74\x78\x74",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -65,10 +67,14 @@ test_read_format_zip_filename_CP932_eucJP(const char *refname)
            "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb4\xc1\xbb\xfa\x2e\x74\x78\x74",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify archive format. */
        assertEqualIntA(a, ARCHIVE_FILTER_NONE, archive_filter_code(a, 0));
@@ -107,6 +113,8 @@ test_read_format_zip_filename_CP932_UTF8(const char *refname)
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 #if defined(__APPLE__)
        /* Compare NFD string. */
        assertEqualUTF8String(
@@ -124,6 +132,8 @@ test_read_format_zip_filename_CP932_UTF8(const char *refname)
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 #if defined(__APPLE__)
        /* Compare NFD string. */
        assertEqualUTF8String(
@@ -189,6 +199,8 @@ test_read_format_zip_filename_UTF8_eucJP(const char *refname)
        assertEqualString("\xc9\xbd\xa4\xc0\xa4\xe8\x2f",
            archive_entry_pathname(ae));
        assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -197,6 +209,8 @@ test_read_format_zip_filename_UTF8_eucJP(const char *refname)
            "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb0\xec\xcd\xf7\xc9\xbd\x2e\x74\x78\x74",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -205,6 +219,8 @@ test_read_format_zip_filename_UTF8_eucJP(const char *refname)
            "\xc9\xbd\xa4\xc0\xa4\xe8\x2f\xb4\xc1\xbb\xfa\x2e\x74\x78\x74",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -257,6 +273,8 @@ test_read_format_zip_filename_UTF8_UTF8(const char *refname)
            archive_entry_pathname(ae));
 #endif
        assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -275,6 +293,8 @@ test_read_format_zip_filename_UTF8_UTF8(const char *refname)
            archive_entry_pathname(ae));
 #endif
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -293,6 +313,8 @@ test_read_format_zip_filename_UTF8_UTF8(const char *refname)
            archive_entry_pathname(ae));
 #endif
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -338,12 +360,16 @@ test_read_format_zip_filename_CP866_KOI8R(const char *refname)
        assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xd2\xc9\xd7\xc5\xd4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -389,12 +415,16 @@ test_read_format_zip_filename_CP866_UTF8(const char *refname)
        assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -441,12 +471,16 @@ test_read_format_zip_filename_KOI8R_CP866(const char *refname)
        assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\x8f\x90\x88\x82\x85\x92",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -492,12 +526,16 @@ test_read_format_zip_filename_KOI8R_UTF8(const char *refname)
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -549,12 +587,16 @@ test_read_format_zip_filename_UTF8_KOI8R(const char *refname)
        assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xd2\xc9\xd7\xc5\xd4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -609,12 +651,16 @@ test_read_format_zip_filename_UTF8_CP866(const char *refname)
        assertEqualString("\x8f\x90\x88\x82\x85\x92",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xaf\xe0\xa8\xa2\xa5\xe2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -657,12 +703,16 @@ test_read_format_zip_filename_UTF8_UTF8_ru(const char *refname)
        assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -709,6 +759,8 @@ test_read_format_zip_filename_CP932_CP932(const char *refname)
                "\x95\x5c\x82\xbe\x82\xe6\x2f\x88\xea\x97\x97\x95\x5c.txt",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -716,6 +768,8 @@ test_read_format_zip_filename_CP932_CP932(const char *refname)
                "\x95\x5c\x82\xbe\x82\xe6\x2f\x8a\xbf\x8e\x9a.txt",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -771,6 +825,8 @@ test_read_format_zip_filename_UTF8_CP932(const char *refname)
                "\x95\x5c\x82\xbe\x82\xe6\x2f",
            archive_entry_pathname(ae));
        assertEqualInt(0, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify directory file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -779,6 +835,8 @@ test_read_format_zip_filename_UTF8_CP932(const char *refname)
                "\x95\x5c\x82\xbe\x82\xe6\x2f\x88\xea\x97\x97\x95\x5c.txt",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -787,6 +845,8 @@ test_read_format_zip_filename_UTF8_CP932(const char *refname)
                "\x95\x5c\x82\xbe\x82\xe6\x2f\x8a\xbf\x8e\x9a.txt",
            archive_entry_pathname(ae));
        assertEqualInt(5, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* End of archive. */
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -832,12 +892,16 @@ test_read_format_zip_filename_CP866_CP1251(const char *refname)
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -884,12 +948,16 @@ test_read_format_zip_filename_CP866_CP1251_win(const char *refname)
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -935,12 +1003,16 @@ test_read_format_zip_filename_KOI8R_CP1251(const char *refname)
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -994,12 +1066,16 @@ test_read_format_zip_filename_UTF8_CP1251(const char *refname)
        assertEqualString("\xcf\xd0\xc8\xc2\xc5\xd2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xef\xf0\xe8\xe2\xe5\xf2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -1055,6 +1131,8 @@ test_read_format_zip_filename_KOI8R_UTF8_2(const char *refname)
        assertEqualString("\xd0\x9f\xd0\xa0\xd0\x98\xd0\x92\xd0\x95\xd0\xa2",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /*
         * Verify regular second file.
@@ -1065,6 +1143,8 @@ test_read_format_zip_filename_KOI8R_UTF8_2(const char *refname)
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
@@ -1100,12 +1180,16 @@ next_test:
        assertEqualString("\xf0\xf2\xe9\xf7\xe5\xf4",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        /* Verify regular file. */
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82",
            archive_entry_pathname(ae));
        assertEqualInt(6, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
 
        /* End of archive. */
index dd48fd433a59bcd43f32d7a9898207c25058f5c9..c6a23a4aff96e065c1d71cc8f23cd2f735cad4de 100644 (file)
@@ -99,6 +99,8 @@ DEFINE_TEST(test_read_format_zip_mac_metadata)
                    "Unsupported ZIP compression method (deflation)");
                assert(archive_errno(a) != 0);
        }
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
        assertEqualString("file3", archive_entry_pathname(ae));
        assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
        failure("Mac metadata should be set");
index 50e5fa723c292f483871ab85bd63db4a46dd7f01..d5992d39565806e6dda998441d4099d9042eb053 100644 (file)
@@ -47,11 +47,15 @@ DEFINE_TEST(test_read_format_zip_sfx)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("file0", archive_entry_pathname(ae));
        assertEqualInt(AE_IFREG | 0644, archive_entry_mode(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString("build.sh", archive_entry_pathname(ae));
        assertEqualInt(AE_IFREG | 0755, archive_entry_mode(ae));
        assertEqualInt(23, archive_entry_size(ae));
+       assertEqualInt(archive_entry_is_encrypted(ae), 0);
+       assertEqualIntA(a, archive_read_has_encrypted_entries(a), 0);
 
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
        assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));