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

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

Issue 757873003: Check that usage isn't empty when generateKey() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and fix bad merges 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/ec_key_openssl.h" 5 #include "content/child/webcrypto/openssl/ec_key_openssl.h"
6 6
7 #include <openssl/ec.h> 7 #include <openssl/ec.h>
8 #include <openssl/ec_key.h> 8 #include <openssl/ec_key.h>
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 #include <openssl/pkcs12.h> 10 #include <openssl/pkcs12.h>
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 Status status = CheckKeyCreationUsages( 211 Status status = CheckKeyCreationUsages(
212 all_public_key_usages_ | all_private_key_usages_, combined_usages); 212 all_public_key_usages_ | all_private_key_usages_, combined_usages);
213 if (status.IsError()) 213 if (status.IsError())
214 return status; 214 return status;
215 215
216 const blink::WebCryptoKeyUsageMask public_usages = 216 const blink::WebCryptoKeyUsageMask public_usages =
217 combined_usages & all_public_key_usages_; 217 combined_usages & all_public_key_usages_;
218 const blink::WebCryptoKeyUsageMask private_usages = 218 const blink::WebCryptoKeyUsageMask private_usages =
219 combined_usages & all_private_key_usages_; 219 combined_usages & all_private_key_usages_;
220 220
221 if (private_usages == 0)
222 return Status::ErrorCreateKeyEmptyUsages();
223
221 const blink::WebCryptoEcKeyGenParams* params = algorithm.ecKeyGenParams(); 224 const blink::WebCryptoEcKeyGenParams* params = algorithm.ecKeyGenParams();
222 225
223 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 226 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
224 227
225 // Generate an EC key pair. 228 // Generate an EC key pair.
226 crypto::ScopedEC_KEY ec_private_key; 229 crypto::ScopedEC_KEY ec_private_key;
227 status = CreateEC_KEY(params->namedCurve(), &ec_private_key); 230 status = CreateEC_KEY(params->namedCurve(), &ec_private_key);
228 if (status.IsError()) 231 if (status.IsError())
229 return status; 232 return status;
230 233
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 key->algorithm().ecParams()->namedCurve()) { 571 key->algorithm().ecParams()->namedCurve()) {
569 return Status::ErrorUnexpected(); 572 return Status::ErrorUnexpected();
570 } 573 }
571 574
572 return Status::Success(); 575 return Status::Success();
573 } 576 }
574 577
575 } // namespace webcrypto 578 } // namespace webcrypto
576 579
577 } // namespace content 580 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/nss/sym_key_nss.cc ('k') | content/child/webcrypto/openssl/rsa_key_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698