[Openvpn-devel] [PATCH v1] Replace ASSERT(rand_bytes(...)) with prng_bytes
Gert Doering <[email protected]> Mon, 3 Aug 2026 15:21:12 +0200
| Newsgroups | net.sourceforge.lists.openvpn-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Arne Schwabe <[email protected]> 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]> Acked-by: Frank Lichtenheld <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1833 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1833 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld <[email protected]> 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 }; _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel