| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 TruncateToBitLength(optional_length_bits, derived_bytes); | 98 TruncateToBitLength(optional_length_bits, derived_bytes); |
| 99 return Status::Success(); | 99 return Status::Success(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, | 102 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, |
| 103 blink::WebCryptoKeyType type, | 103 blink::WebCryptoKeyType type, |
| 104 bool extractable, | 104 bool extractable, |
| 105 blink::WebCryptoKeyUsageMask usages, | 105 blink::WebCryptoKeyUsageMask usages, |
| 106 const CryptoData& key_data, | 106 const CryptoData& key_data, |
| 107 blink::WebCryptoKey* key) const override { | 107 blink::WebCryptoKey* key) const override { |
| 108 if (algorithm.paramsType() != blink::WebCryptoKeyAlgorithmParamsTypeNone || |
| 109 type != blink::WebCryptoKeyTypeSecret) |
| 110 return Status::ErrorUnexpected(); |
| 111 |
| 108 // NOTE: Unlike ImportKeyRaw(), this does not enforce extractable==false. | 112 // NOTE: Unlike ImportKeyRaw(), this does not enforce extractable==false. |
| 109 // This is intentional. Although keys cannot currently be created with | 113 // This is intentional. Although keys cannot currently be created with |
| 110 // extractable==true, earlier implementations permitted this, so | 114 // extractable==true, earlier implementations permitted this, so |
| 111 // de-serialization by structured clone should not reject them. | 115 // de-serialization by structured clone should not reject them. |
| 112 return CreateWebCryptoSecretKey(key_data, algorithm, extractable, usages, | 116 return CreateWebCryptoSecretKey(key_data, algorithm, extractable, usages, |
| 113 key); | 117 key); |
| 114 } | 118 } |
| 115 | 119 |
| 116 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, | 120 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, |
| 117 bool* has_length_bits, | 121 bool* has_length_bits, |
| 118 unsigned int* length_bits) const override { | 122 unsigned int* length_bits) const override { |
| 119 *has_length_bits = false; | 123 *has_length_bits = false; |
| 120 return Status::Success(); | 124 return Status::Success(); |
| 121 } | 125 } |
| 122 }; | 126 }; |
| 123 | 127 |
| 124 } // namespace | 128 } // namespace |
| 125 | 129 |
| 126 std::unique_ptr<AlgorithmImplementation> CreateHkdfImplementation() { | 130 std::unique_ptr<AlgorithmImplementation> CreateHkdfImplementation() { |
| 127 return base::WrapUnique(new HkdfImplementation); | 131 return base::WrapUnique(new HkdfImplementation); |
| 128 } | 132 } |
| 129 | 133 |
| 130 } // namespace webcrypto | 134 } // namespace webcrypto |
| OLD | NEW |