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 blink::WebCrypto
) {
21 const blink::WebCryptoAlgorithm
& algorithm
,
22 const blink::WebCryptoKey
& key
,
23 const unsigned char* data
,
25 blink::WebCryptoResult result
);
27 const blink::WebCryptoAlgorithm
& algorithm
,
28 const blink::WebCryptoKey
& key
,
29 const unsigned char* data
,
31 blink::WebCryptoResult result
);
33 const blink::WebCryptoAlgorithm
& algorithm
,
34 const unsigned char* data
,
36 blink::WebCryptoResult result
);
37 virtual void generateKey(
38 const blink::WebCryptoAlgorithm
& algorithm
,
40 blink::WebCryptoKeyUsageMask usage_mask
,
41 blink::WebCryptoResult result
);
42 virtual void importKey(
43 blink::WebCryptoKeyFormat format
,
44 const unsigned char* key_data
,
45 unsigned key_data_size
,
46 const blink::WebCryptoAlgorithm
& algorithm_or_null
,
48 blink::WebCryptoKeyUsageMask usage_mask
,
49 blink::WebCryptoResult result
);
50 virtual void exportKey(
51 blink::WebCryptoKeyFormat format
,
52 const blink::WebCryptoKey
& key
,
53 blink::WebCryptoResult result
);
55 const blink::WebCryptoAlgorithm
& algorithm
,
56 const blink::WebCryptoKey
& key
,
57 const unsigned char* data
,
59 blink::WebCryptoResult result
);
60 virtual void verifySignature(
61 const blink::WebCryptoAlgorithm
& algorithm
,
62 const blink::WebCryptoKey
& key
,
63 const unsigned char* signature
,
64 unsigned signature_size
,
65 const unsigned char* data
,
67 blink::WebCryptoResult result
);
71 friend class WebCryptoImplTest
;
76 const blink::WebCryptoAlgorithm
& algorithm
,
77 const blink::WebCryptoKey
& key
,
78 const unsigned char* data
,
80 blink::WebArrayBuffer
* buffer
);
82 const blink::WebCryptoAlgorithm
& algorithm
,
83 const blink::WebCryptoKey
& key
,
84 const unsigned char* data
,
86 blink::WebArrayBuffer
* buffer
);
88 const blink::WebCryptoAlgorithm
& algorithm
,
89 const unsigned char* data
,
91 blink::WebArrayBuffer
* buffer
);
92 bool GenerateKeyInternal(
93 const blink::WebCryptoAlgorithm
& algorithm
,
95 blink::WebCryptoKeyUsageMask usage_mask
,
96 blink::WebCryptoKey
* key
);
97 bool GenerateKeyPairInternal(
98 const blink::WebCryptoAlgorithm
& algorithm
,
100 blink::WebCryptoKeyUsageMask usage_mask
,
101 blink::WebCryptoKey
* public_key
,
102 blink::WebCryptoKey
* private_key
);
103 bool ImportKeyInternal(
104 blink::WebCryptoKeyFormat format
,
105 const unsigned char* key_data
,
106 unsigned key_data_size
,
107 const blink::WebCryptoAlgorithm
& algorithm_or_null
,
109 blink::WebCryptoKeyUsageMask usage_mask
,
110 blink::WebCryptoKey
* key
);
111 bool ExportKeyInternal(
112 blink::WebCryptoKeyFormat format
,
113 const blink::WebCryptoKey
& key
,
114 blink::WebArrayBuffer
* buffer
);
116 const blink::WebCryptoAlgorithm
& algorithm
,
117 const blink::WebCryptoKey
& key
,
118 const unsigned char* data
,
120 blink::WebArrayBuffer
* buffer
);
121 bool VerifySignatureInternal(
122 const blink::WebCryptoAlgorithm
& algorithm
,
123 const blink::WebCryptoKey
& key
,
124 const unsigned char* signature
,
125 unsigned signature_size
,
126 const unsigned char* data
,
128 bool* signature_match
);
131 const unsigned char* key_data
,
132 unsigned key_data_size
,
133 const blink::WebCryptoAlgorithm
& algorithm_or_null
,
135 blink::WebCryptoKeyUsageMask usage_mask
,
136 blink::WebCryptoKey
* key
);
137 bool ImportRsaPublicKeyInternal(
138 const unsigned char* modulus_data
,
139 unsigned modulus_size
,
140 const unsigned char* exponent_data
,
141 unsigned exponent_size
,
142 const blink::WebCryptoAlgorithm
& algorithm
,
144 blink::WebCryptoKeyUsageMask usage_mask
,
145 blink::WebCryptoKey
* key
);
148 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl
);
151 } // namespace content
153 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_IMPL_H_