* Also-- before attempting to compile this, make sure the aliases in "OpenSSL-0.9.4:include:openssl"
* are installed! Use the AppleScript applet in the "openssl-0.9.4" folder to do this!
*/
+/* modified to seed the PRNG */
+/* modified to use CRandomizer for seeding */
// Include some funky libs I've developed over time
#include "CPStringUtils.hpp"
#include "ErrorHandling.hpp"
#include "MacSocket.h"
-
+#include "Randomizer.h"
// We use the OpenSSL implementation of SSL....
// This was a lot of work to finally get going, though you wouldn't know it by the results!
#include <openssl/ssl.h>
#include <openssl/err.h>
-
+#include <timer.h>
// Let's try grabbing some data from here:
OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr);
-
-
-
-
// My idle-wait callback. Doesn't do much, does it? Silly cooperative multitasking.
OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr)
#pragma unused(inUserRefPtr)
EventRecord theEvent;
-
::EventAvail(everyEvent,&theEvent);
+
+ CRandomizer *randomizer = (CRandomizer*)inUserRefPtr;
+ if (randomizer)
+ randomizer->PeriodicAction();
return(noErr);
}
-
// Finally!
void main(void)
{
-OSErr errCode;
-int theSocket = -1;
-int theTimeout = 30;
+ OSErr errCode;
+ int theSocket = -1;
+ int theTimeout = 30;
+
+ SSL_CTX *ssl_ctx = nil;
+ SSL *ssl = nil;
-SSL_CTX *ssl_ctx = nil;
-SSL *ssl = nil;
+ char tempString[256];
+ UnsignedWide microTickCount;
-char tempString[256];
+ CRandomizer randomizer;
printf("OpenSSL Demo by Roy Wood, roy@centricsystems.ca\n\n");
// Create a socket-like object
- BailIfError(errCode = MacSocket_socket(&theSocket,false,theTimeout * 60,MyMacSocket_IdleWaitCallback,nil));
+ BailIfError(errCode = MacSocket_socket(&theSocket,false,theTimeout * 60,MyMacSocket_IdleWaitCallback,&randomizer));
// Set up the connect string and try to connect
tempString[bytesRead] = '\0';
- printf(tempString);
+ printf("%s", tempString);
}
printf("\n\n\n");
{
printf("An error occurred:\n");
- printf(GetErrorMessage());
+ printf("%s",GetErrorMessage());
}