|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "nsISupports.idl" |
|
6 #include "nsIKeyModule.idl" |
|
7 |
|
8 interface nsIInputStream; |
|
9 |
|
10 /** |
|
11 * Stream cipher interface. We're basically copying the interface from |
|
12 * nsICryptoHash interface. |
|
13 */ |
|
14 [scriptable, uuid(1d507cd6-1630-4710-af1b-4012dbcc514c)] |
|
15 interface nsIStreamCipher : nsISupports |
|
16 { |
|
17 /** |
|
18 * Initialize a stream cipher. |
|
19 * @param aKey nsIKeyObject |
|
20 */ |
|
21 void init(in nsIKeyObject aKey); |
|
22 |
|
23 /** |
|
24 * Initialize a stream cipher with an initialization vector. |
|
25 * @param aKey nsIKeyObject |
|
26 * @param aIV the initialization vector |
|
27 * @param aIVLen the length of the initialization vector |
|
28 */ |
|
29 void initWithIV(in nsIKeyObject aKey, |
|
30 [const, array, size_is(aIVLen)] in octet aIV, |
|
31 in unsigned long aIVLen); |
|
32 |
|
33 /** |
|
34 * Update from an array of bytes. |
|
35 */ |
|
36 void update([const, array, size_is(aLen)] in octet aData, in unsigned long aLen); |
|
37 |
|
38 /** |
|
39 * Update from a stream. |
|
40 */ |
|
41 void updateFromStream(in nsIInputStream aStream, in long aLen); |
|
42 |
|
43 /** |
|
44 * A more script friendly method (not in nsICryptoHash interface). |
|
45 */ |
|
46 void updateFromString(in ACString aInput); |
|
47 |
|
48 /** |
|
49 * @param aASCII if true then the returned value is a base-64 |
|
50 * encoded string. if false, then the returned value is |
|
51 * binary data. |
|
52 */ |
|
53 ACString finish(in boolean aASCII); |
|
54 |
|
55 /** |
|
56 * Discard aLen bytes of the keystream. |
|
57 * These days 1536 is considered a decent amount to drop to get |
|
58 * the key state warmed-up enough for secure usage. |
|
59 */ |
|
60 void discard(in long aLen); |
|
61 }; |