Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 tag to allow dartium to run the test. | 5 // Library tag to allow dartium to run the test. |
| 6 library sha1_test; | 6 library sha1_test; |
| 7 | 7 |
| 8 import "package:crypto/crypto.dart"; | 8 import "package:crypto/crypto.dart"; |
| 9 import "package:test/test.dart"; | 9 import "package:test/test.dart"; |
| 10 import 'very_long_input.dart'; | |
| 10 | 11 |
| 11 part 'sha1_long_test_vectors.dart'; | 12 part 'sha1_long_test_vectors.dart'; |
| 12 part 'sha1_short_test_vectors.dart'; | 13 part 'sha1_short_test_vectors.dart'; |
| 13 | 14 |
| 14 void main() { | 15 void main() { |
| 15 test('expected values', _testExpectedValues); | 16 test('expected values', _testExpectedValues); |
| 16 test('invalid use', _testInvalidUse); | 17 test('invalid use', _testInvalidUse); |
| 17 test('repeated digest', _testRepeatedDigest); | 18 test('repeated digest', _testRepeatedDigest); |
| 18 test('long inputs', () { | 19 test('long inputs', () { |
| 19 _testStandardVectors(sha1_long_inputs, sha1_long_mds); | 20 _testStandardVectors(sha1_long_inputs, sha1_long_mds); |
| 20 }); | 21 }); |
| 21 test('short inputs', () { | 22 test('short inputs', () { |
| 22 _testStandardVectors(sha1_short_inputs, sha1_short_mds); | 23 _testStandardVectors(sha1_short_inputs, sha1_short_mds); |
| 23 }); | 24 }); |
| 25 test('input length greater than 32 bits', () { | |
|
rmacnak
2015/09/17 21:21:31
input bit length greater than 32 bits
sethladd
2015/09/17 21:30:52
Done.
| |
| 26 veryLongInput( | |
| 27 new SHA1(), 1000000000, '1dd775261d7abab0b66910acc1d827a2c3799eaf'); | |
| 28 }); | |
| 24 } | 29 } |
| 25 | 30 |
| 26 void _testExpectedValues() { | 31 void _testExpectedValues() { |
| 27 var expectedValues = const [ | 32 var expectedValues = const [ |
| 28 "da39a3ee5e6b4b0d3255bfef95601890afd80709", | 33 "da39a3ee5e6b4b0d3255bfef95601890afd80709", |
| 29 "5ba93c9db0cff93f52b521d7420e43f6eda2784f", | 34 "5ba93c9db0cff93f52b521d7420e43f6eda2784f", |
| 30 "3f29546453678b855931c174a97d6c0894b8f546", | 35 "3f29546453678b855931c174a97d6c0894b8f546", |
| 31 "0c7a623fd2bbc05b06423be359e4021d36e721ad", | 36 "0c7a623fd2bbc05b06423be359e4021d36e721ad", |
| 32 "a02a05b025b928c039cf1ae7e8ee04e7c190c0db", | 37 "a02a05b025b928c039cf1ae7e8ee04e7c190c0db", |
| 33 "1cf251472d59f8fadeb3ab258e90999d8491be19", | 38 "1cf251472d59f8fadeb3ab258e90999d8491be19", |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 } | 564 } |
| 560 | 565 |
| 561 void _testStandardVectors(inputs, mds) { | 566 void _testStandardVectors(inputs, mds) { |
| 562 for (var i = 0; i < inputs.length; i++) { | 567 for (var i = 0; i < inputs.length; i++) { |
| 563 var hash = new SHA1(); | 568 var hash = new SHA1(); |
| 564 hash.add(inputs[i]); | 569 hash.add(inputs[i]); |
| 565 var d = hash.close(); | 570 var d = hash.close(); |
| 566 expect(mds[i], CryptoUtils.bytesToHex(d), reason: '$i'); | 571 expect(mds[i], CryptoUtils.bytesToHex(d), reason: '$i'); |
| 567 } | 572 } |
| 568 } | 573 } |
| OLD | NEW |