aboutsummaryrefslogtreecommitdiff
path: root/stmhal/cc3k/security.c
diff options
context:
space:
mode:
authorDamien George2014-05-10 21:28:40 +0100
committerDamien George2014-05-10 21:28:40 +0100
commit50073ed5d61a89af95f1497c24965e50e95e6e9d (patch)
tree5cf8a2b051c25cc2dfcf87f1e8dd2a2c0b3abc8b /stmhal/cc3k/security.c
parent94d8246272b2df7dbfb70ec85ed06e3b13793bac (diff)
stmhal/cc3k: Remove spaces and tabs at end of lines.
Diffstat (limited to 'stmhal/cc3k/security.c')
-rw-r--r--stmhal/cc3k/security.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/stmhal/cc3k/security.c b/stmhal/cc3k/security.c
index c52d7f67e..dfd8d9432 100644
--- a/stmhal/cc3k/security.c
+++ b/stmhal/cc3k/security.c
@@ -12,23 +12,23 @@
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the
+* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
@@ -49,7 +49,7 @@
#ifndef CC3000_UNENCRYPTED_SMART_CONFIG
// foreward sbox
-const unsigned char sbox[256] = {
+const unsigned char sbox[256] = {
//0 1 2 3 4 5 6 7 8 9 A B C D E F
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1
@@ -66,7 +66,7 @@ const unsigned char sbox[256] = {
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E
-0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F
+0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F
// inverse sbox
const unsigned char rsbox[256] =
{ 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb
@@ -130,7 +130,7 @@ void expandKey(unsigned char *expandedKey,
expandedKey[ii*16 +14] = expandedKey[(ii-1)*16 +14]^expandedKey[ii*16 +10];
expandedKey[ii*16 +15] = expandedKey[(ii-1)*16 +15]^expandedKey[ii*16 +11];
}
-
+
}
//*****************************************************************************
@@ -171,18 +171,18 @@ unsigned char galois_mul2(unsigned char value)
//! - subbytes
//! - shiftrows
//! - mixcolums
-//! is executed 9 times, after this addroundkey to finish the 9th
+//! is executed 9 times, after this addroundkey to finish the 9th
//! round, after that the 10th round without mixcolums
//! no further subfunctions to save cycles for function calls
//! no structuring with "for (....)" to save cycles.
-//!
+//!
//!
//*****************************************************************************
void aes_encr(unsigned char *state, unsigned char *expandedKey)
{
unsigned char buf1, buf2, buf3, round;
-
+
for (round = 0; round < 9; round ++){
// addroundkey, sbox and shiftrows
// row 0
@@ -209,7 +209,7 @@ void aes_encr(unsigned char *state, unsigned char *expandedKey)
state[11] = sbox[(state[ 7] ^ expandedKey[(round*16) + 7])];
state[ 7] = sbox[(state[ 3] ^ expandedKey[(round*16) + 3])];
state[ 3] = sbox[buf1];
-
+
// mixcolums //////////
// col1
buf1 = state[0] ^ state[1] ^ state[2] ^ state[3];
@@ -238,8 +238,8 @@ void aes_encr(unsigned char *state, unsigned char *expandedKey)
buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1;
buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1;
buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1;
- buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
-
+ buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
+
}
// 10th round without mixcols
state[ 0] = sbox[(state[ 0] ^ expandedKey[(round*16) ])];
@@ -280,9 +280,9 @@ void aes_encr(unsigned char *state, unsigned char *expandedKey)
state[11]^=expandedKey[171];
state[12]^=expandedKey[172];
state[13]^=expandedKey[173];
- state[14]^=expandedKey[174];
+ state[14]^=expandedKey[174];
state[15]^=expandedKey[175];
-}
+}
//*****************************************************************************
//
@@ -311,7 +311,7 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey)
unsigned char buf1, buf2, buf3;
signed char round;
round = 9;
-
+
// initial addroundkey
state[ 0]^=expandedKey[160];
state[ 1]^=expandedKey[161];
@@ -327,9 +327,9 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey)
state[11]^=expandedKey[171];
state[12]^=expandedKey[172];
state[13]^=expandedKey[173];
- state[14]^=expandedKey[174];
+ state[14]^=expandedKey[174];
state[15]^=expandedKey[175];
-
+
// 10th round without mixcols
state[ 0] = rsbox[state[ 0]] ^ expandedKey[(round*16) ];
state[ 4] = rsbox[state[ 4]] ^ expandedKey[(round*16) + 4];
@@ -354,7 +354,7 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey)
state[ 7] = rsbox[state[11]] ^ expandedKey[(round*16) + 7];
state[11] = rsbox[state[15]] ^ expandedKey[(round*16) + 11];
state[15] = buf1;
-
+
for (round = 8; round >= 0; round--){
// barreto
//col1
@@ -401,8 +401,8 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey)
buf3 = state[12]^state[13]; buf3=galois_mul2(buf3); state[12] = state[12] ^ buf3 ^ buf1;
buf3 = state[13]^state[14]; buf3=galois_mul2(buf3); state[13] = state[13] ^ buf3 ^ buf1;
buf3 = state[14]^state[15]; buf3=galois_mul2(buf3); state[14] = state[14] ^ buf3 ^ buf1;
- buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
-
+ buf3 = state[15]^buf2; buf3=galois_mul2(buf3); state[15] = state[15] ^ buf3 ^ buf1;
+
// addroundkey, rsbox and shiftrows
// row 0
state[ 0] = rsbox[state[ 0]] ^ expandedKey[(round*16) ];
@@ -429,8 +429,8 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey)
state[11] = rsbox[state[15]] ^ expandedKey[(round*16) + 11];
state[15] = buf1;
}
-
-}
+
+}
//*****************************************************************************
//
@@ -443,9 +443,9 @@ void aes_decr(unsigned char *state, unsigned char *expandedKey)
//!
//! @brief AES128 encryption:
//! Given AES128 key and 16 bytes plain text, cipher text of 16 bytes
-//! is computed. The AES implementation is in mode ECB (Electronic
-//! Code Book).
-//!
+//! is computed. The AES implementation is in mode ECB (Electronic
+//! Code Book).
+//!
//!
//*****************************************************************************
@@ -453,7 +453,7 @@ void aes_encrypt(unsigned char *state,
unsigned char *key)
{
// expand the key into 176 bytes
- expandKey(expandedKey, key);
+ expandKey(expandedKey, key);
aes_encr(state, expandedKey);
}
@@ -468,9 +468,9 @@ void aes_encrypt(unsigned char *state,
//!
//! @brief AES128 decryption:
//! Given AES128 key and 16 bytes cipher text, plain text of 16 bytes
-//! is computed The AES implementation is in mode ECB
+//! is computed The AES implementation is in mode ECB
//! (Electronic Code Book).
-//!
+//!
//!
//*****************************************************************************
@@ -491,15 +491,15 @@ void aes_decrypt(unsigned char *state,
//!
//! @brief Reads AES128 key from EEPROM
//! Reads the AES128 key from fileID #12 in EEPROM
-//! returns an error if the key does not exist.
-//!
+//! returns an error if the key does not exist.
+//!
//!
//*****************************************************************************
signed long aes_read_key(unsigned char *key)
{
signed long returnValue;
-
+
returnValue = nvmem_read(NVMEM_AES128_KEY_FILEID, AES128_KEY_SIZE, 0, key);
return returnValue;
@@ -515,7 +515,7 @@ signed long aes_read_key(unsigned char *key)
//!
//! @brief writes AES128 key from EEPROM
//! Writes the AES128 key to fileID #12 in EEPROM
-//!
+//!
//!
//*****************************************************************************