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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "content/common/content_export.h"
11 #include "third_party/WebKit/public/platform/WebCrypto.h"
15 class CONTENT_EXPORT WebCryptoImpl
16 : NON_EXPORTED_BASE(public WebKit::WebCrypto) {
21 const WebKit::WebCryptoAlgorithm& algorithm,
22 const WebKit::WebCryptoKey& key,
23 const unsigned char* data,
25 WebKit::WebCryptoResult result);
27 const WebKit::WebCryptoAlgorithm& algorithm,
28 const WebKit::WebCryptoKey& key,
29 const unsigned char* data,
31 WebKit::WebCryptoResult result);
33 const WebKit::WebCryptoAlgorithm& algorithm,
34 const unsigned char* data,
36 WebKit::WebCryptoResult result);
37 virtual void generateKey(
38 const WebKit::WebCryptoAlgorithm& algorithm,
40 WebKit::WebCryptoKeyUsageMask usage_mask,
41 WebKit::WebCryptoResult result);
42 virtual void importKey(
43 WebKit::WebCryptoKeyFormat format,
44 const unsigned char* key_data,
45 unsigned key_data_size,
46 const WebKit::WebCryptoAlgorithm& algorithm_or_null,
48 WebKit::WebCryptoKeyUsageMask usage_mask,
49 WebKit::WebCryptoResult result);
51 const WebKit::WebCryptoAlgorithm& algorithm,
52 const WebKit::WebCryptoKey& key,
53 const unsigned char* data,
55 WebKit::WebCryptoResult result);
56 virtual void verifySignature(
57 const WebKit::WebCryptoAlgorithm& algorithm,
58 const WebKit::WebCryptoKey& key,
59 const unsigned char* signature,
60 unsigned signature_size,
61 const unsigned char* data,
63 WebKit::WebCryptoResult result);
65 static void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size);
66 static WebKit::WebCryptoKey NullKey();
69 friend class WebCryptoImplTest;
74 const WebKit::WebCryptoAlgorithm& algorithm,
75 const WebKit::WebCryptoKey& key,
76 const unsigned char* data,
78 WebKit::WebArrayBuffer* buffer);
80 const WebKit::WebCryptoAlgorithm& algorithm,
81 const WebKit::WebCryptoKey& key,
82 const unsigned char* data,
84 WebKit::WebArrayBuffer* buffer);
86 const WebKit::WebCryptoAlgorithm& algorithm,
87 const unsigned char* data,
89 WebKit::WebArrayBuffer* buffer);
90 bool GenerateKeyInternal(
91 const WebKit::WebCryptoAlgorithm& algorithm,
93 WebKit::WebCryptoKeyUsageMask usage_mask,
94 WebKit::WebCryptoKey* key);
95 bool GenerateKeyPairInternal(
96 const WebKit::WebCryptoAlgorithm& algorithm,
98 WebKit::WebCryptoKeyUsageMask usage_mask,
99 WebKit::WebCryptoKey* public_key,
100 WebKit::WebCryptoKey* private_key);
101 bool ImportKeyInternal(
102 WebKit::WebCryptoKeyFormat format,
103 const unsigned char* key_data,
104 unsigned key_data_size,
105 const WebKit::WebCryptoAlgorithm& algorithm_or_null,
107 WebKit::WebCryptoKeyUsageMask usage_mask,
108 WebKit::WebCryptoKey* key);
110 const WebKit::WebCryptoAlgorithm& algorithm,
111 const WebKit::WebCryptoKey& key,
112 const unsigned char* data,
114 WebKit::WebArrayBuffer* buffer);
115 bool VerifySignatureInternal(
116 const WebKit::WebCryptoAlgorithm& algorithm,
117 const WebKit::WebCryptoKey& key,
118 const unsigned char* signature,
119 unsigned signature_size,
120 const unsigned char* data,
122 bool* signature_match);
125 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl);
128 } // namespace content
130 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_