diff --git a/src/lib/rng/rng.h b/src/lib/rng/rng.h index c7d97c6f629..f28413d2799 100644 --- a/src/lib/rng/rng.h +++ b/src/lib/rng/rng.h @@ -196,12 +196,17 @@ class BOTAN_PUBLIC_API(2, 0) RandomNumberGenerator { /** * Fill a given byte container with @p bytes random bytes * - * @todo deprecate this overload (in favor of randomize()) + * Deprecated + * Use randomize(std::span) overload instead. No resizing or + * allocation operations are performed here. This overload exists for + * historical reasons and will be removed in Botan4. * * @param v the container to be filled with @p bytes random bytes * @throws Exception if RNG fails + * + * TODO(Botan4) remove this function */ - void random_vec(std::span v) { this->randomize(v); } + BOTAN_DEPRECATED("Use randomize() instead") void random_vec(std::span v) { this->randomize(v); } /** * Resize a given byte container to @p bytes and fill it with random bytes @@ -214,7 +219,7 @@ class BOTAN_PUBLIC_API(2, 0) RandomNumberGenerator { template void random_vec(T& v, size_t bytes) { v.resize(bytes); - random_vec(v); + randomize(v); } /** @@ -239,7 +244,7 @@ class BOTAN_PUBLIC_API(2, 0) RandomNumberGenerator { template std::array random_array() { std::array result{}; - random_vec(result); + randomize(result); return result; } diff --git a/src/tests/test_rng.h b/src/tests/test_rng.h index 430324ad1b3..b0a016f32e4 100644 --- a/src/tests/test_rng.h +++ b/src/tests/test_rng.h @@ -100,7 +100,7 @@ class Fixed_Output_Position_RNG final : public Fixed_Output_RNG { Fixed_Output_RNG::fill_bytes_with_input(output, input); } else { // return random - m_rng.random_vec(output); + m_rng.randomize(output); } } diff --git a/src/tests/test_strong_type.cpp b/src/tests/test_strong_type.cpp index bff96117189..09022549cf6 100644 --- a/src/tests/test_strong_type.cpp +++ b/src/tests/test_strong_type.cpp @@ -265,7 +265,7 @@ class Strong_Type_Tests final : public Test { auto tb = rng.random_vec(4); auto tsb = rng.random_vec(4); Test_Fixed_Array tfa; - rng.random_vec(tfa); + rng.randomize(tfa); result.test_bin_eq("generated expected output", tb.get(), "deadbeef"); result.test_bin_eq("generated expected secure output", tsb.get(), "baadcafe");