crypto_wrapper.h 1000 B

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