diff options
Diffstat (limited to 'third_party/srtp/crypto/rng/ctr_prng.c')
-rw-r--r-- | third_party/srtp/crypto/rng/ctr_prng.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/third_party/srtp/crypto/rng/ctr_prng.c b/third_party/srtp/crypto/rng/ctr_prng.c index ab76df36..e24b0aba 100644 --- a/third_party/srtp/crypto/rng/ctr_prng.c +++ b/third_party/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 */ - status = aes_icm_context_init(&ctr_prng.state, tmp_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; |