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 | 14 |
15 class CONTENT_EXPORT WebCryptoImpl | 15 class CONTENT_EXPORT WebCryptoImpl |
16 : NON_EXPORTED_BASE(public WebKit::WebCrypto) { | 16 : NON_EXPORTED_BASE(public blink::WebCrypto) { |
17 public: | 17 public: |
18 WebCryptoImpl(); | 18 WebCryptoImpl(); |
19 | 19 |
20 virtual void encrypt( | 20 virtual void encrypt( |
21 const WebKit::WebCryptoAlgorithm& algorithm, | 21 const blink::WebCryptoAlgorithm& algorithm, |
22 const WebKit::WebCryptoKey& key, | 22 const blink::WebCryptoKey& key, |
23 const unsigned char* data, | 23 const unsigned char* data, |
24 unsigned data_size, | 24 unsigned data_size, |
25 WebKit::WebCryptoResult result); | 25 blink::WebCryptoResult result); |
26 virtual void decrypt( | 26 virtual void decrypt( |
27 const WebKit::WebCryptoAlgorithm& algorithm, | 27 const blink::WebCryptoAlgorithm& algorithm, |
28 const WebKit::WebCryptoKey& key, | 28 const blink::WebCryptoKey& key, |
29 const unsigned char* data, | 29 const unsigned char* data, |
30 unsigned data_size, | 30 unsigned data_size, |
31 WebKit::WebCryptoResult result); | 31 blink::WebCryptoResult result); |
32 virtual void digest( | 32 virtual void digest( |
33 const WebKit::WebCryptoAlgorithm& algorithm, | 33 const blink::WebCryptoAlgorithm& algorithm, |
34 const unsigned char* data, | 34 const unsigned char* data, |
35 unsigned data_size, | 35 unsigned data_size, |
36 WebKit::WebCryptoResult result); | 36 blink::WebCryptoResult result); |
37 virtual void generateKey( | 37 virtual void generateKey( |
38 const WebKit::WebCryptoAlgorithm& algorithm, | 38 const blink::WebCryptoAlgorithm& algorithm, |
39 bool extractable, | 39 bool extractable, |
40 WebKit::WebCryptoKeyUsageMask usage_mask, | 40 blink::WebCryptoKeyUsageMask usage_mask, |
41 WebKit::WebCryptoResult result); | 41 blink::WebCryptoResult result); |
42 virtual void importKey( | 42 virtual void importKey( |
43 WebKit::WebCryptoKeyFormat format, | 43 blink::WebCryptoKeyFormat format, |
44 const unsigned char* key_data, | 44 const unsigned char* key_data, |
45 unsigned key_data_size, | 45 unsigned key_data_size, |
46 const WebKit::WebCryptoAlgorithm& algorithm_or_null, | 46 const blink::WebCryptoAlgorithm& algorithm_or_null, |
47 bool extractable, | 47 bool extractable, |
48 WebKit::WebCryptoKeyUsageMask usage_mask, | 48 blink::WebCryptoKeyUsageMask usage_mask, |
49 WebKit::WebCryptoResult result); | 49 blink::WebCryptoResult result); |
50 virtual void sign( | 50 virtual void sign( |
51 const WebKit::WebCryptoAlgorithm& algorithm, | 51 const blink::WebCryptoAlgorithm& algorithm, |
52 const WebKit::WebCryptoKey& key, | 52 const blink::WebCryptoKey& key, |
53 const unsigned char* data, | 53 const unsigned char* data, |
54 unsigned data_size, | 54 unsigned data_size, |
55 WebKit::WebCryptoResult result); | 55 blink::WebCryptoResult result); |
56 virtual void verifySignature( | 56 virtual void verifySignature( |
57 const WebKit::WebCryptoAlgorithm& algorithm, | 57 const blink::WebCryptoAlgorithm& algorithm, |
58 const WebKit::WebCryptoKey& key, | 58 const blink::WebCryptoKey& key, |
59 const unsigned char* signature, | 59 const unsigned char* signature, |
60 unsigned signature_size, | 60 unsigned signature_size, |
61 const unsigned char* data, | 61 const unsigned char* data, |
62 unsigned data_size, | 62 unsigned data_size, |
63 WebKit::WebCryptoResult result); | 63 blink::WebCryptoResult result); |
64 | 64 |
65 static void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size); | 65 static void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned new_size); |
66 | 66 |
67 protected: | 67 protected: |
68 friend class WebCryptoImplTest; | 68 friend class WebCryptoImplTest; |
69 | 69 |
70 void Init(); | 70 void Init(); |
71 | 71 |
72 bool EncryptInternal( | 72 bool EncryptInternal( |
73 const WebKit::WebCryptoAlgorithm& algorithm, | 73 const blink::WebCryptoAlgorithm& algorithm, |
74 const WebKit::WebCryptoKey& key, | 74 const blink::WebCryptoKey& key, |
75 const unsigned char* data, | 75 const unsigned char* data, |
76 unsigned data_size, | 76 unsigned data_size, |
77 WebKit::WebArrayBuffer* buffer); | 77 blink::WebArrayBuffer* buffer); |
78 bool DecryptInternal( | 78 bool DecryptInternal( |
79 const WebKit::WebCryptoAlgorithm& algorithm, | 79 const blink::WebCryptoAlgorithm& algorithm, |
80 const WebKit::WebCryptoKey& key, | 80 const blink::WebCryptoKey& key, |
81 const unsigned char* data, | 81 const unsigned char* data, |
82 unsigned data_size, | 82 unsigned data_size, |
83 WebKit::WebArrayBuffer* buffer); | 83 blink::WebArrayBuffer* buffer); |
84 bool DigestInternal( | 84 bool DigestInternal( |
85 const WebKit::WebCryptoAlgorithm& algorithm, | 85 const blink::WebCryptoAlgorithm& algorithm, |
86 const unsigned char* data, | 86 const unsigned char* data, |
87 unsigned data_size, | 87 unsigned data_size, |
88 WebKit::WebArrayBuffer* buffer); | 88 blink::WebArrayBuffer* buffer); |
89 bool GenerateKeyInternal( | 89 bool GenerateKeyInternal( |
90 const WebKit::WebCryptoAlgorithm& algorithm, | 90 const blink::WebCryptoAlgorithm& algorithm, |
91 bool extractable, | 91 bool extractable, |
92 WebKit::WebCryptoKeyUsageMask usage_mask, | 92 blink::WebCryptoKeyUsageMask usage_mask, |
93 WebKit::WebCryptoKey* key); | 93 blink::WebCryptoKey* key); |
94 bool GenerateKeyPairInternal( | 94 bool GenerateKeyPairInternal( |
95 const WebKit::WebCryptoAlgorithm& algorithm, | 95 const blink::WebCryptoAlgorithm& algorithm, |
96 bool extractable, | 96 bool extractable, |
97 WebKit::WebCryptoKeyUsageMask usage_mask, | 97 blink::WebCryptoKeyUsageMask usage_mask, |
98 WebKit::WebCryptoKey* public_key, | 98 blink::WebCryptoKey* public_key, |
99 WebKit::WebCryptoKey* private_key); | 99 blink::WebCryptoKey* private_key); |
100 bool ImportKeyInternal( | 100 bool ImportKeyInternal( |
101 WebKit::WebCryptoKeyFormat format, | 101 blink::WebCryptoKeyFormat format, |
102 const unsigned char* key_data, | 102 const unsigned char* key_data, |
103 unsigned key_data_size, | 103 unsigned key_data_size, |
104 const WebKit::WebCryptoAlgorithm& algorithm_or_null, | 104 const blink::WebCryptoAlgorithm& algorithm_or_null, |
105 bool extractable, | 105 bool extractable, |
106 WebKit::WebCryptoKeyUsageMask usage_mask, | 106 blink::WebCryptoKeyUsageMask usage_mask, |
107 WebKit::WebCryptoKey* key); | 107 blink::WebCryptoKey* key); |
108 bool SignInternal( | 108 bool SignInternal( |
109 const WebKit::WebCryptoAlgorithm& algorithm, | 109 const blink::WebCryptoAlgorithm& algorithm, |
110 const WebKit::WebCryptoKey& key, | 110 const blink::WebCryptoKey& key, |
111 const unsigned char* data, | 111 const unsigned char* data, |
112 unsigned data_size, | 112 unsigned data_size, |
113 WebKit::WebArrayBuffer* buffer); | 113 blink::WebArrayBuffer* buffer); |
114 bool VerifySignatureInternal( | 114 bool VerifySignatureInternal( |
115 const WebKit::WebCryptoAlgorithm& algorithm, | 115 const blink::WebCryptoAlgorithm& algorithm, |
116 const WebKit::WebCryptoKey& key, | 116 const blink::WebCryptoKey& key, |
117 const unsigned char* signature, | 117 const unsigned char* signature, |
118 unsigned signature_size, | 118 unsigned signature_size, |
119 const unsigned char* data, | 119 const unsigned char* data, |
120 unsigned data_size, | 120 unsigned data_size, |
121 bool* signature_match); | 121 bool* signature_match); |
122 | 122 |
123 private: | 123 private: |
124 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); | 124 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); |
125 }; | 125 }; |
126 | 126 |
127 } // namespace content | 127 } // namespace content |
128 | 128 |
129 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ | 129 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ |
OLD | NEW |