OLD | NEW |
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_BASE_X509_UTIL_NSS_H_ | 5 #ifndef NET_BASE_X509_UTIL_NSS_H_ |
6 #define NET_BASE_X509_UTIL_NSS_H_ | 6 #define NET_BASE_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/x509_certificate.h" | 12 #include "net/base/x509_certificate.h" |
13 | 13 |
14 class PickleIterator; | 14 class PickleIterator; |
15 | 15 |
16 typedef struct CERTCertificateStr CERTCertificate; | 16 typedef struct CERTCertificateStr CERTCertificate; |
17 typedef struct CERTNameStr CERTName; | 17 typedef struct CERTNameStr CERTName; |
| 18 typedef struct PLArenaPool PLArenaPool; |
18 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; | 19 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; |
19 typedef struct SECItemStr SECItem; | 20 typedef struct SECItemStr SECItem; |
20 typedef struct SECKEYPublicKeyStr SECKEYPublicKey; | 21 typedef struct SECKEYPublicKeyStr SECKEYPublicKey; |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
24 namespace x509_util { | 25 namespace x509_util { |
25 | 26 |
26 // Creates a self-signed certificate containing |public_key|. Subject, serial | 27 // Creates a self-signed certificate containing |public_key|. Subject, serial |
27 // number and validity period are given as parameters. The certificate is | 28 // number and validity period are given as parameters. The certificate is |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // certificate handle. Returns an invalid handle, NULL, on failure. | 64 // certificate handle. Returns an invalid handle, NULL, on failure. |
64 X509Certificate::OSCertHandle ReadOSCertHandleFromPickle( | 65 X509Certificate::OSCertHandle ReadOSCertHandleFromPickle( |
65 PickleIterator* pickle_iter); | 66 PickleIterator* pickle_iter); |
66 | 67 |
67 // Sets |*size_bits| to be the length of the public key in bits, and sets | 68 // Sets |*size_bits| to be the length of the public key in bits, and sets |
68 // |*type| to one of the |PublicKeyType| values. In case of | 69 // |*type| to one of the |PublicKeyType| values. In case of |
69 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0. | 70 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0. |
70 void GetPublicKeyInfo(CERTCertificate* handle, | 71 void GetPublicKeyInfo(CERTCertificate* handle, |
71 size_t* size_bits, | 72 size_t* size_bits, |
72 X509Certificate::PublicKeyType* type); | 73 X509Certificate::PublicKeyType* type); |
| 74 |
| 75 // Create a list of CERTName objects from a list of DER-encoded X.509 |
| 76 // DistinguishedName items. All objects are created in a given arena. |
| 77 // |encoded_issuers| is the list of encoded DNs. |
| 78 // |arena| is the arena used for all allocations. |
| 79 // |out| will receive the result list on success. |
| 80 // Return true on success. On failure, the caller must free the |
| 81 // intermediate CERTName objects pushed to |out|. |
| 82 bool GetIssuersFromEncodedList( |
| 83 const std::vector<std::string>& issuers, |
| 84 PLArenaPool* arena, |
| 85 std::vector<CERTName*>* out); |
| 86 |
| 87 // Returns true iff a certificate is issued by any of the issuers listed |
| 88 // by name in |valid_issuers|. |
| 89 // |cert_chain| is the certificate's chain. |
| 90 // |valid_issuers| is a list of strings, where each string contains |
| 91 // a DER-encoded X.509 Distinguished Name. |
| 92 bool IsCertificateIssuedBy(const std::vector<CERTCertificate*>& cert_chain, |
| 93 const std::vector<CERTName*>& valid_issuers); |
| 94 |
73 #endif // defined(USE_NSS) || defined(OS_IOS) | 95 #endif // defined(USE_NSS) || defined(OS_IOS) |
74 | 96 |
75 } // namespace x509_util | 97 } // namespace x509_util |
76 | 98 |
77 } // namespace net | 99 } // namespace net |
78 | 100 |
79 #endif // NET_BASE_X509_UTIL_NSS_H_ | 101 #endif // NET_BASE_X509_UTIL_NSS_H_ |
OLD | NEW |