Close underlying Hash sinks.
Closes #33
R=kevmoo@google.com
Review URL: https://codereview.chromium.org//1906093002 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f3bda0..8f059cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 1.1.1
+
+* Properly close sinks passed to `Hash.startChunkedConversion()` when
+ `ByteConversionSink.close()` is called.
+
## 1.1.0
* `Hmac` and `Hash` now extend the new `ChunkedConverter` class from
diff --git a/lib/src/hash_sink.dart b/lib/src/hash_sink.dart
index f4adcb3..c593bd1 100644
--- a/lib/src/hash_sink.dart
+++ b/lib/src/hash_sink.dart
@@ -70,6 +70,7 @@
_iterate();
assert(_pendingData.isEmpty);
_sink.add(new Digest(_byteDigest()));
+ _sink.close();
}
Uint8List _byteDigest() {
diff --git a/pubspec.yaml b/pubspec.yaml
index 1351d12..385244c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: crypto
-version: 1.1.0
+version: 1.1.1
author: Dart Team <misc@dartlang.org>
description: Library of cryptographic functions.
homepage: https://www.github.com/dart-lang/crypto
diff --git a/test/sha1_test.dart b/test/sha1_test.dart
index 5b7398b..3b629b0 100644
--- a/test/sha1_test.dart
+++ b/test/sha1_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import "dart:async";
+import "dart:convert";
import "package:crypto/crypto.dart";
import "package:test/test.dart";
@@ -24,6 +25,18 @@
sink.close();
sink.close();
});
+
+ test('close closes the underlying sink', () {
+ var inner = new ChunkedConversionSink<Digest>.withCallback(
+ expectAsync((accumulated) {
+ expect(accumulated.length, equals(1));
+ expect(accumulated.first.toString(),
+ equals("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
+ }));
+
+ var outer = sha1.startChunkedConversion(inner);
+ outer.close();
+ });
});
group("standard vector", () {
diff --git a/test/sha256_test.dart b/test/sha256_test.dart
index a56d75a..1c6653e 100644
--- a/test/sha256_test.dart
+++ b/test/sha256_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import "dart:async";
+import "dart:convert";
import "package:test/test.dart";
import "package:crypto/crypto.dart";
@@ -24,6 +25,21 @@
sink.close();
sink.close();
});
+
+ test('close closes the underlying sink', () {
+ var inner = new ChunkedConversionSink<Digest>.withCallback(
+ expectAsync((accumulated) {
+ expect(accumulated.length, equals(1));
+ expect(
+ accumulated.first.toString(),
+ equals(
+ "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8"
+ "55"));
+ }));
+
+ var outer = sha256.startChunkedConversion(inner);
+ outer.close();
+ });
});
group("standard vector", () {