CC3000HostDriver for device TI CC3000 some changes were made due to mbed compiler and the use of void*

Dependents:   CC3000Test

Committer:
dflet
Date:
Fri Aug 02 15:06:15 2013 +0000
Revision:
0:9cb694f00b7b
First commit TI CC3000HostDriver library

Who changed what in which revision?

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