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

Side by Side Diff: Source/platform/exported/WebCryptoKey.cpp

Issue 179353002: [webcrypto] Add the KeyAlgorithm interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase yet again (another conflict) Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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
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 #include "config.h" 31 #include "config.h"
32 #include "public/platform/WebCryptoKey.h" 32 #include "public/platform/WebCryptoKey.h"
33 33
34 #include "public/platform/WebCryptoAlgorithm.h" 34 #include "public/platform/WebCryptoAlgorithm.h"
35 #include "public/platform/WebCryptoAlgorithmParams.h"
36 #include "public/platform/WebCryptoKeyAlgorithm.h"
35 #include "wtf/OwnPtr.h" 37 #include "wtf/OwnPtr.h"
36 #include "wtf/ThreadSafeRefCounted.h" 38 #include "wtf/ThreadSafeRefCounted.h"
37 39
38 namespace blink { 40 namespace blink {
39 41
40 class WebCryptoKeyPrivate : public ThreadSafeRefCounted<WebCryptoKeyPrivate> { 42 class WebCryptoKeyPrivate : public ThreadSafeRefCounted<WebCryptoKeyPrivate> {
41 public: 43 public:
42 WebCryptoKeyPrivate(PassOwnPtr<WebCryptoKeyHandle> handle, WebCryptoKeyType type, bool extractable, const WebCryptoAlgorithm& algorithm, WebCryptoKeyUsageMa sk usages) 44 WebCryptoKeyPrivate(PassOwnPtr<WebCryptoKeyHandle> handle, WebCryptoKeyType type, bool extractable, const WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyUsag eMask usages)
43 : handle(handle) 45 : handle(handle)
44 , type(type) 46 , type(type)
45 , extractable(extractable) 47 , extractable(extractable)
46 , algorithm(algorithm) 48 , algorithm(algorithm)
47 , usages(usages) 49 , usages(usages)
48 { 50 {
49 ASSERT(!algorithm.isNull()); 51 ASSERT(!algorithm.isNull());
50 } 52 }
51 53
52 const OwnPtr<WebCryptoKeyHandle> handle; 54 const OwnPtr<WebCryptoKeyHandle> handle;
53 const WebCryptoKeyType type; 55 const WebCryptoKeyType type;
54 const bool extractable; 56 const bool extractable;
55 const WebCryptoAlgorithm algorithm; 57 const WebCryptoKeyAlgorithm algorithm;
56 const WebCryptoKeyUsageMask usages; 58 const WebCryptoKeyUsageMask usages;
57 }; 59 };
58 60
59 WebCryptoKey WebCryptoKey::create(WebCryptoKeyHandle* handle, WebCryptoKeyType t ype, bool extractable, const WebCryptoAlgorithm& algorithm, WebCryptoKeyUsageMas k usages) 61 WebCryptoKey WebCryptoKey::create(WebCryptoKeyHandle* handle, WebCryptoKeyType t ype, bool extractable, const WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyUsage Mask usages)
60 { 62 {
61 WebCryptoKey key; 63 WebCryptoKey key;
62 key.m_private = adoptRef(new WebCryptoKeyPrivate(adoptPtr(handle), type, ext ractable, algorithm, usages)); 64 key.m_private = adoptRef(new WebCryptoKeyPrivate(adoptPtr(handle), type, ext ractable, algorithm, usages));
63 return key; 65 return key;
64 } 66 }
65 67
66 WebCryptoKey WebCryptoKey::createNull() 68 WebCryptoKey WebCryptoKey::createNull()
67 { 69 {
68 return WebCryptoKey(); 70 return WebCryptoKey();
69 } 71 }
70 72
71 WebCryptoKeyHandle* WebCryptoKey::handle() const 73 WebCryptoKeyHandle* WebCryptoKey::handle() const
72 { 74 {
73 ASSERT(!isNull()); 75 ASSERT(!isNull());
74 return m_private->handle.get(); 76 return m_private->handle.get();
75 } 77 }
76 78
77 WebCryptoKeyType WebCryptoKey::type() const 79 WebCryptoKeyType WebCryptoKey::type() const
78 { 80 {
79 ASSERT(!isNull()); 81 ASSERT(!isNull());
80 return m_private->type; 82 return m_private->type;
81 } 83 }
82 84
83 bool WebCryptoKey::extractable() const 85 bool WebCryptoKey::extractable() const
84 { 86 {
85 ASSERT(!isNull()); 87 ASSERT(!isNull());
86 return m_private->extractable; 88 return m_private->extractable;
87 } 89 }
88 90
89 const WebCryptoAlgorithm& WebCryptoKey::algorithm() const 91 const WebCryptoKeyAlgorithm& WebCryptoKey::algorithm() const
90 { 92 {
91 ASSERT(!isNull()); 93 ASSERT(!isNull());
92 return m_private->algorithm; 94 return m_private->algorithm;
93 } 95 }
94 96
95 WebCryptoKeyUsageMask WebCryptoKey::usages() const 97 WebCryptoKeyUsageMask WebCryptoKey::usages() const
96 { 98 {
97 ASSERT(!isNull()); 99 ASSERT(!isNull());
98 return m_private->usages; 100 return m_private->usages;
99 } 101 }
100 102
101 bool WebCryptoKey::isNull() const 103 bool WebCryptoKey::isNull() const
102 { 104 {
103 return m_private.isNull(); 105 return m_private.isNull();
104 } 106 }
105 107
106 void WebCryptoKey::assign(const WebCryptoKey& other) 108 void WebCryptoKey::assign(const WebCryptoKey& other)
107 { 109 {
108 m_private = other.m_private; 110 m_private = other.m_private;
109 } 111 }
110 112
111 void WebCryptoKey::reset() 113 void WebCryptoKey::reset()
112 { 114 {
113 m_private.reset(); 115 m_private.reset();
114 } 116 }
115 117
116 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/exported/WebCryptoAlgorithm.cpp ('k') | Source/platform/exported/WebCryptoKeyAlgorithm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698