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

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

Issue 745443002: 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, 1 month 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"
(...skipping 25 matching lines...) Expand all
36 if (!pk11_key) 36 if (!pk11_key)
37 return Status::OperationError(); 37 return Status::OperationError();
38 38
39 if (PK11_ExtractKeyValue(pk11_key.get()) != SECSuccess) 39 if (PK11_ExtractKeyValue(pk11_key.get()) != SECSuccess)
40 return Status::OperationError(); 40 return Status::OperationError();
41 41
42 const SECItem* key_data = PK11_GetKeyData(pk11_key.get()); 42 const SECItem* key_data = PK11_GetKeyData(pk11_key.get());
43 if (!key_data) 43 if (!key_data)
44 return Status::OperationError(); 44 return Status::OperationError();
45 45
46 if (usages == 0)
47 return Status::ErrorCreateKeyEmptyUsages();
eroman 2014/11/21 23:35:34 Please move this towards the top of the function (
nharper 2014/11/22 00:26:45 Done.
48
46 scoped_ptr<SymKeyNss> handle(new SymKeyNss( 49 scoped_ptr<SymKeyNss> handle(new SymKeyNss(
47 pk11_key.Pass(), CryptoData(key_data->data, key_data->len))); 50 pk11_key.Pass(), CryptoData(key_data->data, key_data->len)));
48 51
49 result->AssignSecretKey( 52 result->AssignSecretKey(
50 blink::WebCryptoKey::create(handle.release(), 53 blink::WebCryptoKey::create(handle.release(),
51 blink::WebCryptoKeyTypeSecret, 54 blink::WebCryptoKeyTypeSecret,
52 extractable, 55 extractable,
53 algorithm, 56 algorithm,
54 usages)); 57 usages));
55 58
(...skipping 29 matching lines...) Expand all
85 blink::WebCryptoKeyTypeSecret, 88 blink::WebCryptoKeyTypeSecret,
86 extractable, 89 extractable,
87 algorithm, 90 algorithm,
88 usages); 91 usages);
89 return Status::Success(); 92 return Status::Success();
90 } 93 }
91 94
92 } // namespace webcrypto 95 } // namespace webcrypto
93 96
94 } // namespace content 97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698