michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "nsIKeyModule.idl" michael@0: michael@0: interface nsIInputStream; michael@0: michael@0: /** michael@0: * Stream cipher interface. We're basically copying the interface from michael@0: * nsICryptoHash interface. michael@0: */ michael@0: [scriptable, uuid(1d507cd6-1630-4710-af1b-4012dbcc514c)] michael@0: interface nsIStreamCipher : nsISupports michael@0: { michael@0: /** michael@0: * Initialize a stream cipher. michael@0: * @param aKey nsIKeyObject michael@0: */ michael@0: void init(in nsIKeyObject aKey); michael@0: michael@0: /** michael@0: * Initialize a stream cipher with an initialization vector. michael@0: * @param aKey nsIKeyObject michael@0: * @param aIV the initialization vector michael@0: * @param aIVLen the length of the initialization vector michael@0: */ michael@0: void initWithIV(in nsIKeyObject aKey, michael@0: [const, array, size_is(aIVLen)] in octet aIV, michael@0: in unsigned long aIVLen); michael@0: michael@0: /** michael@0: * Update from an array of bytes. michael@0: */ michael@0: void update([const, array, size_is(aLen)] in octet aData, in unsigned long aLen); michael@0: michael@0: /** michael@0: * Update from a stream. michael@0: */ michael@0: void updateFromStream(in nsIInputStream aStream, in long aLen); michael@0: michael@0: /** michael@0: * A more script friendly method (not in nsICryptoHash interface). michael@0: */ michael@0: void updateFromString(in ACString aInput); michael@0: michael@0: /** michael@0: * @param aASCII if true then the returned value is a base-64 michael@0: * encoded string. if false, then the returned value is michael@0: * binary data. michael@0: */ michael@0: ACString finish(in boolean aASCII); michael@0: michael@0: /** michael@0: * Discard aLen bytes of the keystream. michael@0: * These days 1536 is considered a decent amount to drop to get michael@0: * the key state warmed-up enough for secure usage. michael@0: */ michael@0: void discard(in long aLen); michael@0: };