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 <cryptohi.h> | 5 #include <cryptohi.h> |
6 #include <pk11pub.h> | 6 #include <pk11pub.h> |
7 #include <secerr.h> | 7 #include <secerr.h> |
8 #include <sechash.h> | 8 #include <sechash.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return status; | 77 return status; |
78 | 78 |
79 return GenerateSecretKeyNss( | 79 return GenerateSecretKeyNss( |
80 blink::WebCryptoKeyAlgorithm::createHmac(hash.id(), keylen_bits), | 80 blink::WebCryptoKeyAlgorithm::createHmac(hash.id(), keylen_bits), |
81 extractable, usages, keylen_bits / 8, mechanism, result); | 81 extractable, usages, keylen_bits / 8, mechanism, result); |
82 } | 82 } |
83 | 83 |
84 Status VerifyKeyUsagesBeforeImportKey( | 84 Status VerifyKeyUsagesBeforeImportKey( |
85 blink::WebCryptoKeyFormat format, | 85 blink::WebCryptoKeyFormat format, |
86 blink::WebCryptoKeyUsageMask usages) const override { | 86 blink::WebCryptoKeyUsageMask usages) const override { |
| 87 bool checkEmptyUsage = true; |
87 switch (format) { | 88 switch (format) { |
88 case blink::WebCryptoKeyFormatRaw: | 89 case blink::WebCryptoKeyFormatRaw: |
89 case blink::WebCryptoKeyFormatJwk: | 90 case blink::WebCryptoKeyFormatJwk: |
90 return CheckKeyCreationUsages(kAllKeyUsages, usages); | 91 return CheckKeyCreationUsages(kAllKeyUsages, usages, checkEmptyUsage); |
91 default: | 92 default: |
92 return Status::ErrorUnsupportedImportKeyFormat(); | 93 return Status::ErrorUnsupportedImportKeyFormat(); |
93 } | 94 } |
94 } | 95 } |
95 | 96 |
96 Status ImportKeyRaw(const CryptoData& key_data, | 97 Status ImportKeyRaw(const CryptoData& key_data, |
97 const blink::WebCryptoAlgorithm& algorithm, | 98 const blink::WebCryptoAlgorithm& algorithm, |
98 bool extractable, | 99 bool extractable, |
99 blink::WebCryptoKeyUsageMask usages, | 100 blink::WebCryptoKeyUsageMask usages, |
100 blink::WebCryptoKey* key) const override { | 101 blink::WebCryptoKey* key) const override { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 237 |
237 } // namespace | 238 } // namespace |
238 | 239 |
239 AlgorithmImplementation* CreatePlatformHmacImplementation() { | 240 AlgorithmImplementation* CreatePlatformHmacImplementation() { |
240 return new HmacImplementation; | 241 return new HmacImplementation; |
241 } | 242 } |
242 | 243 |
243 } // namespace webcrypto | 244 } // namespace webcrypto |
244 | 245 |
245 } // namespace content | 246 } // namespace content |
OLD | NEW |