comparison dcrypt/crypto/ciphers/RC6.d @ 21:ec23779ee794

Removed redundant test vector from Blowfish unittest.
author Thomas Dixon <reikon@reikon.us>
date Sat, 10 Jan 2009 13:15:14 -0500
parents 5ce3012f1def
children 4589f8c5eb3c
comparison
equal deleted inserted replaced
20:3a57367afe34 21:ec23779ee794
132 void setup(ubyte[] key) { 132 void setup(ubyte[] key) {
133 uint c = key.length/4; 133 uint c = key.length/4;
134 uint[] L = new uint[c]; 134 uint[] L = new uint[c];
135 for (int i = 0, j = 0; i < c; i++, j+=4) 135 for (int i = 0, j = 0; i < c; i++, j+=4)
136 L[i] = Util.ubytesToUintLittle(key, j); 136 L[i] = Util.ubytesToUintLittle(key, j);
137
137 S[0] = P; 138 S[0] = P;
138 for (int i = 1; i <= 2*ROUNDS+3; i++) 139 for (int i = 1; i <= 2*ROUNDS+3; i++)
139 S[i] = S[i-1] + Q; 140 S[i] = S[i-1] + Q;
140 uint A, B, i, j, v = 3*(2*ROUNDS+4); // Relying on ints initializing to 0 141
142 uint A, B, i, j, v = 3*(2*ROUNDS+4); // Relying on ints initializing to 0
141 for (int s = 1; s <= v; s++) { 143 for (int s = 1; s <= v; s++) {
142 A = S[i] = Util.rotateLeft(S[i]+A+B, 3); 144 A = S[i] = Util.rotateLeft(S[i]+A+B, 3);
143 B = L[j] = Util.rotateLeft(L[j]+A+B, A+B); 145 B = L[j] = Util.rotateLeft(L[j]+A+B, A+B);
144 i = (i + 1) % (2*ROUNDS+4); 146 i = (i + 1) % (2*ROUNDS+4);
145 j = (j + 1) % c; 147 j = (j + 1) % c;
149 /** Some RC6 test vectors from the spec. */ 151 /** Some RC6 test vectors from the spec. */
150 version (UnitTest) { 152 version (UnitTest) {
151 unittest { 153 unittest {
152 static const char[][] test_keys = [ 154 static const char[][] test_keys = [
153 "00000000000000000000000000000000", 155 "00000000000000000000000000000000",
154
155 "0123456789abcdef0112233445566778", 156 "0123456789abcdef0112233445566778",
156
157 "00000000000000000000000000000000"~ 157 "00000000000000000000000000000000"~
158 "0000000000000000", 158 "0000000000000000",
159
160 "0123456789abcdef0112233445566778"~ 159 "0123456789abcdef0112233445566778"~
161 "899aabbccddeeff0", 160 "899aabbccddeeff0",
162
163 "00000000000000000000000000000000"~ 161 "00000000000000000000000000000000"~
164 "00000000000000000000000000000000", 162 "00000000000000000000000000000000",
165
166 "0123456789abcdef0112233445566778"~ 163 "0123456789abcdef0112233445566778"~
167 "899aabbccddeeff01032547698badcfe" 164 "899aabbccddeeff01032547698badcfe"
168 ]; 165 ];
169 166
170 static const char[][] test_plaintexts = [ 167 static const char[][] test_plaintexts = [