|
diff --git a/Reference/C++/Sources/Farfalle.cpp b/Reference/C++/Sources/Farfalle.cpp |
|
index dc988fd..c1e3e99 100644 |
|
--- a/Reference/C++/Sources/Farfalle.cpp |
|
+++ b/Reference/C++/Sources/Farfalle.cpp |
|
@@ -57,15 +57,18 @@ BitString Farfalle::operator()(const BitString &K, const BitStrings &Mseq, unsig |
|
unsigned int b = width(); |
|
if (!(K.size() <= b - 1)) throw Exception("Key length must be less than b bits"); |
|
unsigned int m = Mseq.size(); |
|
+ std::cout << "key: " << K << "\n"; |
|
|
|
BitString Kp = K || BitString::pad10(b, K.size()); |
|
BitString k = p_b(Kp); |
|
|
|
BitString x = BitString::zeroes(b); |
|
unsigned int I = 0; |
|
+ std::cout << "msg: "; |
|
|
|
for (unsigned int j = 0; j <= m - 1; j++) |
|
{ |
|
+ std::cout << Mseq[j] << "\n"; |
|
unsigned int mu = (Mseq[j].size() + b) / b; |
|
BitString M = Mseq[j] || BitString::pad10(mu * b, Mseq[j].size()); |
|
Blocks mblocks(M, b); |
|
@@ -88,7 +91,9 @@ BitString Farfalle::operator()(const BitString &K, const BitStrings &Mseq, unsig |
|
zblocks[j] = p_e(roll_e(y, j)) ^ kp; |
|
} |
|
|
|
+ std::cout << "q: " << std::dec << (q / 8) << "\n"; |
|
BitString Z = BitString::substring(zblocks.bits(), q, n); |
|
+ std::cout << "out: " << Z << "\n\n"; |
|
return Z; |
|
} |
|
|
|
diff --git a/Reference/C++/Sources/Xoofff-test.cpp b/Reference/C++/Sources/Xoofff-test.cpp |
|
index 24aec41..70f0f5d 100644 |
|
--- a/Reference/C++/Sources/Xoofff-test.cpp |
|
+++ b/Reference/C++/Sources/Xoofff-test.cpp |
|
@@ -54,7 +54,7 @@ uint8_t random8( void ); |
|
static void randomize( unsigned char* data, unsigned int length) |
|
{ |
|
#if !defined(EMBEDDED) |
|
- srand((unsigned int)time(0)); |
|
+ // srand((unsigned int)time(0)); |
|
#endif |
|
while (length--) |
|
{ |
|
@@ -76,6 +76,36 @@ static void generateSimpleRawMaterial(unsigned char* data, unsigned int length, |
|
} |
|
} |
|
|
|
+void genXoofffKAT() { |
|
+ srand((unsigned int)0); |
|
+ |
|
+ const size_t MIN_KEY_LEN = 16; |
|
+ const size_t MAX_KEY_LEN = XnP_widthInBytes - 1; |
|
+ |
|
+ const size_t MIN_MSG_LEN = 0; |
|
+ const size_t MAX_MSG_LEN = 119; |
|
+ |
|
+ const size_t MIN_Q = 0; |
|
+ const size_t MAX_Q = XnP_widthInBytes; |
|
+ |
|
+ const size_t OUT_LEN = 32; |
|
+ |
|
+ for(size_t klen = MIN_KEY_LEN; klen <= MAX_KEY_LEN; klen++) { |
|
+ auto key = static_cast<UINT8*>(malloc(klen)); |
|
+ randomize(key, klen); |
|
+ |
|
+ for(size_t mlen = MIN_MSG_LEN; mlen <= MAX_MSG_LEN; mlen++) { |
|
+ auto msg = static_cast<UINT8*>(malloc(mlen)); |
|
+ randomize(msg, mlen); |
|
+ |
|
+ for (size_t q = MIN_Q; q <= MAX_Q; q++) { |
|
+ Xoofff xp; |
|
+ xp(BitString(key, klen*8), BitString(msg, mlen*8), OUT_LEN*8, q*8); |
|
+ } |
|
+ } |
|
+ } |
|
+} |
|
+ |
|
static void performTestXoofffOneInput(BitLength keyLen, BitLength inputLen, BitLength outputLen, int /*flags*/, Keccak &rSpongeChecksum, unsigned int mode) |
|
{ |
|
BitSequence input[inputByteSize]; |
|
diff --git a/Reference/C++/Sources/Xoofff-test.h b/Reference/C++/Sources/Xoofff-test.h |
|
index 5dd0c48..bafc6ec 100644 |
|
--- a/Reference/C++/Sources/Xoofff-test.h |
|
+++ b/Reference/C++/Sources/Xoofff-test.h |
|
@@ -13,5 +13,6 @@ http://creativecommons.org/publicdomain/zero/1.0/ |
|
#define _XOOFFFTEST_H_ |
|
|
|
void testXoofff(void); |
|
+void genXoofffKAT(); |
|
|
|
#endif |
|
diff --git a/Reference/C++/Sources/bitstring.cpp b/Reference/C++/Sources/bitstring.cpp |
|
index 1d6dd21..af7c75a 100644 |
|
--- a/Reference/C++/Sources/bitstring.cpp |
|
+++ b/Reference/C++/Sources/bitstring.cpp |
|
@@ -292,12 +292,12 @@ std::ostream &operator<<(std::ostream &os, const BitString &S) |
|
os.fill('0'); |
|
os << std::hex << ((int)UINT8(*i)); |
|
++i; |
|
- if ( i != S.v.end()) { |
|
- os << " "; |
|
- } |
|
- else { |
|
- os << "(" << ((S.vSize - 1) % 8 + 1) << ")"; |
|
- } |
|
+ // if ( i != S.v.end()) { |
|
+ // os << " "; |
|
+ // } |
|
+ // else { |
|
+ // os << "(" << ((S.vSize - 1) % 8 + 1) << ")"; |
|
+ // } |
|
} |
|
return os; |
|
} |
|
diff --git a/Reference/C++/Sources/main.cpp b/Reference/C++/Sources/main.cpp |
|
index 82fcda0..37a1475 100644 |
|
--- a/Reference/C++/Sources/main.cpp |
|
+++ b/Reference/C++/Sources/main.cpp |
|
@@ -49,9 +49,10 @@ int main(int argc, char *argv[]) |
|
try |
|
{ |
|
//testXoodoo(384, std::cout); |
|
- testXoofff(); |
|
- testXooModes(); |
|
- testXoodyak(); |
|
+ genXoofffKAT(); |
|
+ // testXoofff(); |
|
+ // testXooModes(); |
|
+ // testXoodyak(); |
|
|
|
std::cout << std::flush; |
|
} |
|
diff --git a/Reference/C++/makefile b/Reference/C++/makefile |
|
index 183687c..7c1d5b4 100644 |
|
--- a/Reference/C++/makefile |
|
+++ b/Reference/C++/makefile |
|
@@ -9,7 +9,7 @@ $(BINDIR): |
|
|
|
OBJECTS = $(addprefix $(BINDIR)/, $(notdir $(patsubst %.cpp,%.o,$(SOURCES)))) |
|
|
|
-CFLAGS = -O3 -g0 -Wreorder |
|
+CFLAGS = -O3 -std=c++14 -g0 -Wreorder |
|
|
|
VPATH = Sources |
|
|