security.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*****************************************************************************
  2. *
  3. * security.h - CC3000 Host Driver Implementation.
  4. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * Neither the name of Texas Instruments Incorporated nor the names of
  19. * its contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. *****************************************************************************/
  35. #ifndef __CC3000_SECURITY__
  36. #define __CC3000_SECURITY__
  37. #include "nvmem.h"
  38. //*****************************************************************************
  39. //
  40. // If building with a C++ compiler, make all of the definitions in this header
  41. // have a C binding.
  42. //
  43. //*****************************************************************************
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. #define AES128_KEY_SIZE 16
  48. #ifndef CC3000_UNENCRYPTED_SMART_CONFIG
  49. //*****************************************************************************
  50. //
  51. //! aes_encrypt
  52. //!
  53. //! @param[in] key AES128 key of size 16 bytes
  54. //! @param[in\out] state 16 bytes of plain text and cipher text
  55. //!
  56. //! @return none
  57. //!
  58. //! @brief AES128 encryption:
  59. //! Given AES128 key and 16 bytes plain text, cipher text of 16 bytes
  60. //! is computed. The AES implementation is in mode ECB (Electronic
  61. //! Code Book).
  62. //!
  63. //!
  64. //*****************************************************************************
  65. extern void aes_encrypt(UINT8 *state, UINT8 *key);
  66. //*****************************************************************************
  67. //
  68. //! aes_decrypt
  69. //!
  70. //! @param[in] key AES128 key of size 16 bytes
  71. //! @param[in\out] state 16 bytes of cipher text and plain text
  72. //!
  73. //! @return none
  74. //!
  75. //! @brief AES128 decryption:
  76. //! Given AES128 key and 16 bytes cipher text, plain text of 16 bytes
  77. //! is computed The AES implementation is in mode ECB
  78. //! (Electronic Code Book).
  79. //!
  80. //!
  81. //*****************************************************************************
  82. extern void aes_decrypt(UINT8 *state, UINT8 *key);
  83. //*****************************************************************************
  84. //
  85. //! aes_read_key
  86. //!
  87. //! @param[out] key AES128 key of size 16 bytes
  88. //!
  89. //! @return on success 0, error otherwise.
  90. //!
  91. //! @brief Reads AES128 key from EEPROM
  92. //! Reads the AES128 key from fileID #12 in EEPROM
  93. //! returns an error if the key does not exist.
  94. //!
  95. //!
  96. //*****************************************************************************
  97. extern INT32 aes_read_key(UINT8 *key);
  98. //*****************************************************************************
  99. //
  100. //! aes_write_key
  101. //!
  102. //! @param[out] key AES128 key of size 16 bytes
  103. //!
  104. //! @return on success 0, error otherwise.
  105. //!
  106. //! @brief writes AES128 key from EEPROM
  107. //! Writes the AES128 key to fileID #12 in EEPROM
  108. //!
  109. //!
  110. //*****************************************************************************
  111. extern INT32 aes_write_key(UINT8 *key);
  112. #endif //CC3000_UNENCRYPTED_SMART_CONFIG
  113. #ifdef __cplusplus
  114. }
  115. #endif // __cplusplus
  116. #endif