Files
Momentum-Firmware/applications/external/esubghz_chat/crypto_wrapper.h
Willy-JL 12004d0ef4 Format
2023-08-11 22:55:06 +02:00

40 lines
1011 B
C

#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define RUN_ID_BYTES (sizeof(uint64_t))
#define COUNTER_BYTES (sizeof(uint32_t))
#define KEY_BITS 256
#define IV_BYTES 12
#define TAG_BYTES 16
#define MSG_OVERHEAD (RUN_ID_BYTES + COUNTER_BYTES + IV_BYTES + TAG_BYTES)
typedef struct ESugGhzChatCryptoCtx ESubGhzChatCryptoCtx;
void crypto_init(void);
/* Function to clear sensitive memory. */
void crypto_explicit_bzero(void* s, size_t len);
ESubGhzChatCryptoCtx* crypto_ctx_alloc(void);
void crypto_ctx_free(ESubGhzChatCryptoCtx* ctx);
void crypto_ctx_clear(ESubGhzChatCryptoCtx* ctx);
bool crypto_ctx_set_key(
ESubGhzChatCryptoCtx* ctx,
const uint8_t* key,
FuriString* flipper_name,
uint32_t tick);
void crypto_ctx_get_key(ESubGhzChatCryptoCtx* ctx, uint8_t* key);
bool crypto_ctx_decrypt(ESubGhzChatCryptoCtx* ctx, uint8_t* in, size_t in_len, uint8_t* out);
bool crypto_ctx_encrypt(ESubGhzChatCryptoCtx* ctx, uint8_t* in, size_t in_len, uint8_t* out);
#ifdef __cplusplus
}
#endif