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: michael@0: // An opaque key object. michael@0: [scriptable, uuid(4b31f4ed-9424-4710-b946-79b7e33cf3a8)] michael@0: interface nsIKeyObject : nsISupports michael@0: { michael@0: // Key types michael@0: const short SYM_KEY = 1; michael@0: const short PRIVATE_KEY = 2; michael@0: const short PUBLIC_KEY = 3; michael@0: michael@0: // Algorithm types michael@0: const short RC4 = 1; michael@0: const short AES_CBC = 2; michael@0: const short HMAC = 257; michael@0: michael@0: // aAlgorithm is an algorithm type michael@0: // aKey is either a PK11SymKey, SECKEYPublicKey, or a SECKEYPrivateKey. michael@0: // The nsIKeyObject will take ownership of the key and be responsible michael@0: // for freeing the key memory when destroyed. michael@0: [noscript] void initKey(in short aAlgorithm, in voidPtr aKey); michael@0: michael@0: // Return a pointer to the underlying key object michael@0: [noscript] voidPtr getKeyObj(); michael@0: michael@0: // Will return NS_ERROR_NOT_INITIALIZED if initKey hasn't been run michael@0: short getType(); michael@0: }; michael@0: michael@0: [scriptable, uuid(264eb54d-e20d-49a0-890c-1a5986ea81c4)] michael@0: interface nsIKeyObjectFactory : nsISupports michael@0: { michael@0: nsIKeyObject lookupKeyByName(in ACString aName); michael@0: michael@0: nsIKeyObject unwrapKey(in short aAlgorithm, michael@0: [const, array, size_is(aWrappedKeyLen)] in octet aWrappedKey, michael@0: in unsigned long aWrappedKeyLen); michael@0: michael@0: // TODO: deriveKeyFrom* michael@0: michael@0: michael@0: // DO NOT USE michael@0: // This is not FIPS compliant and should not be used. michael@0: nsIKeyObject keyFromString(in short aAlgorithm, in ACString aKey); michael@0: };