| 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 part of crypto; | 5 part of crypto; |
| 6 | 6 |
| 7 // Constants. | 7 // Constants. |
| 8 const _MASK_8 = 0xff; | 8 const _MASK_8 = 0xff; |
| 9 const _MASK_32 = 0xffffffff; | 9 const _MASK_32 = 0xffffffff; |
| 10 const _BITS_PER_BYTE = 8; | 10 const _BITS_PER_BYTE = 8; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 dataIndex += 4; | 96 dataIndex += 4; |
| 97 var word = (w3 & 0xff) << 24; | 97 var word = (w3 & 0xff) << 24; |
| 98 word |= (w2 & _MASK_8) << 16; | 98 word |= (w2 & _MASK_8) << 16; |
| 99 word |= (w1 & _MASK_8) << 8; | 99 word |= (w1 & _MASK_8) << 8; |
| 100 word |= (w0 & _MASK_8); | 100 word |= (w0 & _MASK_8); |
| 101 _currentChunk[wordIndex] = word; | 101 _currentChunk[wordIndex] = word; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Convert a 32-bit word to four bytes. | 105 // Convert a 32-bit word to four bytes. |
| 106 Uint32List _wordToBytes(int word) { | 106 List<int> _wordToBytes(int word) { |
| 107 Uint32List bytes = new Uint32List(_BYTES_PER_WORD); | 107 List bytes = new List<int>(_BYTES_PER_WORD); |
| 108 bytes[0] = (word >> (_bigEndianWords ? 24 : 0)) & _MASK_8; | 108 bytes[0] = (word >> (_bigEndianWords ? 24 : 0)) & _MASK_8; |
| 109 bytes[1] = (word >> (_bigEndianWords ? 16 : 8)) & _MASK_8; | 109 bytes[1] = (word >> (_bigEndianWords ? 16 : 8)) & _MASK_8; |
| 110 bytes[2] = (word >> (_bigEndianWords ? 8 : 16)) & _MASK_8; | 110 bytes[2] = (word >> (_bigEndianWords ? 8 : 16)) & _MASK_8; |
| 111 bytes[3] = (word >> (_bigEndianWords ? 0 : 24)) & _MASK_8; | 111 bytes[3] = (word >> (_bigEndianWords ? 0 : 24)) & _MASK_8; |
| 112 return bytes; | 112 return bytes; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Iterate through data updating the hash computation for each | 115 // Iterate through data updating the hash computation for each |
| 116 // chunk. | 116 // chunk. |
| 117 void _iterate() { | 117 void _iterate() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 142 assert(lengthInBits < pow(2, 32)); | 142 assert(lengthInBits < pow(2, 32)); |
| 143 if (_bigEndianWords) { | 143 if (_bigEndianWords) { |
| 144 _pendingData.addAll(_wordToBytes(0)); | 144 _pendingData.addAll(_wordToBytes(0)); |
| 145 _pendingData.addAll(_wordToBytes(lengthInBits & _MASK_32)); | 145 _pendingData.addAll(_wordToBytes(lengthInBits & _MASK_32)); |
| 146 } else { | 146 } else { |
| 147 _pendingData.addAll(_wordToBytes(lengthInBits & _MASK_32)); | 147 _pendingData.addAll(_wordToBytes(lengthInBits & _MASK_32)); |
| 148 _pendingData.addAll(_wordToBytes(0)); | 148 _pendingData.addAll(_wordToBytes(0)); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 } | 151 } |
| OLD | NEW |