OLD | NEW |
---|---|
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 17 matching lines...) Expand all Loading... | |
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 WebCrypto_h | 31 #ifndef WebCrypto_h |
32 #define WebCrypto_h | 32 #define WebCrypto_h |
33 | 33 |
34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
35 #include "WebCryptoKey.h" | 35 #include "WebCryptoKey.h" |
36 #include "WebPrivatePtr.h" | 36 #include "WebPrivatePtr.h" |
37 | 37 |
38 namespace WebCore { class CryptoResult; } | |
39 | |
38 namespace WebKit { | 40 namespace WebKit { |
39 | 41 |
40 class WebArrayBuffer; | 42 class WebArrayBuffer; |
41 class WebCryptoOperation; | 43 class WebCryptoOperation; |
42 | 44 |
43 class WebCryptoResultPrivate { | |
44 public: | |
45 virtual void ref() = 0; | |
46 virtual void deref() = 0; | |
47 | |
48 virtual void completeWithError() = 0; | |
49 virtual void completeWithBuffer(const WebArrayBuffer&) = 0; | |
50 virtual void completeWithBoolean(bool) = 0; | |
51 virtual void completeWithKey(const WebCryptoKey&) = 0; | |
52 | |
53 protected: | |
54 virtual ~WebCryptoResultPrivate() { } | |
55 }; | |
56 | |
57 class WebCryptoResult { | 45 class WebCryptoResult { |
58 public: | 46 public: |
59 explicit WebCryptoResult(WebCryptoResultPrivate* impl) | 47 #if WEBKIT_IMPLEMENTATION |
60 { | 48 explicit WebCryptoResult(WebCore::CryptoResult* impl) : m_impl(impl) { } |
jamesr
2013/08/24 02:02:26
nit: this is slightly more commonly done with Pass
eroman
2013/08/27 19:00:06
Done.
| |
61 assign(impl); | 49 #endif |
62 } | |
63 | 50 |
64 WebCryptoResult(const WebCryptoResult& o) | 51 WebCryptoResult(const WebCryptoResult& o) |
65 { | 52 { |
66 assign(o); | 53 assign(o); |
67 } | 54 } |
68 | 55 |
69 ~WebCryptoResult() | 56 ~WebCryptoResult() |
70 { | 57 { |
71 reset(); | 58 reset(); |
72 } | 59 } |
73 | 60 |
74 WebCryptoResult& operator=(const WebCryptoResult& o) | 61 WebCryptoResult& operator=(const WebCryptoResult& o) |
75 { | 62 { |
76 assign(o); | 63 assign(o); |
77 return *this; | 64 return *this; |
78 } | 65 } |
79 | 66 |
80 WEBKIT_EXPORT void completeWithError(); | 67 WEBKIT_EXPORT void completeWithError(); |
81 WEBKIT_EXPORT void completeWithBuffer(const WebArrayBuffer&); | 68 WEBKIT_EXPORT void completeWithBuffer(const WebArrayBuffer&); |
82 WEBKIT_EXPORT void completeWithBuffer(const void*, size_t); | 69 WEBKIT_EXPORT void completeWithBuffer(const void*, size_t); |
83 WEBKIT_EXPORT void completeWithBoolean(bool); | 70 WEBKIT_EXPORT void completeWithBoolean(bool); |
84 WEBKIT_EXPORT void completeWithKey(const WebCryptoKey&); | 71 WEBKIT_EXPORT void completeWithKey(const WebCryptoKey&); |
85 | 72 |
86 private: | 73 private: |
87 WEBKIT_EXPORT void reset(); | 74 WEBKIT_EXPORT void reset(); |
88 WEBKIT_EXPORT void assign(const WebCryptoResult&); | 75 WEBKIT_EXPORT void assign(const WebCryptoResult&); |
89 WEBKIT_EXPORT void assign(WebCryptoResultPrivate*); | |
90 | 76 |
91 WebPrivatePtr<WebCryptoResultPrivate> m_impl; | 77 WebPrivatePtr<WebCore::CryptoResult> m_impl; |
92 }; | 78 }; |
93 | 79 |
94 class WebCrypto { | 80 class WebCrypto { |
95 public: | 81 public: |
96 // FIXME: Deprecated, delete once chromium side is updated. | 82 // FIXME: Deprecated, delete once chromium side is updated. |
97 virtual WebCryptoOperation* digest(const WebCryptoAlgorithm&) { WEBKIT_ASSER T_NOT_REACHED(); return 0; } | 83 virtual WebCryptoOperation* digest(const WebCryptoAlgorithm&) { WEBKIT_ASSER T_NOT_REACHED(); return 0; } |
98 | 84 |
99 // Starts a one-shot cryptographic operation which can complete either | 85 // Starts a one-shot cryptographic operation which can complete either |
100 // synchronously, or asynchronously. | 86 // synchronously, or asynchronously. |
101 // | 87 // |
102 // Let the WebCryptoResult be called "result". | 88 // Let the WebCryptoResult be called "result". |
103 // | 89 // |
104 // The result should be set exactly once, from the same thread which | 90 // The result should be set exactly once, from the same thread which |
105 // initiated the operation. | 91 // initiated the operation. |
106 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACH ED(); } | 92 virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACH ED(); } |
107 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACH ED(); } | 93 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACH ED(); } |
108 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED( ); } | 94 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED( ); } |
109 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, size_t signature_size, const unsigned char* dat a, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } | 95 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, size_t signature_size, const unsigned char* dat a, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
110 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, si ze_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } | 96 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, si ze_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
111 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } | 97 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
112 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, siz e_t keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageM ask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } | 98 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, siz e_t keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageM ask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
113 | 99 |
114 protected: | 100 protected: |
115 virtual ~WebCrypto() { } | 101 virtual ~WebCrypto() { } |
116 }; | 102 }; |
117 | 103 |
118 } // namespace WebKit | 104 } // namespace WebKit |
119 | 105 |
120 #endif | 106 #endif |
OLD | NEW |