Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/lib/crypto/sha256_test.dart

Issue 10170027: Implement HMAC support in lib/crypto. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update after test renaming. Added back lib testing in test.dart." Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/crypto/sha1_test.dart ('k') | tools/test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('sha256Test'); 5 #library('sha256Test');
6 // TODO(ager): Replace with "dart:crypto" when ready. 6 // TODO(ager): Replace with "dart:crypto" when ready.
7 #import("../../../lib/crypto/crypto.dart"); 7 #import("../../../lib/crypto/crypto.dart");
8 8
9 #source('sha256_long_test_vectors.dart'); 9 #source('sha256_long_test_vectors.dart');
10 #source('sha256_short_test_vectors.dart'); 10 #source('sha256_short_test_vectors.dart');
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 for (var i = 0; i < expected_values.length; i++) { 287 for (var i = 0; i < expected_values.length; i++) {
288 var d = new SHA256().update(createTestArr(i)).digest(); 288 var d = new SHA256().update(createTestArr(i)).digest();
289 Expect.equals(expected_values[i], digestToString(d), '$i'); 289 Expect.equals(expected_values[i], digestToString(d), '$i');
290 } 290 }
291 } 291 }
292 292
293 void testInvalidUse() { 293 void testInvalidUse() {
294 var sha = new SHA256(); 294 var sha = new SHA256();
295 sha.digest(); 295 sha.digest();
296 Expect.throws(sha.digest, 296 Expect.throws(() => sha.update([0]), (e) => e is HashException);
297 (e) => e is CryptoHashException); 297 }
298 Expect.throws(() => sha.update([0]), 298
299 (e) => e is CryptoHashException); 299 void testRepeatedDigest() {
300 var sha = new SHA256();
301 var digest = sha.digest();
302 Expect.listEquals(digest, sha.digest());
300 } 303 }
301 304
302 void testStandardVectors(inputs, mds) { 305 void testStandardVectors(inputs, mds) {
303 for (var i = 0; i < inputs.length; i++) { 306 for (var i = 0; i < inputs.length; i++) {
304 var d = new SHA256().update(inputs[i]).digest(); 307 var d = new SHA256().update(inputs[i]).digest();
305 Expect.equals(mds[i], digestToString(d), '$i'); 308 Expect.equals(mds[i], digestToString(d), '$i');
306 } 309 }
307 } 310 }
308 311
309 void main() { 312 void main() {
310 test(); 313 test();
311 testInvalidUse(); 314 testInvalidUse();
315 testRepeatedDigest();
312 testStandardVectors(sha256_long_inputs, sha256_long_mds); 316 testStandardVectors(sha256_long_inputs, sha256_long_mds);
313 testStandardVectors(sha256_short_inputs, sha256_short_mds); 317 testStandardVectors(sha256_short_inputs, sha256_short_mds);
314 } 318 }
315 319
OLDNEW
« no previous file with comments | « tests/lib/crypto/sha1_test.dart ('k') | tools/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698