add secure random for rho_ssl
#include <CoreFoundation/CoreFoundation.h>
#include <CFNetwork/CFNetwork.h>
+#include <Security/Security.h>
#include "sslimpl.h"
@@ -166,16 +167,9 @@ ssize_t SSLImpl::recv(char *buf, size_t size, int *wouldblock, void *storage)
bool SSLImpl::rand(unsigned char *entropy, size_t length)
{
- //JNIEnv *env = jnienv();
- //jholder<jbyteArray> array = env->NewByteArray(length);
- //if(!array) return false;
-
- //jboolean result = env->CallStaticBooleanMethod(cls, midRand, array.get());
- //if(result)
- //{
- // jbyte *arr = env->GetByteArrayElements(array.get(), NULL);
- // std::memmove(entropy, arr, length);
- //}
+ //unsigned char* rand_array = new unsigned char[length];
+ int res = SecRandomCopyBytes(kSecRandomDefault, length, entropy);
+ if (res) return false;
return true;
}
