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 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 'digest_sink.dart'; | 9 import 'digest_sink.dart'; |
10 import 'hash.dart'; | 10 import 'hash.dart'; |
11 | 11 |
12 /// An implementation of [keyed-hash method authentication codes][rfc]. | 12 /// An implementation of [keyed-hash method authentication codes][rfc]. |
13 /// | 13 /// |
14 /// [rfc]: https://tools.ietf.org/html/rfc2104 | 14 /// [rfc]: https://tools.ietf.org/html/rfc2104 |
15 /// | 15 /// |
16 /// HMAC allows messages to be cryptographically authenticated using any | 16 /// HMAC allows messages to be cryptographically authenticated using any |
17 /// iterated cryptographic hash function. | 17 /// iterated cryptographic hash function. |
18 class Hmac extends ChunkedConverter<List<int>, Digest, List<int>, Digest> { | 18 class Hmac extends Converter<List<int>, Digest> { |
19 /// The hash function used to compute the authentication digest. | 19 /// The hash function used to compute the authentication digest. |
20 final Hash _hash; | 20 final Hash _hash; |
21 | 21 |
22 /// The secret key shared by the sender and the receiver. | 22 /// The secret key shared by the sender and the receiver. |
23 final Uint8List _key; | 23 final Uint8List _key; |
24 | 24 |
25 /// Create an [HMAC] object from a [Hash] and a binary key. | 25 /// Create an [HMAC] object from a [Hash] and a binary key. |
26 /// | 26 /// |
27 /// The key should be a secret shared between the sender and receiver of the | 27 /// The key should be a secret shared between the sender and receiver of the |
28 /// message. | 28 /// message. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 void close() { | 94 void close() { |
95 if (_isClosed) return; | 95 if (_isClosed) return; |
96 _isClosed = true; | 96 _isClosed = true; |
97 | 97 |
98 _innerSink.close(); | 98 _innerSink.close(); |
99 _outerSink.add(_innerResultSink.value.bytes); | 99 _outerSink.add(_innerResultSink.value.bytes); |
100 _outerSink.close(); | 100 _outerSink.close(); |
101 } | 101 } |
102 } | 102 } |
OLD | NEW |