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

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: Fix for openssl 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" 10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/WebKit/public/platform/WebCrypto.h" 11 #include "third_party/WebKit/public/platform/WebCrypto.h"
12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
12 13
13 namespace content { 14 namespace content {
14 namespace webcrypto { class Status; }
15 15
16 class CONTENT_EXPORT WebCryptoImpl 16 namespace webcrypto {
17 : NON_EXPORTED_BASE(public blink::WebCrypto) { 17 class PlatformCrypto;
18 }
19
20 class WebCryptoImpl : public blink::WebCrypto {
18 public: 21 public:
19 WebCryptoImpl(); 22 WebCryptoImpl();
23 virtual ~WebCryptoImpl();
20 24
21 virtual void encrypt( 25 virtual void encrypt(
22 const blink::WebCryptoAlgorithm& algorithm, 26 const blink::WebCryptoAlgorithm& algorithm,
23 const blink::WebCryptoKey& key, 27 const blink::WebCryptoKey& key,
24 const unsigned char* data, 28 const unsigned char* data,
25 unsigned int data_size, 29 unsigned int data_size,
26 blink::WebCryptoResult result); 30 blink::WebCryptoResult result);
27 virtual void decrypt( 31 virtual void decrypt(
28 const blink::WebCryptoAlgorithm& algorithm, 32 const blink::WebCryptoAlgorithm& algorithm,
29 const blink::WebCryptoKey& key, 33 const blink::WebCryptoKey& key,
(...skipping 30 matching lines...) Expand all
60 blink::WebCryptoResult result); 64 blink::WebCryptoResult result);
61 virtual void verifySignature( 65 virtual void verifySignature(
62 const blink::WebCryptoAlgorithm& algorithm, 66 const blink::WebCryptoAlgorithm& algorithm,
63 const blink::WebCryptoKey& key, 67 const blink::WebCryptoKey& key,
64 const unsigned char* signature, 68 const unsigned char* signature,
65 unsigned int signature_size, 69 unsigned int signature_size,
66 const unsigned char* data, 70 const unsigned char* data,
67 unsigned int data_size, 71 unsigned int data_size,
68 blink::WebCryptoResult result); 72 blink::WebCryptoResult result);
69 73
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: 74 private:
149 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); 75 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl);
76
77 scoped_ptr<webcrypto::PlatformCrypto> crypto_;
150 }; 78 };
151 79
152 } // namespace content 80 } // namespace content
153 81
154 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ 82 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698