zip_fopen_encrypted
,
zip_fopen_index_encrypted
—
open encrypted file in zip archive for reading
#include
<zip.h>
zip_file_t *
zip_fopen_encrypted
(zip_t
*archive, const char
*fname, zip_flags_t
flags, const char
*password);
zip_file_t *
zip_fopen_index_encrypted
(zip_t
*archive, zip_uint64_t
index, zip_flags_t
flags, const char
*password);
Upon successful completion, a struct
zip_file pointer is returned. Otherwise, NULL
is returned and the error code in archive is set to
indicate the error.
- [
ZIP_ER_NOPASSWD
]
- No password was provided.
The function zip_fopen_encrypted
() may
also fail and set zip_err for any of the errors
specified for the routine
zip_fopen(3).
The function zip_fopen_index_encrypted
()
may also fail and set zip_err for any of the errors
specified for the routine
zip_fopen_index(3).
zip_fopen_encrypted
() and
zip_fopen_index_encrypted
() were added in libzip
1.0.
The zip file format provides very limited possibility for password
verification (a short hash of is compared against one byte in the zip
archive). For this reason, reading a file while using an incorrect password
may immediately fail with ZIP_ER_WRONGPASSWD
, but if
the mismatch is not detected, a zlib error may be returned later instead.
Since zlib errors can also be caused by broken compressed data, there is no
way to make sure if the password was incorrect or if it was correct, but the
compressed data was invalid.