diff options
Diffstat (limited to 'third_party/srtp/crypto')
-rw-r--r-- | third_party/srtp/crypto/rng/rand_source.c | 12 |
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; } |