OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
| 6 #define CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/platform/WebCrypto.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 namespace webcrypto { |
| 18 |
| 19 class AlgorithmImplementation; |
| 20 class CryptoData; |
| 21 class Status; |
| 22 |
| 23 // These functions provide an entry point for synchronous webcrypto operations. |
| 24 // |
| 25 // The inputs to these methods come from Blink, and hence the validations done |
| 26 // by Blink can be assumed: |
| 27 // |
| 28 // * The algorithm parameters are consistent with the algorithm |
| 29 // * The key contains the required usage for the operation |
| 30 |
| 31 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 32 const blink::WebCryptoKey& key, |
| 33 const CryptoData& data, |
| 34 std::vector<uint8>* buffer); |
| 35 |
| 36 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 37 const blink::WebCryptoKey& key, |
| 38 const CryptoData& data, |
| 39 std::vector<uint8>* buffer); |
| 40 |
| 41 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
| 42 const CryptoData& data, |
| 43 std::vector<uint8>* buffer); |
| 44 |
| 45 CONTENT_EXPORT Status |
| 46 GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, |
| 47 bool extractable, |
| 48 blink::WebCryptoKeyUsageMask usage_mask, |
| 49 blink::WebCryptoKey* key); |
| 50 |
| 51 CONTENT_EXPORT Status |
| 52 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, |
| 53 bool extractable, |
| 54 blink::WebCryptoKeyUsageMask usage_mask, |
| 55 blink::WebCryptoKey* public_key, |
| 56 blink::WebCryptoKey* private_key); |
| 57 |
| 58 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, |
| 59 const CryptoData& key_data, |
| 60 const blink::WebCryptoAlgorithm& algorithm, |
| 61 bool extractable, |
| 62 blink::WebCryptoKeyUsageMask usage_mask, |
| 63 blink::WebCryptoKey* key); |
| 64 |
| 65 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, |
| 66 const blink::WebCryptoKey& key, |
| 67 std::vector<uint8>* buffer); |
| 68 |
| 69 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm, |
| 70 const blink::WebCryptoKey& key, |
| 71 const CryptoData& data, |
| 72 std::vector<uint8>* buffer); |
| 73 |
| 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); |
| 79 |
| 80 CONTENT_EXPORT Status |
| 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>* buffer); |
| 86 |
| 87 CONTENT_EXPORT Status |
| 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, |
| 93 bool extractable, |
| 94 blink::WebCryptoKeyUsageMask usage_mask, |
| 95 blink::WebCryptoKey* key); |
| 96 |
| 97 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( |
| 98 blink::WebCryptoAlgorithmId algorithm); |
| 99 |
| 100 } // namespace webcrypto |
| 101 |
| 102 } // namespace content |
| 103 |
| 104 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
OLD | NEW |