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_ALGORITHM_DISPATCH_H_
6 #define CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
13 #include "third_party/WebKit/public/platform/WebCrypto.h"
19 class AlgorithmImplementation
;
23 // These functions provide an entry point for synchronous webcrypto operations.
25 // The inputs to these methods come from Blink, and hence the validations done
26 // by Blink can be assumed:
28 // * The algorithm parameters are consistent with the algorithm
29 // * The key contains the required usage for the operation
31 CONTENT_EXPORT Status
Encrypt(const blink::WebCryptoAlgorithm
& algorithm
,
32 const blink::WebCryptoKey
& key
,
33 const CryptoData
& data
,
34 std::vector
<uint8_t>* buffer
);
36 CONTENT_EXPORT Status
Decrypt(const blink::WebCryptoAlgorithm
& algorithm
,
37 const blink::WebCryptoKey
& key
,
38 const CryptoData
& data
,
39 std::vector
<uint8_t>* buffer
);
41 CONTENT_EXPORT Status
Digest(const blink::WebCryptoAlgorithm
& algorithm
,
42 const CryptoData
& data
,
43 std::vector
<uint8_t>* buffer
);
46 GenerateSecretKey(const blink::WebCryptoAlgorithm
& algorithm
,
48 blink::WebCryptoKeyUsageMask usage_mask
,
49 blink::WebCryptoKey
* key
);
52 GenerateKeyPair(const blink::WebCryptoAlgorithm
& algorithm
,
54 blink::WebCryptoKeyUsageMask usage_mask
,
55 blink::WebCryptoKey
* public_key
,
56 blink::WebCryptoKey
* private_key
);
58 CONTENT_EXPORT Status
ImportKey(blink::WebCryptoKeyFormat format
,
59 const CryptoData
& key_data
,
60 const blink::WebCryptoAlgorithm
& algorithm
,
62 blink::WebCryptoKeyUsageMask usage_mask
,
63 blink::WebCryptoKey
* key
);
65 CONTENT_EXPORT Status
ExportKey(blink::WebCryptoKeyFormat format
,
66 const blink::WebCryptoKey
& key
,
67 std::vector
<uint8_t>* buffer
);
69 CONTENT_EXPORT Status
Sign(const blink::WebCryptoAlgorithm
& algorithm
,
70 const blink::WebCryptoKey
& key
,
71 const CryptoData
& data
,
72 std::vector
<uint8_t>* buffer
);
74 CONTENT_EXPORT Status
Verify(const blink::WebCryptoAlgorithm
& algorithm
,
75 const blink::WebCryptoKey
& key
,
76 const CryptoData
& signature
,
77 const CryptoData
& data
,
78 bool* signature_match
);
81 WrapKey(blink::WebCryptoKeyFormat format
,
82 const blink::WebCryptoKey
& key_to_wrap
,
83 const blink::WebCryptoKey
& wrapping_key
,
84 const blink::WebCryptoAlgorithm
& wrapping_algorithm
,
85 std::vector
<uint8_t>* buffer
);
88 UnwrapKey(blink::WebCryptoKeyFormat format
,
89 const CryptoData
& wrapped_key_data
,
90 const blink::WebCryptoKey
& wrapping_key
,
91 const blink::WebCryptoAlgorithm
& wrapping_algorithm
,
92 const blink::WebCryptoAlgorithm
& algorithm
,
94 blink::WebCryptoKeyUsageMask usage_mask
,
95 blink::WebCryptoKey
* key
);
97 CONTENT_EXPORT scoped_ptr
<blink::WebCryptoDigestor
> CreateDigestor(
98 blink::WebCryptoAlgorithmId algorithm
);
100 } // namespace webcrypto
102 } // namespace content
104 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_