crypto_v1.h 1.7 KB

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