Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1446)

Side by Side Diff: content/child/webcrypto/openssl/aes_key_openssl.cc

Issue 777403004: [WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated issues in ecdh tests and other review comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
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, result); 48 extractable, usages, keylen_bits, 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, false);
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 Status AesAlgorithm::GetKeyLength( 132 Status AesAlgorithm::GetKeyLength(
133 const blink::WebCryptoAlgorithm& key_length_algorithm, 133 const blink::WebCryptoAlgorithm& key_length_algorithm,
134 bool* has_length_bits, 134 bool* has_length_bits,
135 unsigned int* length_bits) const { 135 unsigned int* length_bits) const {
136 return GetAesKeyLength(key_length_algorithm, has_length_bits, length_bits); 136 return GetAesKeyLength(key_length_algorithm, has_length_bits, length_bits);
137 } 137 }
138 138
139 } // namespace webcrypto 139 } // namespace webcrypto
140 140
141 } // namespace content 141 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698