crypto_wrapper.h 845 B

1234567891011121314151617181920212223242526272829303132333435
  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. void crypto_ctx_get_key(ESubGhzChatCryptoCtx *ctx, uint8_t *key);
  18. bool crypto_ctx_decrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
  19. uint8_t *out);
  20. bool crypto_ctx_encrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
  21. uint8_t *out);
  22. #ifdef __cplusplus
  23. }
  24. #endif