albertocarp/Primitives_SmartCard

Twine Cipher is unfinished

Opened this issue · 1 comments

Hello,

at Twine CIpher, I am looking at the specification ( https://pdfs.semanticscholar.org/26b9/d188fc506fb34247c57dc365547f961576d7.pdf ). At the top of page 4 there is algorithm of 80bit key schedule.
In your code you follow this algorithm very well, but I can't find the line 8 of algorithm in your code (bitwise Rot4 in WK_0 - WK_3). This should shift WK_3 to WK_2, WK_2 to WK_1, WK_1 to WK_0 and WK_0 to WK_3, but it isn't there.
I believe this step is missing and it should be at line 128 of your code. Am I right?
I didn't run your implementation, but I am quite sure it doesn't compute the same result as test vectors.

Also, 128bit key schedule is missing (I am working on it).

Add this to line 123 of your code (just under xoring with roundconst section):

temp_val = temp[0];
temp[0] = temp[1];
temp[1] = temp[2];
temp[2] = temp[3];
temp[3] = temp_val;

and it should work correctly.