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