Get definition of ssize_t.
[openssl.git] / MacOS / GetHTTPS.src / GetHTTPS.cpp
index 8e02333..d62dc50 100644 (file)
@@ -18,6 +18,8 @@
  *                             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
@@ -25,7 +27,7 @@
 #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!
@@ -33,7 +35,7 @@
 #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)
@@ -57,27 +55,32 @@ 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");
        
@@ -87,7 +90,7 @@ char                          tempString[256];
 
        //      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