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

Side by Side Diff: lib/src/sha256.dart

Issue 1826543003: Update deprecations. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Created 4 years, 9 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 | « lib/src/sha1.dart ('k') | pubspec.yaml » ('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 import 'dart:convert'; 5 import 'dart:convert';
6 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 7
8 import 'digest.dart'; 8 import 'digest.dart';
9 import 'hash.dart'; 9 import 'hash.dart';
10 import 'hash_sink.dart'; 10 import 'hash_sink.dart';
11 import 'utils.dart'; 11 import 'utils.dart';
12 12
13 /// An instance of [SHA256]. 13 /// An instance of [Sha256].
14 /// 14 ///
15 /// This instance provides convenient access to the [SHA256][rfc] hash function. 15 /// This instance provides convenient access to the [Sha256][rfc] hash function.
16 /// 16 ///
17 /// [rfc]: http://tools.ietf.org/html/rfc6234 17 /// [rfc]: http://tools.ietf.org/html/rfc6234
18 final sha256 = new SHA256(); 18 final sha256 = new Sha256._();
19 19
20 /// An implementation of the [SHA-256][rfc] hash function. 20 /// An implementation of the [SHA-256][rfc] hash function.
21 /// 21 ///
22 /// [rfc]: http://tools.ietf.org/html/rfc6234 22 /// [rfc]: http://tools.ietf.org/html/rfc6234
23 /// 23 ///
24 /// Note that it's almost always easier to use [sha256] rather than creating a 24 /// Note that it's almost always easier to use [sha256] rather than creating a
25 /// new instance. 25 /// new instance.
26 class SHA256 extends Hash { 26 class Sha256 extends Hash {
27 final int blockSize = 16 * bytesPerWord; 27 final int blockSize = 16 * bytesPerWord;
28 28
29 @Deprecated("Use the sha256 field instead.") 29 Sha256._();
30 SHA256(); 30
31 Sha256 newInstance() => new Sha256._();
32
33 ByteConversionSink startChunkedConversion(Sink<Digest> sink) =>
34 new ByteConversionSink.from(new _Sha256Sink(sink));
35 }
36
37 /// This class is deprecated.
38 ///
39 /// Use [sha256] instead.
40 @Deprecated("Will be removed in crypto 1.0.0.")
41 class SHA256 extends Sha256 {
42 SHA256() : super._();
31 43
32 SHA256 newInstance() => new SHA256(); 44 SHA256 newInstance() => new SHA256();
33
34 ByteConversionSink startChunkedConversion(Sink<Digest> sink) =>
35 new ByteConversionSink.from(new _SHA256Sink(sink));
36 } 45 }
37 46
38 /// Data from a non-linear function that functions as reproducible noise. 47 /// Data from a non-linear function that functions as reproducible noise.
39 const List<int> _noise = const [ 48 const List<int> _noise = const [
40 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 49 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
41 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 50 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
42 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 51 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
43 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 52 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
44 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 53 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
45 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 54 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
46 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 55 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
47 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 56 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
48 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 57 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
49 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 58 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
50 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 59 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
51 ]; 60 ];
52 61
53 /// The concrete implementation of [SHA256]. 62 /// The concrete implementation of [Sha256].
54 /// 63 ///
55 /// This is separate so that it can extend [HashBase] without leaking additional 64 /// This is separate so that it can extend [HashBase] without leaking additional
56 /// public memebers. 65 /// public memebers.
57 class _SHA256Sink extends HashSink { 66 class _Sha256Sink extends HashSink {
58 final digest = new Uint32List(8); 67 final digest = new Uint32List(8);
59 68
60 /// The sixteen words from the original chunk, extended to 64 words. 69 /// The sixteen words from the original chunk, extended to 64 words.
61 /// 70 ///
62 /// This is an instance variable to avoid re-allocating, but its data isn't 71 /// This is an instance variable to avoid re-allocating, but its data isn't
63 /// used across invocations of [updateHash]. 72 /// used across invocations of [updateHash].
64 final Uint32List _extended; 73 final Uint32List _extended;
65 74
66 _SHA256Sink(Sink<Digest> sink) 75 _Sha256Sink(Sink<Digest> sink)
67 : _extended = new Uint32List(64), 76 : _extended = new Uint32List(64),
68 super(sink, 16) { 77 super(sink, 16) {
69 // Initial value of the hash parts. First 32 bits of the fractional parts 78 // Initial value of the hash parts. First 32 bits of the fractional parts
70 // of the square roots of the first 8 prime numbers. 79 // of the square roots of the first 8 prime numbers.
71 digest[0] = 0x6a09e667; 80 digest[0] = 0x6a09e667;
72 digest[1] = 0xbb67ae85; 81 digest[1] = 0xbb67ae85;
73 digest[2] = 0x3c6ef372; 82 digest[2] = 0x3c6ef372;
74 digest[3] = 0xa54ff53a; 83 digest[3] = 0xa54ff53a;
75 digest[4] = 0x510e527f; 84 digest[4] = 0x510e527f;
76 digest[5] = 0x9b05688c; 85 digest[5] = 0x9b05688c;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 digest[0] = add32(a, digest[0]); 142 digest[0] = add32(a, digest[0]);
134 digest[1] = add32(b, digest[1]); 143 digest[1] = add32(b, digest[1]);
135 digest[2] = add32(c, digest[2]); 144 digest[2] = add32(c, digest[2]);
136 digest[3] = add32(d, digest[3]); 145 digest[3] = add32(d, digest[3]);
137 digest[4] = add32(e, digest[4]); 146 digest[4] = add32(e, digest[4]);
138 digest[5] = add32(f, digest[5]); 147 digest[5] = add32(f, digest[5]);
139 digest[6] = add32(g, digest[6]); 148 digest[6] = add32(g, digest[6]);
140 digest[7] = add32(h, digest[7]); 149 digest[7] = add32(h, digest[7]);
141 } 150 }
142 } 151 }
OLDNEW
« no previous file with comments | « lib/src/sha1.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698