plaisthos has uploaded this change for review. ( 
http://gerrit.openvpn.net/c/openvpn/+/1833?usp=email )


Change subject: Replace ASSERT(rand_bytes(...)) with prng_bytes
......................................................................

Replace ASSERT(rand_bytes(...)) with prng_bytes

prng_bytes is already ASSERT(rand_bytes(...)), so this change is
just a little cleanup that makes a code a little bit nicer.

Change-Id: If458a3362e03630ce699bd122e957169601657a5
Signed-off-by: Arne Schwabe <[email protected]>
---
M src/openvpn/crypto.c
M src/openvpn/proxy.c
M tests/unit_tests/openvpn/test_ssl.c
3 files changed, 9 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/1833/1

diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index ee43d65..8f59838 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/crypto.c
@@ -1219,7 +1219,7 @@
             ASSERT(cipher_ctx_iv_length(cipher) >= OPENVPN_AEAD_MIN_IV_LEN);

             /* Generate dummy implicit IV */
-            ASSERT(rand_bytes(co->key_ctx_bi.encrypt.implicit_iv, 
OPENVPN_MAX_IV_LENGTH));
+            prng_bytes(co->key_ctx_bi.encrypt.implicit_iv, 
OPENVPN_MAX_IV_LENGTH);

             memcpy(co->key_ctx_bi.decrypt.implicit_iv, 
co->key_ctx_bi.encrypt.implicit_iv,
                    OPENVPN_MAX_IV_LENGTH);
@@ -1239,7 +1239,7 @@
         ASSERT(buf_init(&src, 0));
         ASSERT(i <= src.capacity);
         src.len = i;
-        ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));
+        prng_bytes(BPTR(&src), BLEN(&src));

         /* copy source to input buf */
         buf = work;
diff --git a/src/openvpn/proxy.c b/src/openvpn/proxy.c
index 9f3ec93..9acb2fa 100644
--- a/src/openvpn/proxy.c
+++ b/src/openvpn/proxy.c
@@ -734,7 +734,7 @@
                 }

                 /* generate a client nonce */
-                ASSERT(rand_bytes(cnonce_raw, sizeof(cnonce_raw)));
+                prng_bytes(cnonce_raw, sizeof(cnonce_raw));
                 cnonce = make_base64_string2(cnonce_raw, sizeof(cnonce_raw), 
&gc);


diff --git a/tests/unit_tests/openvpn/test_ssl.c 
b/tests/unit_tests/openvpn/test_ssl.c
index d473d67..b86d57c 100644
--- a/tests/unit_tests/openvpn/test_ssl.c
+++ b/tests/unit_tests/openvpn/test_ssl.c
@@ -322,7 +322,7 @@
         ASSERT(buf_init(&src, 0));
         ASSERT(i <= src.capacity);
         src.len = i;
-        ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));
+        prng_bytes(BPTR(&src), BLEN(&src));

         /* copy source to input buf */
         buf = work;
@@ -368,7 +368,7 @@
     ASSERT(buf_init(&src, 0));
     ASSERT(len <= src.capacity);
     src.len = len;
-    ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));
+    prng_bytes(BPTR(&src), BLEN(&src));

     /* copy source to input buf */
     buf = work;
@@ -453,10 +453,10 @@
     }
     else
     {
-        ASSERT(rand_bytes(key2.keys[0].cipher, sizeof(key2.keys[0].cipher)));
-        ASSERT(rand_bytes(key2.keys[0].hmac, sizeof(key2.keys[0].hmac)));
-        ASSERT(rand_bytes(key2.keys[1].cipher, sizeof(key2.keys[1].cipher)));
-        ASSERT(rand_bytes(key2.keys[1].hmac, sizeof(key2.keys)[1].hmac));
+        prng_bytes(key2.keys[0].cipher, sizeof(key2.keys[0].cipher));
+        prng_bytes(key2.keys[0].hmac, sizeof(key2.keys[0].hmac));
+        prng_bytes(key2.keys[1].cipher, sizeof(key2.keys[1].cipher));
+        prng_bytes(key2.keys[1].hmac, sizeof(key2.keys)[1].hmac);
     }

     struct crypto_options co = { 0 };

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1833?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If458a3362e03630ce699bd122e957169601657a5
Gerrit-Change-Number: 1833
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to