| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
| 6 #define CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/platform/WebCrypto.h" | 13 #include "third_party/WebKit/public/platform/WebCrypto.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 namespace webcrypto { | 17 namespace webcrypto { |
| 18 | 18 |
| 19 class AlgorithmImplementation; | 19 class AlgorithmImplementation; |
| 20 class CryptoData; | 20 class CryptoData; |
| 21 class GenerateKeyResult; |
| 21 class Status; | 22 class Status; |
| 22 | 23 |
| 23 // These functions provide an entry point for synchronous webcrypto operations. | 24 // These functions provide an entry point for synchronous webcrypto operations. |
| 24 // | 25 // |
| 25 // The inputs to these methods come from Blink, and hence the validations done | 26 // The inputs to these methods come from Blink, and hence the validations done |
| 26 // by Blink can be assumed: | 27 // by Blink can be assumed: |
| 27 // | 28 // |
| 28 // * The algorithm parameters are consistent with the algorithm | 29 // * The algorithm parameters are consistent with the algorithm |
| 29 // * The key contains the required usage for the operation | 30 // * The key contains the required usage for the operation |
| 30 | 31 |
| 31 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, | 32 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 32 const blink::WebCryptoKey& key, | 33 const blink::WebCryptoKey& key, |
| 33 const CryptoData& data, | 34 const CryptoData& data, |
| 34 std::vector<uint8_t>* buffer); | 35 std::vector<uint8_t>* buffer); |
| 35 | 36 |
| 36 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, | 37 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 37 const blink::WebCryptoKey& key, | 38 const blink::WebCryptoKey& key, |
| 38 const CryptoData& data, | 39 const CryptoData& data, |
| 39 std::vector<uint8_t>* buffer); | 40 std::vector<uint8_t>* buffer); |
| 40 | 41 |
| 41 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, | 42 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
| 42 const CryptoData& data, | 43 const CryptoData& data, |
| 43 std::vector<uint8_t>* buffer); | 44 std::vector<uint8_t>* buffer); |
| 44 | 45 |
| 45 CONTENT_EXPORT Status | 46 CONTENT_EXPORT Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, |
| 46 GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, | 47 bool extractable, |
| 47 bool extractable, | 48 blink::WebCryptoKeyUsageMask usage_mask, |
| 48 blink::WebCryptoKeyUsageMask usage_mask, | 49 GenerateKeyResult* result); |
| 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 | 50 |
| 58 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, | 51 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, |
| 59 const CryptoData& key_data, | 52 const CryptoData& key_data, |
| 60 const blink::WebCryptoAlgorithm& algorithm, | 53 const blink::WebCryptoAlgorithm& algorithm, |
| 61 bool extractable, | 54 bool extractable, |
| 62 blink::WebCryptoKeyUsageMask usage_mask, | 55 blink::WebCryptoKeyUsageMask usage_mask, |
| 63 blink::WebCryptoKey* key); | 56 blink::WebCryptoKey* key); |
| 64 | 57 |
| 65 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, | 58 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, |
| 66 const blink::WebCryptoKey& key, | 59 const blink::WebCryptoKey& key, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 95 blink::WebCryptoKey* key); | 88 blink::WebCryptoKey* key); |
| 96 | 89 |
| 97 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( | 90 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( |
| 98 blink::WebCryptoAlgorithmId algorithm); | 91 blink::WebCryptoAlgorithmId algorithm); |
| 99 | 92 |
| 100 } // namespace webcrypto | 93 } // namespace webcrypto |
| 101 | 94 |
| 102 } // namespace content | 95 } // namespace content |
| 103 | 96 |
| 104 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ | 97 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
| OLD | NEW |