| 1 | /* mz_crypt.h -- Crypto/hash functions |
| 2 | part of the minizip-ng project |
| 3 | |
| 4 | Copyright (C) Nathan Moinvaziri |
| 5 | https://github.com/zlib-ng/minizip-ng |
| 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 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | /***************************************************************************/ |
| 19 | |
| 20 | uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size); |
| 21 | |
| 22 | int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, int32_t salt_length, |
| 23 | uint32_t iteration_count, uint8_t *key, uint16_t key_length); |
| 24 | |
| 25 | /***************************************************************************/ |
| 26 | |
| 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 | int32_t mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm); |
| 34 | void *mz_crypt_sha_create(void); |
| 35 | void mz_crypt_sha_delete(void **handle); |
| 36 | |
| 37 | void mz_crypt_aes_reset(void *handle); |
| 38 | int32_t mz_crypt_aes_encrypt(void *handle, const void *aad, int32_t aad_size, uint8_t *buf, int32_t size); |
| 39 | int32_t mz_crypt_aes_encrypt_final(void *handle, uint8_t *buf, int32_t size, uint8_t *tag, int32_t tag_size); |
| 40 | int32_t mz_crypt_aes_decrypt(void *handle, const void *aad, int32_t aad_size, uint8_t *buf, int32_t size); |
| 41 | int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, const uint8_t *tag, int32_t tag_size); |
| 42 | int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length, const void *iv, |
| 43 | int32_t iv_length); |
| 44 | int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length, const void *iv, |
| 45 | int32_t iv_length); |
| 46 | void mz_crypt_aes_set_mode(void *handle, int32_t mode); |
| 47 | void *mz_crypt_aes_create(void); |
| 48 | void mz_crypt_aes_delete(void **handle); |
| 49 | |
| 50 | void mz_crypt_hmac_reset(void *handle); |
| 51 | int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length); |
| 52 | int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size); |
| 53 | int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size); |
| 54 | int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle); |
| 55 | void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm); |
| 56 | void *mz_crypt_hmac_create(void); |
| 57 | void mz_crypt_hmac_delete(void **handle); |
| 58 | |
| 59 | /***************************************************************************/ |
| 60 | |
| 61 | #ifdef __cplusplus |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | #endif |