Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / netwerk / base / public / nsICryptoHMAC.idl
blobce8fcc2e6f82e27824e3703d4a6e8eb546e5f24a
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is
17 * Doug Turner <dougt@meer.net>.
18 * Portions created by the Initial Developer are Copyright (C) 2005
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Doug Turner <dougt@meer.net>
23 * Honza Bambas <honzab@firemni.cz>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsISupports.idl"
40 interface nsIInputStream;
41 interface nsIKeyObject;
43 /**
44 * nsICryptoHMAC
45 * This interface provides HMAC signature algorithms.
48 [scriptable, uuid(8FEB4C7C-1641-4a7b-BC6D-1964E2099497)]
49 interface nsICryptoHMAC : nsISupports
51 /**
52 * Hashing Algorithms. These values are to be used by the
53 * |init| method to indicate which hashing function to
54 * use. These values map onto the values defined in
55 * mozilla/security/nss/lib/softoken/pkcs11t.h and are
56 * switched to CKM_*_HMAC constant.
58 const short MD2 = 1;
59 const short MD5 = 2;
60 const short SHA1 = 3;
61 const short SHA256 = 4;
62 const short SHA384 = 5;
63 const short SHA512 = 6;
65 /**
66 * Initialize the hashing object. This method may be
67 * called multiple times with different algorithm types.
69 * @param aAlgorithm the algorithm type to be used.
70 * This value must be one of the above valid
71 * algorithm types.
73 * @param aKeyObject
74 * Object holding a key. To create the key object use for instance:
75 * var keyObject = Components.classes["@mozilla.org/security/keyobjectfactory;1"]
76 * .getService(Components.interfaces.nsIKeyObjectFactory)
77 * .keyFromString(Components.interfaces.nsIKeyObject.HMAC, rawKeyData);
79 * WARNING: This approach is not FIPS compliant.
81 * @throws NS_ERROR_INVALID_ARG if an unsupported algorithm
82 * type is passed.
84 * NOTE: This method must be called before any other method
85 * on this interface is called.
87 void init(in unsigned long aAlgorithm, in nsIKeyObject aKeyObject);
89 /**
90 * @param aData a buffer to calculate the hash over
92 * @param aLen the length of the buffer |aData|
94 * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been
95 * called.
97 void update([const, array, size_is(aLen)] in octet aData, in unsigned long aLen);
99 /**
100 * Calculates and updates a new hash based on a given data stream.
102 * @param aStream an input stream to read from.
104 * @param aLen how much to read from the given |aStream|. Passing
105 * PR_UINT32_MAX indicates that all data available will be used
106 * to update the hash.
108 * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been
109 * called.
111 * @throws NS_ERROR_NOT_AVAILABLE if the requested amount of
112 * data to be calculated into the hash is not available.
115 void updateFromStream(in nsIInputStream aStream, in unsigned long aLen);
118 * Completes this HMAC object and produces the actual HMAC diegest data.
120 * @param aASCII if true then the returned value is a base-64
121 * encoded string. if false, then the returned value is
122 * binary data.
124 * @return a hash of the data that was read by this object. This can
125 * be either binary data or base 64 encoded.
127 * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been
128 * called.
130 * NOTE: This method may be called any time after |init|
131 * is called. This call resets the object to its
132 * pre-init state.
134 ACString finish(in PRBool aASCII);
137 * Reinitialize HMAC context to be reused with the same
138 * settings (the key and hash algorithm) but on different
139 * set of data.
141 void reset();