Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / net / cert / x509_util_nss.h
blob66c634cc1576822d5bf5d61e7b1a964eea8daed4
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
3 // found in the LICENSE file.
5 #ifndef NET_CERT_X509_UTIL_NSS_H_
6 #define NET_CERT_X509_UTIL_NSS_H_
8 #include <string>
9 #include <vector>
11 #include "base/time.h"
12 #include "net/cert/x509_certificate.h"
14 class PickleIterator;
16 typedef struct CERTCertificateStr CERTCertificate;
17 typedef struct CERTNameStr CERTName;
18 typedef struct PLArenaPool PLArenaPool;
19 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
20 typedef struct SECItemStr SECItem;
21 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
23 namespace net {
25 namespace x509_util {
27 // Creates a self-signed certificate containing |public_key|. Subject, serial
28 // number and validity period are given as parameters. The certificate is
29 // signed by |private_key|. The hashing algorithm for the signature is SHA-1.
30 // |subject| is a distinguished name defined in RFC4514.
31 CERTCertificate* CreateSelfSignedCert(
32 SECKEYPublicKey* public_key,
33 SECKEYPrivateKey* private_key,
34 const std::string& subject,
35 uint32 serial_number,
36 base::Time not_valid_before,
37 base::Time not_valid_after);
39 #if defined(USE_NSS) || defined(OS_IOS)
40 // Parses the Principal attribute from |name| and outputs the result in
41 // |principal|.
42 void ParsePrincipal(CERTName* name,
43 CertPrincipal* principal);
45 // Parses the date from |der_date| and outputs the result in |result|.
46 void ParseDate(const SECItem* der_date, base::Time* result);
48 // Parses the serial number from |certificate|.
49 std::string ParseSerialNumber(const CERTCertificate* certificate);
51 // Gets the subjectAltName extension field from the certificate, if any.
52 void GetSubjectAltName(CERTCertificate* cert_handle,
53 std::vector<std::string>* dns_names,
54 std::vector<std::string>* ip_addrs);
56 // Creates all possible OS certificate handles from |data| encoded in a specific
57 // |format|. Returns an empty collection on failure.
58 X509Certificate::OSCertHandles CreateOSCertHandlesFromBytes(
59 const char* data,
60 int length,
61 X509Certificate::Format format);
63 // Reads a single certificate from |pickle_iter| and returns a platform-specific
64 // certificate handle. Returns an invalid handle, NULL, on failure.
65 X509Certificate::OSCertHandle ReadOSCertHandleFromPickle(
66 PickleIterator* pickle_iter);
68 // Sets |*size_bits| to be the length of the public key in bits, and sets
69 // |*type| to one of the |PublicKeyType| values. In case of
70 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0.
71 void GetPublicKeyInfo(CERTCertificate* handle,
72 size_t* size_bits,
73 X509Certificate::PublicKeyType* type);
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);
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);
95 #endif // defined(USE_NSS) || defined(OS_IOS)
97 } // namespace x509_util
99 } // namespace net
101 #endif // NET_CERT_X509_UTIL_NSS_H_