Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: sdk/lib/io/crypto.dart

Issue 1974043002: Revert "Fix remaining strong-mode warnings and errors in dart:io." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/io/common.dart ('k') | sdk/lib/io/data_transformer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 dart.io; 5 part of dart.io;
6 6
7 class _CryptoUtils { 7 class _CryptoUtils {
8 static const int PAD = 61; // '=' 8 static const int PAD = 61; // '='
9 static const int CR = 13; // '\r' 9 static const int CR = 13; // '\r'
10 static const int LF = 10; // '\n' 10 static const int LF = 10; // '\n'
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // Rotate left limiting to unsigned 32-bit values. 228 // Rotate left limiting to unsigned 32-bit values.
229 int _rotl32(int val, int shift) { 229 int _rotl32(int val, int shift) {
230 var mod_shift = shift & 31; 230 var mod_shift = shift & 31;
231 return ((val << mod_shift) & _MASK_32) | 231 return ((val << mod_shift) & _MASK_32) |
232 ((val & _MASK_32) >> (32 - mod_shift)); 232 ((val & _MASK_32) >> (32 - mod_shift));
233 } 233 }
234 234
235 235
236 // Compute the final result as a list of bytes from the hash words. 236 // Compute the final result as a list of bytes from the hash words.
237 List<int> _resultAsBytes() { 237 _resultAsBytes() {
238 var result = <int>[]; 238 var result = [];
239 for (var i = 0; i < _h.length; i++) { 239 for (var i = 0; i < _h.length; i++) {
240 result.addAll(_wordToBytes(_h[i])); 240 result.addAll(_wordToBytes(_h[i]));
241 } 241 }
242 return result; 242 return result;
243 } 243 }
244 244
245 // Converts a list of bytes to a chunk of 32-bit words. 245 // Converts a list of bytes to a chunk of 32-bit words.
246 _bytesToChunk(List<int> data, int dataIndex) { 246 _bytesToChunk(List<int> data, int dataIndex) {
247 assert((data.length - dataIndex) >= (_chunkSizeInWords * _BYTES_PER_WORD)); 247 assert((data.length - dataIndex) >= (_chunkSizeInWords * _BYTES_PER_WORD));
248 248
249 for (var wordIndex = 0; wordIndex < _chunkSizeInWords; wordIndex++) { 249 for (var wordIndex = 0; wordIndex < _chunkSizeInWords; wordIndex++) {
250 var w3 = _bigEndianWords ? data[dataIndex] : data[dataIndex + 3]; 250 var w3 = _bigEndianWords ? data[dataIndex] : data[dataIndex + 3];
251 var w2 = _bigEndianWords ? data[dataIndex + 1] : data[dataIndex + 2]; 251 var w2 = _bigEndianWords ? data[dataIndex + 1] : data[dataIndex + 2];
252 var w1 = _bigEndianWords ? data[dataIndex + 2] : data[dataIndex + 1]; 252 var w1 = _bigEndianWords ? data[dataIndex + 2] : data[dataIndex + 1];
253 var w0 = _bigEndianWords ? data[dataIndex + 3] : data[dataIndex]; 253 var w0 = _bigEndianWords ? data[dataIndex + 3] : data[dataIndex];
254 dataIndex += 4; 254 dataIndex += 4;
255 var word = (w3 & 0xff) << 24; 255 var word = (w3 & 0xff) << 24;
256 word |= (w2 & _MASK_8) << 16; 256 word |= (w2 & _MASK_8) << 16;
257 word |= (w1 & _MASK_8) << 8; 257 word |= (w1 & _MASK_8) << 8;
258 word |= (w0 & _MASK_8); 258 word |= (w0 & _MASK_8);
259 _currentChunk[wordIndex] = word; 259 _currentChunk[wordIndex] = word;
260 } 260 }
261 } 261 }
262 262
263 // Convert a 32-bit word to four bytes. 263 // Convert a 32-bit word to four bytes.
264 List<int> _wordToBytes(int word) { 264 _wordToBytes(int word) {
265 List<int> bytes = new List(_BYTES_PER_WORD); 265 List<int> bytes = new List(_BYTES_PER_WORD);
266 bytes[0] = (word >> (_bigEndianWords ? 24 : 0)) & _MASK_8; 266 bytes[0] = (word >> (_bigEndianWords ? 24 : 0)) & _MASK_8;
267 bytes[1] = (word >> (_bigEndianWords ? 16 : 8)) & _MASK_8; 267 bytes[1] = (word >> (_bigEndianWords ? 16 : 8)) & _MASK_8;
268 bytes[2] = (word >> (_bigEndianWords ? 8 : 16)) & _MASK_8; 268 bytes[2] = (word >> (_bigEndianWords ? 8 : 16)) & _MASK_8;
269 bytes[3] = (word >> (_bigEndianWords ? 0 : 24)) & _MASK_8; 269 bytes[3] = (word >> (_bigEndianWords ? 0 : 24)) & _MASK_8;
270 return bytes; 270 return bytes;
271 } 271 }
272 272
273 // Iterate through data updating the hash computation for each 273 // Iterate through data updating the hash computation for each
274 // chunk. 274 // chunk.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 _h[0] = _add32(a, _h[0]); 440 _h[0] = _add32(a, _h[0]);
441 _h[1] = _add32(b, _h[1]); 441 _h[1] = _add32(b, _h[1]);
442 _h[2] = _add32(c, _h[2]); 442 _h[2] = _add32(c, _h[2]);
443 _h[3] = _add32(d, _h[3]); 443 _h[3] = _add32(d, _h[3]);
444 _h[4] = _add32(e, _h[4]); 444 _h[4] = _add32(e, _h[4]);
445 } 445 }
446 446
447 List<int> _w; 447 List<int> _w;
448 } 448 }
OLDNEW
« no previous file with comments | « sdk/lib/io/common.dart ('k') | sdk/lib/io/data_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698