[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / content / child / webcrypto / webcrypto_impl.h
blob485beb9698d382bb3f28da3ea4f8a39615d82c68
1 // Copyright 2014 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_CHILD_WEBCRYPTO_WEBCRYPTO_IMPL_H_
6 #define CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_IMPL_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "third_party/WebKit/public/platform/WebCrypto.h"
11 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
12 #include "third_party/WebKit/public/platform/WebVector.h"
14 namespace content {
16 // Wrapper around the Blink WebCrypto asynchronous interface, which forwards to
17 // the synchronous platform (NSS or OpenSSL) implementation.
19 // WebCryptoImpl is threadsafe.
21 // EnsureInit() must be called prior to using methods on WebCryptoImpl().
22 class WebCryptoImpl : public blink::WebCrypto {
23 public:
24 WebCryptoImpl();
26 virtual ~WebCryptoImpl();
28 static void EnsureInit();
30 virtual void encrypt(const blink::WebCryptoAlgorithm& algorithm,
31 const blink::WebCryptoKey& key,
32 const unsigned char* data,
33 unsigned int data_size,
34 blink::WebCryptoResult result);
35 virtual void decrypt(const blink::WebCryptoAlgorithm& algorithm,
36 const blink::WebCryptoKey& key,
37 const unsigned char* data,
38 unsigned int data_size,
39 blink::WebCryptoResult result);
40 virtual void digest(const blink::WebCryptoAlgorithm& algorithm,
41 const unsigned char* data,
42 unsigned int data_size,
43 blink::WebCryptoResult result);
44 virtual void generateKey(const blink::WebCryptoAlgorithm& algorithm,
45 bool extractable,
46 blink::WebCryptoKeyUsageMask usage_mask,
47 blink::WebCryptoResult result);
48 virtual void importKey(blink::WebCryptoKeyFormat format,
49 const unsigned char* key_data,
50 unsigned int key_data_size,
51 const blink::WebCryptoAlgorithm& algorithm,
52 bool extractable,
53 blink::WebCryptoKeyUsageMask usage_mask,
54 blink::WebCryptoResult result);
55 virtual void exportKey(blink::WebCryptoKeyFormat format,
56 const blink::WebCryptoKey& key,
57 blink::WebCryptoResult result);
58 virtual void sign(const blink::WebCryptoAlgorithm& algorithm,
59 const blink::WebCryptoKey& key,
60 const unsigned char* data,
61 unsigned int data_size,
62 blink::WebCryptoResult result);
63 virtual void verifySignature(const blink::WebCryptoAlgorithm& algorithm,
64 const blink::WebCryptoKey& key,
65 const unsigned char* signature,
66 unsigned int signature_size,
67 const unsigned char* data,
68 unsigned int data_size,
69 blink::WebCryptoResult result);
70 virtual void wrapKey(blink::WebCryptoKeyFormat format,
71 const blink::WebCryptoKey& key,
72 const blink::WebCryptoKey& wrapping_key,
73 const blink::WebCryptoAlgorithm& wrap_algorithm,
74 blink::WebCryptoResult result);
75 virtual void unwrapKey(
76 blink::WebCryptoKeyFormat format,
77 const unsigned char* wrapped_key,
78 unsigned wrapped_key_size,
79 const blink::WebCryptoKey& wrapping_key,
80 const blink::WebCryptoAlgorithm& unwrap_algorithm,
81 const blink::WebCryptoAlgorithm& unwrapped_key_algorithm,
82 bool extractable,
83 blink::WebCryptoKeyUsageMask usages,
84 blink::WebCryptoResult result);
86 // This method returns a digestor object that can be used to synchronously
87 // compute a digest one chunk at a time. Thus, the consume does not need to
88 // hold onto a large buffer with all the data to digest. Chunks can be given
89 // one at a time and the digest will be computed piecemeal. The allocated
90 // WebCrytpoDigestor that is returned by createDigestor must be freed by the
91 // caller.
92 virtual blink::WebCryptoDigestor* createDigestor(
93 blink::WebCryptoAlgorithmId algorithm_id);
95 virtual bool deserializeKeyForClone(
96 const blink::WebCryptoKeyAlgorithm& algorithm,
97 blink::WebCryptoKeyType type,
98 bool extractable,
99 blink::WebCryptoKeyUsageMask usages,
100 const unsigned char* key_data,
101 unsigned key_data_size,
102 blink::WebCryptoKey& key);
104 virtual bool serializeKeyForClone(const blink::WebCryptoKey& key,
105 blink::WebVector<unsigned char>& key_data);
107 private:
108 DISALLOW_COPY_AND_ASSIGN(WebCryptoImpl);
111 } // namespace content
113 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_IMPL_H_