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 "base/memory/scoped_ptr.h" | |
11 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
12 #include "third_party/WebKit/public/platform/WebCrypto.h" | 11 #include "third_party/WebKit/public/platform/WebCrypto.h" |
13 | 12 |
14 namespace content { | 13 namespace content { |
15 | 14 |
16 class CONTENT_EXPORT WebCryptoImpl | 15 class CONTENT_EXPORT WebCryptoImpl |
17 : NON_EXPORTED_BASE(public WebKit::WebCrypto) { | 16 : NON_EXPORTED_BASE(public WebKit::WebCrypto) { |
18 public: | 17 public: |
19 WebCryptoImpl(); | 18 WebCryptoImpl(); |
20 | 19 |
(...skipping 10 matching lines...) Expand all Loading... |
31 unsigned data_size, | 30 unsigned data_size, |
32 WebKit::WebCryptoResult result); | 31 WebKit::WebCryptoResult result); |
33 virtual void digest( | 32 virtual void digest( |
34 const WebKit::WebCryptoAlgorithm& algorithm, | 33 const WebKit::WebCryptoAlgorithm& algorithm, |
35 const unsigned char* data, | 34 const unsigned char* data, |
36 unsigned data_size, | 35 unsigned data_size, |
37 WebKit::WebCryptoResult result); | 36 WebKit::WebCryptoResult result); |
38 virtual void generateKey( | 37 virtual void generateKey( |
39 const WebKit::WebCryptoAlgorithm& algorithm, | 38 const WebKit::WebCryptoAlgorithm& algorithm, |
40 bool extractable, | 39 bool extractable, |
41 WebKit::WebCryptoKeyUsageMask usage, | 40 WebKit::WebCryptoKeyUsageMask usage_mask, |
42 WebKit::WebCryptoResult result); | 41 WebKit::WebCryptoResult result); |
43 virtual void importKey( | 42 virtual void importKey( |
44 WebKit::WebCryptoKeyFormat format, | 43 WebKit::WebCryptoKeyFormat format, |
45 const unsigned char* key_data, | 44 const unsigned char* key_data, |
46 unsigned key_data_size, | 45 unsigned key_data_size, |
47 const WebKit::WebCryptoAlgorithm& algorithm, | 46 const WebKit::WebCryptoAlgorithm& algorithm_or_null, |
48 bool extractable, | 47 bool extractable, |
49 WebKit::WebCryptoKeyUsageMask usage_mask, | 48 WebKit::WebCryptoKeyUsageMask usage_mask, |
50 WebKit::WebCryptoResult result); | 49 WebKit::WebCryptoResult result); |
51 virtual void sign( | 50 virtual void sign( |
52 const WebKit::WebCryptoAlgorithm& algorithm, | 51 const WebKit::WebCryptoAlgorithm& algorithm, |
53 const WebKit::WebCryptoKey& key, | 52 const WebKit::WebCryptoKey& key, |
54 const unsigned char* data, | 53 const unsigned char* data, |
55 unsigned data_size, | 54 unsigned data_size, |
56 WebKit::WebCryptoResult result); | 55 WebKit::WebCryptoResult result); |
57 virtual void verifySignature( | 56 virtual void verifySignature( |
58 const WebKit::WebCryptoAlgorithm& algorithm, | 57 const WebKit::WebCryptoAlgorithm& algorithm, |
59 const WebKit::WebCryptoKey& key, | 58 const WebKit::WebCryptoKey& key, |
60 const unsigned char* signature, | 59 const unsigned char* signature, |
61 unsigned signature_size, | 60 unsigned signature_size, |
62 const unsigned char* data, | 61 const unsigned char* data, |
63 unsigned data_size, | 62 unsigned data_size, |
64 WebKit::WebCryptoResult result); | 63 WebKit::WebCryptoResult result); |
65 | 64 |
66 static void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size); | 65 static void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size); |
| 66 static WebKit::WebCryptoKey NullKey(); |
67 | 67 |
68 protected: | 68 protected: |
69 friend class WebCryptoImplTest; | 69 friend class WebCryptoImplTest; |
70 | 70 |
71 void Init(); | 71 void Init(); |
72 | 72 |
73 bool EncryptInternal( | 73 bool EncryptInternal( |
74 const WebKit::WebCryptoAlgorithm& algorithm, | 74 const WebKit::WebCryptoAlgorithm& algorithm, |
75 const WebKit::WebCryptoKey& key, | 75 const WebKit::WebCryptoKey& key, |
76 const unsigned char* data, | 76 const unsigned char* data, |
77 unsigned data_size, | 77 unsigned data_size, |
78 WebKit::WebArrayBuffer* buffer); | 78 WebKit::WebArrayBuffer* buffer); |
79 bool DecryptInternal( | 79 bool DecryptInternal( |
80 const WebKit::WebCryptoAlgorithm& algorithm, | 80 const WebKit::WebCryptoAlgorithm& algorithm, |
81 const WebKit::WebCryptoKey& key, | 81 const WebKit::WebCryptoKey& key, |
82 const unsigned char* data, | 82 const unsigned char* data, |
83 unsigned data_size, | 83 unsigned data_size, |
84 WebKit::WebArrayBuffer* buffer); | 84 WebKit::WebArrayBuffer* buffer); |
85 bool DigestInternal( | 85 bool DigestInternal( |
86 const WebKit::WebCryptoAlgorithm& algorithm, | 86 const WebKit::WebCryptoAlgorithm& algorithm, |
87 const unsigned char* data, | 87 const unsigned char* data, |
88 unsigned data_size, | 88 unsigned data_size, |
89 WebKit::WebArrayBuffer* buffer); | 89 WebKit::WebArrayBuffer* buffer); |
90 bool GenerateKeyInternal( | 90 bool GenerateKeyInternal( |
91 const WebKit::WebCryptoAlgorithm& algorithm, | 91 const WebKit::WebCryptoAlgorithm& algorithm, |
92 scoped_ptr<WebKit::WebCryptoKeyHandle>* key, | 92 bool extractable, |
93 WebKit::WebCryptoKeyType* type); | 93 WebKit::WebCryptoKeyUsageMask usage_mask, |
| 94 WebKit::WebCryptoKey* key); |
94 bool ImportKeyInternal( | 95 bool ImportKeyInternal( |
95 WebKit::WebCryptoKeyFormat format, | 96 WebKit::WebCryptoKeyFormat format, |
96 const unsigned char* key_data, | 97 const unsigned char* key_data, |
97 unsigned key_data_size, | 98 unsigned key_data_size, |
98 const WebKit::WebCryptoAlgorithm& algorithm, | 99 const WebKit::WebCryptoAlgorithm& algorithm_or_null, |
| 100 bool extractable, |
99 WebKit::WebCryptoKeyUsageMask usage_mask, | 101 WebKit::WebCryptoKeyUsageMask usage_mask, |
100 scoped_ptr<WebKit::WebCryptoKeyHandle>* handle, | 102 WebKit::WebCryptoKey* key); |
101 WebKit::WebCryptoKeyType* type); | |
102 bool SignInternal( | 103 bool SignInternal( |
103 const WebKit::WebCryptoAlgorithm& algorithm, | 104 const WebKit::WebCryptoAlgorithm& algorithm, |
104 const WebKit::WebCryptoKey& key, | 105 const WebKit::WebCryptoKey& key, |
105 const unsigned char* data, | 106 const unsigned char* data, |
106 unsigned data_size, | 107 unsigned data_size, |
107 WebKit::WebArrayBuffer* buffer); | 108 WebKit::WebArrayBuffer* buffer); |
108 bool VerifySignatureInternal( | 109 bool VerifySignatureInternal( |
109 const WebKit::WebCryptoAlgorithm& algorithm, | 110 const WebKit::WebCryptoAlgorithm& algorithm, |
110 const WebKit::WebCryptoKey& key, | 111 const WebKit::WebCryptoKey& key, |
111 const unsigned char* signature, | 112 const unsigned char* signature, |
112 unsigned signature_size, | 113 unsigned signature_size, |
113 const unsigned char* data, | 114 const unsigned char* data, |
114 unsigned data_size, | 115 unsigned data_size, |
115 bool* signature_match); | 116 bool* signature_match); |
116 | 117 |
117 private: | 118 private: |
118 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); | 119 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl); |
119 }; | 120 }; |
120 | 121 |
121 } // namespace content | 122 } // namespace content |
122 | 123 |
123 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ | 124 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_ |
OLD | NEW |