OLD | NEW |
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 "content/common/content_export.h" |
11 #include "third_party/WebKit/public/platform/WebCrypto.h" | 11 #include "third_party/WebKit/public/platform/WebCrypto.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 namespace webcrypto { class Status; } | 14 namespace webcrypto { class Status; } |
15 | 15 |
16 class CONTENT_EXPORT WebCryptoImpl | 16 class CONTENT_EXPORT WebCryptoImpl |
17 : NON_EXPORTED_BASE(public blink::WebCrypto) { | 17 : NON_EXPORTED_BASE(public blink::WebCrypto) { |
18 public: | 18 public: |
19 WebCryptoImpl(); | 19 WebCryptoImpl(); |
20 | 20 |
21 virtual void encrypt( | 21 virtual void encrypt( |
22 const blink::WebCryptoAlgorithm& algorithm, | 22 const blink::WebCryptoAlgorithm& algorithm, |
23 const blink::WebCryptoKey& key, | 23 const blink::WebCryptoKey& key, |
24 const unsigned char* data, | 24 const unsigned char* data, |
25 unsigned data_size, | 25 unsigned int data_size, |
26 blink::WebCryptoResult result); | 26 blink::WebCryptoResult result); |
27 virtual void decrypt( | 27 virtual void decrypt( |
28 const blink::WebCryptoAlgorithm& algorithm, | 28 const blink::WebCryptoAlgorithm& algorithm, |
29 const blink::WebCryptoKey& key, | 29 const blink::WebCryptoKey& key, |
30 const unsigned char* data, | 30 const unsigned char* data, |
31 unsigned data_size, | 31 unsigned int data_size, |
32 blink::WebCryptoResult result); | 32 blink::WebCryptoResult result); |
33 virtual void digest( | 33 virtual void digest( |
34 const blink::WebCryptoAlgorithm& algorithm, | 34 const blink::WebCryptoAlgorithm& algorithm, |
35 const unsigned char* data, | 35 const unsigned char* data, |
36 unsigned data_size, | 36 unsigned int data_size, |
37 blink::WebCryptoResult result); | 37 blink::WebCryptoResult result); |
38 virtual void generateKey( | 38 virtual void generateKey( |
39 const blink::WebCryptoAlgorithm& algorithm, | 39 const blink::WebCryptoAlgorithm& algorithm, |
40 bool extractable, | 40 bool extractable, |
41 blink::WebCryptoKeyUsageMask usage_mask, | 41 blink::WebCryptoKeyUsageMask usage_mask, |
42 blink::WebCryptoResult result); | 42 blink::WebCryptoResult result); |
43 virtual void importKey( | 43 virtual void importKey( |
44 blink::WebCryptoKeyFormat format, | 44 blink::WebCryptoKeyFormat format, |
45 const unsigned char* key_data, | 45 const unsigned char* key_data, |
46 unsigned key_data_size, | 46 unsigned int key_data_size, |
47 const blink::WebCryptoAlgorithm& algorithm_or_null, | 47 const blink::WebCryptoAlgorithm& algorithm_or_null, |
48 bool extractable, | 48 bool extractable, |
49 blink::WebCryptoKeyUsageMask usage_mask, | 49 blink::WebCryptoKeyUsageMask usage_mask, |
50 blink::WebCryptoResult result); | 50 blink::WebCryptoResult result); |
51 virtual void exportKey( | 51 virtual void exportKey( |
52 blink::WebCryptoKeyFormat format, | 52 blink::WebCryptoKeyFormat format, |
53 const blink::WebCryptoKey& key, | 53 const blink::WebCryptoKey& key, |
54 blink::WebCryptoResult result); | 54 blink::WebCryptoResult result); |
55 virtual void sign( | 55 virtual void sign( |
56 const blink::WebCryptoAlgorithm& algorithm, | 56 const blink::WebCryptoAlgorithm& algorithm, |
57 const blink::WebCryptoKey& key, | 57 const blink::WebCryptoKey& key, |
58 const unsigned char* data, | 58 const unsigned char* data, |
59 unsigned data_size, | 59 unsigned int data_size, |
60 blink::WebCryptoResult result); | 60 blink::WebCryptoResult result); |
61 virtual void verifySignature( | 61 virtual void verifySignature( |
62 const blink::WebCryptoAlgorithm& algorithm, | 62 const blink::WebCryptoAlgorithm& algorithm, |
63 const blink::WebCryptoKey& key, | 63 const blink::WebCryptoKey& key, |
64 const unsigned char* signature, | 64 const unsigned char* signature, |
65 unsigned signature_size, | 65 unsigned int signature_size, |
66 const unsigned char* data, | 66 const unsigned char* data, |
67 unsigned data_size, | 67 unsigned int data_size, |
68 blink::WebCryptoResult result); | 68 blink::WebCryptoResult result); |
69 | 69 |
70 | 70 |
71 protected: | 71 protected: |
72 friend class WebCryptoImplTest; | 72 friend class WebCryptoImplTest; |
73 | 73 |
74 void Init(); | 74 void Init(); |
75 | 75 |
76 webcrypto::Status EncryptInternal( | 76 webcrypto::Status EncryptInternal( |
77 const blink::WebCryptoAlgorithm& algorithm, | 77 const blink::WebCryptoAlgorithm& algorithm, |
78 const blink::WebCryptoKey& key, | 78 const blink::WebCryptoKey& key, |
79 const unsigned char* data, | 79 const unsigned char* data, |
80 unsigned data_size, | 80 unsigned int data_size, |
81 blink::WebArrayBuffer* buffer); | 81 blink::WebArrayBuffer* buffer); |
82 webcrypto::Status DecryptInternal( | 82 webcrypto::Status DecryptInternal( |
83 const blink::WebCryptoAlgorithm& algorithm, | 83 const blink::WebCryptoAlgorithm& algorithm, |
84 const blink::WebCryptoKey& key, | 84 const blink::WebCryptoKey& key, |
85 const unsigned char* data, | 85 const unsigned char* data, |
86 unsigned data_size, | 86 unsigned int data_size, |
87 blink::WebArrayBuffer* buffer); | 87 blink::WebArrayBuffer* buffer); |
88 webcrypto::Status DigestInternal( | 88 webcrypto::Status DigestInternal( |
89 const blink::WebCryptoAlgorithm& algorithm, | 89 const blink::WebCryptoAlgorithm& algorithm, |
90 const unsigned char* data, | 90 const unsigned char* data, |
91 unsigned data_size, | 91 unsigned int data_size, |
92 blink::WebArrayBuffer* buffer); | 92 blink::WebArrayBuffer* buffer); |
93 webcrypto::Status GenerateSecretKeyInternal( | 93 webcrypto::Status GenerateSecretKeyInternal( |
94 const blink::WebCryptoAlgorithm& algorithm, | 94 const blink::WebCryptoAlgorithm& algorithm, |
95 bool extractable, | 95 bool extractable, |
96 blink::WebCryptoKeyUsageMask usage_mask, | 96 blink::WebCryptoKeyUsageMask usage_mask, |
97 blink::WebCryptoKey* key); | 97 blink::WebCryptoKey* key); |
98 webcrypto::Status GenerateKeyPairInternal( | 98 webcrypto::Status GenerateKeyPairInternal( |
99 const blink::WebCryptoAlgorithm& algorithm, | 99 const blink::WebCryptoAlgorithm& algorithm, |
100 bool extractable, | 100 bool extractable, |
101 blink::WebCryptoKeyUsageMask usage_mask, | 101 blink::WebCryptoKeyUsageMask usage_mask, |
102 blink::WebCryptoKey* public_key, | 102 blink::WebCryptoKey* public_key, |
103 blink::WebCryptoKey* private_key); | 103 blink::WebCryptoKey* private_key); |
104 webcrypto::Status ImportKeyInternal( | 104 webcrypto::Status ImportKeyInternal( |
105 blink::WebCryptoKeyFormat format, | 105 blink::WebCryptoKeyFormat format, |
106 const unsigned char* key_data, | 106 const unsigned char* key_data, |
107 unsigned key_data_size, | 107 unsigned int key_data_size, |
108 const blink::WebCryptoAlgorithm& algorithm_or_null, | 108 const blink::WebCryptoAlgorithm& algorithm_or_null, |
109 bool extractable, | 109 bool extractable, |
110 blink::WebCryptoKeyUsageMask usage_mask, | 110 blink::WebCryptoKeyUsageMask usage_mask, |
111 blink::WebCryptoKey* key); | 111 blink::WebCryptoKey* key); |
112 webcrypto::Status ExportKeyInternal( | 112 webcrypto::Status ExportKeyInternal( |
113 blink::WebCryptoKeyFormat format, | 113 blink::WebCryptoKeyFormat format, |
114 const blink::WebCryptoKey& key, | 114 const blink::WebCryptoKey& key, |
115 blink::WebArrayBuffer* buffer); | 115 blink::WebArrayBuffer* buffer); |
116 webcrypto::Status SignInternal( | 116 webcrypto::Status SignInternal( |
117 const blink::WebCryptoAlgorithm& algorithm, | 117 const blink::WebCryptoAlgorithm& algorithm, |
118 const blink::WebCryptoKey& key, | 118 const blink::WebCryptoKey& key, |
119 const unsigned char* data, | 119 const unsigned char* data, |
120 unsigned data_size, | 120 unsigned int data_size, |
121 blink::WebArrayBuffer* buffer); | 121 blink::WebArrayBuffer* buffer); |
122 webcrypto::Status VerifySignatureInternal( | 122 webcrypto::Status VerifySignatureInternal( |
123 const blink::WebCryptoAlgorithm& algorithm, | 123 const blink::WebCryptoAlgorithm& algorithm, |
124 const blink::WebCryptoKey& key, | 124 const blink::WebCryptoKey& key, |
125 const unsigned char* signature, | 125 const unsigned char* signature, |
126 unsigned signature_size, | 126 unsigned int signature_size, |
127 const unsigned char* data, | 127 const unsigned char* data, |
128 unsigned data_size, | 128 unsigned int data_size, |
129 bool* signature_match); | 129 bool* signature_match); |
130 | 130 |
131 webcrypto::Status ImportKeyJwk( | 131 webcrypto::Status ImportKeyJwk( |
132 const unsigned char* key_data, | 132 const unsigned char* key_data, |
133 unsigned key_data_size, | 133 unsigned int key_data_size, |
134 const blink::WebCryptoAlgorithm& algorithm_or_null, | 134 const blink::WebCryptoAlgorithm& algorithm_or_null, |
135 bool extractable, | 135 bool extractable, |
136 blink::WebCryptoKeyUsageMask usage_mask, | 136 blink::WebCryptoKeyUsageMask usage_mask, |
137 blink::WebCryptoKey* key); | 137 blink::WebCryptoKey* key); |
138 webcrypto::Status ImportRsaPublicKeyInternal( | 138 webcrypto::Status ImportRsaPublicKeyInternal( |
139 const unsigned char* modulus_data, | 139 const unsigned char* modulus_data, |
140 unsigned modulus_size, | 140 unsigned int modulus_size, |
141 const unsigned char* exponent_data, | 141 const unsigned char* exponent_data, |
142 unsigned exponent_size, | 142 unsigned int exponent_size, |
143 const blink::WebCryptoAlgorithm& algorithm, | 143 const blink::WebCryptoAlgorithm& algorithm, |
144 bool extractable, | 144 bool extractable, |
145 blink::WebCryptoKeyUsageMask usage_mask, | 145 blink::WebCryptoKeyUsageMask usage_mask, |
146 blink::WebCryptoKey* key); | 146 blink::WebCryptoKey* key); |
147 | 147 |
148 private: | 148 private: |
149 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); | 149 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); |
150 }; | 150 }; |
151 | 151 |
152 } // namespace content | 152 } // namespace content |
153 | 153 |
154 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ | 154 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ |
OLD | NEW |