• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BSSL_PKI_CERT_ERROR_PARAMS_H_
6 #define BSSL_PKI_CERT_ERROR_PARAMS_H_
7 
8 #include "fillins/openssl_util.h"
9 #include <memory>
10 #include <string>
11 
12 
13 
14 namespace bssl {
15 
16 namespace der {
17 class Input;
18 }
19 
20 // CertErrorParams is a base class for describing extra parameters attached to
21 // a CertErrorNode.
22 //
23 // An example use for parameters is to identify the OID for an unconsumed
24 // critical extension. This parameter could then be pretty printed when
25 // diagnosing the error.
26 class OPENSSL_EXPORT CertErrorParams {
27  public:
28   CertErrorParams();
29 
30   CertErrorParams(const CertErrorParams&) = delete;
31   CertErrorParams& operator=(const CertErrorParams&) = delete;
32 
33   virtual ~CertErrorParams();
34 
35   // Creates a representation of this parameter as a string, which may be
36   // used for pretty printing the error.
37   virtual std::string ToDebugString() const = 0;
38 };
39 
40 // Creates a parameter object that holds a copy of |der|, and names it |name|
41 // in debug string outputs.
42 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1Der(
43     const char* name,
44     const der::Input& der);
45 
46 // Same as CreateCertErrorParams1Der() but has a second DER blob.
47 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2Der(
48     const char* name1,
49     const der::Input& der1,
50     const char* name2,
51     const der::Input& der2);
52 
53 // Creates a parameter object that holds a single size_t value. |name| is used
54 // when pretty-printing the parameters.
55 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1SizeT(
56     const char* name,
57     size_t value);
58 
59 // Same as CreateCertErrorParams1SizeT() but has a second size_t.
60 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2SizeT(
61     const char* name1,
62     size_t value1,
63     const char* name2,
64     size_t value2);
65 
66 }  // namespace net
67 
68 #endif  // BSSL_PKI_CERT_ERROR_PARAMS_H_
69