Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: AES_HelloWorld AES_ExtendedTests AESslave_modified_test AESslave_modified_test_27-9-2017 ... more
Revision 1:09347d4bc827, committed 2016-09-15
- Comitter:
- neilt6
- Date:
- Thu Sep 15 15:34:59 2016 +0000
- Parent:
- 0:6132f54fa9e9
- Commit message:
- Fixed compiler error and improved readability
Changed in this revision
| AES.cpp | Show annotated file Show diff for this revision Revisions of this file |
| AES.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/AES.cpp Fri Sep 04 02:03:00 2015 +0000
+++ b/AES.cpp Thu Sep 15 15:34:59 2016 +0000
@@ -1,5 +1,5 @@
/* AES Cipher Library
- * Copyright (c) 2015 Neil Thiessen
+ * Copyright (c) 2016 Neil Thiessen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -161,8 +161,9 @@
//Perform CBC pre-processing if necessary
if (m_CipherMode == MODE_CBC) {
//XOR the state array with the carry vector
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
m_State[i] = m_State[i] ^ m_CarryVector[i];
+ }
}
//Encrypt the state array
@@ -189,8 +190,9 @@
//Perform CBC pre-processing if necessary
if (m_CipherMode == MODE_CBC) {
//XOR the state array with the carry vector
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
m_State[i] = m_State[i] ^ m_CarryVector[i];
+ }
}
//Encrypt the state array
@@ -205,7 +207,7 @@
//Perform ciphertext stealing if the next block is a partial block
if (length > 0 && length < 16) {
//Copy the last partial source block to a temporary buffer (in case of in-place encryption)
- char temp[length];
+ char temp[16];
memcpy(temp, srcBytes, length);
//Copy the leading bytes of the state array to the last partial destination block
@@ -220,8 +222,9 @@
memset(m_State + length, 0, 16 - length);
//XOR the state array with the carry vector
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
m_State[i] = m_State[i] ^ m_CarryVector[i];
+ }
}
//Encrypt the state array
@@ -257,8 +260,9 @@
//Perform CBC processing if necessary
if (m_CipherMode == MODE_CBC) {
//XOR the state array with the carry vector
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
m_State[i] = m_State[i] ^ m_CarryVector[i];
+ }
//Save the source block as the next carry vector
memcpy(m_CarryVector, src, 16);
@@ -284,12 +288,13 @@
//Perform CBC processing if necessary
if (m_CipherMode == MODE_CBC) {
//XOR the state array with the last partial source block
- for (int i = 0; i < length; i++)
+ for (int i = 0; i < length; i++) {
m_State[i] = m_State[i] ^ src[i];
+ }
}
//Copy the last partial source block to a temporary buffer (in case of in-place decryption)
- char temp[length];
+ char temp[16];
memcpy(temp, src, length);
//Copy the leading bytes of the state array to the last partial destination block
@@ -306,8 +311,9 @@
//Perform CBC processing if necessary
if (m_CipherMode == MODE_CBC) {
//XOR the state array with the carry vector
- for (int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++) {
m_State[i] = m_State[i] ^ m_CarryVector[i];
+ }
//Save the source block as the next carry vector
memcpy(m_CarryVector, src - 16, 16);
--- a/AES.h Fri Sep 04 02:03:00 2015 +0000 +++ b/AES.h Thu Sep 15 15:34:59 2016 +0000 @@ -1,5 +1,5 @@ /* AES Cipher Library - * Copyright (c) 2015 Neil Thiessen + * Copyright (c) 2016 Neil Thiessen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.