summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbryner%uiuc.edu <devnull@localhost>2001-06-28 01:40:39 +0000
committerbryner%uiuc.edu <devnull@localhost>2001-06-28 01:40:39 +0000
commit766f758254f8b06ee8d8c3316d4b4cb8fd766508 (patch)
treedcb80eba2d6ae0915eb5ea554a2c52aadf86663d
parentbaac321d502484993ebbb7f9884164fdb1be551c (diff)
downloadnss-hg-766f758254f8b06ee8d8c3316d4b4cb8fd766508.tar.gz
Bug 75049 - Enable NSS for carbon build. patch from beard, r=mcgreer, sr=nelsonb, a=asa.
-rw-r--r--security/nss/lib/util/mac_rand.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/security/nss/lib/util/mac_rand.c b/security/nss/lib/util/mac_rand.c
index c8596a9f0..6198f3407 100644
--- a/security/nss/lib/util/mac_rand.c
+++ b/security/nss/lib/util/mac_rand.c
@@ -44,6 +44,7 @@
#include <PPCToolbox.h>
#include <Processes.h>
#include <LowMem.h>
+#include <Scrap.h>
/* Static prototypes */
static size_t CopyLowBits(void *dst, size_t dstlen, void *src, size_t srclen);
@@ -73,8 +74,9 @@ static size_t CopyLowBits(void *dst, size_t dstlen, void *src, size_t srclen)
size_t RNG_GetNoise(void *buf, size_t maxbytes)
{
- uint32 c = TickCount();
- return CopyLowBits(buf, maxbytes, &c, sizeof(c));
+ UnsignedWide microTickCount;
+ Microseconds(&microTickCount);
+ return CopyLowBits(buf, maxbytes, &microTickCount, sizeof(microTickCount));
}
void RNG_FileForRNG(char *filename)
@@ -125,6 +127,7 @@ void RNG_SystemInfoForRNG()
ReadLocation(&loc);
RNG_RandomUpdate( &loc, sizeof(loc));
}
+#if !TARGET_CARBON
/* User name */
{
unsigned long userRef;
@@ -133,6 +136,7 @@ void RNG_SystemInfoForRNG()
RNG_RandomUpdate( &userRef, sizeof(userRef));
RNG_RandomUpdate( userName, sizeof(userName));
}
+#endif
/* Mouse location */
{
Point mouseLoc;
@@ -155,11 +159,13 @@ void RNG_SystemInfoForRNG()
UInt8 volume = LMGetSdVolume();
RNG_RandomUpdate( &volume, sizeof(volume));
}
+#if !TARGET_CARBON
/* Current directory */
{
SInt32 dir = LMGetCurDirStore();
RNG_RandomUpdate( &dir, sizeof(dir));
}
+#endif
/* Process information about all the processes in the machine */
{
ProcessSerialNumber process;
@@ -179,17 +185,21 @@ void RNG_SystemInfoForRNG()
}
}
+#if !TARGET_CARBON
/* Heap */
{
THz zone = LMGetTheZone();
RNG_RandomUpdate( &zone, sizeof(zone));
}
+#endif
/* Screen */
{
- GDHandle h = LMGetMainDevice(); /* GDHandle is **GDevice */
+ GDHandle h = GetMainDevice(); /* GDHandle is **GDevice */
RNG_RandomUpdate( *h, sizeof(GDevice));
}
+
+#if !TARGET_CARBON
/* Scrap size */
{
SInt32 scrapSize = LMGetScrapSize();
@@ -200,6 +210,29 @@ void RNG_SystemInfoForRNG()
SInt16 scrapCount = LMGetScrapCount();
RNG_RandomUpdate( &scrapCount, sizeof(scrapCount));
}
+#else
+ {
+ ScrapRef scrap;
+ if (GetCurrentScrap(&scrap) == noErr) {
+ UInt32 flavorCount;
+ if (GetScrapFlavorCount(scrap, &flavorCount) == noErr) {
+ ScrapFlavorInfo* flavorInfo = (ScrapFlavorInfo*) malloc(flavorCount * sizeof(ScrapFlavorInfo));
+ if (flavorInfo != NULL) {
+ if (GetScrapFlavorInfoList(scrap, &flavorCount, flavorInfo) == noErr) {
+ UInt32 i;
+ RNG_RandomUpdate(&flavorCount, sizeof(flavorCount));
+ for (i = 0; i < flavorCount; ++i) {
+ Size flavorSize;
+ if (GetScrapFlavorSize(scrap, flavorInfo[i].flavorType, &flavorSize) == noErr)
+ RNG_RandomUpdate(&flavorSize, sizeof(flavorSize));
+ }
+ }
+ free(flavorInfo);
+ }
+ }
+ }
+ }
+#endif
/* File stuff, last modified, etc. */
{
HParamBlockRec pb;
@@ -211,6 +244,7 @@ void RNG_SystemInfoForRNG()
PBHGetVolParmsSync(&pb);
RNG_RandomUpdate( &volInfo, sizeof(volInfo));
}
+#if !TARGET_CARBON
/* Event queue */
{
EvQElPtr eventQ;
@@ -219,6 +253,7 @@ void RNG_SystemInfoForRNG()
eventQ = (EvQElPtr)eventQ->qLink)
RNG_RandomUpdate( &eventQ->evtQWhat, sizeof(EventRecord));
}
+#endif
FE_ReadScreen();
RNG_FileForRNG(NULL);
}