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

Side by Side Diff: webrtc/base/opensslidentity.cc

Issue 2534773002: Set OPENSSL_EC_NAMED_CURVE explicitly on EC key so that certificate has ASN1 OID and NIST curve inf… (Closed)
Patch Set: Fixes BUG=webrtc:6763 Set OPENSSL_EC_NAMED_CURVE explicitly on EC key so that curve name is include… Created 4 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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 BN_free(exponent); 54 BN_free(exponent);
55 RSA_free(rsa); 55 RSA_free(rsa);
56 LOG(LS_ERROR) << "Failed to make RSA key pair"; 56 LOG(LS_ERROR) << "Failed to make RSA key pair";
57 return NULL; 57 return NULL;
58 } 58 }
59 // ownership of rsa struct was assigned, don't free it. 59 // ownership of rsa struct was assigned, don't free it.
60 BN_free(exponent); 60 BN_free(exponent);
61 } else if (key_params.type() == KT_ECDSA) { 61 } else if (key_params.type() == KT_ECDSA) {
62 if (key_params.ec_curve() == EC_NIST_P256) { 62 if (key_params.ec_curve() == EC_NIST_P256) {
63 EC_KEY* ec_key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); 63 EC_KEY* ec_key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
64
65 // Ensure curve name is included when EC key is serialized.
66 // Without this call, OpenSSL versions before 1.1.0 will create
67 // certificates that don't work for TLS.
68 // This is a no-op for BoringSSL and OpenSSL 1.1.0+
69 EC_KEY_set_asn1_flag(ec_key, OPENSSL_EC_NAMED_CURVE);
70
64 if (!pkey || !ec_key || !EC_KEY_generate_key(ec_key) || 71 if (!pkey || !ec_key || !EC_KEY_generate_key(ec_key) ||
65 !EVP_PKEY_assign_EC_KEY(pkey, ec_key)) { 72 !EVP_PKEY_assign_EC_KEY(pkey, ec_key)) {
66 EVP_PKEY_free(pkey); 73 EVP_PKEY_free(pkey);
67 EC_KEY_free(ec_key); 74 EC_KEY_free(ec_key);
68 LOG(LS_ERROR) << "Failed to make EC key pair"; 75 LOG(LS_ERROR) << "Failed to make EC key pair";
69 return NULL; 76 return NULL;
70 } 77 }
71 // ownership of ec_key struct was assigned, don't free it. 78 // ownership of ec_key struct was assigned, don't free it.
72 } else { 79 } else {
73 // Add generation of any other curves here. 80 // Add generation of any other curves here.
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 *this->certificate_ == *other.certificate_; 571 *this->certificate_ == *other.certificate_;
565 } 572 }
566 573
567 bool OpenSSLIdentity::operator!=(const OpenSSLIdentity& other) const { 574 bool OpenSSLIdentity::operator!=(const OpenSSLIdentity& other) const {
568 return !(*this == other); 575 return !(*this == other);
569 } 576 }
570 577
571 } // namespace rtc 578 } // namespace rtc
572 579
573 #endif // HAVE_OPENSSL_SSL_H 580 #endif // HAVE_OPENSSL_SSL_H
OLDNEW
« AUTHORS ('K') | « AUTHORS ('k') | webrtc/base/opensslstreamadapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698