nrf_ecb.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is confidential property of Nordic
  4. * Semiconductor ASA.Terms and conditions of usage are described in detail
  5. * in NORDIC SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. * $LastChangedRevision: 13999 $
  12. */
  13. /**
  14. * @file
  15. * @brief ECB driver API.
  16. */
  17. #ifndef NRF_ECB_H__
  18. #define NRF_ECB_H__
  19. /**
  20. * @defgroup nrf_ecb AES ECB encryption
  21. * @{
  22. * @ingroup nrf_drivers
  23. * @brief Driver for the AES Electronic Code Book (ECB) peripheral.
  24. *
  25. * To encrypt and decrypt data, the peripheral must first be powered on
  26. * using @ref nrf_ecb_init. Next, the key must be set using @ref nrf_ecb_set_key.
  27. */
  28. #include <stdint.h>
  29. /**
  30. * @brief Function for initializing and powering on the ECB peripheral.
  31. *
  32. * This function allocates memory for the ECBDATAPTR.
  33. * @retval true If initialization was successful.
  34. * @retval false If powering on failed.
  35. */
  36. bool nrf_ecb_init(void);
  37. /**
  38. * @brief Function for encrypting and decrypting 16-byte data using current key.
  39. *
  40. * This function avoids unnecessary copying of data if the parameters point to the
  41. * correct locations in the ECB data structure.
  42. *
  43. * @param dst Result of encryption/decryption. 16 bytes will be written.
  44. * @param src Source with 16-byte data to be encrypted/decrypted.
  45. *
  46. * @retval true If the encryption operation completed.
  47. * @retval false If the encryption operation did not complete.
  48. */
  49. bool nrf_ecb_crypt(uint8_t * dst, const uint8_t * src);
  50. /**
  51. * @brief Function for setting the key to be used for encryption and decryption.
  52. *
  53. * @param key Pointer to the key. 16 bytes will be read.
  54. */
  55. void nrf_ecb_set_key(const uint8_t * key);
  56. #endif // NRF_ECB_H__
  57. /** @} */