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

Side by Side Diff: content/renderer/webcrypto/webcrypto_impl.h

Issue 155623005: Refactor to share more code between OpenSSL and NSS implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change header guard Created 6 years, 10 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 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "content/common/content_export.h"
11 #include "third_party/WebKit/public/platform/WebCrypto.h" 10 #include "third_party/WebKit/public/platform/WebCrypto.h"
12 11
13 namespace content { 12 namespace content {
14 namespace webcrypto { class Status; }
15 13
16 class CONTENT_EXPORT WebCryptoImpl 14 // Wrapper around the blink WebCrypto asynchronous interface, which forwards to
17 : NON_EXPORTED_BASE(public blink::WebCrypto) { 15 // the synchronous platfrom (NSS or OpenSSL) implementation.
16 //
17 // TODO(eroman): Post the synchronous work to a background thread.
18 class WebCryptoImpl : public blink::WebCrypto {
18 public: 19 public:
19 WebCryptoImpl(); 20 WebCryptoImpl();
21 virtual ~WebCryptoImpl();
20 22
21 virtual void encrypt( 23 virtual void encrypt(
22 const blink::WebCryptoAlgorithm& algorithm, 24 const blink::WebCryptoAlgorithm& algorithm,
23 const blink::WebCryptoKey& key, 25 const blink::WebCryptoKey& key,
24 const unsigned char* data, 26 const unsigned char* data,
25 unsigned int data_size, 27 unsigned int data_size,
26 blink::WebCryptoResult result); 28 blink::WebCryptoResult result);
27 virtual void decrypt( 29 virtual void decrypt(
28 const blink::WebCryptoAlgorithm& algorithm, 30 const blink::WebCryptoAlgorithm& algorithm,
29 const blink::WebCryptoKey& key, 31 const blink::WebCryptoKey& key,
(...skipping 30 matching lines...) Expand all
60 blink::WebCryptoResult result); 62 blink::WebCryptoResult result);
61 virtual void verifySignature( 63 virtual void verifySignature(
62 const blink::WebCryptoAlgorithm& algorithm, 64 const blink::WebCryptoAlgorithm& algorithm,
63 const blink::WebCryptoKey& key, 65 const blink::WebCryptoKey& key,
64 const unsigned char* signature, 66 const unsigned char* signature,
65 unsigned int signature_size, 67 unsigned int signature_size,
66 const unsigned char* data, 68 const unsigned char* data,
67 unsigned int data_size, 69 unsigned int data_size,
68 blink::WebCryptoResult result); 70 blink::WebCryptoResult result);
69 71
70
71 protected:
72 friend class WebCryptoImplTest;
73
74 void Init();
75
76 webcrypto::Status EncryptInternal(
77 const blink::WebCryptoAlgorithm& algorithm,
78 const blink::WebCryptoKey& key,
79 const unsigned char* data,
80 unsigned int data_size,
81 blink::WebArrayBuffer* buffer);
82 webcrypto::Status DecryptInternal(
83 const blink::WebCryptoAlgorithm& algorithm,
84 const blink::WebCryptoKey& key,
85 const unsigned char* data,
86 unsigned int data_size,
87 blink::WebArrayBuffer* buffer);
88 webcrypto::Status DigestInternal(
89 const blink::WebCryptoAlgorithm& algorithm,
90 const unsigned char* data,
91 unsigned int data_size,
92 blink::WebArrayBuffer* buffer);
93 webcrypto::Status GenerateSecretKeyInternal(
94 const blink::WebCryptoAlgorithm& algorithm,
95 bool extractable,
96 blink::WebCryptoKeyUsageMask usage_mask,
97 blink::WebCryptoKey* key);
98 webcrypto::Status GenerateKeyPairInternal(
99 const blink::WebCryptoAlgorithm& algorithm,
100 bool extractable,
101 blink::WebCryptoKeyUsageMask usage_mask,
102 blink::WebCryptoKey* public_key,
103 blink::WebCryptoKey* private_key);
104 webcrypto::Status ImportKeyInternal(
105 blink::WebCryptoKeyFormat format,
106 const unsigned char* key_data,
107 unsigned int key_data_size,
108 const blink::WebCryptoAlgorithm& algorithm_or_null,
109 bool extractable,
110 blink::WebCryptoKeyUsageMask usage_mask,
111 blink::WebCryptoKey* key);
112 webcrypto::Status ExportKeyInternal(
113 blink::WebCryptoKeyFormat format,
114 const blink::WebCryptoKey& key,
115 blink::WebArrayBuffer* buffer);
116 webcrypto::Status SignInternal(
117 const blink::WebCryptoAlgorithm& algorithm,
118 const blink::WebCryptoKey& key,
119 const unsigned char* data,
120 unsigned int data_size,
121 blink::WebArrayBuffer* buffer);
122 webcrypto::Status VerifySignatureInternal(
123 const blink::WebCryptoAlgorithm& algorithm,
124 const blink::WebCryptoKey& key,
125 const unsigned char* signature,
126 unsigned int signature_size,
127 const unsigned char* data,
128 unsigned int data_size,
129 bool* signature_match);
130
131 webcrypto::Status ImportKeyJwk(
132 const unsigned char* key_data,
133 unsigned int key_data_size,
134 const blink::WebCryptoAlgorithm& algorithm_or_null,
135 bool extractable,
136 blink::WebCryptoKeyUsageMask usage_mask,
137 blink::WebCryptoKey* key);
138 webcrypto::Status ImportRsaPublicKeyInternal(
139 const unsigned char* modulus_data,
140 unsigned int modulus_size,
141 const unsigned char* exponent_data,
142 unsigned int exponent_size,
143 const blink::WebCryptoAlgorithm& algorithm,
144 bool extractable,
145 blink::WebCryptoKeyUsageMask usage_mask,
146 blink::WebCryptoKey* key);
147
148 private: 72 private:
149 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); 73 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl);
150 }; 74 };
151 75
152 } // namespace content 76 } // namespace content
153 77
154 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ 78 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/webcrypto/shared_crypto_unittest.cc ('k') | content/renderer/webcrypto/webcrypto_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698