mz_crypt.h 2.7 KB

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