| 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/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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 return Status::Success(); | 202 return Status::Success(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| 206 | 206 |
| 207 Status EcAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, | 207 Status EcAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, |
| 208 bool extractable, | 208 bool extractable, |
| 209 blink::WebCryptoKeyUsageMask combined_usages, | 209 blink::WebCryptoKeyUsageMask combined_usages, |
| 210 GenerateKeyResult* result) const { | 210 GenerateKeyResult* result) const { |
| 211 Status status = CheckKeyCreationUsages( | 211 blink::WebCryptoKeyUsageMask public_usages = 0; |
| 212 all_public_key_usages_ | all_private_key_usages_, combined_usages); | 212 blink::WebCryptoKeyUsageMask private_usages = 0; |
| 213 |
| 214 Status status = GetUsagesForGenerateAsymmetricKey( |
| 215 all_public_key_usages_, all_private_key_usages_, combined_usages, |
| 216 &public_usages, &private_usages); |
| 213 if (status.IsError()) | 217 if (status.IsError()) |
| 214 return status; | 218 return status; |
| 215 | 219 |
| 216 const blink::WebCryptoKeyUsageMask public_usages = | |
| 217 combined_usages & all_public_key_usages_; | |
| 218 const blink::WebCryptoKeyUsageMask private_usages = | |
| 219 combined_usages & all_private_key_usages_; | |
| 220 | |
| 221 if (private_usages == 0) | |
| 222 return Status::ErrorCreateKeyEmptyUsages(); | |
| 223 | |
| 224 const blink::WebCryptoEcKeyGenParams* params = algorithm.ecKeyGenParams(); | 220 const blink::WebCryptoEcKeyGenParams* params = algorithm.ecKeyGenParams(); |
| 225 | 221 |
| 226 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 222 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 227 | 223 |
| 228 // Generate an EC key pair. | 224 // Generate an EC key pair. |
| 229 crypto::ScopedEC_KEY ec_private_key; | 225 crypto::ScopedEC_KEY ec_private_key; |
| 230 status = CreateEC_KEY(params->namedCurve(), &ec_private_key); | 226 status = CreateEC_KEY(params->namedCurve(), &ec_private_key); |
| 231 if (status.IsError()) | 227 if (status.IsError()) |
| 232 return status; | 228 return status; |
| 233 | 229 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 key->algorithm().ecParams()->namedCurve()) { | 567 key->algorithm().ecParams()->namedCurve()) { |
| 572 return Status::ErrorUnexpected(); | 568 return Status::ErrorUnexpected(); |
| 573 } | 569 } |
| 574 | 570 |
| 575 return Status::Success(); | 571 return Status::Success(); |
| 576 } | 572 } |
| 577 | 573 |
| 578 } // namespace webcrypto | 574 } // namespace webcrypto |
| 579 | 575 |
| 580 } // namespace content | 576 } // namespace content |
| OLD | NEW |