Chromium Code Reviews| Index: webrtc/base/opensslstreamadapter.cc |
| diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc |
| index 67ed5db4b5f38520a498bb940fdea51dace7bce8..3c5052e52935f71337d3562805f95d4faee5232f 100644 |
| --- a/webrtc/base/opensslstreamadapter.cc |
| +++ b/webrtc/base/opensslstreamadapter.cc |
| @@ -43,17 +43,19 @@ namespace rtc { |
| #endif |
| #ifdef HAVE_DTLS_SRTP |
| -// SRTP cipher suite table |
| +// SRTP cipher suite table. |internal_name| is used to construct a |
| +// colon-separated profile strings which is needed by |
| +// SSL_CTX_set_tlsext_use_srtp(). |
| struct SrtpCipherMapEntry { |
| - const char* external_name; |
| const char* internal_name; |
| + const int id; |
| }; |
| // This isn't elegant, but it's better than an external reference |
| static SrtpCipherMapEntry SrtpCipherMap[] = { |
| - {CS_AES_CM_128_HMAC_SHA1_80, "SRTP_AES128_CM_SHA1_80"}, |
| - {CS_AES_CM_128_HMAC_SHA1_32, "SRTP_AES128_CM_SHA1_32"}, |
| - {NULL, NULL}}; |
| + {"SRTP_AES128_CM_SHA1_80", SRTP_AES128_CM_SHA1_80}, |
| + {"SRTP_AES128_CM_SHA1_32", SRTP_AES128_CM_SHA1_32}, |
| + {nullptr, 0}}; |
| #endif |
| #ifndef OPENSSL_IS_BORINGSSL |
| @@ -348,7 +350,7 @@ bool OpenSSLStreamAdapter::SetPeerCertificateDigest(const std::string |
| return true; |
| } |
| -std::string OpenSSLStreamAdapter::GetSslCipherSuiteName(int cipher) { |
| +std::string OpenSSLStreamAdapter::SslCipherSuiteToName(int cipher) { |
|
pthatcher1
2015/11/11 19:59:40
cipher_suite or suite?
Same here and below
guoweis_webrtc
2015/11/17 01:21:16
Done.
|
| #ifdef OPENSSL_IS_BORINGSSL |
| const SSL_CIPHER* ssl_cipher = SSL_get_cipher_by_value(cipher); |
| if (!ssl_cipher) { |
| @@ -405,20 +407,20 @@ bool OpenSSLStreamAdapter::ExportKeyingMaterial(const std::string& label, |
| #endif |
| } |
| -bool OpenSSLStreamAdapter::SetDtlsSrtpCiphers( |
| - const std::vector<std::string>& ciphers) { |
| +bool OpenSSLStreamAdapter::SetDtlsSrtpCryptoSuites( |
| + const std::vector<int>& ciphers) { |
| #ifdef HAVE_DTLS_SRTP |
| std::string internal_ciphers; |
| if (state_ != SSL_NONE) |
| return false; |
| - for (std::vector<std::string>::const_iterator cipher = ciphers.begin(); |
| + for (std::vector<int>::const_iterator cipher = ciphers.begin(); |
| cipher != ciphers.end(); ++cipher) { |
| bool found = false; |
| - for (SrtpCipherMapEntry *entry = SrtpCipherMap; entry->internal_name; |
| + for (SrtpCipherMapEntry* entry = SrtpCipherMap; entry->internal_name; |
| ++entry) { |
| - if (*cipher == entry->external_name) { |
| + if (*cipher == entry->id) { |
| found = true; |
| if (!internal_ciphers.empty()) |
| internal_ciphers += ":"; |
| @@ -443,7 +445,7 @@ bool OpenSSLStreamAdapter::SetDtlsSrtpCiphers( |
| #endif |
| } |
| -bool OpenSSLStreamAdapter::GetDtlsSrtpCipher(std::string* cipher) { |
| +bool OpenSSLStreamAdapter::GetDtlsSrtpCryptoSuite(int* cipher) { |
|
pthatcher1
2015/11/11 19:59:40
crypto_suite
guoweis_webrtc
2015/11/17 01:21:16
Done.
|
| #ifdef HAVE_DTLS_SRTP |
| ASSERT(state_ == SSL_CONNECTED); |
| if (state_ != SSL_CONNECTED) |
| @@ -455,17 +457,9 @@ bool OpenSSLStreamAdapter::GetDtlsSrtpCipher(std::string* cipher) { |
| if (!srtp_profile) |
| return false; |
| - for (SrtpCipherMapEntry *entry = SrtpCipherMap; |
| - entry->internal_name; ++entry) { |
| - if (!strcmp(entry->internal_name, srtp_profile->name)) { |
| - *cipher = entry->external_name; |
| - return true; |
| - } |
| - } |
| - |
| - ASSERT(false); // This should never happen |
| - |
| - return false; |
| + *cipher = srtp_profile->id; |
| + ASSERT(!SrtpCryptoSuiteToName(*cipher).empty()); |
| + return true; |
| #else |
| return false; |
| #endif |