1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Refactor the low-memory versions of Speck

Rename SpeckLowMemory to SpeckTiny for the encrypt-only version.
SpeckSmall for the version that supports both encryption and decryption.
This commit is contained in:
Rhys Weatherley
2016-02-13 06:59:05 +10:00
parent e66f8fe6e0
commit 33df6a873d
10 changed files with 790 additions and 77 deletions

View File

@@ -28,7 +28,7 @@ This example runs tests on the EAX implementation to verify correct behaviour.
#include <EAX.h>
#include <AES.h>
#include <Speck.h>
#include <SpeckLowMemory.h>
#include <SpeckTiny.h>
#include <string.h>
#include <avr/pgmspace.h>
@@ -235,7 +235,7 @@ TestVector testVector;
EAX<AES128> *eax;
EAX<AES256> *eax256;
EAX<Speck> *eaxSpeck;
EAX<SpeckLowMemory> *eaxSpeckLowMemory;
EAX<SpeckTiny> *eaxSpeckTiny;
byte buffer[128];
@@ -500,8 +500,8 @@ void setup()
Serial.println(sizeof(*eax256));
Serial.print("EAX<Speck> ... ");
Serial.println(sizeof(*eaxSpeck));
Serial.print("EAX<SpeckLowMemory> ... ");
Serial.println(sizeof(*eaxSpeckLowMemory));
Serial.print("EAX<SpeckTiny> ... ");
Serial.println(sizeof(*eaxSpeckTiny));
Serial.println();
Serial.println("Test Vectors:");
@@ -531,9 +531,9 @@ void setup()
perfCipher(eaxSpeck, &testVectorEAX1, "Speck");
Serial.println();
delete eaxSpeck;
eaxSpeckLowMemory = new EAX<SpeckLowMemory>();
perfCipher(eaxSpeckLowMemory, &testVectorEAX1, "SpeckLowMemory");
delete eaxSpeckLowMemory;
eaxSpeckTiny = new EAX<SpeckTiny>();
perfCipher(eaxSpeckTiny, &testVectorEAX1, "SpeckTiny");
delete eaxSpeckTiny;
}
void loop()

View File

@@ -27,7 +27,7 @@ This example runs tests on the GCM implementation to verify correct behaviour.
#include <Crypto.h>
#include <AES.h>
#include <Speck.h>
#include <SpeckLowMemory.h>
#include <SpeckTiny.h>
#include <GCM.h>
#include <string.h>
#include <avr/pgmspace.h>
@@ -261,7 +261,7 @@ GCM<AES128> *gcmaes128 = 0;
GCM<AES192> *gcmaes192 = 0;
GCM<AES256> *gcmaes256 = 0;
GCM<Speck> *gcmspeck = 0;
GCM<SpeckLowMemory> *gcmspecklm = 0;
GCM<SpeckTiny> *gcmspecklm = 0;
byte buffer[128];
@@ -516,7 +516,7 @@ void setup()
Serial.println(sizeof(*gcmaes256));
Serial.print("GCM<Speck> ... ");
Serial.println(sizeof(*gcmspeck));
Serial.print("GCM<SpeckLowMemory> ... ");
Serial.print("GCM<SpeckTiny> ... ");
Serial.println(sizeof(*gcmspecklm));
Serial.println();
#endif
@@ -556,8 +556,8 @@ void setup()
gcmspeck = new GCM<Speck>();
perfCipher(gcmspeck, &testVectorGCM16, "GCM-Speck-256");
delete gcmspeck;
gcmspecklm = new GCM<SpeckLowMemory>();
perfCipher(gcmspecklm, &testVectorGCM16, "GCM-SpeckLowMemory-256");
gcmspecklm = new GCM<SpeckTiny>();
perfCipher(gcmspecklm, &testVectorGCM16, "GCM-SpeckTiny-256");
delete gcmspecklm;
#endif
}

View File

@@ -26,7 +26,8 @@ This example runs tests on the Speck implementation to verify correct behaviour.
#include <Crypto.h>
#include <Speck.h>
#include <SpeckLowMemory.h>
#include <SpeckSmall.h>
#include <SpeckTiny.h>
#include <string.h>
struct TestVector
@@ -70,7 +71,8 @@ static TestVector const testVectorSpeck256 = {
};
Speck speck;
SpeckLowMemory speckLowMemory;
SpeckSmall speckSmall;
SpeckTiny speckTiny;
byte buffer[16];
@@ -156,8 +158,10 @@ void setup()
Serial.println("State Sizes:");
Serial.print("Speck ... ");
Serial.println(sizeof(Speck));
Serial.print("SpeckLowMemory ... ");
Serial.println(sizeof(SpeckLowMemory));
Serial.print("SpeckSmall ... ");
Serial.println(sizeof(SpeckSmall));
Serial.print("SpeckTiny ... ");
Serial.println(sizeof(SpeckTiny));
Serial.println();
Serial.println("Speck Test Vectors:");
@@ -167,10 +171,17 @@ void setup()
Serial.println();
Serial.println("SpeckLowMemory Test Vectors:");
testCipher(&speckLowMemory, &testVectorSpeck128, 16, false);
testCipher(&speckLowMemory, &testVectorSpeck192, 24, false);
testCipher(&speckLowMemory, &testVectorSpeck256, 32, false);
Serial.println("SpeckSmall Test Vectors:");
testCipher(&speckSmall, &testVectorSpeck128, 16);
testCipher(&speckSmall, &testVectorSpeck192, 24);
testCipher(&speckSmall, &testVectorSpeck256, 32);
Serial.println();
Serial.println("SpeckTiny Test Vectors:");
testCipher(&speckTiny, &testVectorSpeck128, 16, false);
testCipher(&speckTiny, &testVectorSpeck192, 24, false);
testCipher(&speckTiny, &testVectorSpeck256, 32, false);
Serial.println();
@@ -179,10 +190,15 @@ void setup()
perfCipher(&speck, &testVectorSpeck192, 24);
perfCipher(&speck, &testVectorSpeck256, 32);
Serial.println("SpeckLowMemory Performance Tests:");
perfCipher(&speckLowMemory, &testVectorSpeck128, 16, false);
perfCipher(&speckLowMemory, &testVectorSpeck192, 24, false);
perfCipher(&speckLowMemory, &testVectorSpeck256, 32, false);
Serial.println("SpeckSmall Performance Tests:");
perfCipher(&speckSmall, &testVectorSpeck128, 16);
perfCipher(&speckSmall, &testVectorSpeck192, 24);
perfCipher(&speckSmall, &testVectorSpeck256, 32);
Serial.println("SpeckTiny Performance Tests:");
perfCipher(&speckTiny, &testVectorSpeck128, 16, false);
perfCipher(&speckTiny, &testVectorSpeck192, 24, false);
perfCipher(&speckTiny, &testVectorSpeck256, 32, false);
}
void loop()