Chromium Code Reviews| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
|
Ryan Sleevi
2014/07/18 23:02:54
Update to stdint
| |
| 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 Status; | 21 class Status; |
| 22 | 22 |
| 23 // These functions provide an entry point for synchronous webcrypto operations. | 23 // These functions provide an entry point for synchronous webcrypto operations. |
| 24 // | 24 // |
| 25 // The inputs to these methods come from Blink, and hence the validations done | 25 // The inputs to these methods come from Blink, and hence the validations done |
| 26 // by Blink can be assumed: | 26 // by Blink can be assumed: |
| 27 // | 27 // |
| 28 // * The algorithm parameters are consistent with the algorithm | 28 // * The algorithm parameters are consistent with the algorithm |
| 29 // * The key contains the required usage for the operation | 29 // * The key contains the required usage for the operation |
| 30 | 30 |
| 31 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, | 31 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 32 const blink::WebCryptoKey& key, | 32 const blink::WebCryptoKey& key, |
| 33 const CryptoData& data, | 33 const CryptoData& data, |
| 34 std::vector<uint8>* buffer); | 34 std::vector<uint8_t>* buffer); |
| 35 | 35 |
| 36 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, | 36 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 37 const blink::WebCryptoKey& key, | 37 const blink::WebCryptoKey& key, |
| 38 const CryptoData& data, | 38 const CryptoData& data, |
| 39 std::vector<uint8>* buffer); | 39 std::vector<uint8_t>* buffer); |
| 40 | 40 |
| 41 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, | 41 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, |
| 42 const CryptoData& data, | 42 const CryptoData& data, |
| 43 std::vector<uint8>* buffer); | 43 std::vector<uint8_t>* buffer); |
| 44 | 44 |
| 45 CONTENT_EXPORT Status | 45 CONTENT_EXPORT Status |
| 46 GenerateSecretKey(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 blink::WebCryptoKey* key); | 49 blink::WebCryptoKey* key); |
| 50 | 50 |
| 51 CONTENT_EXPORT Status | 51 CONTENT_EXPORT Status |
| 52 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, | 52 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, |
| 53 bool extractable, | 53 bool extractable, |
| 54 blink::WebCryptoKeyUsageMask usage_mask, | 54 blink::WebCryptoKeyUsageMask usage_mask, |
| 55 blink::WebCryptoKey* public_key, | 55 blink::WebCryptoKey* public_key, |
| 56 blink::WebCryptoKey* private_key); | 56 blink::WebCryptoKey* private_key); |
| 57 | 57 |
| 58 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, | 58 CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, |
| 59 const CryptoData& key_data, | 59 const CryptoData& key_data, |
| 60 const blink::WebCryptoAlgorithm& algorithm, | 60 const blink::WebCryptoAlgorithm& algorithm, |
| 61 bool extractable, | 61 bool extractable, |
| 62 blink::WebCryptoKeyUsageMask usage_mask, | 62 blink::WebCryptoKeyUsageMask usage_mask, |
| 63 blink::WebCryptoKey* key); | 63 blink::WebCryptoKey* key); |
| 64 | 64 |
| 65 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, | 65 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, |
| 66 const blink::WebCryptoKey& key, | 66 const blink::WebCryptoKey& key, |
| 67 std::vector<uint8>* buffer); | 67 std::vector<uint8_t>* buffer); |
| 68 | 68 |
| 69 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm, | 69 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm, |
| 70 const blink::WebCryptoKey& key, | 70 const blink::WebCryptoKey& key, |
| 71 const CryptoData& data, | 71 const CryptoData& data, |
| 72 std::vector<uint8>* buffer); | 72 std::vector<uint8_t>* buffer); |
| 73 | 73 |
| 74 CONTENT_EXPORT Status Verify(const blink::WebCryptoAlgorithm& algorithm, | 74 CONTENT_EXPORT Status Verify(const blink::WebCryptoAlgorithm& algorithm, |
| 75 const blink::WebCryptoKey& key, | 75 const blink::WebCryptoKey& key, |
| 76 const CryptoData& signature, | 76 const CryptoData& signature, |
| 77 const CryptoData& data, | 77 const CryptoData& data, |
| 78 bool* signature_match); | 78 bool* signature_match); |
| 79 | 79 |
| 80 CONTENT_EXPORT Status | 80 CONTENT_EXPORT Status |
| 81 WrapKey(blink::WebCryptoKeyFormat format, | 81 WrapKey(blink::WebCryptoKeyFormat format, |
| 82 const blink::WebCryptoKey& key_to_wrap, | 82 const blink::WebCryptoKey& key_to_wrap, |
| 83 const blink::WebCryptoKey& wrapping_key, | 83 const blink::WebCryptoKey& wrapping_key, |
| 84 const blink::WebCryptoAlgorithm& wrapping_algorithm, | 84 const blink::WebCryptoAlgorithm& wrapping_algorithm, |
| 85 std::vector<uint8>* buffer); | 85 std::vector<uint8_t>* buffer); |
| 86 | 86 |
| 87 CONTENT_EXPORT Status | 87 CONTENT_EXPORT Status |
| 88 UnwrapKey(blink::WebCryptoKeyFormat format, | 88 UnwrapKey(blink::WebCryptoKeyFormat format, |
| 89 const CryptoData& wrapped_key_data, | 89 const CryptoData& wrapped_key_data, |
| 90 const blink::WebCryptoKey& wrapping_key, | 90 const blink::WebCryptoKey& wrapping_key, |
| 91 const blink::WebCryptoAlgorithm& wrapping_algorithm, | 91 const blink::WebCryptoAlgorithm& wrapping_algorithm, |
| 92 const blink::WebCryptoAlgorithm& algorithm, | 92 const blink::WebCryptoAlgorithm& algorithm, |
| 93 bool extractable, | 93 bool extractable, |
| 94 blink::WebCryptoKeyUsageMask usage_mask, | 94 blink::WebCryptoKeyUsageMask usage_mask, |
| 95 blink::WebCryptoKey* key); | 95 blink::WebCryptoKey* key); |
| 96 | 96 |
| 97 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( | 97 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( |
| 98 blink::WebCryptoAlgorithmId algorithm); | 98 blink::WebCryptoAlgorithmId algorithm); |
| 99 | 99 |
| 100 } // namespace webcrypto | 100 } // namespace webcrypto |
| 101 | 101 |
| 102 } // namespace content | 102 } // namespace content |
| 103 | 103 |
| 104 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ | 104 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
| OLD | NEW |