Split "helpers" from SSL target to "crypto_random" and rename
since it contains helpers mostly related to cryptographically secure random numbers and strings.
BUG=webrtc:339300437
Change-Id: I10db939534b25dc792ac1600a4721d1b84521880
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/352620
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42441}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index b0f95eb..283d105 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -184,11 +184,11 @@
"../p2p:p2p_constants",
"../rtc_base:checks",
"../rtc_base:crc32",
+ "../rtc_base:crypto_random",
"../rtc_base:ip_address",
"../rtc_base:logging",
"../rtc_base:network_constants",
"../rtc_base:socket_address",
- "../rtc_base:ssl",
"../rtc_base:stringutils",
"../rtc_base/system:rtc_export",
"//third_party/abseil-cpp/absl/base:core_headers",
diff --git a/api/candidate.cc b/api/candidate.cc
index 9a35201..4e462dd 100644
--- a/api/candidate.cc
+++ b/api/candidate.cc
@@ -13,7 +13,7 @@
#include "absl/base/attributes.h"
#include "p2p/base/p2p_constants.h"
#include "rtc_base/crc32.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn
index 8a64411..8758578 100644
--- a/api/transport/BUILD.gn
+++ b/api/transport/BUILD.gn
@@ -115,11 +115,11 @@
"../../rtc_base:byte_order",
"../../rtc_base:checks",
"../../rtc_base:crc32",
+ "../../rtc_base:crypto_random",
"../../rtc_base:digest",
"../../rtc_base:ip_address",
"../../rtc_base:logging",
"../../rtc_base:socket_address",
- "../../rtc_base:ssl",
"../../system_wrappers:metrics",
"//third_party/abseil-cpp/absl/strings:string_view",
]
diff --git a/api/transport/stun.cc b/api/transport/stun.cc
index ca90515..27266d9 100644
--- a/api/transport/stun.cc
+++ b/api/transport/stun.cc
@@ -21,7 +21,7 @@
#include "rtc_base/byte_order.h"
#include "rtc_base/checks.h"
#include "rtc_base/crc32.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/message_digest.h"
#include "system_wrappers/include/metrics.h"
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index 9bcbba2..ed02eb7 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -866,10 +866,10 @@
"../p2p:libstunprober",
"../p2p:rtc_p2p",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:logging",
"../rtc_base:network",
"../rtc_base:socket_address",
- "../rtc_base:ssl",
"../rtc_base:ssl_adapter",
"../rtc_base:threading",
"../rtc_base:timeutils",
diff --git a/examples/stunprober/main.cc b/examples/stunprober/main.cc
index 3b3c06b..7c180d6 100644
--- a/examples/stunprober/main.cc
+++ b/examples/stunprober/main.cc
@@ -18,7 +18,7 @@
#include "absl/flags/parse.h"
#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/stunprober/stun_prober.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/network.h"
#include "rtc_base/physical_socket_server.h"
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index 9f216a5..cff643a 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -116,6 +116,7 @@
"../rtc_base:callback_list",
"../rtc_base:checks",
"../rtc_base:crc32",
+ "../rtc_base:crypto_random",
"../rtc_base:dscp",
"../rtc_base:event_tracer",
"../rtc_base:ip_address",
@@ -277,12 +278,12 @@
"../api/transport:field_trial_based_config",
"../api/units:time_delta",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:event_tracer",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:network",
"../rtc_base:network_constants",
- "../rtc_base:ssl",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base/experiments:field_trial_parser",
@@ -332,6 +333,7 @@
"../rtc_base:callback_list",
"../rtc_base:checks",
"../rtc_base:crc32",
+ "../rtc_base:crypto_random",
"../rtc_base:dscp",
"../rtc_base:event_tracer",
"../rtc_base:ip_address",
@@ -346,7 +348,6 @@
"../rtc_base:safe_minmax",
"../rtc_base:socket",
"../rtc_base:socket_address",
- "../rtc_base:ssl",
"../rtc_base:stringutils",
"../rtc_base:threading",
"../rtc_base:timeutils",
@@ -492,7 +493,7 @@
deps = [
":p2p_constants",
":transport_description",
- "../rtc_base:ssl",
+ "../rtc_base:crypto_random",
]
}
@@ -656,6 +657,7 @@
"../rtc_base:byte_buffer",
"../rtc_base:callback_list",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:dscp",
"../rtc_base:event_tracer",
"../rtc_base:ip_address",
@@ -666,7 +668,6 @@
"../rtc_base:network",
"../rtc_base:rate_tracker",
"../rtc_base:socket_address",
- "../rtc_base:ssl",
"../rtc_base:stringutils",
"../rtc_base:timeutils",
"../rtc_base:weak_ptr",
@@ -698,6 +699,7 @@
"../api:sequence_checker",
"../api/transport:enums",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:network",
"../rtc_base:socket_address",
"../rtc_base:ssl",
@@ -788,9 +790,9 @@
"../api/transport:stun_types",
"../rtc_base:async_packet_socket",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:ip_address",
"../rtc_base:logging",
- "../rtc_base:ssl",
"../rtc_base:stringutils",
"../rtc_base/experiments:field_trial_parser",
"../rtc_base/network:received_packet",
@@ -811,8 +813,8 @@
"../api/transport:stun_types",
"../api/units:time_delta",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:logging",
- "../rtc_base:ssl",
"../rtc_base:stringutils",
"../rtc_base:timeutils",
"//third_party/abseil-cpp/absl/memory",
@@ -1149,6 +1151,7 @@
"../rtc_base:byte_buffer",
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
+ "../rtc_base:crypto_random",
"../rtc_base:digest",
"../rtc_base:dscp",
"../rtc_base:gunit_helpers",
@@ -1210,6 +1213,7 @@
"../rtc_base:async_udp_socket",
"../rtc_base:byte_buffer",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:digest",
"../rtc_base:logging",
"../rtc_base:rtc_base_tests_utils",
diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc
index d133159..762b692 100644
--- a/p2p/base/connection.cc
+++ b/p2p/base/connection.cc
@@ -26,7 +26,7 @@
#include "p2p/base/p2p_constants.h"
#include "rtc_base/byte_buffer.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/network.h"
diff --git a/p2p/base/dtls_transport_unittest.cc b/p2p/base/dtls_transport_unittest.cc
index f870c1e..9e2d069 100644
--- a/p2p/base/dtls_transport_unittest.cc
+++ b/p2p/base/dtls_transport_unittest.cc
@@ -22,9 +22,9 @@
#include "p2p/base/fake_ice_transport.h"
#include "p2p/base/packet_transport_internal.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/dscp.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/ssl_adapter.h"
diff --git a/p2p/base/ice_credentials_iterator.cc b/p2p/base/ice_credentials_iterator.cc
index 373c851..2a12d41 100644
--- a/p2p/base/ice_credentials_iterator.cc
+++ b/p2p/base/ice_credentials_iterator.cc
@@ -11,7 +11,7 @@
#include "p2p/base/ice_credentials_iterator.h"
#include "p2p/base/p2p_constants.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
namespace cricket {
diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc
index 29bdd99..cad0a08 100644
--- a/p2p/base/p2p_transport_channel_unittest.cc
+++ b/p2p/base/p2p_transport_channel_unittest.cc
@@ -32,13 +32,13 @@
#include "p2p/base/test_turn_server.h"
#include "p2p/client/basic_port_allocator.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/dscp.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/fake_mdns_responder.h"
#include "rtc_base/fake_network.h"
#include "rtc_base/firewall_socket_server.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/internal/default_socket_server.h"
#include "rtc_base/logging.h"
#include "rtc_base/mdns_responder_interface.h"
diff --git a/p2p/base/port.cc b/p2p/base/port.cc
index d9bacf3..25105dc 100644
--- a/p2p/base/port.cc
+++ b/p2p/base/port.cc
@@ -26,7 +26,7 @@
#include "p2p/base/stun_request.h"
#include "rtc_base/byte_buffer.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/mdns_responder_interface.h"
diff --git a/p2p/base/port_allocator.cc b/p2p/base/port_allocator.cc
index 52fc8c1..5694007 100644
--- a/p2p/base/port_allocator.cc
+++ b/p2p/base/port_allocator.cc
@@ -18,6 +18,7 @@
#include "absl/strings/string_view.h"
#include "p2p/base/ice_credentials_iterator.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
namespace cricket {
diff --git a/p2p/base/port_allocator.h b/p2p/base/port_allocator.h
index 7958538..0ae2182 100644
--- a/p2p/base/port_allocator.h
+++ b/p2p/base/port_allocator.h
@@ -27,7 +27,7 @@
#include "p2p/base/port_interface.h"
#include "p2p/base/transport_description.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/network.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_certificate.h"
diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc
index be3b365..48d52da 100644
--- a/p2p/base/port_unittest.cc
+++ b/p2p/base/port_unittest.cc
@@ -46,10 +46,10 @@
#include "rtc_base/buffer.h"
#include "rtc_base/byte_buffer.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/dscp.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/nat_server.h"
#include "rtc_base/nat_socket_factory.h"
diff --git a/p2p/base/pseudo_tcp_unittest.cc b/p2p/base/pseudo_tcp_unittest.cc
index 48df2b1..b32f07d 100644
--- a/p2p/base/pseudo_tcp_unittest.cc
+++ b/p2p/base/pseudo_tcp_unittest.cc
@@ -21,8 +21,8 @@
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/task_queue/task_queue_base.h"
#include "api/units/time_delta.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/memory_stream.h"
#include "rtc_base/time_utils.h"
diff --git a/p2p/base/stun_port.cc b/p2p/base/stun_port.cc
index 93c3030..fd1eb72 100644
--- a/p2p/base/stun_port.cc
+++ b/p2p/base/stun_port.cc
@@ -20,8 +20,8 @@
#include "p2p/base/p2p_constants.h"
#include "p2p/base/port_allocator.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/experiments/field_trial_parser.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/network/received_packet.h"
diff --git a/p2p/base/stun_port_unittest.cc b/p2p/base/stun_port_unittest.cc
index 423d16b..842f3e4 100644
--- a/p2p/base/stun_port_unittest.cc
+++ b/p2p/base/stun_port_unittest.cc
@@ -17,8 +17,8 @@
#include "p2p/base/mock_dns_resolving_packet_socket_factory.h"
#include "p2p/base/test_stun_server.h"
#include "rtc_base/async_packet_socket.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_adapter.h"
diff --git a/p2p/base/stun_request.cc b/p2p/base/stun_request.cc
index fc5d43d..a44518b 100644
--- a/p2p/base/stun_request.cc
+++ b/p2p/base/stun_request.cc
@@ -18,7 +18,7 @@
#include "absl/memory/memory.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/time_utils.h" // For TimeMillis
diff --git a/p2p/base/stun_request_unittest.cc b/p2p/base/stun_request_unittest.cc
index 8ce89f8..188ffbf 100644
--- a/p2p/base/stun_request_unittest.cc
+++ b/p2p/base/stun_request_unittest.cc
@@ -13,9 +13,9 @@
#include <utility>
#include <vector>
+#include "rtc_base/crypto_random.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/time_utils.h"
#include "test/gtest.h"
diff --git a/p2p/base/tcp_port_unittest.cc b/p2p/base/tcp_port_unittest.cc
index be246a8..8bdae5a 100644
--- a/p2p/base/tcp_port_unittest.cc
+++ b/p2p/base/tcp_port_unittest.cc
@@ -17,8 +17,8 @@
#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/base/transport_description.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h"
diff --git a/p2p/base/transport_info.h b/p2p/base/transport_info.h
index 1f60b64..f9bd198 100644
--- a/p2p/base/transport_info.h
+++ b/p2p/base/transport_info.h
@@ -17,7 +17,6 @@
#include "api/candidate.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/base/transport_description.h"
-#include "rtc_base/helpers.h"
namespace cricket {
diff --git a/p2p/base/turn_server.cc b/p2p/base/turn_server.cc
index 4e039de..98b9f3e 100644
--- a/p2p/base/turn_server.cc
+++ b/p2p/base/turn_server.cc
@@ -25,7 +25,7 @@
#include "p2p/base/async_stun_tcp_socket.h"
#include "rtc_base/byte_buffer.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/message_digest.h"
#include "rtc_base/socket_adapters.h"
diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc
index f1525b0..c8b293a 100644
--- a/p2p/client/basic_port_allocator.cc
+++ b/p2p/client/basic_port_allocator.cc
@@ -31,8 +31,8 @@
#include "p2p/base/turn_port.h"
#include "p2p/base/udp_port.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/experiments/field_trial_parser.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/network_constants.h"
#include "rtc_base/strings/string_builder.h"
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 25dd280..51025ec 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -317,6 +317,7 @@
"../rtc_base:callback_list",
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
+ "../rtc_base:crypto_random",
"../rtc_base:event_tracer",
"../rtc_base:logging",
"../rtc_base:macromagic",
@@ -810,12 +811,12 @@
"../p2p:basic_packet_socket_factory",
"../p2p:rtc_p2p",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:macromagic",
"../rtc_base:network",
"../rtc_base:rtc_certificate_generator",
"../rtc_base:socket_factory",
"../rtc_base:socket_server",
- "../rtc_base:ssl",
"../rtc_base:threading",
"../rtc_base:timeutils",
"../rtc_base/memory:always_valid_pointer",
@@ -1024,6 +1025,7 @@
"../p2p:transport_description_factory",
"../p2p:transport_info",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:event_tracer",
"../rtc_base:logging",
"../rtc_base:macromagic",
@@ -1141,6 +1143,7 @@
"../p2p:transport_info",
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
+ "../rtc_base:crypto_random",
"../rtc_base:event_tracer",
"../rtc_base:ip_address",
"../rtc_base:logging",
@@ -1311,6 +1314,7 @@
"../p2p:transport_description",
"../p2p:transport_info",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:ip_address",
"../rtc_base:logging",
"../rtc_base:macromagic",
@@ -1576,6 +1580,7 @@
"../api:sequence_checker",
"../media:media_channel",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:ssl",
@@ -1827,10 +1832,10 @@
"../media:media_channel",
"../media:media_engine",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:event_tracer",
"../rtc_base:logging",
"../rtc_base:macromagic",
- "../rtc_base:ssl",
"../rtc_base:threading",
"../rtc_base/synchronization:mutex",
"../rtc_base/third_party/sigslot",
@@ -2045,6 +2050,7 @@
"../rtc_base:byte_order",
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
+ "../rtc_base:crypto_random",
"../rtc_base:gunit_helpers",
"../rtc_base:logging",
"../rtc_base:macromagic",
@@ -2129,6 +2135,7 @@
"../p2p:port_interface",
"../p2p:rtc_p2p",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:gunit_helpers",
"../rtc_base:rtc_base_tests_utils",
"../rtc_base:socket_address",
@@ -2379,6 +2386,7 @@
"../rtc_base:byte_buffer",
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
+ "../rtc_base:crypto_random",
"../rtc_base:digest",
"../rtc_base:event_tracer",
"../rtc_base:gunit_helpers",
@@ -2596,6 +2604,7 @@
"../p2p:port_interface",
"../p2p:rtc_p2p",
"../rtc_base:checks",
+ "../rtc_base:crypto_random",
"../rtc_base:gunit_helpers",
"../rtc_base:ip_address",
"../rtc_base:logging",
diff --git a/pc/connection_context.cc b/pc/connection_context.cc
index 56a6e91..ab682b7 100644
--- a/pc/connection_context.cc
+++ b/pc/connection_context.cc
@@ -18,7 +18,7 @@
#include "media/base/media_engine.h"
#include "media/sctp/sctp_transport_factory.h"
#include "pc/media_factory.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/internal/default_socket_server.h"
#include "rtc_base/socket_server.h"
#include "rtc_base/time_utils.h"
diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc
index 95661d7..4489618 100644
--- a/pc/data_channel_integrationtest.cc
+++ b/pc/data_channel_integrationtest.cc
@@ -33,9 +33,9 @@
#include "pc/test/integration_test_helpers.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/copy_on_write_buffer.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/virtual_socket_server.h"
diff --git a/pc/jsep_session_description_unittest.cc b/pc/jsep_session_description_unittest.cc
index c3e1f33..f1f99ee 100644
--- a/pc/jsep_session_description_unittest.cc
+++ b/pc/jsep_session_description_unittest.cc
@@ -26,7 +26,7 @@
#include "p2p/base/transport_info.h"
#include "pc/session_description.h"
#include "pc/webrtc_sdp.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/string_encode.h"
diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h
index da0b921..373b603 100644
--- a/pc/jsep_transport_controller.h
+++ b/pc/jsep_transport_controller.h
@@ -61,7 +61,7 @@
#include "rtc_base/callback_list.h"
#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/ssl_certificate.h"
#include "rtc_base/ssl_stream_adapter.h"
diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc
index 8112c97..01b826b 100644
--- a/pc/jsep_transport_unittest.cc
+++ b/pc/jsep_transport_unittest.cc
@@ -28,7 +28,7 @@
#include "rtc_base/buffer.h"
#include "rtc_base/byte_order.h"
#include "rtc_base/copy_on_write_buffer.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/network/received_packet.h"
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 44fae13..1cf560e 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -53,7 +53,7 @@
#include "pc/sctp_transport.h"
#include "pc/simulcast_description.h"
#include "pc/webrtc_session_description_factory.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc
index 0e4e52b..dbbe9e8 100644
--- a/pc/peer_connection_integrationtest.cc
+++ b/pc/peer_connection_integrationtest.cc
@@ -77,12 +77,12 @@
#include "pc/test/fake_periodic_video_source.h"
#include "pc/test/integration_test_helpers.h"
#include "pc/test/mock_peer_connection_observers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/fake_mdns_responder.h"
#include "rtc_base/fake_network.h"
#include "rtc_base/firewall_socket_server.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_certificate.h"
diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc
index 08bc373..e51e5aa 100644
--- a/pc/peer_connection_rampup_tests.cc
+++ b/pc/peer_connection_rampup_tests.cc
@@ -51,10 +51,10 @@
#include "pc/test/frame_generator_capturer_video_track_source.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/fake_network.h"
#include "rtc_base/firewall_socket_server.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/socket_factory.h"
#include "rtc_base/ssl_certificate.h"
diff --git a/pc/peer_connection_svc_integrationtest.cc b/pc/peer_connection_svc_integrationtest.cc
index 7deafbf..6ab77e1 100644
--- a/pc/peer_connection_svc_integrationtest.cc
+++ b/pc/peer_connection_svc_integrationtest.cc
@@ -22,8 +22,8 @@
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
#include "pc/test/integration_test_helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "test/gtest.h"
namespace webrtc {
diff --git a/pc/rtp_sender.cc b/pc/rtp_sender.cc
index 60b8813..6e28734 100644
--- a/pc/rtp_sender.cc
+++ b/pc/rtp_sender.cc
@@ -24,7 +24,7 @@
#include "media/base/media_engine.h"
#include "pc/legacy_stats_collector_interface.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"
diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc
index 96b3088..ab9c58a 100644
--- a/pc/rtp_transmission_manager.cc
+++ b/pc/rtp_transmission_manager.cc
@@ -21,7 +21,7 @@
#include "pc/legacy_stats_collector_interface.h"
#include "pc/video_rtp_receiver.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
namespace webrtc {
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index 8b348ba..199d7ec 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -86,7 +86,7 @@
#include "pc/used_ids.h"
#include "pc/webrtc_session_description_factory.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/operations_chain.h"
#include "rtc_base/rtc_certificate.h"
diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h
index 72ea286..dbce979 100644
--- a/pc/test/integration_test_helpers.h
+++ b/pc/test/integration_test_helpers.h
@@ -97,13 +97,13 @@
#include "pc/test/mock_peer_connection_observers.h"
#include "pc/video_track_source.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/event.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/fake_mdns_responder.h"
#include "rtc_base/fake_network.h"
#include "rtc_base/firewall_socket_server.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/mdns_responder_interface.h"
diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc
index 56f1f43..3e638b0 100644
--- a/pc/webrtc_sdp.cc
+++ b/pc/webrtc_sdp.cc
@@ -58,7 +58,7 @@
#include "pc/simulcast_sdp_serializer.h"
#include "rtc_base/arraysize.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index acfefb7..85ec8edb 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -1413,7 +1413,7 @@
"unique_id_generator.h",
]
deps = [
- ":ssl",
+ ":crypto_random",
":stringutils",
"../api:array_view",
"../api:sequence_checker",
@@ -1503,10 +1503,31 @@
}
}
+rtc_library("crypto_random") {
+ visibility = [ "*" ]
+ sources = [
+ "crypto_random.cc",
+ "crypto_random.h",
+ ]
+ deps = [
+ ":checks",
+ ":logging",
+ "synchronization:mutex",
+ "system:rtc_export",
+ "//third_party/abseil-cpp/absl/strings:string_view",
+ ]
+
+ # If we are building the SSL library ourselves, we know it's BoringSSL.
+ if (rtc_build_ssl) {
+ deps += [ "//third_party/boringssl" ]
+ } else {
+ configs += [ ":external_ssl_library" ]
+ }
+}
+
rtc_library("ssl") {
visibility = [ "*" ]
sources = [
- "helpers.cc",
"helpers.h",
"openssl_key_pair.cc",
"openssl_key_pair.h",
@@ -1527,6 +1548,7 @@
":buffer",
":checks",
":copy_on_write_buffer",
+ ":crypto_random",
":digest",
":logging",
":macromagic",
@@ -1938,6 +1960,7 @@
":checks",
":copy_on_write_buffer",
":criticalsection",
+ ":crypto_random",
":divide_round",
":event_tracer",
":frequency_tracker",
@@ -2082,9 +2105,9 @@
sources = [
"crc32_unittest.cc",
+ "crypto_random_unittest.cc",
"data_rate_limiter_unittest.cc",
"fake_clock_unittest.cc",
- "helpers_unittest.cc",
"ip_address_unittest.cc",
"memory_usage_unittest.cc",
"message_digest_unittest.cc",
@@ -2107,6 +2130,7 @@
":buffer_queue",
":checks",
":crc32",
+ ":crypto_random",
":data_rate_limiter",
":digest",
":gunit_helpers",
diff --git a/rtc_base/boringssl_certificate.cc b/rtc_base/boringssl_certificate.cc
index a866224..6781443 100644
--- a/rtc_base/boringssl_certificate.cc
+++ b/rtc_base/boringssl_certificate.cc
@@ -32,7 +32,7 @@
#include <vector>
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/message_digest.h"
#include "rtc_base/openssl_digest.h"
diff --git a/rtc_base/helpers.cc b/rtc_base/crypto_random.cc
similarity index 98%
rename from rtc_base/helpers.cc
rename to rtc_base/crypto_random.cc
index 5aca40c..68b86a0 100644
--- a/rtc_base/helpers.cc
+++ b/rtc_base/crypto_random.cc
@@ -8,13 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include <openssl/rand.h>
#include <cstdint>
#include <limits>
#include <memory>
+#include <utility>
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
diff --git a/rtc_base/crypto_random.h b/rtc_base/crypto_random.h
new file mode 100644
index 0000000..8b1baf5
--- /dev/null
+++ b/rtc_base/crypto_random.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef RTC_BASE_CRYPTO_RANDOM_H_
+#define RTC_BASE_CRYPTO_RANDOM_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <memory>
+#include <string>
+
+#include "absl/strings/string_view.h"
+#include "rtc_base/system/rtc_export.h"
+
+namespace rtc {
+
+// Interface for RNG implementations.
+class RandomGenerator {
+ public:
+ virtual ~RandomGenerator() {}
+ virtual bool Init(const void* seed, size_t len) = 0;
+ virtual bool Generate(void* buf, size_t len) = 0;
+};
+
+// Sets the default random generator as the source of randomness. The default
+// source uses the OpenSSL RNG and provides cryptographically secure randomness.
+void SetDefaultRandomGenerator();
+
+// Set a custom random generator. Results produced by CreateRandomXyz
+// are cryptographically random iff the output of the supplied generator is
+// cryptographically random.
+void SetRandomGenerator(std::unique_ptr<RandomGenerator> generator);
+
+// For testing, we can return predictable data.
+void SetRandomTestMode(bool test);
+
+// Initializes the RNG, and seeds it with the specified entropy.
+bool InitRandom(int seed);
+bool InitRandom(const char* seed, size_t len);
+
+// Generates a (cryptographically) random string of the given length.
+// We generate base64 values so that they will be printable.
+RTC_EXPORT std::string CreateRandomString(size_t length);
+
+// Generates a (cryptographically) random string of the given length.
+// We generate base64 values so that they will be printable.
+// Return false if the random number generator failed.
+RTC_EXPORT bool CreateRandomString(size_t length, std::string* str);
+
+// Generates a (cryptographically) random string of the given length,
+// with characters from the given table. Return false if the random
+// number generator failed.
+// For ease of implementation, the function requires that the table
+// size evenly divide 256; otherwise, it returns false.
+RTC_EXPORT bool CreateRandomString(size_t length,
+ absl::string_view table,
+ std::string* str);
+
+// Generates (cryptographically) random data of the given length.
+// Return false if the random number generator failed.
+bool CreateRandomData(size_t length, std::string* data);
+
+// Generates a (cryptographically) random UUID version 4 string.
+std::string CreateRandomUuid();
+
+// Generates a random id.
+uint32_t CreateRandomId();
+
+// Generates a 64 bit random id.
+RTC_EXPORT uint64_t CreateRandomId64();
+
+// Generates a random id > 0.
+uint32_t CreateRandomNonZeroId();
+
+// Generates a random double between 0.0 (inclusive) and 1.0 (exclusive).
+double CreateRandomDouble();
+
+} // namespace rtc
+
+#endif // RTC_BASE_CRYPTO_RANDOM_H_
diff --git a/rtc_base/helpers_unittest.cc b/rtc_base/crypto_random_unittest.cc
similarity index 98%
rename from rtc_base/helpers_unittest.cc
rename to rtc_base/crypto_random_unittest.cc
index 015b4d0..9c2657d 100644
--- a/rtc_base/helpers_unittest.cc
+++ b/rtc_base/crypto_random_unittest.cc
@@ -8,12 +8,13 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include <string.h>
#include <cstring>
#include <string>
+#include <utility>
#include "rtc_base/buffer.h"
#include "test/gmock.h"
diff --git a/rtc_base/helpers.h b/rtc_base/helpers.h
index 095a645..3d154a7 100644
--- a/rtc_base/helpers.h
+++ b/rtc_base/helpers.h
@@ -7,82 +7,4 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
-
-#ifndef RTC_BASE_HELPERS_H_
-#define RTC_BASE_HELPERS_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include <memory>
-#include <string>
-
-#include "absl/strings/string_view.h"
-#include "rtc_base/system/rtc_export.h"
-
-namespace rtc {
-
-// Interface for RNG implementations.
-class RandomGenerator {
- public:
- virtual ~RandomGenerator() {}
- virtual bool Init(const void* seed, size_t len) = 0;
- virtual bool Generate(void* buf, size_t len) = 0;
-};
-
-// Sets the default random generator as the source of randomness. The default
-// source uses the OpenSSL RNG and provides cryptographically secure randomness.
-void SetDefaultRandomGenerator();
-
-// Set a custom random generator. Results produced by CreateRandomXyz
-// are cryptographically random iff the output of the supplied generator is
-// cryptographically random.
-void SetRandomGenerator(std::unique_ptr<RandomGenerator> generator);
-
-// For testing, we can return predictable data.
-void SetRandomTestMode(bool test);
-
-// Initializes the RNG, and seeds it with the specified entropy.
-bool InitRandom(int seed);
-bool InitRandom(const char* seed, size_t len);
-
-// Generates a (cryptographically) random string of the given length.
-// We generate base64 values so that they will be printable.
-RTC_EXPORT std::string CreateRandomString(size_t length);
-
-// Generates a (cryptographically) random string of the given length.
-// We generate base64 values so that they will be printable.
-// Return false if the random number generator failed.
-RTC_EXPORT bool CreateRandomString(size_t length, std::string* str);
-
-// Generates a (cryptographically) random string of the given length,
-// with characters from the given table. Return false if the random
-// number generator failed.
-// For ease of implementation, the function requires that the table
-// size evenly divide 256; otherwise, it returns false.
-RTC_EXPORT bool CreateRandomString(size_t length,
- absl::string_view table,
- std::string* str);
-
-// Generates (cryptographically) random data of the given length.
-// Return false if the random number generator failed.
-bool CreateRandomData(size_t length, std::string* data);
-
-// Generates a (cryptographically) random UUID version 4 string.
-std::string CreateRandomUuid();
-
-// Generates a random id.
-uint32_t CreateRandomId();
-
-// Generates a 64 bit random id.
-RTC_EXPORT uint64_t CreateRandomId64();
-
-// Generates a random id > 0.
-uint32_t CreateRandomNonZeroId();
-
-// Generates a random double between 0.0 (inclusive) and 1.0 (exclusive).
-double CreateRandomDouble();
-
-} // namespace rtc
-
-#endif // RTC_BASE_HELPERS_H_
+#include "rtc_base/crypto_random.h"
diff --git a/rtc_base/openssl_certificate.cc b/rtc_base/openssl_certificate.cc
index faed72b..46ff576 100644
--- a/rtc_base/openssl_certificate.cc
+++ b/rtc_base/openssl_certificate.cc
@@ -23,7 +23,7 @@
#include <memory>
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/logging.h"
#include "rtc_base/message_digest.h"
#include "rtc_base/openssl_digest.h"
diff --git a/rtc_base/ssl_identity_unittest.cc b/rtc_base/ssl_identity_unittest.cc
index 1f0278a..11fff7f 100644
--- a/rtc_base/ssl_identity_unittest.cc
+++ b/rtc_base/ssl_identity_unittest.cc
@@ -19,8 +19,8 @@
#include "absl/strings/str_replace.h"
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/fake_ssl_identity.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/logging.h"
#include "rtc_base/message_digest.h"
#include "rtc_base/ssl_fingerprint.h"
diff --git a/rtc_base/ssl_stream_adapter_unittest.cc b/rtc_base/ssl_stream_adapter_unittest.cc
index 6d76c7b..6970af6 100644
--- a/rtc_base/ssl_stream_adapter_unittest.cc
+++ b/rtc_base/ssl_stream_adapter_unittest.cc
@@ -22,8 +22,8 @@
#include "rtc_base/buffer_queue.h"
#include "rtc_base/callback_list.h"
#include "rtc_base/checks.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/memory/fifo_buffer.h"
#include "rtc_base/memory_stream.h"
#include "rtc_base/message_digest.h"
diff --git a/rtc_base/time_utils_unittest.cc b/rtc_base/time_utils_unittest.cc
index 09fb816..c60c333 100644
--- a/rtc_base/time_utils_unittest.cc
+++ b/rtc_base/time_utils_unittest.cc
@@ -13,9 +13,9 @@
#include <memory>
#include "api/units/time_delta.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/event.h"
#include "rtc_base/fake_clock.h"
-#include "rtc_base/helpers.h"
#include "rtc_base/thread.h"
#include "test/gtest.h"
diff --git a/rtc_base/unique_id_generator.cc b/rtc_base/unique_id_generator.cc
index e68c643..c80a843 100644
--- a/rtc_base/unique_id_generator.cc
+++ b/rtc_base/unique_id_generator.cc
@@ -14,7 +14,7 @@
#include <vector>
#include "absl/strings/string_view.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/string_to_number.h"
diff --git a/rtc_base/unique_id_generator_unittest.cc b/rtc_base/unique_id_generator_unittest.cc
index a6ae8ec..c83a0d7 100644
--- a/rtc_base/unique_id_generator_unittest.cc
+++ b/rtc_base/unique_id_generator_unittest.cc
@@ -18,8 +18,8 @@
#include "api/array_view.h"
#include "api/task_queue/task_queue_base.h"
#include "api/units/time_delta.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/helpers.h"
#include "test/gmock.h"
using ::testing::IsEmpty;
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 0ba8e1f..dd003f0 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -843,7 +843,7 @@
":fileutils_override_api",
":fileutils_override_impl",
"../rtc_base:checks",
- "../rtc_base:ssl",
+ "../rtc_base:crypto_random",
"../rtc_base:stringutils",
"//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/strings:string_view",
@@ -929,7 +929,7 @@
":fileutils",
":test_support",
"../rtc_base:checks",
- "../rtc_base:ssl",
+ "../rtc_base:crypto_random",
"//third_party/abseil-cpp/absl/strings:string_view",
"//third_party/abseil-cpp/absl/types:optional",
]
diff --git a/test/testsupport/file_utils.cc b/test/testsupport/file_utils.cc
index afabbaa..4826c3b 100644
--- a/test/testsupport/file_utils.cc
+++ b/test/testsupport/file_utils.cc
@@ -54,7 +54,7 @@
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "rtc_base/string_utils.h"
#include "rtc_base/strings/string_builder.h"
#include "test/testsupport/file_utils_override.h"
diff --git a/test/testsupport/file_utils_unittest.cc b/test/testsupport/file_utils_unittest.cc
index 1101a63..005e12c 100644
--- a/test/testsupport/file_utils_unittest.cc
+++ b/test/testsupport/file_utils_unittest.cc
@@ -19,7 +19,7 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "rtc_base/checks.h"
-#include "rtc_base/helpers.h"
+#include "rtc_base/crypto_random.h"
#include "test/gmock.h"
#include "test/gtest.h"