crypto_v3.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include <stddef.h>
  5. #include "../../types/crypto_settings.h"
  6. #include "common_types.h"
  7. /**
  8. * @brief Encrypts plain data using built-in certificate and given initialization vector (IV)
  9. * @param plain_data plain data to be encrypted
  10. * @param plain_data_length plain data length
  11. * @param crypto_settings crypto settings
  12. * @param[out] encrypted_data_length encrypted data length
  13. * @return Encrypted data
  14. */
  15. uint8_t* totp_crypto_encrypt_v3(
  16. const uint8_t* plain_data,
  17. const size_t plain_data_length,
  18. const CryptoSettings* crypto_settings,
  19. size_t* encrypted_data_length);
  20. /**
  21. * @brief Decrypts encrypted data using built-in certificate and given initialization vector (IV)
  22. * @param encrypted_data encrypted data to be decrypted
  23. * @param encrypted_data_length encrypted data length
  24. * @param crypto_settings crypto settings
  25. * @param[out] decrypted_data_length decrypted data length
  26. * @return Decrypted data
  27. */
  28. uint8_t* totp_crypto_decrypt_v3(
  29. const uint8_t* encrypted_data,
  30. const size_t encrypted_data_length,
  31. const CryptoSettings* crypto_settings,
  32. size_t* decrypted_data_length);
  33. /**
  34. * @brief Seed initialization vector (IV) using user's PIN
  35. * @param crypto_settings crypto settings
  36. * @param pin user's PIN
  37. * @param pin_length user's PIN length
  38. * @return Results of seeding IV
  39. */
  40. CryptoSeedIVResult
  41. totp_crypto_seed_iv_v3(CryptoSettings* crypto_settings, const uint8_t* pin, uint8_t pin_length);
  42. /**
  43. * @brief Verifies whether cryptographic information (certificate + IV) is valid and can be used for encryption and decryption
  44. * @param crypto_settings crypto settings
  45. * @return \c true if cryptographic information is valid; \c false otherwise
  46. */
  47. bool totp_crypto_verify_key_v3(const CryptoSettings* crypto_settings);