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

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

Issue 1350913002: Run the formatter over crypto. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Fix a missing value. Created 5 years, 3 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/hash_utils.dart ('k') | lib/src/md5.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 crypto; 5 part of crypto;
6 6
7 /** 7 /**
8 * Hash-based Message Authentication Code support. 8 * Hash-based Message Authentication Code support.
9 * 9 *
10 * The [add] method is used to add data to the message. The [digest] and 10 * The [add] method is used to add data to the message. The [digest] and
11 * [close] methods are used to extract the message authentication code. 11 * [close] methods are used to extract the message authentication code.
12 */ 12 */
13 // TODO(floitsch): make Hash implement Sink, EventSink or similar. 13 // TODO(floitsch): make Hash implement Sink, EventSink or similar.
14 class HMAC { 14 class HMAC {
15 final List<int> _message; 15 final List<int> _message;
16 Hash _hash; 16 Hash _hash;
17 List<int> _key; 17 List<int> _key;
18 bool _isClosed = false; 18 bool _isClosed = false;
19 19
20 /** 20 /**
21 * Create an [HMAC] object from a [Hash] and a key. 21 * Create an [HMAC] object from a [Hash] and a key.
22 */ 22 */
23 HMAC(Hash this._hash, List<int> this._key): _message = []; 23 HMAC(Hash this._hash, List<int> this._key) : _message = [];
24 24
25 /** 25 /**
26 * Add a list of bytes to the message. 26 * Add a list of bytes to the message.
27 */ 27 */
28 void add(List<int> data) { 28 void add(List<int> data) {
29 if (_isClosed) throw new StateError("HMAC is closed"); 29 if (_isClosed) throw new StateError("HMAC is closed");
30 _message.addAll(data); 30 _message.addAll(data);
31 } 31 }
32 32
33 /** 33 /**
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 'Invalid digest size: ${digest.length} in HMAC.verify. ' 103 'Invalid digest size: ${digest.length} in HMAC.verify. '
104 'Expected: ${_hash.blockSize}.'); 104 'Expected: ${_hash.blockSize}.');
105 } 105 }
106 int result = 0; 106 int result = 0;
107 for (var i = 0; i < digest.length; i++) { 107 for (var i = 0; i < digest.length; i++) {
108 result |= digest[i] ^ computedDigest[i]; 108 result |= digest[i] ^ computedDigest[i];
109 } 109 }
110 return result == 0; 110 return result == 0;
111 } 111 }
112 } 112 }
OLDNEW
« no previous file with comments | « lib/src/hash_utils.dart ('k') | lib/src/md5.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698