#ifndef _HAD_ZIPINT_H #define _HAD_ZIPINT_H /* zipint.h -- internal declarations. Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted 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. */ #include "config.h" #include "compat.h" #ifdef ZIP_ALLOCATE_BUFFER #include #endif #include #ifndef _ZIP_COMPILING_DEPRECATED #define ZIP_DISABLE_DEPRECATED #endif #include "zip.h" #define CENTRAL_MAGIC "PK\1\2" #define LOCAL_MAGIC "PK\3\4" #define EOCD_MAGIC "PK\5\6" #define DATADES_MAGIC "PK\7\10" #define EOCD64LOC_MAGIC "PK\6\7" #define EOCD64_MAGIC "PK\6\6" #define CDENTRYSIZE 46u #define LENTRYSIZE 30 #define MAXCOMLEN 65536 #define MAXEXTLEN 65536 #define EOCDLEN 22 #define EOCD64LOCLEN 20 #define EOCD64LEN 56 #define CDBUFSIZE (MAXCOMLEN + EOCDLEN + EOCD64LOCLEN) #define BUFSIZE 8192 #define EFZIP64SIZE 28 #define EF_WINZIP_AES_SIZE 7 #define MAX_DATA_DESCRIPTOR_LENGTH 24 #define ZIP_CRYPTO_PKWARE_HEADERLEN 12 #define ZIP_CM_REPLACED_DEFAULT (-2) #define ZIP_CM_WINZIP_AES 99 /* Winzip AES encrypted */ #define WINZIP_AES_PASSWORD_VERIFY_LENGTH 2 #define WINZIP_AES_MAX_HEADER_LENGTH (16 + WINZIP_AES_PASSWORD_VERIFY_LENGTH) #define AES_BLOCK_SIZE 16 #define HMAC_LENGTH 10 #define SHA1_LENGTH 20 #define SALT_LENGTH(method) ((method) == ZIP_EM_AES_128 ? 8 : ((method) == ZIP_EM_AES_192 ? 12 : 16)) #define ZIP_CM_IS_DEFAULT(x) ((x) == ZIP_CM_DEFAULT || (x) == ZIP_CM_REPLACED_DEFAULT) #define ZIP_CM_ACTUAL(x) ((zip_uint16_t)(ZIP_CM_IS_DEFAULT(x) ? ZIP_CM_DEFLATE : (x))) #define ZIP_EF_UTF_8_COMMENT 0x6375 #define ZIP_EF_UTF_8_NAME 0x7075 #define ZIP_EF_WINZIP_AES 0x9901 #define ZIP_EF_ZIP64 0x0001 #define ZIP_EF_IS_INTERNAL(id) ((id) == ZIP_EF_UTF_8_COMMENT || (id) == ZIP_EF_UTF_8_NAME || (id) == ZIP_EF_WINZIP_AES || (id) == ZIP_EF_ZIP64) /* according to unzip-6.0's zipinfo.c, this corresponds to a regular file with rw permissions for everyone */ #define ZIP_EXT_ATTRIB_DEFAULT (0100666u << 16) /* according to unzip-6.0's zipinfo.c, this corresponds to a directory with rwx permissions for everyone */ #define ZIP_EXT_ATTRIB_DEFAULT_DIR (0040777u << 16) #define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK 0x0836 #define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b)) #define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b)) /* This section contains API that won't materialize like this. It's placed in the internal section, pending cleanup. */ /* flags for compression and encryption sources */ #define ZIP_CODEC_DECODE 0 /* decompress/decrypt (encode flag not set) */ #define ZIP_CODEC_ENCODE 1 /* compress/encrypt */ typedef zip_source_t *(*zip_encryption_implementation)(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); zip_encryption_implementation _zip_get_encryption_implementation(zip_uint16_t method, int operation); /* clang-format off */ enum zip_compression_status { ZIP_COMPRESSION_OK, ZIP_COMPRESSION_END, ZIP_COMPRESSION_ERROR, ZIP_COMPRESSION_NEED_DATA }; /* clang-format on */ typedef enum zip_compression_status zip_compression_status_t; struct zip_compression_algorithm { /* called once to create new context */ void *(*allocate)(zip_uint16_t method, int compression_flags, zip_error_t *error); /* called once to free context */ void (*deallocate)(void *ctx); /* get compression specific general purpose bitflags */ zip_uint16_t (*general_purpose_bit_flags)(void *ctx); /* minimum version needed when using this algorithm */ zip_uint8_t version_needed; /* start processing */ bool (*start)(void *ctx); /* stop processing */ bool (*end)(void *ctx); /* provide new input data, remains valid until next call to input or end */ bool (*input)(void *ctx, zip_uint8_t *data, zip_uint64_t length); /* all input data has been provided */ void (*end_of_input)(void *ctx); /* process input data, writing to data, which has room for length bytes, update length to number of bytes written */ zip_compression_status_t (*process)(void *ctx, zip_uint8_t *data, zip_uint64_t *length); }; typedef struct zip_compression_algorithm zip_compression_algorithm_t; extern zip_compression_algorithm_t zip_algorithm_bzip2_compress; extern zip_compression_algorithm_t zip_algorithm_bzip2_decompress; extern zip_compression_algorithm_t zip_algorithm_deflate_compress; extern zip_compression_algorithm_t zip_algorithm_deflate_decompress; extern zip_compression_algorithm_t zip_algorithm_xz_compress; extern zip_compression_algorithm_t zip_algorithm_xz_decompress; /* 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 *); /* This section contains API that is of limited use until support for user-supplied compression/encryption implementation is finished. Thus we will keep it private for now. */ typedef zip_int64_t (*zip_source_layered_callback)(zip_source_t *, void *, void *, zip_uint64_t, enum zip_source_cmd); zip_source_t *zip_source_compress(zip_t *za, zip_source_t *src, zip_int32_t cm, int compression_flags); zip_source_t *zip_source_crc(zip_t *, zip_source_t *, int); zip_source_t *zip_source_decompress(zip_t *za, zip_source_t *src, zip_int32_t cm); zip_source_t *zip_source_layered(zip_t *, zip_source_t *, zip_source_layered_callback, void *); zip_source_t *zip_source_layered_create(zip_source_t *src, zip_source_layered_callback cb, void *ud, zip_error_t *error); zip_source_t *zip_source_pkware_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); zip_source_t *zip_source_pkware_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); int zip_source_remove(zip_source_t *); zip_int64_t zip_source_supports(zip_source_t *src); zip_source_t *zip_source_window(zip_t *, zip_source_t *, zip_uint64_t, zip_uint64_t); zip_source_t *zip_source_winzip_aes_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); zip_source_t *zip_source_winzip_aes_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); zip_source_t *zip_source_buffer_with_attributes(zip_t *za, const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes); /* error source for layered sources */ enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL }; /* directory entry: general purpose bit flags */ #define ZIP_GPBF_ENCRYPTED 0x0001u /* is encrypted */ #define ZIP_GPBF_DATA_DESCRIPTOR 0x0008u /* crc/size after file data */ #define ZIP_GPBF_STRONG_ENCRYPTION 0x0040u /* uses strong encryption */ #define ZIP_GPBF_ENCODING_UTF_8 0x0800u /* file name encoding is UTF-8 */ /* extra fields */ #define ZIP_EF_LOCAL ZIP_FL_LOCAL /* include in local header */ #define ZIP_EF_CENTRAL ZIP_FL_CENTRAL /* include in central directory */ #define ZIP_EF_BOTH (ZIP_EF_LOCAL | ZIP_EF_CENTRAL) /* include in both */ #define ZIP_FL_FORCE_ZIP64 1024 /* force zip64 extra field (_zip_dirent_write) */ #define ZIP_FL_ENCODING_ALL (ZIP_FL_ENC_GUESS | ZIP_FL_ENC_CP437 | ZIP_FL_ENC_UTF_8) /* encoding type */ enum zip_encoding_type { ZIP_ENCODING_UNKNOWN, /* not yet analyzed */ ZIP_ENCODING_ASCII, /* plain ASCII */ ZIP_ENCODING_UTF8_KNOWN, /* is UTF-8 */ ZIP_ENCODING_UTF8_GUESSED, /* possibly UTF-8 */ ZIP_ENCODING_CP437, /* Code Page 437 */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>VeraCrypt - Бесплатное надёжное шифрование дисков с открытым исходным кодом</title>
<meta name="description" content="VeraCrypt это бесплатное программное обеспечение для шифрования дисков с открытым исходным кодом для Windows, Mac OS X (macOS) и Linux. В случае, если злоумышленник вынуждает вас раскрыть пароль, VeraCrypt обеспечивает правдоподобное отрицание наличия шифрования. В отличие от пофайлового шифрования, VeraCrypt шифрует данные в реальном времени (на лету), автоматически, прозрачно, требует очень мало памяти и не использует временные незашифрованные файлы."/>
<meta name="keywords" content="encryption, security, шифрование, безопасность"/>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div>
<a href="Documentation.html"><img src="VeraCrypt128x128.png" alt="VeraCrypt"/></a>
</div>

<div id="menu">
	<ul>
	  <li><a href="Home.html">Начало</a></li>
	  <li><a href="/code/">Исходный код</a></li>
	  <li><a href="Downloads.html">Загрузить</a></li>
	  <li><a class="active" href="Documentation.html">Документация</a></li>
	  <li><a href="Donation.html">Поддержать разработку</a></li>
	  <li><a href="https://sourceforge.net/p/veracrypt/discussion/" target="_blank">Форум</a></li>
	</ul>
</div>

<div class="wikidoc">
<h1>Содержание</h1>
<p><em style="text-align:left">Эта документация поставляется по принципу &quot;как есть&quot;, без гарантии отсутствия ошибок и любых других гарантий.
См. подробности в разделе <a href="Disclaimers.html">Отказ от обязательств</a>.</em></p>
<ul>
<li><a title="Предисловие" href="Preface.html"><strong>Предисловие</strong></a>
</li><li><strong><a href="Introduction.html">Введение</a></strong>
</li><li><strong><a href="Beginner%27s%20Tutorial.html">Руководство для начинающих</a></strong>
</li><li><strong><a href="VeraCrypt%20Volume.html">Том VeraCrypt</a></strong>
<ul>
<li><a href="Creating%20New%20Volumes.html">Создание нового тома VeraCrypt</a>
</li><li><a href="Favorite%20Volumes.html">Избранные тома</a>
</li><li><a href="System%20Favorite%20Volumes.html">Системные избранные тома</a>
</li></ul>
</li><li><strong><a href="System%20Encryption.html">Шифрование системы</a></strong>
<ul>
<li><a href="Hidden%20Operating%20System.html">Скрытая операционная система</a>
</li><li><a href="Supported%20Systems%20for%20System%20Encryption.html">Операционные системы, поддерживающие системное шифрование</a>
</li><li><a href="VeraCrypt%20Rescue%20Disk.html">Диск восстановления VeraCrypt (Rescue Disk)</a>
</li></ul>
</li><li><strong><a href="Plausible%20Deniability.html">Правдоподобное отрицание наличия шифрования</a></strong><br>
<ul>
<li><a href="Hidden%20Volume.html">Скрытый том</a>
<ul>
<li><a href="Protection%20of%20Hidden%20Volumes.html">Защита скрытых томов от повреждений</a>
</li><li><a href="Security%20Requirements%20for%20Hidden%20Volumes.html">Требования безопасности и меры предосторожности, касающиеся скрытых томов</a>
</li></ul>
</li><li><a href="VeraCrypt%20Hidden%20Operating%20System.html">Скрытая операционная система</a>
</li></ul>
</li><li><strong><a href="Main%20Program%20Window.html">Главное окно программы</a></strong>
<ul>
<li><a href="Program%20Menu.html">Меню программы</a>
</li><li><a href="Mounting%20VeraCrypt%20Volumes.html">Монтирование томов</a>
</li></ul>
</li><li><strong><a href="Normal%20Dismount%20vs%20Force%20Dismount.html">Обычное размонтирование против принудительного</a></strong>
</li><li><strong><a href="Avoid%20Third-Party%20File%20Extensions.html">О рисках, связанных со сторонними расширениями файлов</a></strong>
</li><li><strong><a href="Parallelization.html">Распараллеливание</a></strong>
</li><li><strong><a href="Pipelining.html">Конвейеризация</a></strong>
</li><li><strong><a href="Hardware%20Acceleration.html">Аппаратное ускорение</a></strong>
</li><li><strong><a href="Hot%20Keys.html">Горячие клавиши</a></strong>
</li><li><strong><a href="Keyfiles%20in%20VeraCrypt.html">Ключевые файлы</a></strong>
</li><li><strong><a href="Security%20Tokens%20%26%20Smart%20Cards.html">Токены безопасности и смарт-карты</a></strong>
</li><li><strong><a href="EMV%20Smart%20Cards.html">Смарт-карты EMV</a></strong>
</li><li><strong><a href="Portable%20Mode.html">Портативный (переносной) режим</a></strong>
</li><li><strong><a href="TrueCrypt%20Support.html">Поддержка TrueCrypt</a></strong>
</li><li><strong><a href="Converting%20TrueCrypt%20volumes%20and%20partitions.html">Преобразование томов и разделов TrueCrypt в формат VeraCrypt</a></strong>
</li><li><strong><a href="Conversion_Guide_VeraCrypt_1.26_and_Later.html">Руководство по преобразованию томов для версий 1.26 и новее</a></strong>
</li><li><strong><a href="Default%20Mount%20Parameters.html">Параметры монтирования по умолчанию</a></strong>
</li><li><strong><a href="Language%20Packs.html">Языковые пакеты</a></strong>
</li><li><strong><a href="Encryption%20Algorithms.html">Алгоритмы шифрования</a></strong>
<ul>
<li><a href="AES.html">AES</a> </li><li><a href="Camellia.html">Camellia</a>
</li><li><a href="Kuznyechik.html">Kuznyechik</a>
</li><li><a href="Serpent.html">Serpent</a> </li><li><a href="Twofish.html">Twofish</a> </li><li><a href="Cascades.html">Каскады шифров</a>
</li></ul>
</li><li><strong><a href="Hash%20Algorithms.html">Алгоритмы хеширования</a></strong>
<ul>
<li><a href="BLAKE2s-256.html">BLAKE2s-256</a></li>
<li><a href="SHA-256.html">SHA-256</a></li>
<li><a href="SHA-512.html">SHA-512</a></li>
<li><a href="Whirlpool.html">Whirlpool</a></li>
<li><a href="Streebog.html">Streebog</a></li>
</ul>
</li><li><strong><a href="Supported%20Operating%20Systems.html">Поддерживаемые операционные системы</a></strong>
</li><li><strong><a href="Command%20Line%20Usage.html">Использование в командной строке</a></strong>
</li><li><strong><a href="Security%20Model.html">Модель безопасности</a></strong>
</li><li><strong><a href="Security%20Requirements%20and%20Precautions.html">Требования безопасности и меры предосторожности<br>
</a></strong>
<ul>
<li><a href="Data%20Leaks.html">Утечки данных</a>
<ul>
<li><a href="Paging%20File.html">Файл подкачки</a>
</li><li><a href="Memory%20Dump%20Files.html">Файлы дампа памяти</a>
</li><li><a href="Hibernation%20File.html">Файл гибернации</a>
</li></ul>
</li><li><a href="Unencrypted%20Data%20in%20RAM.html">Незашифрованные данные в ОЗУ</a>
</li><li><a href="VeraCrypt%20RAM%20Encryption.html">Шифрование оперативной памяти в VeraCrypt</a>
</li><li><a href="VeraCrypt%20Memory%20Protection.html">Защита памяти в VeraCrypt</a>
</li><li><a href="Physical%20Security.html">Физическая безопасность</a>
</li><li><a href="Malware.html">Вредоносное ПО (malware)</a> </li><li><a href="Multi-User%20Environment.html">Многопользовательская среда</a>
</li><li><a href="Authenticity%20and%20Integrity.html">Подлинность и целостность данных</a>
</li><li><a href="Choosing%20Passwords%20and%20Keyfiles.html">Выбор паролей и ключевых файлов</a>
</li><li><a href="Changing%20Passwords%20and%20Keyfiles.html">Изменение паролей и ключевых файлов</a>
</li><li><a href="Trim%20Operation.html">Операция Trim</a>
</li><li><a href="Wear-Leveling.html">Распределение износа (Wear-Leveling)</a>
</li><li><a href="Reallocated%20Sectors.html">Перераспределённые сектора</a>
</li><li><a href="Defragmenting.html">Дефрагментация</a>
</li><li><a href="Journaling%20File%20Systems.html">Журналируемые файловые системы</a>
</li><li><a href="Volume%20Clones.html">Клонирование томов</a>
</li><li><a href="Additional%20Security%20Requirements%20and%20Precautions.html">Дополнительные требования безопасности и меры предосторожности</a>
</li></ul>
</li><li><strong><a href="How%20to%20Back%20Up%20Securely.html">О безопасном резервном копировании</a></strong>
</li><li><strong><a href="Miscellaneous.html">Разное</a></strong>
<ul>
<li><a href="Using%20VeraCrypt%20Without%20Administrator%20Privileges.html">Использование VeraCrypt без прав администратора</a>
</li><li><a href="Sharing%20over%20Network.html">Общий доступ по сети</a>
</li><li><a href="VeraCrypt%20Background%20Task.html">Работа VeraCrypt в фоновом режиме</a>
</li><li><a href="Removable%20Medium%20Volume.html">Том, смонтированный как сменный носитель</a>
</li><li><a href="VeraCrypt%20System%20Files.html">Системные файлы VeraCrypt и программные данные</a>
</li><li><a href="Removing%20Encryption.html">Как удалить шифрование</a>
</li><li><a href="Uninstalling%20VeraCrypt.html">Удаление VeraCrypt</a>
</li><li><a href="Digital%20Signatures.html">Цифровые подписи</a>
</li></ul>
</li><li><strong><a href="Troubleshooting.html">Устранение затруднений</a></strong>
</li><li><strong><a href="Incompatibilities.html">Несовместимости</a></strong>
</li><li><strong><a href="Issues%20and%20Limitations.html">Замеченные проблемы и ограничения</a></strong>
</li><li><strong><a href="FAQ.html">Вопросы и ответы</a></strong>
</li><li><strong><a href="Technical%20Details.html">Технические подробности</a></strong>
<ul>
<li><a href="Notation.html">Система обозначений</a>
</li><li><a href="Encryption%20Scheme.html">Схема шифрования</a>
</li><li><a href="Modes%20of%20Operation.html">Режимы работы</a>
</li><li><a href="Header%20Key%20Derivation.html">Формирование ключа заголовка, соль и количество итераций</a>
</li><li><a href="Random%20Number%20Generator.html">Генератор случайных чисел</a>
</li><li><a href="Keyfiles.html">Ключевые файлы</a>
</li><li><a title="PIM" href="Personal%20Iterations%20Multiplier%20(PIM).html">PIM (Персональный множитель итераций)</a>
</li><li><a href="VeraCrypt%20Volume%20Format%20Specification.html">Спецификация формата томов VeraCrypt</a>
</li><li><a href="Standard%20Compliance.html">Соответствие стандартам и спецификациям</a>
</li><li><a href="Source%20Code.html">Исходный код программы</a>
</li><li><a href="CompilingGuidelines.html">Сборка VeraCrypt из исходного кода</a>
<ul>
<li><a href="CompilingGuidelineWin.html">Руководство по сборке в Windows</a>
</li><li><a href="CompilingGuidelineLinux.html">Руководство по сборке в Linux</a>
</li></ul>
</li></ul>
</li><li><strong><a href="Contact.html">Связь с авторами</a></strong>
</li><li><strong><a href="Legal%20Information.html">Правовая информация</a></strong>
</li><li><strong><a href="Release%20Notes.html">История версий</a></strong>
</li><li><strong><a href="Acknowledgements.html">Благодарности</a></strong>
</li><li><strong><a href="References.html">Ссылки</a></strong>
</li></ul>
</div>

</body></html>