41 #include <openssl/rand.h>
43 #if OPENSSL_VERSION_NUMBER < 0x1010000fL || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL)
44 #define USE_OPENSSL_1_0_API
51 const EVP_CIPHER* cipher_type;
55 cipher_type = EVP_aes_128_ecb();
58 cipher_type = EVP_aes_192_ecb();
61 cipher_type = EVP_aes_256_ecb();
68 #ifdef USE_OPENSSL_1_0_API
73 memset(aes, 0,
sizeof(*aes));
75 if ((aes = EVP_CIPHER_CTX_new()) ==
NULL) {
81 if (EVP_EncryptInit_ex(aes, cipher_type,
NULL,
key,
NULL) != 1) {
82 #ifdef USE_OPENSSL_1_0_API
85 EVP_CIPHER_CTX_free(aes);
100 #ifdef USE_OPENSSL_1_0_API
101 EVP_CIPHER_CTX_cleanup(aes);
105 EVP_CIPHER_CTX_free(aes);
129 #ifdef USE_OPENSSL_1_0_API
137 if ((hmac = HMAC_CTX_new()) ==
NULL) {
143 if (HMAC_Init_ex(hmac, secret, (
int)secret_length, EVP_sha1(),
NULL) != 1) {
145 #ifdef USE_OPENSSL_1_0_API
163 #ifdef USE_OPENSSL_1_0_API
164 HMAC_CTX_cleanup(hmac);
177 return HMAC_Final(hmac, data, &
length) == 1;
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
void * malloc(size_t size)
void error(const char *msg)
#define ZIP_CRYPTO_AES_BLOCK_LENGTH
bool _zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data)
bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out)
void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac)
void _zip_crypto_aes_free(_zip_crypto_aes_t *aes)
_zip_crypto_aes_t * _zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error)
ZIP_EXTERN bool zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length)
_zip_crypto_hmac_t * _zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error)
#define _zip_crypto_clear(b, l)