summaryrefslogtreecommitdiff
path: root/node/EllipticCurveKeyPair.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/EllipticCurveKeyPair.cpp')
-rw-r--r--node/EllipticCurveKeyPair.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/node/EllipticCurveKeyPair.cpp b/node/EllipticCurveKeyPair.cpp
index d2e2920a..047b2b4f 100644
--- a/node/EllipticCurveKeyPair.cpp
+++ b/node/EllipticCurveKeyPair.cpp
@@ -29,6 +29,13 @@
#include <stdlib.h>
#include <string.h>
+#include "Constants.hpp"
+
+#ifdef __WINDOWS__
+#include <WinSock2.h>
+#include <Windows.h>
+#endif
+
#include <openssl/bn.h>
#include <openssl/obj_mac.h>
#include <openssl/rand.h>
@@ -129,32 +136,9 @@ const EllipticCurveKeyPair &EllipticCurveKeyPair::operator=(const EllipticCurveK
bool EllipticCurveKeyPair::generate()
{
- unsigned char tmp[16384];
EC_KEY *key;
int len;
- // Make sure OpenSSL libcrypto has sufficient randomness (on most
- // platforms it auto-seeds, so this is a sanity check).
- if (!RAND_status()) {
-#if defined(__APPLE__) || defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux)
- FILE *rf = fopen("/dev/urandom","r");
- if (rf) {
- fread(tmp,sizeof(tmp),1,rf);
- fclose(rf);
- } else {
- fprintf(stderr,"FATAL: could not open /dev/urandom\n");
- exit(-1);
- }
- RAND_seed(tmp,sizeof(tmp));
-#else
-#ifdef _WIN32
- error need win32;
-#else
- error;
-#endif
-#endif
- }
-
key = EC_KEY_new();
if (!key) return false;