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 tests. | 5 // Library tag to allow Dartium to run the tests. |
6 library sha256_test; | 6 library sha256_test; |
7 | 7 |
8 import "package:test/test.dart"; | 8 import "package:test/test.dart"; |
9 import "package:crypto/crypto.dart"; | 9 import "package:crypto/crypto.dart"; |
10 import 'very_long_input.dart'; | |
10 | 11 |
11 part 'sha256_long_test_vectors.dart'; | 12 part 'sha256_long_test_vectors.dart'; |
12 part 'sha256_short_test_vectors.dart'; | 13 part 'sha256_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(sha256_long_inputs, sha256_long_mds)); | 20 () => _testStandardVectors(sha256_long_inputs, sha256_long_mds)); |
20 test('short inputs', | 21 test('short inputs', |
21 () => _testStandardVectors(sha256_short_inputs, sha256_short_mds)); | 22 () => _testStandardVectors(sha256_short_inputs, sha256_short_mds)); |
23 test('input length greater than 32 bits', () { | |
rmacnak
2015/09/17 21:21:31
"
sethladd
2015/09/17 21:30:52
Done.
| |
24 veryLongInput(new SHA256(), 1000000000, | |
25 'bc17f06f9d9b5f6f79ca189a1772b1a3a38d6e40c45bec50f9c4f28144efddca'); | |
26 }); | |
22 } | 27 } |
23 | 28 |
24 void _testExpectedValues() { | 29 void _testExpectedValues() { |
25 var expectedValues = const [ | 30 var expectedValues = const [ |
26 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', | 31 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', |
27 '6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d', | 32 '6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d', |
28 'b413f47d13ee2fe6c845b2ee141af81de858df4ec549a58b7970bb96645bc8d2', | 33 'b413f47d13ee2fe6c845b2ee141af81de858df4ec549a58b7970bb96645bc8d2', |
29 'ae4b3280e56e2faf83f414a6e3dabe9d5fbe18976544c05fed121accb85b53fc', | 34 'ae4b3280e56e2faf83f414a6e3dabe9d5fbe18976544c05fed121accb85b53fc', |
30 '054edec1d0211f624fed0cbca9d4f9400b0e491c43742af2c5b0abebf0c990d8', | 35 '054edec1d0211f624fed0cbca9d4f9400b0e491c43742af2c5b0abebf0c990d8', |
31 '08bb5e5d6eaac1049ede0893d30ed022b1a4d9b5b48db414871f51c9cb35283d', | 36 '08bb5e5d6eaac1049ede0893d30ed022b1a4d9b5b48db414871f51c9cb35283d', |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 } | 307 } |
303 | 308 |
304 void _testStandardVectors(inputs, mds) { | 309 void _testStandardVectors(inputs, mds) { |
305 for (var i = 0; i < inputs.length; i++) { | 310 for (var i = 0; i < inputs.length; i++) { |
306 var hash = new SHA256(); | 311 var hash = new SHA256(); |
307 hash.add(inputs[i]); | 312 hash.add(inputs[i]); |
308 var d = hash.close(); | 313 var d = hash.close(); |
309 expect(mds[i], CryptoUtils.bytesToHex(d), reason: '$i'); | 314 expect(mds[i], CryptoUtils.bytesToHex(d), reason: '$i'); |
310 } | 315 } |
311 } | 316 } |
OLD | NEW |