Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(954)

Unified Diff: srtp/crypto/rng/ctr_prng.c

Issue 889083003: Update libsrtp to upstream 1.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libsrtp@master
Patch Set: Updated to libsrtp 1.5.1 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « srtp/crypto/replay/ut_sim.c ('k') | srtp/crypto/rng/prng.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « srtp/crypto/replay/ut_sim.c ('k') | srtp/crypto/rng/prng.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698