Bug 513798 - Rewrite WeaveCrypto in JS. r=mconnor, r=dwitte

--HG--
rename : services/crypto/components/IWeaveCrypto.xpt => services/crypto/IWeaveCrypto.xpt
This commit is contained in:
Justin Dolske 2010-04-21 19:02:16 -07:00
Родитель fba87f0c14
Коммит 75fe297323
24 изменённых файлов: 1581 добавлений и 1466 удалений

Просмотреть файл

@ -0,0 +1,359 @@
/*
* DO NOT EDIT. THIS FILE IS GENERATED FROM IWeaveCrypto.idl
*/
#ifndef __gen_IWeaveCrypto_h__
#define __gen_IWeaveCrypto_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
/* starting interface: IWeaveCrypto */
#define IWEAVECRYPTO_IID_STR "f4463043-315e-41f3-b779-82e900e6fffa"
#define IWEAVECRYPTO_IID \
{0xf4463043, 0x315e, 0x41f3, \
{ 0xb7, 0x79, 0x82, 0xe9, 0x00, 0xe6, 0xff, 0xfa }}
class NS_NO_VTABLE NS_SCRIPTABLE IWeaveCrypto : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(IWEAVECRYPTO_IID)
/**
* Shortcuts for some algorithm SEC OIDs. Full list available here:
* http://lxr.mozilla.org/seamonkey/source/security/nss/lib/util/secoidt.h
*/
enum { DES_EDE3_CBC = 156U };
enum { AES_128_CBC = 184U };
enum { AES_192_CBC = 186U };
enum { AES_256_CBC = 188U };
/**
* One of the above constants. Used as the mechanism for encrypting bulk
* data and wrapping keys.
*
* Default is AES_256_CBC.
*/
/* attribute unsigned long algorithm; */
NS_SCRIPTABLE NS_IMETHOD GetAlgorithm(PRUint32 *aAlgorithm) = 0;
NS_SCRIPTABLE NS_IMETHOD SetAlgorithm(PRUint32 aAlgorithm) = 0;
/**
* The size of the RSA key to create with generateKeypair().
*
* Default is 2048.
*/
/* attribute unsigned long keypairBits; */
NS_SCRIPTABLE NS_IMETHOD GetKeypairBits(PRUint32 *aKeypairBits) = 0;
NS_SCRIPTABLE NS_IMETHOD SetKeypairBits(PRUint32 aKeypairBits) = 0;
/**
* Encrypt data using a symmetric key.
* The algorithm attribute specifies how the encryption is performed.
*
* @param clearText
* The data to be encrypted (not base64 encoded).
* @param symmetricKey
* A base64-encoded symmetric key (eg, one from generateRandomKey).
* @param iv
* A base64-encoded initialization vector
* @returns Encrypted data, base64 encoded
*/
/* ACString encrypt (in AUTF8String clearText, in ACString symmetricKey, in ACString iv); */
NS_SCRIPTABLE NS_IMETHOD Encrypt(const nsACString & clearText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM) = 0;
/**
* Encrypt data using a symmetric key.
* The algorithm attribute specifies how the encryption is performed.
*
* @param cipherText
* The base64-encoded data to be decrypted
* @param symmetricKey
* A base64-encoded symmetric key (eg, one from unwrapSymmetricKey)
* @param iv
* A base64-encoded initialization vector
* @returns Decrypted data (not base64-encoded)
*/
/* AUTF8String decrypt (in ACString cipherText, in ACString symmetricKey, in ACString iv); */
NS_SCRIPTABLE NS_IMETHOD Decrypt(const nsACString & cipherText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM) = 0;
/**
* Generate a RSA public/private keypair.
*
* @param aPassphrase
* User's passphrase. Used with PKCS#5 to generate a symmetric key
* for wrapping the private key.
* @param aSalt
* Salt for the user's passphrase.
* @param aIV
* Random IV, used when wrapping the private key.
* @param aEncodedPublicKey
* The public key, base-64 encoded.
* @param aWrappedPrivateKey
* The public key, encrypted with the user's passphrase, and base-64 encoded.
*/
/* void generateKeypair (in ACString aPassphrase, in ACString aSalt, in ACString aIV, out ACString aEncodedPublicKey, out ACString aWrappedPrivateKey); */
NS_SCRIPTABLE NS_IMETHOD GenerateKeypair(const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & aEncodedPublicKey NS_OUTPARAM, nsACString & aWrappedPrivateKey NS_OUTPARAM) = 0;
/* ACString generateRandomKey (); */
NS_SCRIPTABLE NS_IMETHOD GenerateRandomKey(nsACString & _retval NS_OUTPARAM) = 0;
/* ACString generateRandomIV (); */
NS_SCRIPTABLE NS_IMETHOD GenerateRandomIV(nsACString & _retval NS_OUTPARAM) = 0;
/* ACString generateRandomBytes (in unsigned long aByteCount); */
NS_SCRIPTABLE NS_IMETHOD GenerateRandomBytes(PRUint32 aByteCount, nsACString & _retval NS_OUTPARAM) = 0;
/**
* Encrypts a symmetric key with a user's public key.
*
* @param aSymmetricKey
* The base64 encoded string holding a symmetric key.
* @param aEncodedPublicKey
* The base64 encoded string holding a public key.
* @returns The wrapped symmetric key, base64 encoded
*
* For RSA, the unencoded public key is a PKCS#1 object.
*/
/* ACString wrapSymmetricKey (in ACString aSymmetricKey, in ACString aEncodedPublicKey); */
NS_SCRIPTABLE NS_IMETHOD WrapSymmetricKey(const nsACString & aSymmetricKey, const nsACString & aEncodedPublicKey, nsACString & _retval NS_OUTPARAM) = 0;
/**
* Decrypts a symmetric key with a user's private key.
*
* @param aWrappedSymmetricKey
* The base64 encoded string holding an encrypted symmetric key.
* @param aWrappedPrivateKey
* The base64 encoded string holdering an encrypted private key.
* @param aPassphrase
* The passphrase to decrypt the private key.
* @param aSalt
* The salt for the passphrase.
* @param aIV
* The random IV used when unwrapping the private key.
* @returns The unwrapped symmetric key, base64 encoded
*
* For RSA, the unencoded, decrypted key is a PKCS#1 object.
*/
/* ACString unwrapSymmetricKey (in ACString aWrappedSymmetricKey, in ACString aWrappedPrivateKey, in ACString aPassphrase, in ACString aSalt, in ACString aIV); */
NS_SCRIPTABLE NS_IMETHOD UnwrapSymmetricKey(const nsACString & aWrappedSymmetricKey, const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & _retval NS_OUTPARAM) = 0;
/**
* Rewrap a private key with a new user passphrase.
*
* @param aWrappedPrivateKey
* The base64 encoded string holding an encrypted private key.
* @param aPassphrase
* The passphrase to decrypt the private key.
* @param aSalt
* The salt for the passphrase.
* @param aIV
* The random IV used when unwrapping the private key.
* @param aNewPassphrase
* The new passphrase to wrap the private key with.
* @returns The (re)wrapped private key, base64 encoded
*
*/
/* ACString rewrapPrivateKey (in ACString aWrappedPrivateKey, in ACString aPassphrase, in ACString aSalt, in ACString aIV, in ACString aNewPassphrase); */
NS_SCRIPTABLE NS_IMETHOD RewrapPrivateKey(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, const nsACString & aNewPassphrase, nsACString & _retval NS_OUTPARAM) = 0;
/**
* Verify a user's passphrase against a private key.
*
* @param aWrappedPrivateKey
* The base64 encoded string holding an encrypted private key.
* @param aPassphrase
* The passphrase to decrypt the private key.
* @param aSalt
* The salt for the passphrase.
* @param aIV
* The random IV used when unwrapping the private key.
* @returns Boolean true if the passphrase decrypted the key correctly.
*
*/
/* boolean verifyPassphrase (in ACString aWrappedPrivateKey, in ACString aPassphrase, in ACString aSalt, in ACString aIV); */
NS_SCRIPTABLE NS_IMETHOD VerifyPassphrase(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, PRBool *_retval NS_OUTPARAM) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(IWeaveCrypto, IWEAVECRYPTO_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_IWEAVECRYPTO \
NS_SCRIPTABLE NS_IMETHOD GetAlgorithm(PRUint32 *aAlgorithm); \
NS_SCRIPTABLE NS_IMETHOD SetAlgorithm(PRUint32 aAlgorithm); \
NS_SCRIPTABLE NS_IMETHOD GetKeypairBits(PRUint32 *aKeypairBits); \
NS_SCRIPTABLE NS_IMETHOD SetKeypairBits(PRUint32 aKeypairBits); \
NS_SCRIPTABLE NS_IMETHOD Encrypt(const nsACString & clearText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD Decrypt(const nsACString & cipherText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GenerateKeypair(const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & aEncodedPublicKey NS_OUTPARAM, nsACString & aWrappedPrivateKey NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomKey(nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomIV(nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomBytes(PRUint32 aByteCount, nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD WrapSymmetricKey(const nsACString & aSymmetricKey, const nsACString & aEncodedPublicKey, nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD UnwrapSymmetricKey(const nsACString & aWrappedSymmetricKey, const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD RewrapPrivateKey(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, const nsACString & aNewPassphrase, nsACString & _retval NS_OUTPARAM); \
NS_SCRIPTABLE NS_IMETHOD VerifyPassphrase(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, PRBool *_retval NS_OUTPARAM);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_IWEAVECRYPTO(_to) \
NS_SCRIPTABLE NS_IMETHOD GetAlgorithm(PRUint32 *aAlgorithm) { return _to GetAlgorithm(aAlgorithm); } \
NS_SCRIPTABLE NS_IMETHOD SetAlgorithm(PRUint32 aAlgorithm) { return _to SetAlgorithm(aAlgorithm); } \
NS_SCRIPTABLE NS_IMETHOD GetKeypairBits(PRUint32 *aKeypairBits) { return _to GetKeypairBits(aKeypairBits); } \
NS_SCRIPTABLE NS_IMETHOD SetKeypairBits(PRUint32 aKeypairBits) { return _to SetKeypairBits(aKeypairBits); } \
NS_SCRIPTABLE NS_IMETHOD Encrypt(const nsACString & clearText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM) { return _to Encrypt(clearText, symmetricKey, iv, _retval); } \
NS_SCRIPTABLE NS_IMETHOD Decrypt(const nsACString & cipherText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM) { return _to Decrypt(cipherText, symmetricKey, iv, _retval); } \
NS_SCRIPTABLE NS_IMETHOD GenerateKeypair(const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & aEncodedPublicKey NS_OUTPARAM, nsACString & aWrappedPrivateKey NS_OUTPARAM) { return _to GenerateKeypair(aPassphrase, aSalt, aIV, aEncodedPublicKey, aWrappedPrivateKey); } \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomKey(nsACString & _retval NS_OUTPARAM) { return _to GenerateRandomKey(_retval); } \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomIV(nsACString & _retval NS_OUTPARAM) { return _to GenerateRandomIV(_retval); } \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomBytes(PRUint32 aByteCount, nsACString & _retval NS_OUTPARAM) { return _to GenerateRandomBytes(aByteCount, _retval); } \
NS_SCRIPTABLE NS_IMETHOD WrapSymmetricKey(const nsACString & aSymmetricKey, const nsACString & aEncodedPublicKey, nsACString & _retval NS_OUTPARAM) { return _to WrapSymmetricKey(aSymmetricKey, aEncodedPublicKey, _retval); } \
NS_SCRIPTABLE NS_IMETHOD UnwrapSymmetricKey(const nsACString & aWrappedSymmetricKey, const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & _retval NS_OUTPARAM) { return _to UnwrapSymmetricKey(aWrappedSymmetricKey, aWrappedPrivateKey, aPassphrase, aSalt, aIV, _retval); } \
NS_SCRIPTABLE NS_IMETHOD RewrapPrivateKey(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, const nsACString & aNewPassphrase, nsACString & _retval NS_OUTPARAM) { return _to RewrapPrivateKey(aWrappedPrivateKey, aPassphrase, aSalt, aIV, aNewPassphrase, _retval); } \
NS_SCRIPTABLE NS_IMETHOD VerifyPassphrase(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, PRBool *_retval NS_OUTPARAM) { return _to VerifyPassphrase(aWrappedPrivateKey, aPassphrase, aSalt, aIV, _retval); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_IWEAVECRYPTO(_to) \
NS_SCRIPTABLE NS_IMETHOD GetAlgorithm(PRUint32 *aAlgorithm) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetAlgorithm(aAlgorithm); } \
NS_SCRIPTABLE NS_IMETHOD SetAlgorithm(PRUint32 aAlgorithm) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetAlgorithm(aAlgorithm); } \
NS_SCRIPTABLE NS_IMETHOD GetKeypairBits(PRUint32 *aKeypairBits) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetKeypairBits(aKeypairBits); } \
NS_SCRIPTABLE NS_IMETHOD SetKeypairBits(PRUint32 aKeypairBits) { return !_to ? NS_ERROR_NULL_POINTER : _to->SetKeypairBits(aKeypairBits); } \
NS_SCRIPTABLE NS_IMETHOD Encrypt(const nsACString & clearText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->Encrypt(clearText, symmetricKey, iv, _retval); } \
NS_SCRIPTABLE NS_IMETHOD Decrypt(const nsACString & cipherText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->Decrypt(cipherText, symmetricKey, iv, _retval); } \
NS_SCRIPTABLE NS_IMETHOD GenerateKeypair(const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & aEncodedPublicKey NS_OUTPARAM, nsACString & aWrappedPrivateKey NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GenerateKeypair(aPassphrase, aSalt, aIV, aEncodedPublicKey, aWrappedPrivateKey); } \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomKey(nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GenerateRandomKey(_retval); } \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomIV(nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GenerateRandomIV(_retval); } \
NS_SCRIPTABLE NS_IMETHOD GenerateRandomBytes(PRUint32 aByteCount, nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->GenerateRandomBytes(aByteCount, _retval); } \
NS_SCRIPTABLE NS_IMETHOD WrapSymmetricKey(const nsACString & aSymmetricKey, const nsACString & aEncodedPublicKey, nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->WrapSymmetricKey(aSymmetricKey, aEncodedPublicKey, _retval); } \
NS_SCRIPTABLE NS_IMETHOD UnwrapSymmetricKey(const nsACString & aWrappedSymmetricKey, const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->UnwrapSymmetricKey(aWrappedSymmetricKey, aWrappedPrivateKey, aPassphrase, aSalt, aIV, _retval); } \
NS_SCRIPTABLE NS_IMETHOD RewrapPrivateKey(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, const nsACString & aNewPassphrase, nsACString & _retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->RewrapPrivateKey(aWrappedPrivateKey, aPassphrase, aSalt, aIV, aNewPassphrase, _retval); } \
NS_SCRIPTABLE NS_IMETHOD VerifyPassphrase(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, PRBool *_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->VerifyPassphrase(aWrappedPrivateKey, aPassphrase, aSalt, aIV, _retval); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class _MYCLASS_ : public IWeaveCrypto
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IWEAVECRYPTO
_MYCLASS_();
private:
~_MYCLASS_();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(_MYCLASS_, IWeaveCrypto)
_MYCLASS_::_MYCLASS_()
{
/* member initializers and constructor code */
}
_MYCLASS_::~_MYCLASS_()
{
/* destructor code */
}
/* attribute unsigned long algorithm; */
NS_IMETHODIMP _MYCLASS_::GetAlgorithm(PRUint32 *aAlgorithm)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP _MYCLASS_::SetAlgorithm(PRUint32 aAlgorithm)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute unsigned long keypairBits; */
NS_IMETHODIMP _MYCLASS_::GetKeypairBits(PRUint32 *aKeypairBits)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP _MYCLASS_::SetKeypairBits(PRUint32 aKeypairBits)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ACString encrypt (in AUTF8String clearText, in ACString symmetricKey, in ACString iv); */
NS_IMETHODIMP _MYCLASS_::Encrypt(const nsACString & clearText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* AUTF8String decrypt (in ACString cipherText, in ACString symmetricKey, in ACString iv); */
NS_IMETHODIMP _MYCLASS_::Decrypt(const nsACString & cipherText, const nsACString & symmetricKey, const nsACString & iv, nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void generateKeypair (in ACString aPassphrase, in ACString aSalt, in ACString aIV, out ACString aEncodedPublicKey, out ACString aWrappedPrivateKey); */
NS_IMETHODIMP _MYCLASS_::GenerateKeypair(const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & aEncodedPublicKey NS_OUTPARAM, nsACString & aWrappedPrivateKey NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ACString generateRandomKey (); */
NS_IMETHODIMP _MYCLASS_::GenerateRandomKey(nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ACString generateRandomIV (); */
NS_IMETHODIMP _MYCLASS_::GenerateRandomIV(nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ACString generateRandomBytes (in unsigned long aByteCount); */
NS_IMETHODIMP _MYCLASS_::GenerateRandomBytes(PRUint32 aByteCount, nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ACString wrapSymmetricKey (in ACString aSymmetricKey, in ACString aEncodedPublicKey); */
NS_IMETHODIMP _MYCLASS_::WrapSymmetricKey(const nsACString & aSymmetricKey, const nsACString & aEncodedPublicKey, nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ACString unwrapSymmetricKey (in ACString aWrappedSymmetricKey, in ACString aWrappedPrivateKey, in ACString aPassphrase, in ACString aSalt, in ACString aIV); */
NS_IMETHODIMP _MYCLASS_::UnwrapSymmetricKey(const nsACString & aWrappedSymmetricKey, const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ACString rewrapPrivateKey (in ACString aWrappedPrivateKey, in ACString aPassphrase, in ACString aSalt, in ACString aIV, in ACString aNewPassphrase); */
NS_IMETHODIMP _MYCLASS_::RewrapPrivateKey(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, const nsACString & aNewPassphrase, nsACString & _retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean verifyPassphrase (in ACString aWrappedPrivateKey, in ACString aPassphrase, in ACString aSalt, in ACString aIV); */
NS_IMETHODIMP _MYCLASS_::VerifyPassphrase(const nsACString & aWrappedPrivateKey, const nsACString & aPassphrase, const nsACString & aSalt, const nsACString & aIV, PRBool *_retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_IWeaveCrypto_h__ */

Просмотреть файл

@ -14,13 +14,13 @@
# #
# The Original Code is Weave code. # The Original Code is Weave code.
# #
# The Initial Developer of the Original Code is # The Initial Developer of the Original Code is Mozilla Foundation.
# Mozilla Corporation
# Portions created by the Initial Developer are Copyright (C) 2008 # Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved. # the Initial Developer. All Rights Reserved.
# #
# Contributor(s): # Contributor(s):
# Dan Mills <thunder@mozilla.com> (original author) # Dan Mills <thunder@mozilla.com> (original author)
# Justin Dolske <dolske@mozilla.com>
# #
# Alternatively, the contents of this file may be used under the terms of # Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or # either the GNU General Public License Version 2 or later (the "GPL"), or
@ -39,29 +39,62 @@
stage_dir=../dist/stage stage_dir=../dist/stage
sdkdir ?= ${MOZSDKDIR} sdkdir ?= ${MOZSDKDIR}
idl = IWeaveCrypto.idl
idl_typelib = $(idl:.idl=.xpt)
idl_header = $(idl:.idl=.h)
#
# The only thing to actually build here is the IDL's .xpt/.h form, which
# requires an SDK. So don't do that unless explicitly requested, and use
# the files checked into Mercurial instead.
#
all: stage
build: $(idl_typelib) $(idl_header) stage
# No SDK is needed unless you're modifying the IDL interface, in which
# case we'll need to rebuild the .h and .xpt files.
xpidl = $(sdkdir)/bin/xpidl
ifdef CROSS_COMPILE
xpidl = $(sdkdir)/host/bin/host_xpidl
endif
$(idl_typelib): $(idl)
ifeq ($(sdkdir),) ifeq ($(sdkdir),)
$(warning No 'sdkdir' variable given) $(warning No 'sdkdir' variable given)
$(warning It should point to the location of the Gecko SDK) $(warning It should point to the location of the Gecko SDK)
$(warning For example: "make sdkdir=/foo/bar/baz") $(warning For example: "make sdkdir=/foo/bar/baz")
$(warning Or set the MOZSDKDIR environment variable to point to it) $(warning Or set the MOZSDKDIR environment variable to point to it)
$(error) $(error)
endif
ifdef platform_target
platform=$(platform_target)
else else
platform=* $(xpidl) -m typelib -I$(sdkdir)/idl $(@:.xpt=.idl)
endif endif
all: build $(idl_header): $(idl)
ifeq ($(sdkdir),)
$(warning No 'sdkdir' variable given)
$(warning It should point to the location of the Gecko SDK)
$(warning For example: "make sdkdir=/foo/bar/baz")
$(warning Or set the MOZSDKDIR environment variable to point to it)
$(error)
else
$(xpidl) -m header -I$(sdkdir)/idl $(@:.h=.idl)
endif
.PHONY: build crypto rebuild_all stage:
mkdir -p $(stage_dir)/components
ifdef NO_SYMLINK
cp -v $(idl_typelib) $(stage_dir)/components
cp -v $(idl_header) $(TOPSRCDIR)/crypto-obsolete/src
cp -v WeaveCrypto.js $(stage_dir)/components
else
ln -vsf `pwd`/$(idl_typelib) $(stage_dir)/components
ln -vsf `pwd`/$(idl_header) $(TOPSRCDIR)/crypto-obsolete/src
ln -vsf `pwd`/WeaveCrypto.js $(stage_dir)/components
endif
crypto: clean:
$(MAKE) -C src install rm -f $(TOPSRCDIR)/crypto-obsolete/src/$(idl_header)
# maybe hg revert the .xpt/.h?
build: .PHONY: all build stage clean
cp -R -v components $(stage_dir)
cd platform;mkdir -p ../$(stage_dir)/platform;cp -R -v $(platform) ../$(stage_dir)/platform
rebuild_all: crypto build

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,92 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is WeaveCrypto code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dan Mills <thunder@mozilla.com> (original author)
* Honza Bambas <honzab@allpeers.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef WeaveCrypto_h_
#define WeaveCrypto_h_
#include "IWeaveCrypto.h"
#include "pk11pub.h"
#define WEAVE_CRYPTO_CONTRACTID "@labs.mozilla.com/Weave/Crypto;1"
#define WEAVE_CRYPTO_CLASSNAME "Weave crypto module"
#define WEAVE_CRYPTO_CID { 0xd3b0f750, 0xc976, 0x46d0, \
{ 0xbe, 0x20, 0x96, 0xb2, 0x4f, 0x46, 0x84, 0xbc } }
class WeaveCrypto : public IWeaveCrypto
{
public:
WeaveCrypto();
NS_DECL_ISUPPORTS
NS_DECL_IWEAVECRYPTO
private:
~WeaveCrypto();
SECOidTag mAlgorithm;
PRUint32 mKeypairBits;
nsresult DecodeBase64(const nsACString& base64, nsACString& retval);
nsresult DecodeBase64(const nsACString& base64, char *aData, PRUint32 *aLength);
nsresult EncodeBase64(const nsACString& binary, nsACString& retval);
nsresult EncodeBase64(const char *aData, PRUint32 aLength, nsACString& retval);
nsresult CommonCrypt(const char *input, PRUint32 inputSize,
char *output, PRUint32 *outputSize,
const nsACString& aSymmetricKey,
const nsACString& aIV,
CK_ATTRIBUTE_TYPE aOperation);
nsresult DeriveKeyFromPassphrase(const nsACString& aPassphrase,
const nsACString& aSalt,
PK11SymKey **aSymKey);
nsresult WrapPrivateKey(SECKEYPrivateKey *aPrivateKey,
const nsACString& aPassphrase,
const nsACString& aSalt,
const nsACString& aIV,
nsACString& aEncodedPublicKey);
nsresult EncodePublicKey(SECKEYPublicKey *aPublicKey,
nsACString& aEncodedPublicKey);
};
#endif // WeaveCrypto_h_

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,94 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Weave code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dan Mills <thunder@mozilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* See http://msdn.microsoft.com/en-us/library/aa381058.aspx for format docs,
* and mozilla/config/version_win.pl for what Mozilla uses
*/
#include<winver.h>
#define VER_BUILDID_STR "@buildid@"
#define VER_FILEVERSION 1,9,0,@buildid_short@
#define VER_PRODUCTVERSION 1,9,0,@buildid_short@
#define VER_FILEFLAGS 0 | VS_FF_PRIVATEBUILD | VS_FF_PRERELEASE
#define VER_PRODUCTNAME_STR "Weave"
#define VER_INTERNALNAME_STR "WeaveCrypto"
#define VER_FILEVERSION_STR "1.9.0.@buildid_short@"
#define VER_PRODUCTVERSION_STR "1.9.0.@buildid_short@"
#define VER_COMPANYNAME_STR "Mozilla Corporation"
#define VER_LEGALTRADEMARKS_STR "Mozilla"
#define VER_LEGALCOPYRIGHT_STR "License: MPL 1.1/GPL 2.0/LGPL 2.1"
#define VER_COMMENTS_STR ""
#define VER_FILEDESCRIPTION_STR ""
#define VER_ORIGINALFILENAME_STR ""
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK 0x3fL
FILEFLAGS VER_FILEFLAGS
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", VER_COMMENTS_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalTrademarks", VER_LEGALTRADEMARKS_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "BuildID", VER_BUILDID_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END

Просмотреть файл

@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Weave code.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Dan Mills <thunder@mozilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "WeaveCrypto.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(WeaveCrypto)
static nsModuleComponentInfo components[] =
{
{
WEAVE_CRYPTO_CLASSNAME,
WEAVE_CRYPTO_CID,
WEAVE_CRYPTO_CONTRACTID,
WeaveCryptoConstructor,
}
};
NS_IMPL_NSGETMODULE(WeaveCryptoModule, components)

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -860,6 +860,23 @@ let FakeSvc = {
/* /*
* Commonly-used services * Commonly-used services
*/ */
let cryptoContractID = "@labs.mozilla.com/Weave/Crypto";
{
let versSvc = Cc["@mozilla.org/xpcom/version-comparator;1"].
getService(Ci.nsIVersionComparator);
let appinfo = Cc["@mozilla.org/xre/app-info;1"].
getService(Ci.nsIXULAppInfo);
let platVers = appinfo.platformVersion;
if (versSvc.compare(platVers, "1.9.3a3") < 0) {
// use old binary component
cryptoContractID += ";1";
} else {
// use new JS-CTypes component
cryptoContractID += ";2";
}
}
let Svc = {}; let Svc = {};
Svc.Prefs = new Preferences(PREFS_BRANCH); Svc.Prefs = new Preferences(PREFS_BRANCH);
@ -867,7 +884,7 @@ Svc.Obs = Observers;
[["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"], [["Annos", "@mozilla.org/browser/annotation-service;1", "nsIAnnotationService"],
["AppInfo", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"], ["AppInfo", "@mozilla.org/xre/app-info;1", "nsIXULAppInfo"],
["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"], ["Bookmark", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"],
["Crypto", "@labs.mozilla.com/Weave/Crypto;1", "IWeaveCrypto"], ["Crypto", cryptoContractID, "IWeaveCrypto"],
["Directory", "@mozilla.org/file/directory_service;1", "nsIProperties"], ["Directory", "@mozilla.org/file/directory_service;1", "nsIProperties"],
["Env", "@mozilla.org/process/environment;1", "nsIEnvironment"], ["Env", "@mozilla.org/process/environment;1", "nsIEnvironment"],
["Favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"], ["Favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"],

Просмотреть файл

@ -28,6 +28,7 @@ pref("extensions.weave.log.logger.engine.history", "Debug");
pref("extensions.weave.log.logger.engine.passwords", "Debug"); pref("extensions.weave.log.logger.engine.passwords", "Debug");
pref("extensions.weave.log.logger.engine.prefs", "Debug"); pref("extensions.weave.log.logger.engine.prefs", "Debug");
pref("extensions.weave.log.logger.engine.tabs", "Debug"); pref("extensions.weave.log.logger.engine.tabs", "Debug");
pref("extensions.weave.log.cryptoDebug", false);
// Preferences to be synced by default // Preferences to be synced by default
pref("extensions.weave.prefs.sync.accessibility.blockautorefresh", true); pref("extensions.weave.prefs.sync.accessibility.blockautorefresh", true);

Просмотреть файл

@ -3,6 +3,23 @@ const Ci = Components.interfaces;
const Cr = Components.results; const Cr = Components.results;
const Cu = Components.utils; const Cu = Components.utils;
let versSvc = Cc["@mozilla.org/xpcom/version-comparator;1"].
getService(Ci.nsIVersionComparator);
let appinfo = Cc["@mozilla.org/xre/app-info;1"].
getService(Ci.nsIXULAppInfo);
let platVers = appinfo.platformVersion;
let cryptoContractID = "@labs.mozilla.com/Weave/Crypto";
if (versSvc.compare(platVers, "1.9.3a3") < 0) {
// use old binary component
cryptoContractID += ";1";
} else {
// use new JS-CTypes component
cryptoContractID += ";2";
}
dump("Using crypto contract " + cryptoContractID + "\n");
// initialize nss // initialize nss
let ch = Cc["@mozilla.org/security/hash;1"]. let ch = Cc["@mozilla.org/security/hash;1"].
createInstance(Ci.nsICryptoHash); createInstance(Ci.nsICryptoHash);

Просмотреть файл

@ -1,5 +1,5 @@
function run_test() { function run_test() {
var cryptoSvc = Cc["@labs.mozilla.com/Weave/Crypto;1"]. var cryptoSvc = Cc[cryptoContractID].
getService(Ci.IWeaveCrypto); getService(Ci.IWeaveCrypto);
// First, do a normal run with expected usage... Generate a random key and // First, do a normal run with expected usage... Generate a random key and

Просмотреть файл

@ -1,5 +1,5 @@
function run_test() { function run_test() {
var cryptoSvc = Cc["@labs.mozilla.com/Weave/Crypto;1"]. var cryptoSvc = Cc[cryptoContractID].
getService(Ci.IWeaveCrypto); getService(Ci.IWeaveCrypto);
var salt = cryptoSvc.generateRandomBytes(16); var salt = cryptoSvc.generateRandomBytes(16);

Просмотреть файл

@ -1,5 +1,5 @@
function run_test() { function run_test() {
var cryptoSvc = Cc["@labs.mozilla.com/Weave/Crypto;1"]. var cryptoSvc = Cc[cryptoContractID].
getService(Ci.IWeaveCrypto); getService(Ci.IWeaveCrypto);
// Test salt generation. // Test salt generation.

Просмотреть файл

@ -1,5 +1,5 @@
function run_test() { function run_test() {
var cryptoSvc = Cc["@labs.mozilla.com/Weave/Crypto;1"]. var cryptoSvc = Cc[cryptoContractID].
getService(Ci.IWeaveCrypto); getService(Ci.IWeaveCrypto);
var salt = cryptoSvc.generateRandomBytes(16); var salt = cryptoSvc.generateRandomBytes(16);

Просмотреть файл

@ -1,5 +1,5 @@
function run_test() { function run_test() {
var cryptoSvc = Cc["@labs.mozilla.com/Weave/Crypto;1"]. var cryptoSvc = Cc[cryptoContractID].
getService(Ci.IWeaveCrypto); getService(Ci.IWeaveCrypto);
var salt = cryptoSvc.generateRandomBytes(16); var salt = cryptoSvc.generateRandomBytes(16);

Просмотреть файл

@ -62,7 +62,7 @@ function run_test() {
keys = PubKeys.createKeypair(passphrase, keys = PubKeys.createKeypair(passphrase,
"http://localhost:8080/pubkey", "http://localhost:8080/pubkey",
"http://localhost:8080/privkey"); "http://localhost:8080/privkey");
let crypto = Cc["@labs.mozilla.com/Weave/Crypto;1"]. let crypto = Cc[cryptoContractID].
getService(Ci.IWeaveCrypto); getService(Ci.IWeaveCrypto);
keys.symkey = crypto.generateRandomKey(); keys.symkey = crypto.generateRandomKey();
keys.wrappedkey = crypto.wrapSymmetricKey(keys.symkey, keys.pubkey.keyData); keys.wrappedkey = crypto.wrapSymmetricKey(keys.symkey, keys.pubkey.keyData);