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 #include <openssl/hmac.h> | 5 #include <openssl/hmac.h> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/numerics/safe_math.h" | 8 #include "base/numerics/safe_math.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/child/webcrypto/algorithm_implementation.h" | 10 #include "content/child/webcrypto/algorithm_implementation.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 return GenerateSecretKeyOpenSsl(blink::WebCryptoKeyAlgorithm::createHmac( | 85 return GenerateSecretKeyOpenSsl(blink::WebCryptoKeyAlgorithm::createHmac( |
86 params->hash().id(), keylen_bits), | 86 params->hash().id(), keylen_bits), |
87 extractable, usages, keylen_bits / 8, | 87 extractable, usages, keylen_bits / 8, |
88 result); | 88 result); |
89 } | 89 } |
90 | 90 |
91 Status VerifyKeyUsagesBeforeImportKey( | 91 Status VerifyKeyUsagesBeforeImportKey( |
92 blink::WebCryptoKeyFormat format, | 92 blink::WebCryptoKeyFormat format, |
93 blink::WebCryptoKeyUsageMask usages) const override { | 93 blink::WebCryptoKeyUsageMask usages) const override { |
| 94 bool checkEmptyUsages = true; |
94 switch (format) { | 95 switch (format) { |
95 case blink::WebCryptoKeyFormatRaw: | 96 case blink::WebCryptoKeyFormatRaw: |
96 case blink::WebCryptoKeyFormatJwk: | 97 case blink::WebCryptoKeyFormatJwk: |
97 return CheckKeyCreationUsages(kAllKeyUsages, usages); | 98 return CheckKeyCreationUsages(kAllKeyUsages, usages, checkEmptyUsages); |
98 default: | 99 default: |
99 return Status::ErrorUnsupportedImportKeyFormat(); | 100 return Status::ErrorUnsupportedImportKeyFormat(); |
100 } | 101 } |
101 } | 102 } |
102 | 103 |
103 Status ImportKeyRaw(const CryptoData& key_data, | 104 Status ImportKeyRaw(const CryptoData& key_data, |
104 const blink::WebCryptoAlgorithm& algorithm, | 105 const blink::WebCryptoAlgorithm& algorithm, |
105 bool extractable, | 106 bool extractable, |
106 blink::WebCryptoKeyUsageMask usages, | 107 blink::WebCryptoKeyUsageMask usages, |
107 blink::WebCryptoKey* key) const override { | 108 blink::WebCryptoKey* key) const override { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 215 |
215 } // namespace | 216 } // namespace |
216 | 217 |
217 AlgorithmImplementation* CreatePlatformHmacImplementation() { | 218 AlgorithmImplementation* CreatePlatformHmacImplementation() { |
218 return new HmacImplementation; | 219 return new HmacImplementation; |
219 } | 220 } |
220 | 221 |
221 } // namespace webcrypto | 222 } // namespace webcrypto |
222 | 223 |
223 } // namespace content | 224 } // namespace content |
OLD | NEW |