1ZIP_FOPEN_ENCRYPTED(3)   BSD Library Functions Manual   ZIP_FOPEN_ENCRYPTED(3)
2

NAME

4     zip_fopen_encrypted, zip_fopen_index_encrypted — open encrypted file in
5     zip archive for reading
6

LIBRARY

8     libzip (-lzip)
9

SYNOPSIS

11     #include <zip.h>
12
13     zip_file_t *
14     zip_fopen_encrypted(zip_t *archive, const char *fname, zip_flags_t flags,
15         const char *password);
16
17     zip_file_t *
18     zip_fopen_index_encrypted(zip_t *archive, zip_uint64_t index,
19         zip_flags_t flags, const char *password);
20

DESCRIPTION

22     The zip_fopen_encrypted() function opens the encrypted file name fname in
23     archive using the password given in the password argument.  If password
24     is NULL or the empty string, the default password is used (see
25     zip_set_default_password(3)).  The flags argument are the same as for
26     zip_fopen(3).
27
28     The zip_fopen_index_encrypted() function opens the file at position
29     index, see zip_fopen_index(3).  These functions are called automatically
30     by zip_fopen(3); you only need to call them if you want to specify a non-
31     default password (see zip_set_default_password(3)).
32

RETURN VALUES

34     Upon successful completion, a struct zip_file pointer is returned.  Oth‐
35     erwise, NULL is returned and the error code in archive is set to indicate
36     the error.
37

ERRORS

39     [ZIP_ER_NOPASSWD]     No password was provided.
40
41     The function zip_fopen_encrypted() may also fail and set zip_err for any
42     of the errors specified for the routine zip_fopen(3).
43
44     The function zip_fopen_index_encrypted() may also fail and set zip_err
45     for any of the errors specified for the routine zip_fopen_index(3).
46

SEE ALSO

48     libzip(3), zip_fclose(3), zip_fopen(3), zip_fread(3),
49     zip_get_num_entries(3), zip_name_locate(3)
50

HISTORY

52     zip_fopen_encrypted() and zip_fopen_index_encrypted() were added in
53     libzip 1.0.
54

AUTHORS

56     Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
57

CAVEATS

59     The zip file format provides very limited possibility for password veri‐
60     fication (a short hash of is compared against one byte in the zip ar‐
61     chive).  For this reason, reading a file while using an incorrect pass‐
62     word may immediately fail with ZIP_ER_WRONGPASSWD, but if the mismatch is
63     not detected, a zlib error may be returned later instead.  Since zlib er‐
64     rors can also be caused by broken compressed data, there is no way to
65     make sure if the password was incorrect or if it was correct, but the
66     compressed data was invalid.
67
68BSD                           September 15, 2020                           BSD
Impressum