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 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 const blink::WebCryptoAlgorithm& algorithm, | 85 const blink::WebCryptoAlgorithm& algorithm, |
86 bool extractable, | 86 bool extractable, |
87 blink::WebCryptoKeyUsageMask usages, | 87 blink::WebCryptoKeyUsageMask usages, |
88 blink::WebCryptoKey* key); | 88 blink::WebCryptoKey* key); |
89 | 89 |
90 CONTENT_EXPORT Status DeriveBits(const blink::WebCryptoAlgorithm& algorithm, | 90 CONTENT_EXPORT Status DeriveBits(const blink::WebCryptoAlgorithm& algorithm, |
91 const blink::WebCryptoKey& base_key, | 91 const blink::WebCryptoKey& base_key, |
92 unsigned int length_bits, | 92 unsigned int length_bits, |
93 std::vector<uint8_t>* derived_bytes); | 93 std::vector<uint8_t>* derived_bytes); |
94 | 94 |
| 95 // Derives a key by calling the underlying deriveBits/getKeyLength/importKey |
| 96 // operations. |
| 97 // |
| 98 // Note that whereas the WebCrypto spec uses a single "derivedKeyType" |
| 99 // AlgorithmIdentifier in its specification of deriveKey(), here two separate |
| 100 // AlgorithmIdentifiers are used: |
| 101 // |
| 102 // * |import_algorithm| -- The parameters required by the derived key's |
| 103 // "importKey" operation. |
| 104 // |
| 105 // * |key_length_algorithm| -- The parameters required by the derived key's |
| 106 // "get key length" operation. |
| 107 // |
| 108 // WebCryptoAlgorithm is not a flexible type like AlgorithmIdentifier (it cannot |
| 109 // be easily re-interpreted as a different parameter type). |
| 110 // |
| 111 // Therefore being provided with separate parameter types for the import |
| 112 // parameters and the key length parameters simplifies passing the right |
| 113 // parameters onto ImportKey() and GetKeyLength() respectively. |
| 114 CONTENT_EXPORT Status |
| 115 DeriveKey(const blink::WebCryptoAlgorithm& algorithm, |
| 116 const blink::WebCryptoKey& base_key, |
| 117 const blink::WebCryptoAlgorithm& import_algorithm, |
| 118 const blink::WebCryptoAlgorithm& key_length_algorithm, |
| 119 bool extractable, |
| 120 blink::WebCryptoKeyUsageMask usages, |
| 121 blink::WebCryptoKey* derived_key); |
| 122 |
95 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( | 123 CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( |
96 blink::WebCryptoAlgorithmId algorithm); | 124 blink::WebCryptoAlgorithmId algorithm); |
97 | 125 |
98 CONTENT_EXPORT bool SerializeKeyForClone(const blink::WebCryptoKey& key, | 126 CONTENT_EXPORT bool SerializeKeyForClone(const blink::WebCryptoKey& key, |
99 blink::WebVector<uint8_t>* key_data); | 127 blink::WebVector<uint8_t>* key_data); |
100 | 128 |
101 CONTENT_EXPORT bool DeserializeKeyForClone( | 129 CONTENT_EXPORT bool DeserializeKeyForClone( |
102 const blink::WebCryptoKeyAlgorithm& algorithm, | 130 const blink::WebCryptoKeyAlgorithm& algorithm, |
103 blink::WebCryptoKeyType type, | 131 blink::WebCryptoKeyType type, |
104 bool extractable, | 132 bool extractable, |
105 blink::WebCryptoKeyUsageMask usages, | 133 blink::WebCryptoKeyUsageMask usages, |
106 const CryptoData& key_data, | 134 const CryptoData& key_data, |
107 blink::WebCryptoKey* key); | 135 blink::WebCryptoKey* key); |
108 | 136 |
109 } // namespace webcrypto | 137 } // namespace webcrypto |
110 | 138 |
111 } // namespace content | 139 } // namespace content |
112 | 140 |
113 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ | 141 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_ |
OLD | NEW |