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

Side by Side Diff: net/cert/x509_util_nss.cc

Issue 16158005: Adds CreateSelfSignedCertEC to x509_util.h in preparation of persistent DTLS identity store for Web… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months 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
« no previous file with comments | « net/cert/x509_util.h ('k') | net/cert/x509_util_nss_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/cert/x509_util.h" 5 #include "net/cert/x509_util.h"
6 #include "net/cert/x509_util_nss.h" 6 #include "net/cert/x509_util_nss.h"
7 7
8 #include <cert.h> // Must be included before certdb.h 8 #include <cert.h> // Must be included before certdb.h
9 #include <certdb.h> 9 #include <certdb.h>
10 #include <cryptohi.h> 10 #include <cryptohi.h>
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 DCHECK(key); 358 DCHECK(key);
359 return CreateDomainBoundCertInternal(key->public_key(), 359 return CreateDomainBoundCertInternal(key->public_key(),
360 key->key(), 360 key->key(),
361 domain, 361 domain,
362 serial_number, 362 serial_number,
363 not_valid_before, 363 not_valid_before,
364 not_valid_after, 364 not_valid_after,
365 der_cert); 365 der_cert);
366 } 366 }
367 367
368 bool CreateSelfSignedCertEC(
369 crypto::ECPrivateKey* key,
370 const std::string& common_name,
371 uint32 serial_number,
372 base::Time not_valid_before,
373 base::Time not_valid_after,
374 std::string* der_cert) {
375 DCHECK(key);
376 CERTCertificate* cert = CreateSelfSignedCert(key->public_key(),
377 key->key(),
378 "CN=" + common_name,
Ryan Sleevi 2013/06/11 20:01:12 From an API perspective, it seems better to allow
jiayl 2013/06/11 20:55:21 Done.
379 serial_number,
380 not_valid_before,
381 not_valid_after);
382 if (!cert)
383 return false;
384 der_cert->assign(reinterpret_cast<char*>(cert->derCert.data),
385 cert->derCert.len);
386 CERT_DestroyCertificate(cert);
387
388 return true;
389 }
390
368 #if defined(USE_NSS) || defined(OS_IOS) 391 #if defined(USE_NSS) || defined(OS_IOS)
369 void ParsePrincipal(CERTName* name, CertPrincipal* principal) { 392 void ParsePrincipal(CERTName* name, CertPrincipal* principal) {
370 // Starting in NSS 3.15, CERTGetNameFunc takes a const CERTName* argument. 393 // Starting in NSS 3.15, CERTGetNameFunc takes a const CERTName* argument.
371 #if NSS_VMINOR >= 15 394 #if NSS_VMINOR >= 15
372 typedef char* (*CERTGetNameFunc)(const CERTName* name); 395 typedef char* (*CERTGetNameFunc)(const CERTName* name);
373 #else 396 #else
374 typedef char* (*CERTGetNameFunc)(CERTName* name); 397 typedef char* (*CERTGetNameFunc)(CERTName* name);
375 #endif 398 #endif
376 399
377 // TODO(jcampan): add business_category and serial_number. 400 // TODO(jcampan): add business_category and serial_number.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 649 }
627 650
628 return new_name; 651 return new_name;
629 } 652 }
630 653
631 #endif // defined(USE_NSS) || defined(OS_IOS) 654 #endif // defined(USE_NSS) || defined(OS_IOS)
632 655
633 } // namespace x509_util 656 } // namespace x509_util
634 657
635 } // namespace net 658 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_util.h ('k') | net/cert/x509_util_nss_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698