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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/time.h" 11 #include "base/time/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 PK11SlotInfoStr PK11SlotInfo; 19 typedef struct PK11SlotInfoStr PK11SlotInfo;
20 typedef struct PLArenaPool PLArenaPool; 20 typedef struct PLArenaPool PLArenaPool;
21 typedef struct SECItemStr SECItem; 21 typedef struct SECItemStr SECItem;
22 22
23 namespace net { 23 namespace net {
24 24
25 namespace x509_util { 25 namespace x509_util {
26 26
27 #if defined(USE_NSS) || defined(OS_IOS) 27 #if defined(USE_NSS) || defined(OS_IOS)
28 // Parses the Principal attribute from |name| and outputs the result in 28 // Parses the Principal attribute from |name| and outputs the result in
29 // |principal|. 29 // |principal|.
30 void ParsePrincipal(CERTName* name, 30 void ParsePrincipal(CERTName* name, CertPrincipal* principal);
31 CertPrincipal* principal);
32 31
33 // Parses the date from |der_date| and outputs the result in |result|. 32 // Parses the date from |der_date| and outputs the result in |result|.
34 void ParseDate(const SECItem* der_date, base::Time* result); 33 void ParseDate(const SECItem* der_date, base::Time* result);
35 34
36 // Parses the serial number from |certificate|. 35 // Parses the serial number from |certificate|.
37 std::string ParseSerialNumber(const CERTCertificate* certificate); 36 std::string ParseSerialNumber(const CERTCertificate* certificate);
38 37
39 // Gets the subjectAltName extension field from the certificate, if any. 38 // Gets the subjectAltName extension field from the certificate, if any.
40 void GetSubjectAltName(CERTCertificate* cert_handle, 39 void GetSubjectAltName(CERTCertificate* cert_handle,
41 std::vector<std::string>* dns_names, 40 std::vector<std::string>* dns_names,
(...skipping 18 matching lines...) Expand all
60 size_t* size_bits, 59 size_t* size_bits,
61 X509Certificate::PublicKeyType* type); 60 X509Certificate::PublicKeyType* type);
62 61
63 // Create a list of CERTName objects from a list of DER-encoded X.509 62 // Create a list of CERTName objects from a list of DER-encoded X.509
64 // DistinguishedName items. All objects are created in a given arena. 63 // DistinguishedName items. All objects are created in a given arena.
65 // |encoded_issuers| is the list of encoded DNs. 64 // |encoded_issuers| is the list of encoded DNs.
66 // |arena| is the arena used for all allocations. 65 // |arena| is the arena used for all allocations.
67 // |out| will receive the result list on success. 66 // |out| will receive the result list on success.
68 // Return true on success. On failure, the caller must free the 67 // Return true on success. On failure, the caller must free the
69 // intermediate CERTName objects pushed to |out|. 68 // intermediate CERTName objects pushed to |out|.
70 bool GetIssuersFromEncodedList( 69 bool GetIssuersFromEncodedList(const std::vector<std::string>& issuers,
71 const std::vector<std::string>& issuers, 70 PLArenaPool* arena,
72 PLArenaPool* arena, 71 std::vector<CERTName*>* out);
73 std::vector<CERTName*>* out);
74 72
75 // Returns true iff a certificate is issued by any of the issuers listed 73 // Returns true iff a certificate is issued by any of the issuers listed
76 // by name in |valid_issuers|. 74 // by name in |valid_issuers|.
77 // |cert_chain| is the certificate's chain. 75 // |cert_chain| is the certificate's chain.
78 // |valid_issuers| is a list of strings, where each string contains 76 // |valid_issuers| is a list of strings, where each string contains
79 // a DER-encoded X.509 Distinguished Name. 77 // a DER-encoded X.509 Distinguished Name.
80 bool IsCertificateIssuedBy(const std::vector<CERTCertificate*>& cert_chain, 78 bool IsCertificateIssuedBy(const std::vector<CERTCertificate*>& cert_chain,
81 const std::vector<CERTName*>& valid_issuers); 79 const std::vector<CERTName*>& valid_issuers);
82 80
83 // Generates a unique nickname for |slot|, returning |nickname| if it is 81 // Generates a unique nickname for |slot|, returning |nickname| if it is
84 // already unique. 82 // already unique.
85 // 83 //
86 // Note: The nickname returned will NOT include the token name, thus the 84 // Note: The nickname returned will NOT include the token name, thus the
87 // token name must be prepended if calling an NSS function that expects 85 // token name must be prepended if calling an NSS function that expects
88 // <token>:<nickname>. 86 // <token>:<nickname>.
89 // TODO(gspencer): Internationalize this: it's wrong to hard-code English. 87 // TODO(gspencer): Internationalize this: it's wrong to hard-code English.
90 std::string GetUniqueNicknameForSlot(const std::string& nickname, 88 std::string GetUniqueNicknameForSlot(const std::string& nickname,
91 const SECItem* subject, 89 const SECItem* subject,
92 PK11SlotInfo* slot); 90 PK11SlotInfo* slot);
93 #endif // defined(USE_NSS) || defined(OS_IOS) 91 #endif // defined(USE_NSS) || defined(OS_IOS)
94 92
95 } // namespace x509_util 93 } // namespace x509_util
96 94
97 } // namespace net 95 } // namespace net
98 96
99 #endif // NET_CERT_X509_UTIL_NSS_H_ 97 #endif // NET_CERT_X509_UTIL_NSS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698