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 "content/child/webcrypto/openssl/aes_key_openssl.h" | 5 #include "content/child/webcrypto/openssl/aes_key_openssl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" |
9 #include "content/child/webcrypto/jwk.h" | 9 #include "content/child/webcrypto/jwk.h" |
10 #include "content/child/webcrypto/openssl/key_openssl.h" | 10 #include "content/child/webcrypto/openssl/key_openssl.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return status; | 44 return status; |
45 | 45 |
46 return GenerateSecretKeyOpenSsl( | 46 return GenerateSecretKeyOpenSsl( |
47 blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits), | 47 blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits), |
48 extractable, usages, keylen_bits / 8, result); | 48 extractable, usages, keylen_bits / 8, result); |
49 } | 49 } |
50 | 50 |
51 Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey( | 51 Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey( |
52 blink::WebCryptoKeyFormat format, | 52 blink::WebCryptoKeyFormat format, |
53 blink::WebCryptoKeyUsageMask usages) const { | 53 blink::WebCryptoKeyUsageMask usages) const { |
| 54 bool checkEmptyUsage = true; |
54 switch (format) { | 55 switch (format) { |
55 case blink::WebCryptoKeyFormatRaw: | 56 case blink::WebCryptoKeyFormatRaw: |
56 case blink::WebCryptoKeyFormatJwk: | 57 case blink::WebCryptoKeyFormatJwk: |
57 return CheckKeyCreationUsages(all_key_usages_, usages); | 58 return CheckKeyCreationUsages(all_key_usages_, usages, checkEmptyUsage); |
58 default: | 59 default: |
59 return Status::ErrorUnsupportedImportKeyFormat(); | 60 return Status::ErrorUnsupportedImportKeyFormat(); |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, | 64 Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, |
64 const blink::WebCryptoAlgorithm& algorithm, | 65 const blink::WebCryptoAlgorithm& algorithm, |
65 bool extractable, | 66 bool extractable, |
66 blink::WebCryptoKeyUsageMask usages, | 67 blink::WebCryptoKeyUsageMask usages, |
67 blink::WebCryptoKey* key) const { | 68 blink::WebCryptoKey* key) const { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 blink::WebCryptoKeyUsageMask usages, | 126 blink::WebCryptoKeyUsageMask usages, |
126 const CryptoData& key_data, | 127 const CryptoData& key_data, |
127 blink::WebCryptoKey* key) const { | 128 blink::WebCryptoKey* key) const { |
128 return ImportKeyRaw(key_data, CreateAlgorithm(algorithm.id()), extractable, | 129 return ImportKeyRaw(key_data, CreateAlgorithm(algorithm.id()), extractable, |
129 usages, key); | 130 usages, key); |
130 } | 131 } |
131 | 132 |
132 } // namespace webcrypto | 133 } // namespace webcrypto |
133 | 134 |
134 } // namespace content | 135 } // namespace content |
OLD | NEW |