mz_crypt.h 2.7 KB

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