Convert uint16_t to int for WebRTC cipher/crypto suite.
This is a follow up CL on https://codereview.webrtc.org/1337673002
BUG=
R=pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1377733004 .
Cr-Commit-Position: refs/heads/master@{#10175}
diff --git a/talk/app/webrtc/statscollector.cc b/talk/app/webrtc/statscollector.cc
index 6e2c950..70cc44d 100644
--- a/talk/app/webrtc/statscollector.cc
+++ b/talk/app/webrtc/statscollector.cc
@@ -734,7 +734,7 @@
channel_report->AddString(StatsReport::kStatsValueNameSrtpCipher,
srtp_cipher);
}
- uint16_t ssl_cipher = channel_iter.ssl_cipher;
+ int ssl_cipher = channel_iter.ssl_cipher;
if (ssl_cipher &&
rtc::SSLStreamAdapter::GetSslCipherSuiteName(ssl_cipher).length()) {
channel_report->AddString(
diff --git a/talk/app/webrtc/statscollector_unittest.cc b/talk/app/webrtc/statscollector_unittest.cc
index 5e65868..34a1c90 100644
--- a/talk/app/webrtc/statscollector_unittest.cc
+++ b/talk/app/webrtc/statscollector_unittest.cc
@@ -61,7 +61,7 @@
namespace {
// This value comes from openssl/tls1.h
-const uint16_t TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014;
+const int TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xC014;
} // namespace
namespace cricket {
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc
index 06b7f6b..15ddc28 100644
--- a/talk/app/webrtc/webrtcsession.cc
+++ b/talk/app/webrtc/webrtcsession.cc
@@ -2149,7 +2149,7 @@
}
const std::string& srtp_cipher = stats.channel_stats[0].srtp_cipher;
- uint16_t ssl_cipher = stats.channel_stats[0].ssl_cipher;
+ int ssl_cipher = stats.channel_stats[0].ssl_cipher;
if (srtp_cipher.empty() && !ssl_cipher) {
return;
}
diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc
index 1330fc8..c759ee5 100644
--- a/webrtc/base/opensslstreamadapter.cc
+++ b/webrtc/base/opensslstreamadapter.cc
@@ -148,26 +148,26 @@
// Default cipher used between OpenSSL/BoringSSL stream adapters.
// This needs to be updated when the default of the SSL library changes.
// static_cast<uint16_t> causes build warnings on windows platform.
-static uint16_t kDefaultSslCipher10 =
+static int kDefaultSslCipher10 =
static_cast<uint16_t>(TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA);
-static uint16_t kDefaultSslEcCipher10 =
+static int kDefaultSslEcCipher10 =
static_cast<uint16_t>(TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA);
#ifdef OPENSSL_IS_BORINGSSL
-static uint16_t kDefaultSslCipher12 =
+static int kDefaultSslCipher12 =
static_cast<uint16_t>(TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256);
-static uint16_t kDefaultSslEcCipher12 =
+static int kDefaultSslEcCipher12 =
static_cast<uint16_t>(TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256);
// Fallback cipher for DTLS 1.2 if hardware-accelerated AES-GCM is unavailable.
-static uint16_t kDefaultSslCipher12NoAesGcm =
+static int kDefaultSslCipher12NoAesGcm =
static_cast<uint16_t>(TLS1_CK_ECDHE_RSA_CHACHA20_POLY1305);
-static uint16_t kDefaultSslEcCipher12NoAesGcm =
+static int kDefaultSslEcCipher12NoAesGcm =
static_cast<uint16_t>(TLS1_CK_ECDHE_ECDSA_CHACHA20_POLY1305);
#else // !OPENSSL_IS_BORINGSSL
// OpenSSL sorts differently than BoringSSL, so the default cipher doesn't
// change between TLS 1.0 and TLS 1.2 with the current setup.
-static uint16_t kDefaultSslCipher12 =
+static int kDefaultSslCipher12 =
static_cast<uint16_t>(TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA);
-static uint16_t kDefaultSslEcCipher12 =
+static int kDefaultSslEcCipher12 =
static_cast<uint16_t>(TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA);
#endif
@@ -348,7 +348,7 @@
return true;
}
-std::string OpenSSLStreamAdapter::GetSslCipherSuiteName(uint16_t cipher) {
+std::string OpenSSLStreamAdapter::GetSslCipherSuiteName(int cipher) {
#ifdef OPENSSL_IS_BORINGSSL
const SSL_CIPHER* ssl_cipher = SSL_get_cipher_by_value(cipher);
if (!ssl_cipher) {
@@ -369,7 +369,7 @@
#endif
}
-bool OpenSSLStreamAdapter::GetSslCipherSuite(uint16_t* cipher) {
+bool OpenSSLStreamAdapter::GetSslCipherSuite(int* cipher) {
if (state_ != SSL_CONNECTED)
return false;
@@ -1130,9 +1130,8 @@
#endif
}
-uint16_t OpenSSLStreamAdapter::GetDefaultSslCipherForTest(
- SSLProtocolVersion version,
- KeyType key_type) {
+int OpenSSLStreamAdapter::GetDefaultSslCipherForTest(SSLProtocolVersion version,
+ KeyType key_type) {
if (key_type == KT_RSA) {
switch (version) {
case SSL_PROTOCOL_TLS_10:
diff --git a/webrtc/base/opensslstreamadapter.h b/webrtc/base/opensslstreamadapter.h
index dfcb439..56bba41 100644
--- a/webrtc/base/opensslstreamadapter.h
+++ b/webrtc/base/opensslstreamadapter.h
@@ -88,9 +88,9 @@
StreamState GetState() const override;
// TODO(guoweis): Move this away from a static class method.
- static std::string GetSslCipherSuiteName(uint16_t cipher);
+ static std::string GetSslCipherSuiteName(int cipher);
- bool GetSslCipherSuite(uint16_t* cipher) override;
+ bool GetSslCipherSuite(int* cipher) override;
// Key Extractor interface
bool ExportKeyingMaterial(const std::string& label,
@@ -110,8 +110,8 @@
static bool HaveExporter();
// TODO(guoweis): Move this away from a static class method.
- static uint16_t GetDefaultSslCipherForTest(SSLProtocolVersion version,
- KeyType key_type);
+ static int GetDefaultSslCipherForTest(SSLProtocolVersion version,
+ KeyType key_type);
protected:
void OnEvent(StreamInterface* stream, int events, int err) override;
diff --git a/webrtc/base/sslstreamadapter.cc b/webrtc/base/sslstreamadapter.cc
index 8930f21..0ce49d1 100644
--- a/webrtc/base/sslstreamadapter.cc
+++ b/webrtc/base/sslstreamadapter.cc
@@ -34,7 +34,7 @@
const char CS_AES_CM_128_HMAC_SHA1_80[] = "AES_CM_128_HMAC_SHA1_80";
const char CS_AES_CM_128_HMAC_SHA1_32[] = "AES_CM_128_HMAC_SHA1_32";
-uint16_t GetSrtpCryptoSuiteFromName(const std::string& cipher) {
+int GetSrtpCryptoSuiteFromName(const std::string& cipher) {
if (cipher == CS_AES_CM_128_HMAC_SHA1_32)
return SRTP_AES128_CM_SHA1_32;
if (cipher == CS_AES_CM_128_HMAC_SHA1_80)
@@ -52,7 +52,7 @@
#endif
}
-bool SSLStreamAdapter::GetSslCipherSuite(uint16_t* cipher) {
+bool SSLStreamAdapter::GetSslCipherSuite(int* cipher) {
return false;
}
@@ -79,9 +79,8 @@
bool SSLStreamAdapter::HaveDtls() { return false; }
bool SSLStreamAdapter::HaveDtlsSrtp() { return false; }
bool SSLStreamAdapter::HaveExporter() { return false; }
-uint16_t SSLStreamAdapter::GetDefaultSslCipherForTest(
- SSLProtocolVersion version,
- KeyType key_type) {
+int SSLStreamAdapter::GetDefaultSslCipherForTest(SSLProtocolVersion version,
+ KeyType key_type) {
return 0;
}
#elif SSL_USE_OPENSSL
@@ -94,13 +93,12 @@
bool SSLStreamAdapter::HaveExporter() {
return OpenSSLStreamAdapter::HaveExporter();
}
-uint16_t SSLStreamAdapter::GetDefaultSslCipherForTest(
- SSLProtocolVersion version,
- KeyType key_type) {
+int SSLStreamAdapter::GetDefaultSslCipherForTest(SSLProtocolVersion version,
+ KeyType key_type) {
return OpenSSLStreamAdapter::GetDefaultSslCipherForTest(version, key_type);
}
-std::string SSLStreamAdapter::GetSslCipherSuiteName(uint16_t cipher) {
+std::string SSLStreamAdapter::GetSslCipherSuiteName(int cipher) {
return OpenSSLStreamAdapter::GetSslCipherSuiteName(cipher);
}
#endif // !SSL_USE_SCHANNEL && !SSL_USE_OPENSSL
diff --git a/webrtc/base/sslstreamadapter.h b/webrtc/base/sslstreamadapter.h
index 867f309..fa49651 100644
--- a/webrtc/base/sslstreamadapter.h
+++ b/webrtc/base/sslstreamadapter.h
@@ -20,8 +20,8 @@
namespace rtc {
// Constants for SRTP profiles.
-const uint16_t SRTP_AES128_CM_SHA1_80 = 0x0001;
-const uint16_t SRTP_AES128_CM_SHA1_32 = 0x0002;
+const int SRTP_AES128_CM_SHA1_80 = 0x0001;
+const int SRTP_AES128_CM_SHA1_32 = 0x0002;
// Cipher suite to use for SRTP. Typically a 80-bit HMAC will be used, except
// in applications (voice) where the additional bandwidth may be significant.
@@ -34,7 +34,7 @@
// Returns the DTLS-SRTP protection profile ID, as defined in
// https://tools.ietf.org/html/rfc5764#section-4.1.2, for the given SRTP
// Crypto-suite, as defined in https://tools.ietf.org/html/rfc4568#section-6.2
-uint16_t GetSrtpCryptoSuiteFromName(const std::string& cipher_rfc_name);
+int GetSrtpCryptoSuiteFromName(const std::string& cipher_rfc_name);
// SSLStreamAdapter : A StreamInterfaceAdapter that does SSL/TLS.
// After SSL has been started, the stream will only open on successful
@@ -152,7 +152,7 @@
// Retrieves the IANA registration id of the cipher suite used for the
// connection (e.g. 0x2F for "TLS_RSA_WITH_AES_128_CBC_SHA").
- virtual bool GetSslCipherSuite(uint16_t* cipher);
+ virtual bool GetSslCipherSuite(int* cipher);
// Key Exporter interface from RFC 5705
// Arguments are:
@@ -185,13 +185,13 @@
// Returns the default Ssl cipher used between streams of this class
// for the given protocol version. This is used by the unit tests.
// TODO(guoweis): Move this away from a static class method.
- static uint16_t GetDefaultSslCipherForTest(SSLProtocolVersion version,
- KeyType key_type);
+ static int GetDefaultSslCipherForTest(SSLProtocolVersion version,
+ KeyType key_type);
// TODO(guoweis): Move this away from a static class method. Currently this is
// introduced such that any caller could depend on sslstreamadapter.h without
// depending on specific SSL implementation.
- static std::string GetSslCipherSuiteName(uint16_t cipher);
+ static std::string GetSslCipherSuiteName(int cipher);
private:
// If true, the server certificate need not match the configured
diff --git a/webrtc/base/sslstreamadapter_unittest.cc b/webrtc/base/sslstreamadapter_unittest.cc
index c8fe9a0..386fe4f 100644
--- a/webrtc/base/sslstreamadapter_unittest.cc
+++ b/webrtc/base/sslstreamadapter_unittest.cc
@@ -410,7 +410,7 @@
return server_ssl_->GetPeerCertificate(cert);
}
- bool GetSslCipherSuite(bool client, uint16_t* retval) {
+ bool GetSslCipherSuite(bool client, int* retval) {
if (client)
return client_ssl_->GetSslCipherSuite(retval);
else
@@ -972,9 +972,9 @@
SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10);
TestHandshake();
- uint16_t client_cipher;
+ int client_cipher;
ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
- uint16_t server_cipher;
+ int server_cipher;
ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
ASSERT_EQ(client_cipher, server_cipher);
@@ -990,9 +990,9 @@
SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12);
TestHandshake();
- uint16_t client_cipher;
+ int client_cipher;
ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
- uint16_t server_cipher;
+ int server_cipher;
ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
ASSERT_EQ(client_cipher, server_cipher);
@@ -1007,9 +1007,9 @@
SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12);
TestHandshake();
- uint16_t client_cipher;
+ int client_cipher;
ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
- uint16_t server_cipher;
+ int server_cipher;
ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
ASSERT_EQ(client_cipher, server_cipher);
@@ -1024,9 +1024,9 @@
SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10);
TestHandshake();
- uint16_t client_cipher;
+ int client_cipher;
ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher));
- uint16_t server_cipher;
+ int server_cipher;
ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher));
ASSERT_EQ(client_cipher, server_cipher);
diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc
index ff42a4d..26bb181 100644
--- a/webrtc/p2p/base/dtlstransportchannel.cc
+++ b/webrtc/p2p/base/dtlstransportchannel.cc
@@ -186,7 +186,7 @@
return true;
}
-bool DtlsTransportChannelWrapper::GetSslCipherSuite(uint16_t* cipher) {
+bool DtlsTransportChannelWrapper::GetSslCipherSuite(int* cipher) {
if (dtls_state_ != STATE_OPEN) {
return false;
}
diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h
index f1a5231..d27d30e 100644
--- a/webrtc/p2p/base/dtlstransportchannel.h
+++ b/webrtc/p2p/base/dtlstransportchannel.h
@@ -141,7 +141,7 @@
bool SetSslRole(rtc::SSLRole role) override;
// Find out which DTLS cipher was negotiated
- bool GetSslCipherSuite(uint16_t* cipher) override;
+ bool GetSslCipherSuite(int* cipher) override;
// Once DTLS has been established, this method retrieves the certificate in
// use by the remote peer, for use in external identity verification.
diff --git a/webrtc/p2p/base/dtlstransportchannel_unittest.cc b/webrtc/p2p/base/dtlstransportchannel_unittest.cc
index 8149577..cad5b56 100644
--- a/webrtc/p2p/base/dtlstransportchannel_unittest.cc
+++ b/webrtc/p2p/base/dtlstransportchannel_unittest.cc
@@ -228,10 +228,10 @@
}
}
- void CheckSsl(uint16_t expected_cipher) {
+ void CheckSsl(int expected_cipher) {
for (std::vector<cricket::DtlsTransportChannelWrapper*>::iterator it =
channels_.begin(); it != channels_.end(); ++it) {
- uint16_t cipher;
+ int cipher;
bool rv = (*it)->GetSslCipherSuite(&cipher);
if (negotiated_dtls_ && expected_cipher) {
diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h
index 961728d..6d337a4 100644
--- a/webrtc/p2p/base/faketransportcontroller.h
+++ b/webrtc/p2p/base/faketransportcontroller.h
@@ -251,7 +251,7 @@
return false;
}
- bool GetSslCipherSuite(uint16_t* cipher) override { return false; }
+ bool GetSslCipherSuite(int* cipher) override { return false; }
rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const {
return local_cert_;
diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h
index 8859111..0e5e019 100644
--- a/webrtc/p2p/base/p2ptransportchannel.h
+++ b/webrtc/p2p/base/p2ptransportchannel.h
@@ -114,7 +114,7 @@
bool GetSrtpCryptoSuite(std::string* cipher) override { return false; }
// Find out which DTLS cipher was negotiated.
- bool GetSslCipherSuite(uint16_t* cipher) override { return false; }
+ bool GetSslCipherSuite(int* cipher) override { return false; }
// Returns null because the channel is not encrypted by default.
rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override {
diff --git a/webrtc/p2p/base/transport.h b/webrtc/p2p/base/transport.h
index df0a34c..6324cd6 100644
--- a/webrtc/p2p/base/transport.h
+++ b/webrtc/p2p/base/transport.h
@@ -111,7 +111,7 @@
int component = 0;
ConnectionInfos connection_infos;
std::string srtp_cipher;
- uint16_t ssl_cipher = 0;
+ int ssl_cipher = 0;
};
// Information about all the channels of a transport.
diff --git a/webrtc/p2p/base/transportchannel.h b/webrtc/p2p/base/transportchannel.h
index afdba42..ca7d7cf 100644
--- a/webrtc/p2p/base/transportchannel.h
+++ b/webrtc/p2p/base/transportchannel.h
@@ -113,9 +113,7 @@
// Finds out which DTLS cipher was negotiated.
// TODO(guoweis): Remove this once all dependencies implement this.
- virtual bool GetSslCipherSuite(uint16_t* cipher) {
- return false;
- }
+ virtual bool GetSslCipherSuite(int* cipher) { return false; }
// Gets the local RTCCertificate used for DTLS.
virtual rtc::scoped_refptr<rtc::RTCCertificate>