зеркало из https://github.com/mozilla/pjs.git
#79153, giving feedback to the user while generating a crypto key
r=javi@netscape.com sr=blizzard@mozilla.org you reach me at kai.engert@gmx.de Mac project file changes will be checked in by javi
This commit is contained in:
Родитель
2431fe705a
Коммит
7e9b475770
|
@ -53,6 +53,8 @@ pippki.jar:
|
|||
content/pippki/pref-masterpass.xul (content/pref-masterpass.xul)
|
||||
content/pippki/serverCrlExpired.js (content/serverCrlExpired.js)
|
||||
content/pippki/serverCrlExpired.xul (content/serverCrlExpired.xul)
|
||||
content/pippki/createCertInfo.xul (content/createCertInfo.xul)
|
||||
content/pippki/createCertInfo.js (content/createCertInfo.js)
|
||||
|
||||
en-US.jar:
|
||||
locale/en-US/pippki/contents.rdf (locale/en-US/contents.rdf)
|
||||
|
|
|
@ -103,3 +103,7 @@
|
|||
<!ENTITY serverCrlExpired.continue "Would you like to continue?">
|
||||
<!ENTITY serverCrlExpired.manageCrls.label "Manager CRLs...">
|
||||
|
||||
<!-- Strings for the CreateCertInfo dialog -->
|
||||
<!ENTITY createCertInfo.title "Generating A Private Key">
|
||||
<!ENTITY createCertInfo.msg1 "Key Generation in progress... This may take a few minutes....">
|
||||
<!ENTITY createCertInfo.msg2 "Please wait...">
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "nsNSSDialogs.h"
|
||||
#include "nsPKIParamBlock.h"
|
||||
#include "nsIKeygenThread.h"
|
||||
|
||||
#define PIPSTRING_BUNDLE_URL "chrome://pippki/locale/pippki.properties"
|
||||
#define STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
|
||||
|
@ -124,14 +125,15 @@ nsNSSDialogs::~nsNSSDialogs()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS8(nsNSSDialogs, nsINSSDialogs,
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS9(nsNSSDialogs, nsINSSDialogs,
|
||||
nsITokenPasswordDialogs,
|
||||
nsISecurityWarningDialogs,
|
||||
nsIBadCertListener,
|
||||
nsICertificateDialogs,
|
||||
nsIClientAuthDialogs,
|
||||
nsITokenDialogs,
|
||||
nsIDOMCryptoDialogs);
|
||||
nsIDOMCryptoDialogs,
|
||||
nsIGeneratingKeypairInfoDialogs);
|
||||
|
||||
nsresult
|
||||
nsNSSDialogs::Init()
|
||||
|
@ -824,6 +826,20 @@ nsNSSDialogs::ViewCert(nsIX509Cert *cert)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSSDialogs::DisplayGeneratingKeypairInfo(nsIInterfaceRequestor *aCtx, nsIKeygenThread *runnable)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Get the parent window for the dialog
|
||||
nsCOMPtr<nsIDOMWindowInternal> parent = do_GetInterface(aCtx);
|
||||
|
||||
rv = nsNSSDialogHelper::openDialog(parent,
|
||||
"chrome://pippki/content/createCertInfo.xul",
|
||||
runnable);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSSDialogs::ChooseToken(nsIInterfaceRequestor *aCtx, const PRUnichar **aTokenList, PRUint32 aCount, PRUnichar **aTokenChosen, PRBool *aCanceled) {
|
||||
nsresult rv;
|
||||
|
|
|
@ -43,7 +43,8 @@ class nsNSSDialogs
|
|||
public nsICertificateDialogs,
|
||||
public nsIClientAuthDialogs,
|
||||
public nsITokenDialogs,
|
||||
public nsIDOMCryptoDialogs
|
||||
public nsIDOMCryptoDialogs,
|
||||
public nsIGeneratingKeypairInfoDialogs
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -55,6 +56,7 @@ public:
|
|||
NS_DECL_NSICLIENTAUTHDIALOGS
|
||||
NS_DECL_NSITOKENDIALOGS
|
||||
NS_DECL_NSIDOMCRYPTODIALOGS
|
||||
NS_DECL_NSIGENERATINGKEYPAIRINFODIALOGS
|
||||
nsNSSDialogs();
|
||||
virtual ~nsNSSDialogs();
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ XPIDLSRCS = \
|
|||
nsINSSDialogs.idl \
|
||||
nsISSLStatus.idl \
|
||||
nsICertOutliner.idl \
|
||||
nsIKeygenThread.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -59,6 +59,7 @@ XPIDLSRCS= \
|
|||
.\nsINSSDialogs.idl \
|
||||
.\nsISSLStatus.idl \
|
||||
.\nsICertOutliner.idl \
|
||||
.\nsIKeygenThread.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsIX509Cert.idl"
|
||||
|
||||
interface nsIInterfaceRequestor;
|
||||
interface nsIKeygenThread;
|
||||
|
||||
/**
|
||||
* nsITokenPasswordDialogs
|
||||
|
@ -48,6 +49,19 @@ interface nsITokenPasswordDialogs : nsISupports
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* nsIGeneratingKeypairInfoDialogs
|
||||
* This is the interface for giving feedback to the user
|
||||
* while generating a key pair.
|
||||
*/
|
||||
[scriptable, uuid(11bf5cdc-1dd2-11b2-ba6a-c76afb326fa1)]
|
||||
interface nsIGeneratingKeypairInfoDialogs : nsISupports
|
||||
{
|
||||
void displayGeneratingKeypairInfo(in nsIInterfaceRequestor ctx,
|
||||
in nsIKeygenThread runnable);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* nsINSSDialogs - a collection of functions that
|
||||
* implement activities that may require interaction
|
||||
|
|
|
@ -68,6 +68,7 @@ CPPSRCS = \
|
|||
nsKeygenHandler.cpp \
|
||||
nsCrypto.cpp \
|
||||
nsPKCS11Slot.cpp \
|
||||
nsKeygenThread.cpp \
|
||||
$(NULL)
|
||||
|
||||
REQUIRES = nspr security xpcom string necko uriloader pref caps dom intl locale profile windowwatcher js docshell widget layout gfx2 pippki xpconnect jar
|
||||
|
|
|
@ -98,6 +98,7 @@ OBJS = \
|
|||
.\$(OBJDIR)\nsNSSASN1Object.obj \
|
||||
.\$(OBJDIR)\nsCrypto.obj \
|
||||
.\$(OBJDIR)\nsPKCS11Slot.obj \
|
||||
.\$(OBJDIR)\nsKeygenThread.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -39,6 +39,7 @@ extern "C" {
|
|||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsKeygenThread.h"
|
||||
|
||||
//These defines are taken from the PKCS#11 spec
|
||||
#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000
|
||||
|
@ -297,7 +298,6 @@ nsKeygenFormProcessor::GetPublicKey(nsString& aValue, nsString& aChallenge,
|
|||
nsString& aOutPublicKey, nsString& aPqg)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
char *emptyCString = "null";
|
||||
char *keystring = nsnull;
|
||||
char *pqgString = nsnull, *str = nsnull;
|
||||
nsAutoString rsaStr;
|
||||
|
@ -321,6 +321,9 @@ nsKeygenFormProcessor::GetPublicKey(nsString& aValue, nsString& aChallenge,
|
|||
SECItem signedItem;
|
||||
CERTPublicKeyAndChallenge pkac;
|
||||
SECKeySizeChoiceInfo *choice = SECKeySizeChoiceList;
|
||||
nsIGeneratingKeypairInfoDialogs * dialogs;
|
||||
nsKeygenThread KeygenRunnable;
|
||||
nsCOMPtr<nsIKeygenThread> runnable;
|
||||
|
||||
// Get the key size //
|
||||
while (choice) {
|
||||
|
@ -398,8 +401,42 @@ found_match:
|
|||
goto loser;
|
||||
}
|
||||
|
||||
rv = getNSSDialogs((void**)&dialogs,
|
||||
NS_GET_IID(nsIGeneratingKeypairInfoDialogs));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
privateKey = PK11_GenerateKeyPair(slot, keyGenMechanism, params,
|
||||
&publicKey, PR_TRUE, PR_TRUE, nsnull);
|
||||
} else {
|
||||
GenerateKeypairParameters gkp;
|
||||
gkp.privateKey = nsnull;
|
||||
gkp.publicKey = nsnull;
|
||||
gkp.slot = slot;
|
||||
gkp.keyGenMechanism = keyGenMechanism;
|
||||
gkp.params = params;
|
||||
KeygenRunnable.SetParams(&gkp);
|
||||
// Our parameters instance will be modified by the thread.
|
||||
|
||||
runnable = do_QueryInterface(&KeygenRunnable);
|
||||
|
||||
if (runnable) {
|
||||
rv = dialogs->DisplayGeneratingKeypairInfo(m_ctx, runnable);
|
||||
|
||||
// We call join on the thread,
|
||||
// so we can be sure that no simultaneous access will happen.
|
||||
KeygenRunnable.Join();
|
||||
|
||||
NS_RELEASE(dialogs);
|
||||
if (!NS_FAILED(rv)) {
|
||||
privateKey = gkp.privateKey;
|
||||
publicKey = gkp.publicKey;
|
||||
slot = gkp.slot;
|
||||
keyGenMechanism = gkp.keyGenMechanism;
|
||||
params = gkp.params;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!privateKey) {
|
||||
goto loser;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче