diff --git a/api/BUILD.gn b/api/BUILD.gn index b0f95ebcf8..283d105163 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -184,11 +184,11 @@ rtc_library("candidate") { "../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 9a35201f64..4e462dda91 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 8a64411ad1..87585782fd 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -115,11 +115,11 @@ rtc_source_set("stun_types") { "../../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 ca90515952..27266d97db 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 9bcbba29a1..ed02eb768c 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -866,10 +866,10 @@ if (!build_with_chromium) { "../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 3b3c06be8f..7c180d661e 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 9f216a5cb5..cff643aa33 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -116,6 +116,7 @@ rtc_library("rtc_p2p") { "../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 @@ rtc_library("basic_port_allocator") { "../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_library("connection") { "../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_library("connection") { "../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 @@ rtc_library("ice_credentials_iterator") { deps = [ ":p2p_constants", ":transport_description", - "../rtc_base:ssl", + "../rtc_base:crypto_random", ] } @@ -656,6 +657,7 @@ rtc_library("port") { "../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_library("port") { "../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 @@ rtc_library("port_allocator") { "../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 @@ rtc_library("stun_port") { "../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 @@ rtc_library("stun_request") { "../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 @@ if (rtc_include_tests) { "../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_library("p2p_server_utils") { "../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 d133159498..762b69259e 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 f870c1e207..9e2d069e11 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 373c8510ac..2a12d41886 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 29bdd990f3..cad0a08a6a 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 d9bacf3a5a..25105dcdb0 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 52fc8c1d39..569400763c 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 7958538e1c..0ae2182c39 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 be3b365427..48d52da9f0 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 48df2b119a..b32f07db5b 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 93c303015c..fd1eb72a92 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 423d16b11b..842f3e49c6 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 fc5d43dc81..a44518bfa8 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 8ce89f8a00..188ffbfdd5 100644 --- a/p2p/base/stun_request_unittest.cc +++ b/p2p/base/stun_request_unittest.cc @@ -13,9 +13,9 @@ #include #include +#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 be246a8576..8bdae5a9c2 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 1f60b64012..f9bd198fe5 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 4e039dec24..98b9f3ef6d 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 f1525b0589..c8b293a290 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 25dd280a8a..51025ecef4 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -317,6 +317,7 @@ rtc_source_set("jsep_transport_controller") { "../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 @@ rtc_library("connection_context") { "../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 @@ rtc_source_set("sdp_offer_answer") { "../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 @@ rtc_source_set("peer_connection") { "../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 @@ rtc_source_set("webrtc_sdp") { "../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 @@ rtc_library("rtp_transmission_manager") { "../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 @@ rtc_library("rtp_sender") { "../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 @@ if (rtc_include_tests && !build_with_chromium) { "../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 @@ if (rtc_include_tests && !build_with_chromium) { "../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 @@ if (rtc_include_tests && !build_with_chromium) { "../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 @@ if (rtc_include_tests && !build_with_chromium) { "../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 56a6e91869..ab682b7dc4 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 95661d73eb..4489618306 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 c3e1f330e4..f1f99ee2bb 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 da0b921473..373b603afe 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 8112c97788..01b826b52d 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 44fae1344e..1cf560e6a0 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 0e4e52b99c..dbbe9e8c74 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 08bc37343f..e51e5aa4d9 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 7deafbf428..6ab77e17f6 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 60b8813037..6e28734ac7 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 96b308842b..ab9c58aefa 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 8b348ba1cf..199d7ecfbe 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 72ea286075..dbce97996f 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 56f1f43d61..3e638b057b 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 acfefb764e..85ec8edb9b 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -1413,7 +1413,7 @@ rtc_library("unique_id_generator") { "unique_id_generator.h", ] deps = [ - ":ssl", + ":crypto_random", ":stringutils", "../api:array_view", "../api:sequence_checker", @@ -1503,10 +1503,31 @@ rtc_source_set("digest") { } } +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 @@ rtc_library("ssl") { ":buffer", ":checks", ":copy_on_write_buffer", + ":crypto_random", ":digest", ":logging", ":macromagic", @@ -1938,6 +1960,7 @@ if (rtc_include_tests) { ":checks", ":copy_on_write_buffer", ":criticalsection", + ":crypto_random", ":divide_round", ":event_tracer", ":frequency_tracker", @@ -2082,9 +2105,9 @@ if (rtc_include_tests) { 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 @@ if (rtc_include_tests) { ":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 a866224496..6781443ff9 100644 --- a/rtc_base/boringssl_certificate.cc +++ b/rtc_base/boringssl_certificate.cc @@ -32,7 +32,7 @@ #include #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 99% rename from rtc_base/helpers.cc rename to rtc_base/crypto_random.cc index 5aca40c7aa..68b86a07c3 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 #include #include #include +#include #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 0000000000..8b1baf5185 --- /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 +#include + +#include +#include + +#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 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 015b4d0a7c..9c2657df67 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 #include #include +#include #include "rtc_base/buffer.h" #include "test/gmock.h" diff --git a/rtc_base/helpers.h b/rtc_base/helpers.h index 095a645e28..3d154a7fe4 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 -#include - -#include -#include - -#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 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 faed72b4db..46ff576124 100644 --- a/rtc_base/openssl_certificate.cc +++ b/rtc_base/openssl_certificate.cc @@ -23,7 +23,7 @@ #include #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 1f0278ac71..11fff7f31e 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 6d76c7b0d2..6970af6c58 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 09fb816636..c60c333846 100644 --- a/rtc_base/time_utils_unittest.cc +++ b/rtc_base/time_utils_unittest.cc @@ -13,9 +13,9 @@ #include #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 e68c643dbe..c80a8437bb 100644 --- a/rtc_base/unique_id_generator.cc +++ b/rtc_base/unique_id_generator.cc @@ -14,7 +14,7 @@ #include #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 a6ae8ec9f5..c83a0d7565 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 0ba8e1fc67..dd003f0e40 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -843,7 +843,7 @@ rtc_library("fileutils") { ":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 @@ rtc_library("fileutils_unittests") { ":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 afabbaad3f..4826c3b985 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 1101a63352..005e12c16e 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"