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

Side by Side Diff: content/child/webcrypto/nss/sym_key_nss.cc

Issue 751883002: Revert of Check that usage isn't empty when generateKey() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/nss/sym_key_nss.h" 5 #include "content/child/webcrypto/nss/sym_key_nss.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/generate_key_result.h" 9 #include "content/child/webcrypto/generate_key_result.h"
10 #include "content/child/webcrypto/nss/key_nss.h" 10 #include "content/child/webcrypto/nss/key_nss.h"
11 #include "content/child/webcrypto/nss/util_nss.h" 11 #include "content/child/webcrypto/nss/util_nss.h"
12 #include "content/child/webcrypto/status.h" 12 #include "content/child/webcrypto/status.h"
13 #include "content/child/webcrypto/webcrypto_util.h" 13 #include "content/child/webcrypto/webcrypto_util.h"
14 #include "crypto/scoped_nss_types.h" 14 #include "crypto/scoped_nss_types.h"
15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 namespace webcrypto { 19 namespace webcrypto {
20 20
21 Status GenerateSecretKeyNss(const blink::WebCryptoKeyAlgorithm& algorithm, 21 Status GenerateSecretKeyNss(const blink::WebCryptoKeyAlgorithm& algorithm,
22 bool extractable, 22 bool extractable,
23 blink::WebCryptoKeyUsageMask usages, 23 blink::WebCryptoKeyUsageMask usages,
24 unsigned keylen_bytes, 24 unsigned keylen_bytes,
25 CK_MECHANISM_TYPE mechanism, 25 CK_MECHANISM_TYPE mechanism,
26 GenerateKeyResult* result) { 26 GenerateKeyResult* result) {
27 DCHECK_NE(CKM_INVALID_MECHANISM, mechanism); 27 DCHECK_NE(CKM_INVALID_MECHANISM, mechanism);
28 28
29 if (usages == 0)
30 return Status::ErrorCreateKeyEmptyUsages();
31
32 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot()); 29 crypto::ScopedPK11Slot slot(PK11_GetInternalKeySlot());
33 if (!slot) 30 if (!slot)
34 return Status::OperationError(); 31 return Status::OperationError();
35 32
36 crypto::ScopedPK11SymKey pk11_key( 33 crypto::ScopedPK11SymKey pk11_key(
37 PK11_KeyGen(slot.get(), mechanism, NULL, keylen_bytes, NULL)); 34 PK11_KeyGen(slot.get(), mechanism, NULL, keylen_bytes, NULL));
38 35
39 if (!pk11_key) 36 if (!pk11_key)
40 return Status::OperationError(); 37 return Status::OperationError();
41 38
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 blink::WebCryptoKeyTypeSecret, 85 blink::WebCryptoKeyTypeSecret,
89 extractable, 86 extractable,
90 algorithm, 87 algorithm,
91 usages); 88 usages);
92 return Status::Success(); 89 return Status::Success();
93 } 90 }
94 91
95 } // namespace webcrypto 92 } // namespace webcrypto
96 93
97 } // namespace content 94 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/nss/rsa_key_nss.cc ('k') | content/child/webcrypto/openssl/ec_key_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698