| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebRTCKeyParams_h | 31 #ifndef WebRTCKeyParams_h |
| 32 #define WebRTCKeyParams_h | 32 #define WebRTCKeyParams_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 #include "base/logging.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 // Corresponds to rtc::KeyType in WebRTC. | 39 // Corresponds to rtc::KeyType in WebRTC. |
| 39 enum WebRTCKeyType { WebRTCKeyTypeRSA, WebRTCKeyTypeECDSA, WebRTCKeyTypeNull }; | 40 enum WebRTCKeyType { WebRTCKeyTypeRSA, WebRTCKeyTypeECDSA, WebRTCKeyTypeNull }; |
| 40 | 41 |
| 41 // Corresponds to rtc::RSAParams in WebRTC. | 42 // Corresponds to rtc::RSAParams in WebRTC. |
| 42 struct WebRTCRSAParams { | 43 struct WebRTCRSAParams { |
| 43 unsigned modLength; | 44 unsigned modLength; |
| 44 unsigned pubExp; | 45 unsigned pubExp; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 62 WebRTCKeyParams keyParams(WebRTCKeyTypeECDSA); | 63 WebRTCKeyParams keyParams(WebRTCKeyTypeECDSA); |
| 63 keyParams.m_params.ecCurve = curve; | 64 keyParams.m_params.ecCurve = curve; |
| 64 return keyParams; | 65 return keyParams; |
| 65 } | 66 } |
| 66 | 67 |
| 67 WebRTCKeyParams() : WebRTCKeyParams(WebRTCKeyTypeNull) {} | 68 WebRTCKeyParams() : WebRTCKeyParams(WebRTCKeyTypeNull) {} |
| 68 | 69 |
| 69 WebRTCKeyType keyType() const { return m_keyType; } | 70 WebRTCKeyType keyType() const { return m_keyType; } |
| 70 WebRTCRSAParams rsaParams() const | 71 WebRTCRSAParams rsaParams() const |
| 71 { | 72 { |
| 72 BLINK_ASSERT(m_keyType == WebRTCKeyTypeRSA); | 73 DCHECK_EQ(m_keyType, WebRTCKeyTypeRSA); |
| 73 return m_params.rsa; | 74 return m_params.rsa; |
| 74 } | 75 } |
| 75 WebRTCECCurve ecCurve() const | 76 WebRTCECCurve ecCurve() const |
| 76 { | 77 { |
| 77 BLINK_ASSERT(m_keyType == WebRTCKeyTypeECDSA); | 78 DCHECK_EQ(m_keyType, WebRTCKeyTypeECDSA); |
| 78 return m_params.ecCurve; | 79 return m_params.ecCurve; |
| 79 } | 80 } |
| 80 | 81 |
| 81 private: | 82 private: |
| 82 WebRTCKeyParams(WebRTCKeyType keyType) : m_keyType(keyType) {} | 83 WebRTCKeyParams(WebRTCKeyType keyType) : m_keyType(keyType) {} |
| 83 | 84 |
| 84 WebRTCKeyType m_keyType; | 85 WebRTCKeyType m_keyType; |
| 85 union { | 86 union { |
| 86 WebRTCRSAParams rsa; | 87 WebRTCRSAParams rsa; |
| 87 WebRTCECCurve ecCurve; | 88 WebRTCECCurve ecCurve; |
| 88 } m_params; | 89 } m_params; |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 } // namespace blink | 92 } // namespace blink |
| 92 | 93 |
| 93 #endif // WebRTCKeyParams_h | 94 #endif // WebRTCKeyParams_h |
| OLD | NEW |