summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-01-24 19:20:09 +0000
committerBenny Prijono <bennylp@teluu.com>2008-01-24 19:20:09 +0000
commit1724cfe4c1b0cc812b890ae648a923ad591996d6 (patch)
treec21ddb6262ebe4b4773ea229c6fcd8324fd63f3e /third_party
parent27a6f11c3076651f2a838bac313a09dd470736d8 (diff)
Fixed libsrtp random string generation on Win32
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1741 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/srtp/crypto/rng/rand_source.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/third_party/srtp/crypto/rng/rand_source.c b/third_party/srtp/crypto/rng/rand_source.c
index d00d9806..9bd7fc21 100644
--- a/third_party/srtp/crypto/rng/rand_source.c
+++ b/third_party/srtp/crypto/rng/rand_source.c
@@ -131,12 +131,14 @@ rand_source_get_octet_string(void *dest, uint32_t len) {
}
#else
uint8_t *dst = (uint8_t *)dest;
-
+
+#ifdef PJ_DEV_URANDOM
/* First try with /dev/urandom, if it's opened */
if (dev_random_fdes >= 0) {
if (read(dev_random_fdes, dest, len) == len)
return err_status_ok; /* success */
- }
+ }
+#endif
/* Generic C-library (rand()) version */
/* This is a random source of last resort */
@@ -160,11 +162,13 @@ rand_source_deinit(void) {
return err_status_dealloc_fail; /* well, we haven't really failed, *
* but there is something wrong */
#endif
-
+
+#if defined(DEV_URANDOM) || defined(PJ_DEV_URANDOM)
if (dev_random_fdes >= 0)
close(dev_random_fdes);
- dev_random_fdes = RAND_SOURCE_NOT_READY;
+ dev_random_fdes = RAND_SOURCE_NOT_READY;
+#endif
return err_status_ok;
}