Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: third_party/WebKit/public/platform/WebRTCKeyParams.h

Issue 1373023002: RTCCertificate, RTCPeerConnection.generateCertificate (WebRTC JavaScript) added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make trybots compile (WebRTCCertificate not including wtf/Noncopyable) Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 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
11 * copyright notice, this list of conditions and the following disclaimer 11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the 12 * in the documentation and/or other materials provided with the
13 * distribution. 13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its 14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from 15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission. 16 * this software without specific prior written permission.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 WebData_h 31 #ifndef WebRTCKeyParams_h
32 #define WebData_h 32 #define WebRTCKeyParams_h
33 33
34 #include "WebCommon.h" 34 #include "WebCommon.h"
35 #include "WebPrivatePtr.h"
36 35
37 namespace blink { 36 namespace blink {
38 37
39 class SharedBuffer; 38 // Corresponds to rtc::KeyType in WebRTC.
39 enum WebRTCKeyType { WebRTCKeyTypeRSA, WebRTCKeyTypeECDSA, WebRTCKeyTypeNull };
40 40
41 // A container for raw bytes. It is inexpensive to copy a WebData object. 41 // Corresponds to rtc::RSAParams in WebRTC.
42 // 42 struct WebRTCRSAParams {
43 // WARNING: It is not safe to pass a WebData across threads!!! 43 unsigned modLength;
44 // 44 unsigned pubExp;
Ryan Sleevi 2015/10/10 04:04:48 See https://www.chromium.org/developers/coding-sty
hbos_chromium 2015/10/14 13:00:50 Making this mirror the types of rtc::RSAParams, ht
45 class BLINK_PLATFORM_EXPORT WebData { 45 };
46
47 // Corresponds to rtc::ECCurve in WebRTC.
48 enum WebRTCECCurve { WebRTCECCurveNistP256 };
49
50 // Corresponds to rtc::KeyParams in WebRTC.
51 class WebRTCKeyParams {
46 public: 52 public:
47 ~WebData() { reset(); } 53 static WebRTCKeyParams createRSA(unsigned modLength, unsigned pubExp)
48
49 WebData() { }
50
51 WebData(const char* data, size_t size)
52 { 54 {
53 assign(data, size); 55 WebRTCKeyParams keyParams(WebRTCKeyTypeRSA);
56 keyParams.m_params.rsa.modLength = modLength;
57 keyParams.m_params.rsa.pubExp = pubExp;
58 return keyParams;
59 }
60 static WebRTCKeyParams createECDSA(WebRTCECCurve curve)
61 {
62 WebRTCKeyParams keyParams(WebRTCKeyTypeECDSA);
63 keyParams.m_params.ecCurve = curve;
64 return keyParams;
54 } 65 }
55 66
56 template <int N> 67 WebRTCKeyParams() : WebRTCKeyParams(WebRTCKeyTypeNull) {}
57 WebData(const char (&data)[N]) 68
69 WebRTCKeyType keyType() const { return m_keyType; }
70 WebRTCRSAParams rsaParams() const
58 { 71 {
59 assign(data, N - 1); 72 BLINK_ASSERT(m_keyType == WebRTCKeyTypeRSA);
73 return m_params.rsa;
74 }
75 WebRTCECCurve ecCurve() const
76 {
77 BLINK_ASSERT(m_keyType == WebRTCKeyTypeECDSA);
78 return m_params.ecCurve;
60 } 79 }
61 80
62 WebData(const WebData& d) { assign(d); } 81 private:
82 WebRTCKeyParams(WebRTCKeyType keyType) : m_keyType(keyType) {}
63 83
64 WebData& operator=(const WebData& d) 84 WebRTCKeyType m_keyType;
65 { 85 union {
66 assign(d); 86 WebRTCRSAParams rsa;
67 return *this; 87 WebRTCECCurve ecCurve;
68 } 88 } m_params;
69
70 void reset();
71 void assign(const WebData&);
72 void assign(const char* data, size_t size);
73
74 size_t size() const;
75 const char* data() const;
76
77 bool isEmpty() const { return !size(); }
78 bool isNull() const { return m_private.isNull(); }
79
80 #if INSIDE_BLINK
81 WebData(const PassRefPtr<SharedBuffer>&);
82 WebData& operator=(const PassRefPtr<SharedBuffer>&);
83 operator PassRefPtr<SharedBuffer>() const;
84 #else
85 template <class C>
86 WebData(const C& c)
87 {
88 assign(c.data(), c.size());
89 }
90
91 template <class C>
92 WebData& operator=(const C& c)
93 {
94 assign(c.data(), c.size());
95 return *this;
96 }
97 #endif
98
99 private:
100 WebPrivatePtr<SharedBuffer> m_private;
101 }; 89 };
102 90
103 } // namespace blink 91 } // namespace blink
104 92
105 #endif 93 #endif // WebRTCKeyParams_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698