diff options
Diffstat (limited to 'MacOS/GetHTTPS.src/GetHTTPS.cpp')
| -rw-r--r-- | MacOS/GetHTTPS.src/GetHTTPS.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/MacOS/GetHTTPS.src/GetHTTPS.cpp b/MacOS/GetHTTPS.src/GetHTTPS.cpp index d62dc50473a..ed8e1cc962f 100644 --- a/MacOS/GetHTTPS.src/GetHTTPS.cpp +++ b/MacOS/GetHTTPS.src/GetHTTPS.cpp @@ -19,7 +19,6 @@ * 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 @@ -27,13 +26,14 @@ #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 <openssl/rand.h> #include <timer.h> @@ -48,6 +48,10 @@ OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr); + + + + // My idle-wait callback. Doesn't do much, does it? Silly cooperative multitasking. OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr) @@ -55,33 +59,31 @@ 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; - - SSL_CTX *ssl_ctx = nil; - SSL *ssl = nil; +OSErr errCode; +int theSocket = -1; +int theTimeout = 30; - char tempString[256]; - UnsignedWide microTickCount; +SSL_CTX *ssl_ctx = nil; +SSL *ssl = nil; - - CRandomizer randomizer; +char tempString[256]; +UnsignedWide microTickCount; +#warning -- USE A TRUE RANDOM SEED, AND ADD ENTROPY WHENEVER POSSIBLE. -- +const char seed[] = "uyq9,7-b(VHGT^%$&^F/,876;,;./lkJHGFUY{PO*"; // Just gobbledygook + printf("OpenSSL Demo by Roy Wood, [email protected]\n\n"); BailIfError(errCode = MacSocket_Startup()); @@ -90,7 +92,7 @@ void main(void) // Create a socket-like object - BailIfError(errCode = MacSocket_socket(&theSocket,false,theTimeout * 60,MyMacSocket_IdleWaitCallback,&randomizer)); + BailIfError(errCode = MacSocket_socket(&theSocket,false,theTimeout * 60,MyMacSocket_IdleWaitCallback,nil)); // Set up the connect string and try to connect @@ -116,6 +118,10 @@ void main(void) // ssl_ctx = SSL_CTX_new(SSLv3_client_method()); + RAND_seed (seed, sizeof (seed)); + Microseconds (µTickCount); + RAND_add (µTickCount, sizeof (microTickCount), 0); // Entropy is actually > 0, needs an estimate + // Create an SSL thingey and try to negotiate the connection ssl = SSL_new(ssl_ctx); |
