Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "components/webcrypto/algorithm_implementation.h" | 9 #include "components/webcrypto/algorithm_implementation.h" |
| 10 #include "components/webcrypto/algorithms/secret_key_util.h" | 10 #include "components/webcrypto/algorithms/secret_key_util.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 } | 103 } |
| 104 return Status::Success(); | 104 return Status::Success(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, | 107 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, |
| 108 blink::WebCryptoKeyType type, | 108 blink::WebCryptoKeyType type, |
| 109 bool extractable, | 109 bool extractable, |
| 110 blink::WebCryptoKeyUsageMask usages, | 110 blink::WebCryptoKeyUsageMask usages, |
| 111 const CryptoData& key_data, | 111 const CryptoData& key_data, |
| 112 blink::WebCryptoKey* key) const override { | 112 blink::WebCryptoKey* key) const override { |
| 113 if (algorithm.paramsType() != blink::WebCryptoKeyAlgorithmParamsTypeNone) | |
| 114 return Status::ErrorUnexpected(); | |
| 115 | |
|
eroman
2016/11/30 19:15:50
Can you also add a test for:
type == WebCryptoK
| |
| 113 // NOTE: Unlike ImportKeyRaw(), this does not enforce extractable==false. | 116 // NOTE: Unlike ImportKeyRaw(), this does not enforce extractable==false. |
| 114 // This is intentional. Although keys cannot currently be created with | 117 // This is intentional. Although keys cannot currently be created with |
| 115 // extractable==true, earlier implementations permitted this, so | 118 // extractable==true, earlier implementations permitted this, so |
| 116 // de-serialization by structured clone should not reject them. | 119 // de-serialization by structured clone should not reject them. |
| 117 return CreateWebCryptoSecretKey(key_data, algorithm, extractable, usages, | 120 return CreateWebCryptoSecretKey(key_data, algorithm, extractable, usages, |
| 118 key); | 121 key); |
| 119 } | 122 } |
| 120 | 123 |
| 121 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, | 124 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, |
| 122 bool* has_length_bits, | 125 bool* has_length_bits, |
| 123 unsigned int* length_bits) const override { | 126 unsigned int* length_bits) const override { |
| 124 *has_length_bits = false; | 127 *has_length_bits = false; |
| 125 return Status::Success(); | 128 return Status::Success(); |
| 126 } | 129 } |
| 127 }; | 130 }; |
| 128 | 131 |
| 129 } // namespace | 132 } // namespace |
| 130 | 133 |
| 131 std::unique_ptr<AlgorithmImplementation> CreatePbkdf2Implementation() { | 134 std::unique_ptr<AlgorithmImplementation> CreatePbkdf2Implementation() { |
| 132 return base::WrapUnique(new Pbkdf2Implementation); | 135 return base::WrapUnique(new Pbkdf2Implementation); |
| 133 } | 136 } |
| 134 | 137 |
| 135 } // namespace webcrypto | 138 } // namespace webcrypto |
| OLD | NEW |