Index: srtp/crypto/rng/ctr_prng.c |
diff --git a/srtp/crypto/rng/ctr_prng.c b/srtp/crypto/rng/ctr_prng.c |
index 41d46a8f55165f14396c5891f7b7bbb9b2ccbd83..e24b0aba93cf1c8e8a6cba73fee3b08a7586d23b 100644 |
--- a/srtp/crypto/rng/ctr_prng.c |
+++ b/srtp/crypto/rng/ctr_prng.c |
@@ -43,6 +43,10 @@ |
*/ |
+#ifdef HAVE_CONFIG_H |
+ #include <config.h> |
+#endif |
+ |
#include "prng.h" |
/* single, global prng structure */ |
@@ -66,7 +70,11 @@ ctr_prng_init(rand_source_func_t random_source) { |
return status; |
/* initialize aes ctr context with random key */ |
+#ifdef OPENSSL |
+ status = aes_icm_openssl_context_init(&ctr_prng.state, tmp_key, 30); |
+#else |
status = aes_icm_context_init(&ctr_prng.state, tmp_key, 30); |
+#endif |
if (status) |
return status; |
@@ -79,10 +87,8 @@ ctr_prng_get_octet_string(void *dest, uint32_t len) { |
/* |
* if we need to re-initialize the prng, do so now |
- * |
- * avoid 32-bit overflows by subtracting instead of adding |
*/ |
- if (ctr_prng.octet_count > MAX_PRNG_OUT_LEN - len) { |
+ if ((aes_icm_bytes_encrypted(&ctr_prng.state) + len) > 0xffff) { |
status = ctr_prng_init(ctr_prng.rand); |
if (status) |
return status; |