Skip to content

Commit

Permalink
new tests from licterature... by now ecb-tbl.
Browse files Browse the repository at this point in the history
  • Loading branch information
wouldgo committed Feb 1, 2015
1 parent d48fcbc commit 12a2ca7
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
},
'target': [
'Gruntfile.js',
'<%= confs.src %>/**/*.js'//, '<%= confs.spec %>/**/*.js'
'<%= confs.src %>/**/*.js',
'<%= confs.spec %>/**/*.js'
]
},
'uglify': {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
211 changes: 211 additions & 0 deletions spec/ecb-tbl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
/*global describe it expect twofish*/
(function doTest(describe, it, expect, twofish){
'use strict';

var twF = twofish()
, useCaseName
, singleTest = function doTestCase(thisTest) {
var ct = twF.encrypt(thisTest.key, thisTest.pt)
, cpt = twF.decrypt(thisTest.key, ct);

expect(ct).toEqual(thisTest.ct);
expect(cpt).toEqual(thisTest.pt);
};
describe('ECB TBL - 128 keysize', function doTestSuite() {
var tests = [
{
'key': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'ct': [0x9F, 0x58, 0x9F, 0x5C, 0xF6, 0x12, 0x2C, 0x32, 0xB6, 0xBF, 0xEC, 0x2F, 0x2A, 0xE8, 0xC3, 0x5A]
},
{
'key': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0x9F, 0x58, 0x9F, 0x5C, 0xF6, 0x12, 0x2C, 0x32, 0xB6, 0xBF, 0xEC, 0x2F, 0x2A, 0xE8, 0xC3, 0x5A],
'ct': [0xD4, 0x91, 0xDB, 0x16, 0xE7, 0xB1, 0xC3, 0x9E, 0x86, 0xCB, 0x08, 0x6B, 0x78, 0x9F, 0x54, 0x19]
},
{
'key': [0x9F, 0x58, 0x9F, 0x5C, 0xF6, 0x12, 0x2C, 0x32, 0xB6, 0xBF, 0xEC, 0x2F, 0x2A, 0xE8, 0xC3, 0x5A],
'pt': [0xD4, 0x91, 0xDB, 0x16, 0xE7, 0xB1, 0xC3, 0x9E, 0x86, 0xCB, 0x08, 0x6B, 0x78, 0x9F, 0x54, 0x19],
'ct': [0x01, 0x9F, 0x98, 0x09, 0xDE, 0x17, 0x11, 0x85, 0x8F, 0xAA, 0xC3, 0xA3, 0xBA, 0x20, 0xFB, 0xC3]
},
{
'key': [0xD4, 0x91, 0xDB, 0x16, 0xE7, 0xB1, 0xC3, 0x9E, 0x86, 0xCB, 0x08, 0x6B, 0x78, 0x9F, 0x54, 0x19],
'pt': [0x01, 0x9F, 0x98, 0x09, 0xDE, 0x17, 0x11, 0x85, 0x8F, 0xAA, 0xC3, 0xA3, 0xBA, 0x20, 0xFB, 0xC3],
'ct': [0x63, 0x63, 0x97, 0x7D, 0xE8, 0x39, 0x48, 0x62, 0x97, 0xE6, 0x61, 0xC6, 0xC9, 0xD6, 0x68, 0xEB]
},
{
'key': [0x01, 0x9F, 0x98, 0x09, 0xDE, 0x17, 0x11, 0x85, 0x8F, 0xAA, 0xC3, 0xA3, 0xBA, 0x20, 0xFB, 0xC3],
'pt': [0x63, 0x63, 0x97, 0x7D, 0xE8, 0x39, 0x48, 0x62, 0x97, 0xE6, 0x61, 0xC6, 0xC9, 0xD6, 0x68, 0xEB],
'ct': [0x81, 0x6D, 0x5B, 0xD0, 0xFA, 0xE3, 0x53, 0x42, 0xBF, 0x2A, 0x74, 0x12, 0xC2, 0x46, 0xF7, 0x52]
},
{
'key': [0x63, 0x63, 0x97, 0x7D, 0xE8, 0x39, 0x48, 0x62, 0x97, 0xE6, 0x61, 0xC6, 0xC9, 0xD6, 0x68, 0xEB],
'pt': [0x81, 0x6D, 0x5B, 0xD0, 0xFA, 0xE3, 0x53, 0x42, 0xBF, 0x2A, 0x74, 0x12, 0xC2, 0x46, 0xF7, 0x52],
'ct': [0x54, 0x49, 0xEC, 0xA0, 0x08, 0xFF, 0x59, 0x21, 0x15, 0x5F, 0x59, 0x8A, 0xF4, 0xCE, 0xD4, 0xD0]
},
{
'key': [0x81, 0x6D, 0x5B, 0xD0, 0xFA, 0xE3, 0x53, 0x42, 0xBF, 0x2A, 0x74, 0x12, 0xC2, 0x46, 0xF7, 0x52],
'pt': [0x54, 0x49, 0xEC, 0xA0, 0x08, 0xFF, 0x59, 0x21, 0x15, 0x5F, 0x59, 0x8A, 0xF4, 0xCE, 0xD4, 0xD0],
'ct': [0x66, 0x00, 0x52, 0x2E, 0x97, 0xAE, 0xB3, 0x09, 0x4E, 0xD5, 0xF9, 0x2A, 0xFC, 0xBC, 0xDD, 0x10]
},
{
'key': [0x54, 0x49, 0xEC, 0xA0, 0x08, 0xFF, 0x59, 0x21, 0x15, 0x5F, 0x59, 0x8A, 0xF4, 0xCE, 0xD4, 0xD0],
'pt': [0x66, 0x00, 0x52, 0x2E, 0x97, 0xAE, 0xB3, 0x09, 0x4E, 0xD5, 0xF9, 0x2A, 0xFC, 0xBC, 0xDD, 0x10],
'ct': [0x34, 0xC8, 0xA5, 0xFB, 0x2D, 0x3D, 0x08, 0xA1, 0x70, 0xD1, 0x20, 0xAC, 0x6D, 0x26, 0xDB, 0xFA]
},
{
'key': [0x66, 0x00, 0x52, 0x2E, 0x97, 0xAE, 0xB3, 0x09, 0x4E, 0xD5, 0xF9, 0x2A, 0xFC, 0xBC, 0xDD, 0x10],
'pt': [0x34, 0xC8, 0xA5, 0xFB, 0x2D, 0x3D, 0x08, 0xA1, 0x70, 0xD1, 0x20, 0xAC, 0x6D, 0x26, 0xDB, 0xFA],
'ct': [0x28, 0x53, 0x0B, 0x35, 0x8C, 0x1B, 0x42, 0xEF, 0x27, 0x7D, 0xE6, 0xD4, 0x40, 0x7F, 0xC5, 0x91]
},
{
'key': [0x34, 0xC8, 0xA5, 0xFB, 0x2D, 0x3D, 0x08, 0xA1, 0x70, 0xD1, 0x20, 0xAC, 0x6D, 0x26, 0xDB, 0xFA],
'pt': [0x28, 0x53, 0x0B, 0x35, 0x8C, 0x1B, 0x42, 0xEF, 0x27, 0x7D, 0xE6, 0xD4, 0x40, 0x7F, 0xC5, 0x91],
'ct': [0x8A, 0x8A, 0xB9, 0x83, 0x31, 0x0E, 0xD7, 0x8C, 0x8C, 0x0E, 0xCD, 0xE0, 0x30, 0xB8, 0xDC, 0xA4]
}
]
, testsIndex = 0
, testsLength = tests.length
, aTest;

for (; testsIndex < testsLength; testsIndex += 1) {

aTest = tests[testsIndex];
useCaseName = 'ecb 128 use case: ' + testsIndex;

it(useCaseName, singleTest.bind(this, aTest));
}
});

describe('ECB TBL - 192 keysize', function doTestSuite() {
var tests = [
{
'key': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'ct': [0xEF, 0xA7, 0x1F, 0x78, 0x89, 0x65, 0xBD, 0x44, 0x53, 0xF8, 0x60, 0x17, 0x8F, 0xC1, 0x91, 0x01]
},
{
'key': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0xEF, 0xA7, 0x1F, 0x78, 0x89, 0x65, 0xBD, 0x44, 0x53, 0xF8, 0x60, 0x17, 0x8F, 0xC1, 0x91, 0x01],
'ct': [0x88, 0xB2, 0xB2, 0x70, 0x6B, 0x10, 0x5E, 0x36, 0xB4, 0x46, 0xBB, 0x6D, 0x73, 0x1A, 0x1E, 0x88]
},
{
'key': [0xEF, 0xA7, 0x1F, 0x78, 0x89, 0x65, 0xBD, 0x44, 0x53, 0xF8, 0x60, 0x17, 0x8F, 0xC1, 0x91, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0x88, 0xB2, 0xB2, 0x70, 0x6B, 0x10, 0x5E, 0x36, 0xB4, 0x46, 0xBB, 0x6D, 0x73, 0x1A, 0x1E, 0x88],
'ct': [0x39, 0xDA, 0x69, 0xD6, 0xBA, 0x49, 0x97, 0xD5, 0x85, 0xB6, 0xDC, 0x07, 0x3C, 0xA3, 0x41, 0xB2]
},
{
'key': [0x88, 0xB2, 0xB2, 0x70, 0x6B, 0x10, 0x5E, 0x36, 0xB4, 0x46, 0xBB, 0x6D, 0x73, 0x1A, 0x1E, 0x88, 0xEF, 0xA7, 0x1F, 0x78, 0x89, 0x65, 0xBD, 0x44],
'pt': [0x39, 0xDA, 0x69, 0xD6, 0xBA, 0x49, 0x97, 0xD5, 0x85, 0xB6, 0xDC, 0x07, 0x3C, 0xA3, 0x41, 0xB2],
'ct': [0x18, 0x2B, 0x02, 0xD8, 0x14, 0x97, 0xEA, 0x45, 0xF9, 0xDA, 0xAC, 0xDC, 0x29, 0x19, 0x3A, 0x65]
},
{
'key': [0x39, 0xDA, 0x69, 0xD6, 0xBA, 0x49, 0x97, 0xD5, 0x85, 0xB6, 0xDC, 0x07, 0x3C, 0xA3, 0x41, 0xB2, 0x88, 0xB2, 0xB2, 0x70, 0x6B, 0x10, 0x5E, 0x36],
'pt': [0x18, 0x2B, 0x02, 0xD8, 0x14, 0x97, 0xEA, 0x45, 0xF9, 0xDA, 0xAC, 0xDC, 0x29, 0x19, 0x3A, 0x65],
'ct':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 0x09, 0xBF, 0xDA, 0x85, 0xC1, 0xF2, 0xC5, 0x03, 0x8B, 0x34, 0xED, 0x69, 0x1B, 0xFF]
},
{
'key': [0x3A, 0xF6, 0xF7, 0xCE, 0x5B, 0xD3, 0x5E, 0xF1, 0x8B, 0xEC, 0x6F, 0xA7, 0x87, 0xAB, 0x50, 0x6B, 0xD1, 0x07, 0x9B, 0x78, 0x9F, 0x66, 0x66, 0x49],
'pt': [0xAE, 0x81, 0x09, 0xBF, 0xDA, 0x85, 0xC1, 0xF2, 0xC5, 0x03, 0x8B, 0x34, 0xED, 0x69, 0x1B, 0xFF],
'ct': [0x89, 0x3F, 0xD6, 0x7B, 0x98, 0xC5, 0x50, 0x07, 0x35, 0x71, 0xBD, 0x63, 0x12, 0x63, 0xFC, 0x78]
},
{
'key': [0xAE, 0x81, 0x09, 0xBF, 0xDA, 0x85, 0xC1, 0xF2, 0xC5, 0x03, 0x8B, 0x34, 0xED, 0x69, 0x1B, 0xFF, 0x3A, 0xF6, 0xF7, 0xCE, 0x5B, 0xD3, 0x5E, 0xF1],
'pt': [0x89, 0x3F, 0xD6, 0x7B, 0x98, 0xC5, 0x50, 0x07, 0x35, 0x71, 0xBD, 0x63, 0x12, 0x63, 0xFC, 0x78],
'ct': [0x16, 0x43, 0x4F, 0xC9, 0xC8, 0x84, 0x1A, 0x63, 0xD5, 0x87, 0x00, 0xB5, 0x57, 0x8E, 0x8F, 0x67]
}
]
, testsIndex = 0
, testsLength = tests.length
, aTest;

for (; testsIndex < testsLength; testsIndex += 1) {

aTest = tests[testsIndex];
useCaseName = 'ecb 192 use case: ' + testsIndex;

it(useCaseName, singleTest.bind(this, aTest));
}
});

describe('ECB TBL - 256 keysize', function doTestSuite() {
var tests = [
{
'key': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'ct': [0x57, 0xFF, 0x73, 0x9D, 0x4D, 0xC9, 0x2C, 0x1B, 0xD7, 0xFC, 0x01, 0x70, 0x0C, 0xC8, 0x21, 0x6F]
},
{
'key': [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0x57, 0xFF, 0x73, 0x9D, 0x4D, 0xC9, 0x2C, 0x1B, 0xD7, 0xFC, 0x01, 0x70, 0x0C, 0xC8, 0x21, 0x6F],
'ct': [0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46, 0xF2, 0xA2, 0x82, 0xB7, 0xD4, 0x5B, 0x4E, 0x0D]
},
{
'key': [0x57, 0xFF, 0x73, 0x9D, 0x4D, 0xC9, 0x2C, 0x1B, 0xD7, 0xFC, 0x01, 0x70, 0x0C, 0xC8, 0x21, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
'pt': [0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46, 0xF2, 0xA2, 0x82, 0xB7, 0xD4, 0x5B, 0x4E, 0x0D],
'ct': [0x90, 0xAF, 0xE9, 0x1B, 0xB2, 0x88, 0x54, 0x4F, 0x2C, 0x32, 0xDC, 0x23, 0x9B, 0x26, 0x35, 0xE6]
},
{
'key': [0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46, 0xF2, 0xA2, 0x82, 0x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0x99, 0x36, 0xD4, 0xC7, 0x48, 0xE7, 0x5A, 0xF7],
'ct': [0xC5, 0xA3, 0xE7, 0xCE, 0xE0, 0xF1, 0xB7, 0x26, 0x05, 0x28, 0xA6, 0x8F, 0xB4, 0xEA, 0x05, 0xF2]
},
{
'key': [0xDC, 0x09, 0x6B, 0xCD, 0x99, 0xFC, 0x72, 0xF7, 0x99, 0x36, 0xD4, 0xC7, 0x48, 0xE7, 0x5A, 0xF7, 0x5A, 0xB6, 0x7A, 0x5F, 0x85, 0x39, 0xA4, 0xA5, 0xFD, 0x9F, 0x03, 0x73, 0xBA, 0x46, 0x34, 0x66],
'pt': [0xC5, 0xA3, 0xE7, 0xCE, 0xE0, 0xF1, 0xB7, 0x26, 0x05, 0x28, 0xA6, 0x8F, 0xB4, 0xEA, 0x05, 0xF2],
'ct': [0x43, 0xD5, 0xCE, 0xC3, 0x27, 0xB2, 0x4A, 0xB9, 0x0A, 0xD3, 0x4A, 0x79, 0xD0, 0x46, 0x91, 0x51]
}
]
, testsIndex = 0
, testsLength = tests.length
, aTest;

for (; testsIndex < testsLength; testsIndex += 1) {

aTest = tests[testsIndex];
useCaseName = 'ecb 256 use case: ' + testsIndex;

it(useCaseName, singleTest.bind(this, aTest));
}
});
}(describe, it, expect, twofish));
9 changes: 2 additions & 7 deletions src/twofish.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,7 @@
var i
, offset
, cpt = []
, tmpBlockDecrypt
, block;
, tmpBlockDecrypt;

if (utils.isAnArray(userKey) &&
utils.isAnArray(chiperText)) {
Expand All @@ -794,11 +793,7 @@
tmpBlockDecrypt = blockDecrypt(chiperText, offset, userKey);
for (i = 0; i < tmpBlockDecrypt.length; i += 1) {

block = tmpBlockDecrypt[i];
if (block !== 0x00) {

cpt.push(block);
}
cpt.push(tmpBlockDecrypt[i]);
}
}

Expand Down

0 comments on commit 12a2ca7

Please sign in to comment.