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 16 matching lines...) Expand all Loading... | |
27 blink::WebCryptoKeyUsageDecrypt | | 27 blink::WebCryptoKeyUsageDecrypt | |
28 blink::WebCryptoKeyUsageWrapKey | | 28 blink::WebCryptoKeyUsageWrapKey | |
29 blink::WebCryptoKeyUsageUnwrapKey), | 29 blink::WebCryptoKeyUsageUnwrapKey), |
30 jwk_suffix_(jwk_suffix) { | 30 jwk_suffix_(jwk_suffix) { |
31 } | 31 } |
32 | 32 |
33 Status AesAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, | 33 Status AesAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, |
34 bool extractable, | 34 bool extractable, |
35 blink::WebCryptoKeyUsageMask usages, | 35 blink::WebCryptoKeyUsageMask usages, |
36 GenerateKeyResult* result) const { | 36 GenerateKeyResult* result) const { |
37 Status status = CheckKeyCreationUsages(all_key_usages_, usages); | 37 Status status = CheckKeyCreationUsages(all_key_usages_, usages, false); |
eroman
2014/12/09 21:04:46
Same comment as before, let's do the empty usage c
Habib Virji
2014/12/15 18:48:55
Done.
| |
38 if (status.IsError()) | 38 if (status.IsError()) |
39 return status; | 39 return status; |
40 | 40 |
41 unsigned int keylen_bits; | 41 unsigned int keylen_bits; |
42 status = GetAesKeyGenLengthInBits(algorithm.aesKeyGenParams(), &keylen_bits); | 42 status = GetAesKeyGenLengthInBits(algorithm.aesKeyGenParams(), &keylen_bits); |
43 if (status.IsError()) | 43 if (status.IsError()) |
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 switch (format) { | 54 switch (format) { |
55 case blink::WebCryptoKeyFormatRaw: | 55 case blink::WebCryptoKeyFormatRaw: |
56 case blink::WebCryptoKeyFormatJwk: | 56 case blink::WebCryptoKeyFormatJwk: |
57 return CheckKeyCreationUsages(all_key_usages_, usages); | 57 return CheckKeyCreationUsages(all_key_usages_, usages, true); |
58 default: | 58 default: |
59 return Status::ErrorUnsupportedImportKeyFormat(); | 59 return Status::ErrorUnsupportedImportKeyFormat(); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, | 63 Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, |
64 const blink::WebCryptoAlgorithm& algorithm, | 64 const blink::WebCryptoAlgorithm& algorithm, |
65 bool extractable, | 65 bool extractable, |
66 blink::WebCryptoKeyUsageMask usages, | 66 blink::WebCryptoKeyUsageMask usages, |
67 blink::WebCryptoKey* key) const { | 67 blink::WebCryptoKey* key) const { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 blink::WebCryptoKeyUsageMask usages, | 125 blink::WebCryptoKeyUsageMask usages, |
126 const CryptoData& key_data, | 126 const CryptoData& key_data, |
127 blink::WebCryptoKey* key) const { | 127 blink::WebCryptoKey* key) const { |
128 return ImportKeyRaw(key_data, CreateAlgorithm(algorithm.id()), extractable, | 128 return ImportKeyRaw(key_data, CreateAlgorithm(algorithm.id()), extractable, |
129 usages, key); | 129 usages, key); |
130 } | 130 } |
131 | 131 |
132 } // namespace webcrypto | 132 } // namespace webcrypto |
133 | 133 |
134 } // namespace content | 134 } // namespace content |
OLD | NEW |