Make zip_compression_method_supported public and add zip_encryption_method_supported.

Adapt ziptool.

Based on diff by Remi Collet.

Closes #152.
diff --git a/NEWS.md b/NEWS.md
index b361fa0..b88f559 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,12 +1,19 @@
+1.7.0 [2020-xx-xx]
+==================
+
+* Add support for encrypting using traditional PKWare encryption.
+* Add `zip_compression_method_supported()`.
+* Add `zip_encryption_method_supported()`.
+
 1.6.1 [2020-02-03]
 ==================
 
-* Bugfix for double-free in zipcmp(1) during cleanup.
+* Bugfix for double-free in `zipcmp(1)` during cleanup.
 
 1.6.0 [2020-01-24]
 ==================
 
-* Avoid using umask() since it's not thread-safe.
+* Avoid using `umask()` since it's not thread-safe.
 * Set close-on-exec flag when opening files.
 * Do not accept empty files as valid zip archives any longer.
 * Add support for XZ compressed files (using liblzma).
@@ -15,6 +22,7 @@
 
 1.5.2 [2019-03-12]
 ==================
+
 * Fix bug in AES encryption affecting certain file sizes
 * Keep file permissions when modifying zip archives
 * Support systems with small stack size.
@@ -52,6 +60,7 @@
 
 1.3.2 [2017-11-20]
 ==================
+
 * Fix bug introduced in last: zip_t was erroneously freed if zip_close() failed.
 
 1.3.1 [2017-11-19]
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 16394ad..8ac6af5 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -227,7 +227,7 @@
 ADD_LIBRARY(zip ${LIBZIP_SOURCES} ${LIBZIP_EXTRA_FILES} ${LIBZIP_OPTIONAL_FILES} ${LIBZIP_OPSYS_FILES})
 
 IF(SHARED_LIB_VERSIONNING)
-SET_TARGET_PROPERTIES(zip PROPERTIES VERSION 5.1 SOVERSION 5)
+SET_TARGET_PROPERTIES(zip PROPERTIES VERSION 5.2 SOVERSION 5)
 ENDIF()
 
 
diff --git a/lib/zip.h b/lib/zip.h
index 018c948..ebedc1f 100644
--- a/lib/zip.h
+++ b/lib/zip.h
@@ -448,6 +448,8 @@
 ZIP_EXTERN int zip_unchange(zip_t * _Nonnull, zip_uint64_t);
 ZIP_EXTERN int zip_unchange_all(zip_t * _Nonnull);
 ZIP_EXTERN int zip_unchange_archive(zip_t * _Nonnull);
+ZIP_EXTERN int zip_compression_method_supported(zip_int32_t method, int compress);
+ZIP_EXTERN int zip_encryption_method_supported(zip_uint16_t method, int encode);
 
 #ifdef __cplusplus
 }
diff --git a/lib/zip_get_encryption_implementation.c b/lib/zip_get_encryption_implementation.c
index 5ec8db5..54456ad 100644
--- a/lib/zip_get_encryption_implementation.c
+++ b/lib/zip_get_encryption_implementation.c
@@ -52,3 +52,11 @@
         return NULL;
     }
 }
+
+ZIP_EXTERN int
+zip_encryption_method_supported(zip_uint16_t method, int encode) {
+    if (method == ZIP_EM_NONE) {
+        return 1;
+    }
+    return _zip_get_encryption_implementation(method, encode ? ZIP_CODEC_ENCODE : ZIP_CODEC_DECODE) != NULL;
+}
diff --git a/lib/zip_source_compress.c b/lib/zip_source_compress.c
index 59b1212..4c318e0 100644
--- a/lib/zip_source_compress.c
+++ b/lib/zip_source_compress.c
@@ -106,10 +106,10 @@
     return NULL;
 }
 
-bool
-zip_compression_method_supported(zip_int32_t method, bool compress) {
+ZIP_EXTERN int
+zip_compression_method_supported(zip_int32_t method, int compress) {
     if (method == ZIP_CM_STORE) {
-	return true;
+	return 1;
     }
     return get_algorithm(method, compress) != NULL;
 }
diff --git a/lib/zipint.h b/lib/zipint.h
index 127d532..b507942 100644
--- a/lib/zipint.h
+++ b/lib/zipint.h
@@ -157,8 +157,6 @@
 extern zip_compression_algorithm_t zip_algorithm_xz_decompress;
 
 
-bool zip_compression_method_supported(zip_int32_t method, bool compress);
-
 /* This API is not final yet, but we need it internally, so it's private for now. */
 
 const zip_uint8_t *zip_get_extra_field_by_id(zip_t *, int, int, zip_uint16_t, int, zip_uint16_t *);
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
index 5d7325a..19d57bc 100644
--- a/man/CMakeLists.txt
+++ b/man/CMakeLists.txt
@@ -4,9 +4,11 @@
   zip_add.3
   zip_add_dir.3
   zip_close.3
+  zip_compression_method_supported.3
   zip_delete.3
   zip_dir_add.3
   zip_discard.3
+  zip_encryption_method_supported.3
   zip_error_clear.3
   zip_error_code_system.3
   zip_error_code_zip.3
diff --git a/man/libzip.mdoc b/man/libzip.mdoc
index 72f18db..70917db 100644
--- a/man/libzip.mdoc
+++ b/man/libzip.mdoc
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 7, 2020
+.Dd April 2, 2020
 .Dt LIBZIP 3
 .Os
 .Sh NAME
@@ -106,6 +106,10 @@
 .It
 .Xr zip_stat 3
 .It
+.Xr zip_compression_method_supported 3
+.It
+.Xr zip_encryption_method_supported 3
+.It
 .Xr zip_file_get_comment 3
 .It
 .Xr zip_file_get_external_attributes 3
diff --git a/man/zip_compression_method_supported.mdoc b/man/zip_compression_method_supported.mdoc
new file mode 100644
index 0000000..b375a30
--- /dev/null
+++ b/man/zip_compression_method_supported.mdoc
@@ -0,0 +1,65 @@
+.\" zip_compression_method_supported.mdoc -- return if compression method is supported
+.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner
+.\"
+.\" This file is part of libzip, a library to manipulate ZIP files.
+.\" The authors can be contacted at <libzip@nih.at>
+.\"
+.\" 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.
+.\" 3. The names of the authors may not be used to endorse or promote
+.\"    products derived from this software without specific prior
+.\"    written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
+.\"
+.Dd April 2, 2020
+.Dt ZIP_COMPRESSION_METHOD_SUPPORTED 3
+.Os
+.Sh NAME
+.Nm zip_compression_method_supported
+.Nd return if a compression method is supported
+.Sh LIBRARY
+libzip (-lzip)
+.Sh SYNOPSIS
+.In zip.h
+.Ft int
+.Fn zip_compression_method_supported "zip_int32_t method" "int compress"
+.Sh DESCRIPTION
+The
+.Fn zip_compression_method_supported
+returns if the compression method
+.Ar method
+is supported for compression (if
+.Ar compress
+is zero) or decompression (otherwise).
+.Sh RETURN VALUES
+Returns 1 if the method is supported, 0 otherwise.
+.Sh SEE ALSO
+.Xr libzip 3 ,
+.Xr zip_encryption_method_supported 3 ,
+.Xr zip_set_file_compression 3
+.Sh HISTORY
+.Fn zip_compression_method_supported
+was added in libzip 1.7.0.
+.Sh AUTHORS
+.An -nosplit
+.An Dieter Baron Aq Mt dillo@nih.at
+and
+.An Thomas Klausner Aq Mt tk@giga.or.at
diff --git a/man/zip_encryption_method_supported.mdoc b/man/zip_encryption_method_supported.mdoc
new file mode 100644
index 0000000..43f6ff9
--- /dev/null
+++ b/man/zip_encryption_method_supported.mdoc
@@ -0,0 +1,65 @@
+.\" zip_encryption_method_supported.mdoc -- return if encryption method is supported
+.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner
+.\"
+.\" This file is part of libzip, a library to manipulate ZIP files.
+.\" The authors can be contacted at <libzip@nih.at>
+.\"
+.\" 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.
+.\" 3. The names of the authors may not be used to endorse or promote
+.\"    products derived from this software without specific prior
+.\"    written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
+.\"
+.Dd April 2, 2020
+.Dt ZIP_ENCRYPTION_METHOD_SUPPORTED 3
+.Os
+.Sh NAME
+.Nm zip_encryption_method_supported
+.Nd return if an encryption method is supported
+.Sh LIBRARY
+libzip (-lzip)
+.Sh SYNOPSIS
+.In zip.h
+.Ft int
+.Fn zip_encryption_method_supported "zip_int16_t method" "int encrypt"
+.Sh DESCRIPTION
+The
+.Fn zip_encryption_method_supported
+returns if the encryption method
+.Ar method
+is supported for encryption (if
+.Ar encrypt
+is zero) or decryption (otherwise).
+.Sh RETURN VALUES
+Returns 1 if the method is supported, 0 otherwise.
+.Sh SEE ALSO
+.Xr libzip 3 ,
+.Xr zip_compression_method_supported 3 ,
+.Xr zip_file_set_encryption 3
+.Sh HISTORY
+.Fn zip_encryption_method_supported
+was added in libzip 1.7.0.
+.Sh AUTHORS
+.An -nosplit
+.An Dieter Baron Aq Mt dillo@nih.at
+and
+.An Thomas Klausner Aq Mt tk@giga.or.at
diff --git a/man/zip_file_set_encryption.mdoc b/man/zip_file_set_encryption.mdoc
index a09c42a..f2b2620 100644
--- a/man/zip_file_set_encryption.mdoc
+++ b/man/zip_file_set_encryption.mdoc
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 18, 2017
+.Dd April 2, 2020
 .Dt ZIP_FILE_SET_ENCRYPTION 3
 .Os
 .Sh NAME
@@ -102,6 +102,9 @@
 .El
 .Sh SEE ALSO
 .Xr libzip 3 ,
+.Xr zip_encryption_method_supported 3 ,
+.Xr zip_fopen_encrypted 3 ,
+.Xr zip_fopen_index_encrypted 3 ,
 .Xr zip_set_default_password 3 ,
 .Xr zip_stat 3
 .Sh HISTORY
diff --git a/man/zip_set_file_compression.mdoc b/man/zip_set_file_compression.mdoc
index 3d3b5f4..db7c10e 100644
--- a/man/zip_set_file_compression.mdoc
+++ b/man/zip_set_file_compression.mdoc
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 18, 2017
+.Dd April 2, 2020
 .Dt ZIP_SET_FILE_COMPRESSION 3
 .Os
 .Sh NAME
@@ -112,6 +112,7 @@
 .El
 .Sh SEE ALSO
 .Xr libzip 3 ,
+.Xr zip_compression_method_supported 3 ,
 .Xr zip_stat 3
 .Sh HISTORY
 .Fn zip_set_file_compression
diff --git a/src/ziptool.c b/src/ziptool.c
index 66a75a7..00376a6 100644
--- a/src/ziptool.c
+++ b/src/ziptool.c
@@ -820,25 +820,34 @@
 	fprintf(out, "\t%s %s\n\t    %s\n\n", dispatch_table[i].cmdline_name, dispatch_table[i].arg_names, dispatch_table[i].description);
     }
     fprintf(out, "\nSupported flags are:\n"
-		 "\t0\t(no flags)\n"
-		 "\tC\tZIP_FL_NOCASE\n"
-		 "\tc\tZIP_FL_CENTRAL\n"
-		 "\td\tZIP_FL_NODIR\n"
-		 "\tl\tZIP_FL_LOCAL\n"
-		 "\tu\tZIP_FL_UNCHANGED\n");
+	    "\t0\t(no flags)\n"
+	    "\tC\tZIP_FL_NOCASE\n"
+	    "\tc\tZIP_FL_CENTRAL\n"
+	    "\td\tZIP_FL_NODIR\n"
+	    "\tl\tZIP_FL_LOCAL\n"
+	    "\tu\tZIP_FL_UNCHANGED\n");
     fprintf(out, "\nSupported compression methods are:\n"
-		 "\tdefault\n"
-#if defined(HAVE_LIBBZ2)
-		 "\tbzip2\n"
-#endif
-		 "\tdeflate\n"
-		 "\tstore\n");
-    fprintf(out, "\nSupported compression methods are:\n"
-		 "\tnone\n"
-		 "\tPKWARE\n"
-		 "\tAES-128\n"
-		 "\tAES-192\n"
-		 "\tAES-256\n");
+	    "\tdefault\n");
+    if (zip_compression_method_supported(ZIP_CM_BZIP2, 1)) {
+	fprintf(out, "\tbzip2\n");
+    }
+    fprintf(out, "\tdeflate\n"
+	    "\tstore\n");
+    if (zip_compression_method_supported(ZIP_CM_XZ, 1)) {
+	fprintf(out, "\txz\n");
+    }
+    fprintf(out, "\nSupported encryption methods are:\n"
+	    "\tnone\n");
+    if (zip_encryption_method_supported(ZIP_EM_AES_128, 1)) {
+	fprintf(out, "\tAES-128\n");
+    }
+    if (zip_encryption_method_supported(ZIP_EM_AES_192, 1)) {
+	fprintf(out, "\tAES-192\n");
+    }
+    if (zip_encryption_method_supported(ZIP_EM_AES_256, 1)) {
+	fprintf(out, "\tAES-256\n");
+    }
+    fprintf(out, "\tPKWARE\n");
     fprintf(out, "\nThe index is zero-based.\n");
     exit(0);
 }