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

Side by Side Diff: tests/lib/crypto/sha1_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/hmac_sha256_test_vectors.dart ('k') | tests/lib/crypto/sha256_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('sha1Test'); 5 #library('sha1Test');
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('sha1_long_test_vectors.dart'); 9 #source('sha1_long_test_vectors.dart');
10 #source('sha1_short_test_vectors.dart'); 10 #source('sha1_short_test_vectors.dart');
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 ]; 542 ];
543 for (var i = 0; i < expected_values.length; i++) { 543 for (var i = 0; i < expected_values.length; i++) {
544 Expect.equals(expected_values[i], 544 Expect.equals(expected_values[i],
545 digestToString(new SHA1().update(createTestArr(i)).digest())); 545 digestToString(new SHA1().update(createTestArr(i)).digest()));
546 } 546 }
547 } 547 }
548 548
549 void testInvalidUse() { 549 void testInvalidUse() {
550 var sha = new SHA1(); 550 var sha = new SHA1();
551 sha.digest(); 551 sha.digest();
552 Expect.throws(sha.digest, 552 Expect.throws(() => sha.update([0]), (e) => e is HashException);
553 (e) => e is CryptoHashException); 553 }
554 Expect.throws(() => sha.update([0]), 554
555 (e) => e is CryptoHashException); 555 void testRepeatedDigest() {
556 var sha = new SHA1();
557 var digest = sha.digest();
558 Expect.listEquals(digest, sha.digest());
556 } 559 }
557 560
558 void testStandardVectors(inputs, mds) { 561 void testStandardVectors(inputs, mds) {
559 for (var i = 0; i < inputs.length; i++) { 562 for (var i = 0; i < inputs.length; i++) {
560 var d = new SHA1().update(inputs[i]).digest(); 563 var d = new SHA1().update(inputs[i]).digest();
561 Expect.equals(mds[i], digestToString(d), '$i'); 564 Expect.equals(mds[i], digestToString(d), '$i');
562 } 565 }
563 } 566 }
564 567
565 void main() { 568 void main() {
566 test(); 569 test();
567 testInvalidUse(); 570 testInvalidUse();
571 testRepeatedDigest();
568 testStandardVectors(sha1_long_inputs, sha1_long_mds); 572 testStandardVectors(sha1_long_inputs, sha1_long_mds);
569 testStandardVectors(sha1_short_inputs, sha1_short_mds); 573 testStandardVectors(sha1_short_inputs, sha1_short_mds);
570 } 574 }
OLDNEW
« no previous file with comments | « tests/lib/crypto/hmac_sha256_test_vectors.dart ('k') | tests/lib/crypto/sha256_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698