Chromium Code Reviews| Index: webrtc/base/sslstreamadapter.cc |
| diff --git a/webrtc/base/sslstreamadapter.cc b/webrtc/base/sslstreamadapter.cc |
| index a2cff3e44874678de052e0636c4d695c221094c3..83d83d0299caa216bf08f47995919337633d4816 100644 |
| --- a/webrtc/base/sslstreamadapter.cc |
| +++ b/webrtc/base/sslstreamadapter.cc |
| @@ -29,13 +29,22 @@ namespace rtc { |
| // webrtc:5043. |
| 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"; |
| +const char CS_AEAD_AES_128_GCM[] = "AEAD_AES_128_GCM"; |
| +const char CS_AEAD_AES_256_GCM[] = "AEAD_AES_256_GCM"; |
| std::string SrtpCryptoSuiteToName(int crypto_suite) { |
| - if (crypto_suite == SRTP_AES128_CM_SHA1_32) |
| + switch (crypto_suite) { |
| + case SRTP_AES128_CM_SHA1_32: |
| return CS_AES_CM_128_HMAC_SHA1_32; |
| - if (crypto_suite == SRTP_AES128_CM_SHA1_80) |
| + case SRTP_AES128_CM_SHA1_80: |
| return CS_AES_CM_128_HMAC_SHA1_80; |
| - return std::string(); |
| + case SRTP_AEAD_AES_128_GCM: |
| + return CS_AEAD_AES_128_GCM; |
| + case SRTP_AEAD_AES_256_GCM: |
| + return CS_AEAD_AES_256_GCM; |
| + default: |
| + return std::string(); |
| + } |
| } |
| int SrtpCryptoSuiteFromName(const std::string& crypto_suite) { |
| @@ -43,9 +52,46 @@ int SrtpCryptoSuiteFromName(const std::string& crypto_suite) { |
| return SRTP_AES128_CM_SHA1_32; |
| if (crypto_suite == CS_AES_CM_128_HMAC_SHA1_80) |
| return SRTP_AES128_CM_SHA1_80; |
| + if (crypto_suite == CS_AEAD_AES_128_GCM) |
| + return SRTP_AEAD_AES_128_GCM; |
| + if (crypto_suite == CS_AEAD_AES_256_GCM) |
| + return SRTP_AEAD_AES_256_GCM; |
| return SRTP_INVALID_CRYPTO_SUITE; |
| } |
| +bool GetSrtpKeyAndSaltLengths(int crypto_suite, int *key_length, |
| + int *salt_length) { |
| + switch (crypto_suite) { |
| + case SRTP_AES128_CM_SHA1_32: |
| + case SRTP_AES128_CM_SHA1_80: |
| + *key_length = 16; |
| + *salt_length = 14; |
| + break; |
| + case SRTP_AEAD_AES_128_GCM: |
| + *key_length = 16; |
| + *salt_length = 12; |
| + break; |
| + case SRTP_AEAD_AES_256_GCM: |
| + *key_length = 32; |
| + *salt_length = 12; |
|
pthatcher1
2016/01/30 00:54:33
Can you leave a comment saying where these values
joachim
2016/01/31 23:39:52
Done.
|
| + break; |
| + default: |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| +bool IsGcmCryptoSuite(int crypto_suite) { |
| + return (crypto_suite == SRTP_AEAD_AES_256_GCM || |
| + crypto_suite == SRTP_AEAD_AES_128_GCM); |
| +} |
| + |
| +bool IsGcmCryptoSuiteName(const std::string& crypto_suite) { |
| + return (crypto_suite == CS_AEAD_AES_256_GCM || |
| + crypto_suite == CS_AEAD_AES_128_GCM); |
| +} |
| + |
| + |
| SSLStreamAdapter* SSLStreamAdapter::Create(StreamInterface* stream) { |
| #if SSL_USE_OPENSSL |
| return new OpenSSLStreamAdapter(stream); |