crypto_wrapper.h 779 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #ifdef __cplusplus
  3. extern "C" {
  4. #endif
  5. #define KEY_BITS 256
  6. #define IV_BYTES 12
  7. #define TAG_BYTES 16
  8. #define MSG_OVERHEAD (IV_BYTES + TAG_BYTES)
  9. typedef struct ESugGhzChatCryptoCtx ESubGhzChatCryptoCtx;
  10. void crypto_init(void);
  11. /* Function to clear sensitive memory. */
  12. void crypto_explicit_bzero(void *s, size_t len);
  13. ESubGhzChatCryptoCtx *crypto_ctx_alloc(void);
  14. void crypto_ctx_free(ESubGhzChatCryptoCtx *ctx);
  15. void crypto_ctx_clear(ESubGhzChatCryptoCtx *ctx);
  16. bool crypto_ctx_set_key(ESubGhzChatCryptoCtx *ctx, const uint8_t *key);
  17. bool crypto_ctx_decrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
  18. uint8_t *out);
  19. bool crypto_ctx_encrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
  20. uint8_t *out);
  21. #ifdef __cplusplus
  22. }
  23. #endif