1 | /**
|
2 | * @license
|
3 | * Copyright 2017 Google LLC
|
4 | *
|
5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | * you may not use this file except in compliance with the License.
|
7 | * You may obtain a copy of the License at
|
8 | *
|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
10 | *
|
11 | * Unless required by applicable law or agreed to in writing, software
|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | * See the License for the specific language governing permissions and
|
15 | * limitations under the License.
|
16 | */
|
17 | /**
|
18 | * @fileoverview SHA-1 cryptographic hash.
|
19 | * Variable names follow the notation in FIPS PUB 180-3:
|
20 | * http://csrc.nist.gov/publications/fips/fips180-3/fips180-3_final.pdf.
|
21 | *
|
22 | * Usage:
|
23 | * var sha1 = new sha1();
|
24 | * sha1.update(bytes);
|
25 | * var hash = sha1.digest();
|
26 | *
|
27 | * Performance:
|
28 | * Chrome 23: ~400 Mbit/s
|
29 | * Firefox 16: ~250 Mbit/s
|
30 | *
|
31 | */
|
32 | /**
|
33 | * SHA-1 cryptographic hash constructor.
|
34 | *
|
35 | * The properties declared here are discussed in the above algorithm document.
|
36 | * @constructor
|
37 | * @final
|
38 | * @struct
|
39 | */
|
40 | export declare class Sha1 {
|
41 | /**
|
42 | * Holds the previous values of accumulated variables a-e in the compress_
|
43 | * function.
|
44 | * @private
|
45 | */
|
46 | private chain_;
|
47 | /**
|
48 | * A buffer holding the partially computed hash result.
|
49 | * @private
|
50 | */
|
51 | private buf_;
|
52 | /**
|
53 | * An array of 80 bytes, each a part of the message to be hashed. Referred to
|
54 | * as the message schedule in the docs.
|
55 | * @private
|
56 | */
|
57 | private W_;
|
58 | /**
|
59 | * Contains data needed to pad messages less than 64 bytes.
|
60 | * @private
|
61 | */
|
62 | private pad_;
|
63 | /**
|
64 | * @private {number}
|
65 | */
|
66 | private inbuf_;
|
67 | /**
|
68 | * @private {number}
|
69 | */
|
70 | private total_;
|
71 | blockSize: number;
|
72 | constructor();
|
73 | reset(): void;
|
74 | /**
|
75 | * Internal compress helper function.
|
76 | * @param buf Block to compress.
|
77 | * @param offset Offset of the block in the buffer.
|
78 | * @private
|
79 | */
|
80 | compress_(buf: number[] | Uint8Array | string, offset?: number): void;
|
81 | update(bytes?: number[] | Uint8Array | string, length?: number): void;
|
82 | /** @override */
|
83 | digest(): number[];
|
84 | }
|