Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit 01b9190

Browse files
authored
Change maximum message width to 3ffff...ff (#52)
* Change max message length.
1 parent c714b42 commit 01b9190

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.0.5
2+
3+
* Changed the max message size instead to 0x3ffffffffffff, which is the largest
4+
portable value for both JS and the Dart VM.
5+
16
## 2.0.4
27

38
* Made max message size a BigNum instead of an int so that dart2js can compile

lib/src/hash_sink.dart

+7-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ abstract class HashSink implements Sink<List<int>> {
2626
/// used across invocations of [_iterate].
2727
final Uint32List _currentChunk;
2828

29+
/// Messages with more than 2^53-1 bits are not supported. (This is the
30+
/// largest value that is representable on both JS and the Dart VM.)
31+
/// So the maximum length in bytes is (2^53-1)/8.
32+
static const _maxMessageLengthInBytes = 0x0003ffffffffffff;
33+
2934
/// The length of the input data so far, in bytes.
3035
int _lengthInBytes = 0;
3136

@@ -121,12 +126,9 @@ abstract class HashSink implements Sink<List<int>> {
121126
_pendingData.add(0);
122127
}
123128

124-
if (new BigInt.from(_lengthInBytes) >
125-
(new BigInt.from(2).pow(64) - BigInt.one)) {
126-
// Messages with more than 2^64-1 bits are not supported.
127-
// So the maximum length in bytes is (2^64-1)/8.
129+
if (_lengthInBytes > _maxMessageLengthInBytes) {
128130
throw new UnsupportedError(
129-
'Hashing is unsupported for messages with more than 2^64 bits.');
131+
'Hashing is unsupported for messages with more than 2^53 bits.');
130132
}
131133

132134
var lengthInBits = _lengthInBytes * bitsPerByte;

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: crypto
2-
version: 2.0.4
2+
version: 2.0.5
33
author: Dart Team <misc@dartlang.org>
44
description: Library of cryptographic functions.
55
homepage: https://github.com/dart-lang/crypto

0 commit comments

Comments
 (0)