]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_cryptkit/lib/platform.c
Security-58286.70.7.tar.gz
[apple/security.git] / OSX / libsecurity_cryptkit / lib / platform.c
index fa6c1b2ef76ca5fe009ed1560eb4229575651d3b..30480d86f9d0b5180250fe592ea8ef3c2e97280a 100644 (file)
@@ -19,6 +19,7 @@
 #include "platform.h"
 #include <stdio.h>
 #include "feeDebug.h"
 #include "platform.h"
 #include <stdio.h>
 #include "feeDebug.h"
+
 #ifdef NeXT
 
 /*
 #ifdef NeXT
 
 /*
@@ -28,140 +29,43 @@ void CKRaise(const char *reason) {
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
-       exit(1);
-}
-
-#import "feeDebug.h"
-
-#if !defined(NeXT_PDO) && FEE_DEBUG
-
-/*
- * Mach, private build. use quick microsecond-accurate system clock.
- */
-
-#include <kern/time_stamp.h>
-
-unsigned createRandomSeed()
-{
-       struct tsval tsp;
-
-       (void)kern_timestamp(&tsp);
-       return tsp.low_val;
+    abort();
 }
 
 }
 
-#else
-
-/*
- * OpenStep, normal case.
- */
-#include <sys/types.h>
-#include <time.h>
-
-extern int getpid();
-
-unsigned createRandomSeed(void)
-{
-       time_t curTime;
-       unsigned thisPid;
-
-       time(&curTime);
-       thisPid = (unsigned)getpid();
-
-       return (unsigned)curTime ^ (unsigned)thisPid;
-}
-
-#endif /* FEE_DEBUG */
-
 #elif  WIN32
 
 /*
  * OpenStep on Windows.
  */
 #elif  WIN32
 
 /*
  * OpenStep on Windows.
  */
-#include <process.h>   /* for _getpid() */
 
 void CKRaise(const char *reason) {
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
 
 void CKRaise(const char *reason) {
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
-       exit(1);
-}
-
-extern void time(unsigned *tp);
-
-unsigned createRandomSeed()
-{
-       unsigned curTime;
-       unsigned thisPid;
-
-       time(&curTime);
-       thisPid = _getpid();
-       return (unsigned)curTime ^ (unsigned)thisPid;
+    abort();
 }
 
 }
 
-
 #elif  __MAC_BUILD__
 
 /*
  * Macintosh, all flavors.
  */
 #include <stdlib.h>
 #elif  __MAC_BUILD__
 
 /*
  * Macintosh, all flavors.
  */
 #include <stdlib.h>
-#include <time.h>
+#include <CrashReporterClient.h>
 
 void CKRaise(const char *reason) {
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
 
 void CKRaise(const char *reason) {
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
-       exit(1);
-}
-
-/* for X, this isn't used except for testing when SecurityServer when
- * Yarrow is not running. So let's strip it down so we don't have
- * to link against CarbonCore. 
- */
-#define BARE_BONES_SEED                1
-#if    BARE_BONES_SEED
-
-#include <sys/types.h>
-
-extern int getpid();
-
-unsigned createRandomSeed()
-{
-       time_t curTime;
-       unsigned thisPid;
-
-       time(&curTime);
-       thisPid = (unsigned)getpid();
-
-       return (unsigned)curTime ^ (unsigned)thisPid;
+    char * msg = NULL;
+    if(asprintf(&msg, "CryptKit fatal error: %s", reason)) {
+        CRSetCrashLogMessage(msg);
+    } else {
+        CRSetCrashLogMessage("CryptKit fatal error");
+    }
+    abort();
 }
 
 }
 
-#else  /* BARE_BONES_SEED */
-
-#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/Timer.h>
-#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/LowMem.h>
-
-// this is mighty pitiful anyway...
-unsigned createRandomSeed()
-{
-       UnsignedWide curTime;           
-       //unsigned ticks;                               /* use 16 bits */
-       unsigned rtnHi;
-       unsigned rtnLo;
-       
-       /* FIXME - need a way to distinguish OS9x from Carbon. Carbon
-        * doesn't have LMGetTicks(). */
-        
-       Microseconds(&curTime);         /* low 16 bits are pretty good */
-
-       // Carbon hack
-       // rtnHi = LMGetTicks();
-       rtnHi = 0x5a5aa5a5;
-       rtnLo = curTime.lo & 0xffff;
-       return (rtnHi ^ rtnLo);
-}
-#endif /* BARE_BONES_SEED */
-
 #elif unix
 
 /* try for generic UNIX */
 #elif unix
 
 /* try for generic UNIX */
@@ -170,26 +74,9 @@ void CKRaise(const char *reason) {
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
        #if     FEE_DEBUG
        printf("CryptKit fatal error: %s\n", reason);
        #endif
-       exit(1);
+    abort();
 }
 
 }
 
-#include <sys/types.h>
-#include <time.h>
-
-extern int getpid();
-
-unsigned createRandomSeed()
-{
-       time_t curTime;
-       unsigned thisPid;
-
-       time(&curTime);
-       thisPid = (unsigned)getpid();
-
-       return (unsigned)curTime ^ (unsigned)thisPid;
-}
-
-
 #else
 
 #error platform-specific work needed in security_cryptkit/platform.c
 #else
 
 #error platform-specific work needed in security_cryptkit/platform.c