summaryrefslogtreecommitdiffstats
path: root/net/base/ev_root_ca_metadata.h
blob: 79040391fee5991c0dbfad26ae11863c3bea9362 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_BASE_EV_ROOT_CA_METADATA_H_
#define NET_BASE_EV_ROOT_CA_METADATA_H_

#include <map>

#include "base/scoped_ptr.h"
#include "net/base/x509_certificate.h"

template <typename T>
struct DefaultSingletonTraits;

namespace net {

// A singleton.  This class stores the meta data of the root CAs that issue
// extended-validation (EV) certificates.
class EVRootCAMetadata {
 public:
  static EVRootCAMetadata* GetInstance();

  // If the root CA cert has an EV policy OID, returns true and stores the
  // policy OID in *policy_oid.  Otherwise, returns false.
  bool GetPolicyOID(const X509Certificate::Fingerprint& fingerprint,
                    std::string* policy_oid) const;

  const char* const* GetPolicyOIDs() const { return policy_oids_.get(); }
  int NumPolicyOIDs() const { return num_policy_oids_; }

 private:
  EVRootCAMetadata();
  ~EVRootCAMetadata() { }

  friend struct DefaultSingletonTraits<EVRootCAMetadata>;

  typedef std::map<X509Certificate::Fingerprint, std::string,
                   X509Certificate::FingerprintLessThan> StringMap;

  // Maps an EV root CA cert's SHA-1 fingerprint to its EV policy OID.
  StringMap ev_policy_;

  // Contains dotted-decimal OID strings (in ASCII).  This is a C array of
  // C strings so that it can be passed directly to Windows CryptoAPI as
  // LPSTR*.
  scoped_array<const char*> policy_oids_;
  int num_policy_oids_;

  DISALLOW_COPY_AND_ASSIGN(EVRootCAMetadata);
};

}  // namespace net

#endif  // NET_BASE_EV_ROOT_CA_METADATA_H_