From 951fd4d23b15bfdde1199490b2fb8dad1527c4c9 Mon Sep 17 00:00:00 2001 From: "javi%netscape.com" Date: Mon, 30 Oct 2000 23:35:46 +0000 Subject: [PATCH] Fix for Bug 57985 r=ddrinan,hyatt a=hyatt Implement the nsIEntropyCollector interface so that we can send entropy bits off to PSM to better improve the randomness of generated keys for SSL git-svn-id: svn://10.0.0.236/trunk@82068 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/psm-glue/src/nsPSMComponent.cpp | 13 +++++++++++-- mozilla/extensions/psm-glue/src/nsPSMComponent.h | 5 ++++- mozilla/extensions/psm-glue/src/nsPSMModule.cpp | 8 ++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp b/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp index 289c9014a44..43fb683df7b 100644 --- a/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp +++ b/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp @@ -153,11 +153,12 @@ nsPSMComponent::RegisterCertContentListener() } /* nsISupports Implementation for the class */ -NS_IMPL_THREADSAFE_ISUPPORTS4(nsPSMComponent, +NS_IMPL_THREADSAFE_ISUPPORTS5(nsPSMComponent, nsIPSMComponent, nsISecurityManagerComponent, nsIContentHandler, - nsISignatureVerifier); + nsISignatureVerifier, + nsIEntropyCollector); #define INIT_NUM_PREFS 100 /* preference types */ @@ -1185,3 +1186,11 @@ nsPSMComponent::VerifySignature(const char* aRSABuf, PRUint32 aRSABufLen, return rv; } +NS_IMETHODIMP +nsPSMComponent::RandomUpdate(void *entropy, PRInt32 bufLen) +{ + if (mControl) { + CMT_RandomUpdate(mControl, entropy, bufLen); + } + return NS_OK; +} diff --git a/mozilla/extensions/psm-glue/src/nsPSMComponent.h b/mozilla/extensions/psm-glue/src/nsPSMComponent.h index d8f033b77aa..d227918606e 100644 --- a/mozilla/extensions/psm-glue/src/nsPSMComponent.h +++ b/mozilla/extensions/psm-glue/src/nsPSMComponent.h @@ -30,6 +30,7 @@ #include "nsIContentHandler.h" #include "nsIURIContentListener.h" +#include "nsIEntropyCollector.h" #define SECURITY_STRING_BUNDLE_URL "chrome://communicator/locale/security.properties" @@ -58,7 +59,8 @@ private: // Implementation of the PSM component interface. class nsPSMComponent : public nsIPSMComponent, public nsIContentHandler, - public nsISignatureVerifier + public nsISignatureVerifier, + public nsIEntropyCollector { public: NS_DEFINE_STATIC_CID_ACCESSOR( NS_PSMCOMPONENT_CID ); @@ -71,6 +73,7 @@ public: NS_DECL_NSIPSMCOMPONENT NS_DECL_NSICONTENTHANDLER NS_DECL_NSISIGNATUREVERIFIER + NS_DECL_NSIENTROPYCOLLECTOR static NS_METHOD CreatePSMComponent(nsISupports* aOuter, REFNSIID aIID, void **aResult); nsresult RegisterCertContentListener(); diff --git a/mozilla/extensions/psm-glue/src/nsPSMModule.cpp b/mozilla/extensions/psm-glue/src/nsPSMModule.cpp index 5e155a9d60d..8dd392deec5 100644 --- a/mozilla/extensions/psm-glue/src/nsPSMModule.cpp +++ b/mozilla/extensions/psm-glue/src/nsPSMModule.cpp @@ -44,6 +44,8 @@ #include "nsCURILoader.h" #include "nsISupportsUtils.h" + + // Define SDR object constructor static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID); @@ -171,6 +173,12 @@ static nsModuleComponentInfo components[] = NS_FORMPROCESSOR_CID, NS_FORMPROCESSOR_CONTRACTID, nsKeygenFormProcessor::Create + }, + { + "Entropy Collector", + NS_ENTROPYCOLLECTOR_CID, + NS_ENTROPYCOLLECTOR_CONTRACTID, + nsPSMComponent::CreatePSMComponent } };