crypto_v2.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 key_slot key slot to be used
  10. * @param[out] encrypted_data_length encrypted data length
  11. * @return Encrypted data
  12. */
  13. uint8_t* totp_crypto_encrypt_v2(
  14. const uint8_t* plain_data,
  15. const size_t plain_data_length,
  16. const uint8_t* iv,
  17. uint8_t key_slot,
  18. size_t* encrypted_data_length);
  19. /**
  20. * @brief Decrypts encrypted data using built-in certificate and given initialization vector (IV)
  21. * @param encrypted_data encrypted data to be decrypted
  22. * @param encrypted_data_length encrypted data length
  23. * @param iv initialization vector (IV) to be used to encrypt plain data
  24. * @param key_slot key slot to be used
  25. * @param[out] decrypted_data_length decrypted data length
  26. * @return Decrypted data
  27. */
  28. uint8_t* totp_crypto_decrypt_v2(
  29. const uint8_t* encrypted_data,
  30. const size_t encrypted_data_length,
  31. const uint8_t* iv,
  32. uint8_t key_slot,
  33. size_t* decrypted_data_length);
  34. /**
  35. * @brief Seed initialization vector (IV) using user's PIN
  36. * @param plugin_state application state
  37. * @param key_slot key slot to be used
  38. * @param pin user's PIN
  39. * @param pin_length user's PIN length
  40. * @return Results of seeding IV
  41. */
  42. CryptoSeedIVResult
  43. totp_crypto_seed_iv_v2(PluginState* plugin_state, const uint8_t* pin, uint8_t pin_length);
  44. /**
  45. * @brief Verifies whether cryptographic information (certificate + IV) is valid and can be used for encryption and decryption
  46. * @param plugin_state application state
  47. * @return \c true if cryptographic information is valid; \c false otherwise
  48. */
  49. bool totp_crypto_verify_key_v2(const PluginState* plugin_state);