#include "platform.h"
#include <stdio.h>
#include "feeDebug.h"
#ifdef NeXT
void CKRaise(const char *reason) {
#if FEE_DEBUG
printf("CryptKit fatal error: %s\n", reason);
#endif
exit(1);
}
#import "feeDebug.h"
#if !defined(NeXT_PDO) && FEE_DEBUG
#include <kern/time_stamp.h>
unsigned createRandomSeed()
{
struct tsval tsp;
(void)kern_timestamp(&tsp);
return tsp.low_val;
}
#else
#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
#elif WIN32
#include <process.h>
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;
}
#elif __MAC_BUILD__
#include <stdlib.h>
#include <time.h>
void CKRaise(const char *reason) {
#if FEE_DEBUG
printf("CryptKit fatal error: %s\n", reason);
#endif
exit(1);
}
#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;
}
#else
#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/Timer.h>
#include <CoreServices/../Frameworks/CarbonCore.framework/Headers/LowMem.h>
unsigned createRandomSeed()
{
UnsignedWide curTime;
unsigned rtnHi;
unsigned rtnLo;
Microseconds(&curTime);
rtnHi = 0x5a5aa5a5;
rtnLo = curTime.lo & 0xffff;
return (rtnHi ^ rtnLo);
}
#endif
#elif unix
void CKRaise(const char *reason) {
#if FEE_DEBUG
printf("CryptKit fatal error: %s\n", reason);
#endif
exit(1);
}
#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
#endif