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

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

Issue 10928107: Support x509 certificate on iOS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Revert unneeded changes Created 8 years, 3 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
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_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 10
10 #include "base/time.h" 11 #include "base/time.h"
12 #include "net/base/x509_certificate.h"
13
14 class PickleIterator;
11 15
12 typedef struct CERTCertificateStr CERTCertificate; 16 typedef struct CERTCertificateStr CERTCertificate;
17 typedef struct CERTNameStr CERTName;
13 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; 18 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
19 typedef struct SECItemStr SECItem;
14 typedef struct SECKEYPublicKeyStr SECKEYPublicKey; 20 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
15 21
16
17 namespace net { 22 namespace net {
18 23
19 namespace x509_util { 24 namespace x509_util {
20 25
21 // Creates a self-signed certificate containing |public_key|. Subject, serial 26 // Creates a self-signed certificate containing |public_key|. Subject, serial
22 // number and validity period are given as parameters. The certificate is 27 // number and validity period are given as parameters. The certificate is
23 // signed by |private_key|. The hashing algorithm for the signature is SHA-1. 28 // signed by |private_key|. The hashing algorithm for the signature is SHA-1.
24 // |subject| is a distinguished name defined in RFC4514. 29 // |subject| is a distinguished name defined in RFC4514.
25 CERTCertificate* CreateSelfSignedCert( 30 CERTCertificate* CreateSelfSignedCert(
26 SECKEYPublicKey* public_key, 31 SECKEYPublicKey* public_key,
27 SECKEYPrivateKey* private_key, 32 SECKEYPrivateKey* private_key,
28 const std::string& subject, 33 const std::string& subject,
29 uint32 serial_number, 34 uint32 serial_number,
30 base::Time not_valid_before, 35 base::Time not_valid_before,
31 base::Time not_valid_after); 36 base::Time not_valid_after);
32 37
38 // Parses the Principal attribute from |name| and outputs the result in
39 // |principal|.
40 void ParsePrincipal(CERTName* name,
41 CertPrincipal* principal);
42
43 // Parses the date from |der_date| and outputs the result in |result|.
44 void ParseDate(const SECItem* der_date, base::Time* result);
45
46 // Parses the serial number from |certificate|.
47 std::string ParseSerialNumber(const CERTCertificate* certificate);
48
49 // Gets the subjectAltName extension field from the certificate, if any.
50 void GetSubjectAltName(CERTCertificate* cert_handle,
51 std::vector<std::string>* dns_names,
52 std::vector<std::string>* ip_addrs);
53
54 // Creates all possible OS certificate handles from |data| encoded in a specific
55 // |format|. Returns an empty collection on failure.
56 X509Certificate::OSCertHandles CreateOSCertHandlesFromBytes(
57 const char* data,
58 int length,
59 X509Certificate::Format format);
60
61 // Reads a single certificate from |pickle_iter| and returns a platform-specific
62 // certificate handle. Returns an invalid handle, NULL, on failure.
63 X509Certificate::OSCertHandle ReadOSCertHandleFromPickle(
64 PickleIterator* pickle_iter);
65
66 // Sets |*size_bits| to be the length of the public key in bits, and sets
67 // |*type| to one of the |PublicKeyType| values. In case of
68 // |kPublicKeyTypeUnknown|, |*size_bits| will be set to 0.
69 void GetPublicKeyInfo(CERTCertificate* handle,
70 size_t* size_bits,
71 X509Certificate::PublicKeyType* type);
72
33 } // namespace x509_util 73 } // namespace x509_util
34 74
35 } // namespace net 75 } // namespace net
36 76
37 #endif // NET_BASE_X509_UTIL_NSS_H_ 77 #endif // NET_BASE_X509_UTIL_NSS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698