Fix from 1.0.0-stable.
[openssl.git] / MacOS / GetHTTPS.src / GetHTTPS.cpp
index 8e02333154955d895d867c5e9e4610b6efb38426..3a5e3f018615e42a94a03be7ffac44b389b9da4c 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
@@ -164,7 +167,7 @@ char                                tempString[256];
                
                tempString[bytesRead] = '\0';
                
-               printf(tempString);
+               printf("%s", tempString);
        }
        
        printf("\n\n\n");
@@ -198,7 +201,7 @@ EXITPOINT:
        {
                printf("An error occurred:\n");
                
-               printf(GetErrorMessage());
+               printf("%s",GetErrorMessage());
        }