1 /* mz_crypt.h -- Crypto/hash functions 2 Version 2.8.1, December 1, 2018 3 part of the MiniZip project 4 5 Copyright (C) 2010-2018 Nathan Moinvaziri 6 https://github.com/nmoinvaz/minizip 7 8 This program is distributed under the terms of the same license as zlib. 9 See the accompanying LICENSE file for the full text of the license. 10 */ 11 12 #ifndef MZ_CRYPT_H 13 #define MZ_CRYPT_H 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /***************************************************************************/ 20 21 uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size); 22 23 int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, 24 int32_t salt_length, int32_t iteration_count, uint8_t *key, int32_t key_length); 25 26 /***************************************************************************/ 27 28 int32_t mz_crypt_rand(uint8_t *buf, int32_t size); 29 30 void mz_crypt_sha_reset(void *handle); 31 int32_t mz_crypt_sha_begin(void *handle); 32 int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size); 33 int32_t mz_crypt_sha_end(void *handle, uint8_t *digest, int32_t digest_size); 34 void mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm); 35 void* mz_crypt_sha_create(void **handle); 36 void mz_crypt_sha_delete(void **handle); 37 38 void mz_crypt_aes_reset(void *handle); 39 int32_t mz_crypt_aes_encrypt(void *handle, uint8_t *buf, int32_t size); 40 int32_t mz_crypt_aes_decrypt(void *handle, uint8_t *buf, int32_t size); 41 int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length); 42 int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length); 43 void mz_crypt_aes_set_mode(void *handle, int32_t mode); 44 void* mz_crypt_aes_create(void **handle); 45 void mz_crypt_aes_delete(void **handle); 46 47 void mz_crypt_hmac_reset(void *handle); 48 int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length); 49 int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size); 50 int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size); 51 int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle); 52 void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm); 53 void* mz_crypt_hmac_create(void **handle); 54 void mz_crypt_hmac_delete(void **handle); 55 56 int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size, 57 const char *cert_pwd, uint8_t **signature, int32_t *signature_size); 58 int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *signature, int32_t signature_size); 59 60 /***************************************************************************/ 61 62 #ifdef __cplusplus 63 } 64 #endif 65 66 #endif 67