assimp/contrib/unzip/crypt.h

64 lines
1.9 KiB
C
Raw Normal View History

2020-12-24 00:53:40 +00:00
/* crypt.h -- base code for traditional PKWARE encryption
2015-08-08 16:02:37 +00:00
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
2020-12-24 00:53:40 +00:00
Modifications for Info-ZIP crypting
Copyright (C) 2003 Terry Thorsen
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
This code is a modified version of crypting code in Info-ZIP distribution
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
#ifndef _MINICRYPT_H
#define _MINICRYPT_H
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
#if ZLIB_VERNUM < 0x1270
2022-01-09 07:19:33 +00:00
#if !defined(Z_U4)
2020-12-24 00:53:40 +00:00
typedef unsigned long z_crc_t;
#endif
2022-01-09 07:19:33 +00:00
#endif
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
#define RAND_HEAD_LEN 12
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
/***************************************************************************/
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
#define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab, c ^= decrypt_byte(pkeys)))
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
#define zencode(pkeys,pcrc_32_tab,c,t) \
(t = decrypt_byte(pkeys), update_keys(pkeys,pcrc_32_tab,c), t^(c))
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
/***************************************************************************/
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
/* Return the next byte in the pseudo-random sequence */
uint8_t decrypt_byte(uint32_t *pkeys);
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
/* Update the encryption keys with the next byte of plain text */
uint8_t update_keys(uint32_t *pkeys, const z_crc_t *pcrc_32_tab, int32_t c);
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
/* Initialize the encryption keys and the random header according to the given password. */
void init_keys(const char *passwd, uint32_t *pkeys, const z_crc_t *pcrc_32_tab);
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
/* Generate cryptographically secure random numbers */
int cryptrand(unsigned char *buf, unsigned int len);
2015-08-08 16:02:37 +00:00
2020-12-24 00:53:40 +00:00
/* Create encryption header */
int crypthead(const char *passwd, uint8_t *buf, int buf_size, uint32_t *pkeys,
const z_crc_t *pcrc_32_tab, uint8_t verify1, uint8_t verify2);
/***************************************************************************/
#ifdef __cplusplus
2015-08-08 16:02:37 +00:00
}
2020-12-24 00:53:40 +00:00
#endif
2015-08-08 16:02:37 +00:00
#endif