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

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

Issue 15315003: Generate unique certificate nicknames on Linux/CrOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update README Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef NET_CERT_X509_UTIL_NSS_H_ 5 #ifndef NET_CERT_X509_UTIL_NSS_H_
6 #define NET_CERT_X509_UTIL_NSS_H_ 6 #define NET_CERT_X509_UTIL_NSS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
13 #include "net/cert/x509_certificate.h" 13 #include "net/cert/x509_certificate.h"
14 14
15 class PickleIterator; 15 class PickleIterator;
16 16
17 typedef struct CERTCertificateStr CERTCertificate; 17 typedef struct CERTCertificateStr CERTCertificate;
18 typedef struct CERTNameStr CERTName; 18 typedef struct CERTNameStr CERTName;
19 typedef struct PLArenaPool PLArenaPool; 19 typedef struct PLArenaPool PLArenaPool;
20 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; 20 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
21 typedef struct SECItemStr SECItem; 21 typedef struct SECItemStr SECItem;
22 typedef struct SECKEYPublicKeyStr SECKEYPublicKey; 22 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
23 typedef struct PK11SlotInfoStr PK11SlotInfo;
wtc 2013/05/22 20:58:45 Nit: list this typedef in sorted order. (The origi
23 24
24 namespace net { 25 namespace net {
25 26
26 namespace x509_util { 27 namespace x509_util {
27 28
28 // Creates a self-signed certificate containing |public_key|. Subject, serial 29 // Creates a self-signed certificate containing |public_key|. Subject, serial
29 // number and validity period are given as parameters. The certificate is 30 // number and validity period are given as parameters. The certificate is
30 // signed by |private_key|. The hashing algorithm for the signature is SHA-1. 31 // signed by |private_key|. The hashing algorithm for the signature is SHA-1.
31 // |subject| is a distinguished name defined in RFC4514. 32 // |subject| is a distinguished name defined in RFC4514.
32 NET_EXPORT_PRIVATE CERTCertificate* CreateSelfSignedCert( 33 NET_EXPORT_PRIVATE CERTCertificate* CreateSelfSignedCert(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 std::vector<CERTName*>* out); 87 std::vector<CERTName*>* out);
87 88
88 // Returns true iff a certificate is issued by any of the issuers listed 89 // Returns true iff a certificate is issued by any of the issuers listed
89 // by name in |valid_issuers|. 90 // by name in |valid_issuers|.
90 // |cert_chain| is the certificate's chain. 91 // |cert_chain| is the certificate's chain.
91 // |valid_issuers| is a list of strings, where each string contains 92 // |valid_issuers| is a list of strings, where each string contains
92 // a DER-encoded X.509 Distinguished Name. 93 // a DER-encoded X.509 Distinguished Name.
93 bool IsCertificateIssuedBy(const std::vector<CERTCertificate*>& cert_chain, 94 bool IsCertificateIssuedBy(const std::vector<CERTCertificate*>& cert_chain,
94 const std::vector<CERTName*>& valid_issuers); 95 const std::vector<CERTName*>& valid_issuers);
95 96
97 // Generates a unique nickname for |slot|, returning |nickname| if it is
98 // already unique.
99 //
100 // Note: The nickname returned will NOT include the token name, and must
101 // be prepended if calling an NSS function that expects <token>:<nickname>.
wtc 2013/05/22 20:58:45 Nit: this should be ..., and the token name must
102 // TODO(gspencer): Internationalize this: it's wrong to hard-code English.
wtc 2013/05/22 20:58:45 We need to describe how we make the nickname uniqu
Ryan Sleevi 2013/05/22 23:20:19 I wanted to try to avoid describing in the header
103 std::string GetUniqueNicknameForSlot(const std::string& nickname,
104 SECItem* subject,
wtc 2013/05/22 20:58:45 Nit: this should ideally be a const pointer. We wi
Ryan Sleevi 2013/05/22 23:20:19 Sure, fixed.
105 PK11SlotInfo* slot);
96 #endif // defined(USE_NSS) || defined(OS_IOS) 106 #endif // defined(USE_NSS) || defined(OS_IOS)
97 107
98 } // namespace x509_util 108 } // namespace x509_util
99 109
100 } // namespace net 110 } // namespace net
101 111
102 #endif // NET_CERT_X509_UTIL_NSS_H_ 112 #endif // NET_CERT_X509_UTIL_NSS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698