| Index: pkg/crypto/lib/src/hash_utils.dart
|
| diff --git a/pkg/crypto/lib/src/hash_utils.dart b/pkg/crypto/lib/src/hash_utils.dart
|
| index 713dbb9d2cd0ce6f8475bb1de5a87de16eb3ea73..84df9d0e4826edde02f9764f52f43423bcbab6a6 100644
|
| --- a/pkg/crypto/lib/src/hash_utils.dart
|
| +++ b/pkg/crypto/lib/src/hash_utils.dart
|
| @@ -22,16 +22,17 @@ int _rotl32(int val, int shift) {
|
| // Base class encapsulating common behavior for cryptographic hash
|
| // functions.
|
| abstract class _HashBase implements Hash {
|
| - _HashBase(int this._chunkSizeInWords,
|
| - int this._digestSizeInWords,
|
| + _HashBase(int chunkSizeInWords,
|
| + int digestSizeInWords,
|
| bool this._bigEndianWords)
|
| - : _pendingData = [] {
|
| - _currentChunk = new List(_chunkSizeInWords);
|
| - _h = new List(_digestSizeInWords);
|
| - }
|
| + : _pendingData = [],
|
| + _currentChunk = new List(chunkSizeInWords),
|
| + _h = new List(digestSizeInWords),
|
| + _chunkSizeInWords = chunkSizeInWords,
|
| + _digestSizeInWords = digestSizeInWords;
|
|
|
| // Update the hasher with more data.
|
| - add(List<int> data) {
|
| + void add(List<int> data) {
|
| if (_digestCalled) {
|
| throw new StateError(
|
| 'Hash update method called after digest was retrieved');
|
| @@ -58,18 +59,15 @@ abstract class _HashBase implements Hash {
|
| return _chunkSizeInWords * _BYTES_PER_WORD;
|
| }
|
|
|
| - // Create a fresh instance of this Hash.
|
| - newInstance();
|
| -
|
| // One round of the hash computation.
|
| - _updateHash(List<int> m);
|
| + void _updateHash(List<int> m);
|
|
|
| // Helper methods.
|
| - _add32(x, y) => (x + y) & _MASK_32;
|
| - _roundUp(val, n) => (val + n - 1) & -n;
|
| + int _add32(x, y) => (x + y) & _MASK_32;
|
| + int _roundUp(val, n) => (val + n - 1) & -n;
|
|
|
| // Compute the final result as a list of bytes from the hash words.
|
| - _resultAsBytes() {
|
| + List<int> _resultAsBytes() {
|
| var result = [];
|
| for (var i = 0; i < _h.length; i++) {
|
| result.addAll(_wordToBytes(_h[i]));
|
| @@ -78,7 +76,7 @@ abstract class _HashBase implements Hash {
|
| }
|
|
|
| // Converts a list of bytes to a chunk of 32-bit words.
|
| - _bytesToChunk(List<int> data, int dataIndex) {
|
| + void _bytesToChunk(List<int> data, int dataIndex) {
|
| assert((data.length - dataIndex) >= (_chunkSizeInWords * _BYTES_PER_WORD));
|
|
|
| for (var wordIndex = 0; wordIndex < _chunkSizeInWords; wordIndex++) {
|
| @@ -96,7 +94,7 @@ abstract class _HashBase implements Hash {
|
| }
|
|
|
| // Convert a 32-bit word to four bytes.
|
| - _wordToBytes(int word) {
|
| + List<int> _wordToBytes(int word) {
|
| List<int> bytes = new List(_BYTES_PER_WORD);
|
| bytes[0] = (word >> (_bigEndianWords ? 24 : 0)) & _MASK_8;
|
| bytes[1] = (word >> (_bigEndianWords ? 16 : 8)) & _MASK_8;
|
| @@ -107,7 +105,7 @@ abstract class _HashBase implements Hash {
|
|
|
| // Iterate through data updating the hash computation for each
|
| // chunk.
|
| - _iterate() {
|
| + void _iterate() {
|
| var len = _pendingData.length;
|
| var chunkSizeInBytes = _chunkSizeInWords * _BYTES_PER_WORD;
|
| if (len >= chunkSizeInBytes) {
|
| @@ -122,7 +120,7 @@ abstract class _HashBase implements Hash {
|
|
|
| // Finalize the data. Add a 1 bit to the end of the message. Expand with
|
| // 0 bits and add the length of the message.
|
| - _finalizeData() {
|
| + void _finalizeData() {
|
| _pendingData.add(0x80);
|
| var contentsLength = _lengthInBytes + 9;
|
| var chunkSizeInBytes = _chunkSizeInWords * _BYTES_PER_WORD;
|
| @@ -148,7 +146,7 @@ abstract class _HashBase implements Hash {
|
| final bool _bigEndianWords;
|
| int _lengthInBytes = 0;
|
| List<int> _pendingData;
|
| - List<int> _currentChunk;
|
| - List<int> _h;
|
| + final List<int> _currentChunk;
|
| + final List<int> _h;
|
| bool _digestCalled = false;
|
| }
|
|
|