xref: /aosp_15_r20/external/cronet/third_party/boringssl/src/pki/cert_error_params.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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 <memory>
9 #include <string>
10 
11 #include <openssl/base.h>
12 
13 namespace bssl {
14 
15 namespace der {
16 class Input;
17 }
18 
19 // CertErrorParams is a base class for describing extra parameters attached to
20 // a CertErrorNode.
21 //
22 // An example use for parameters is to identify the OID for an unconsumed
23 // critical extension. This parameter could then be pretty printed when
24 // diagnosing the error.
25 class OPENSSL_EXPORT CertErrorParams {
26  public:
27   CertErrorParams();
28 
29   CertErrorParams(const CertErrorParams &) = delete;
30   CertErrorParams &operator=(const CertErrorParams &) = delete;
31 
32   virtual ~CertErrorParams();
33 
34   // Creates a representation of this parameter as a string, which may be
35   // used for pretty printing the error.
36   virtual std::string ToDebugString() const = 0;
37 };
38 
39 // Creates a parameter object that holds a copy of |der|, and names it |name|
40 // in debug string outputs.
41 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1Der(
42     const char *name, der::Input der);
43 
44 // Same as CreateCertErrorParams1Der() but has a second DER blob.
45 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2Der(
46     const char *name1, der::Input der1, const char *name2, der::Input der2);
47 
48 // Creates a parameter object that holds a single size_t value. |name| is used
49 // when pretty-printing the parameters.
50 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1SizeT(
51     const char *name, size_t value);
52 
53 // Same as CreateCertErrorParams1SizeT() but has a second size_t.
54 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2SizeT(
55     const char *name1, size_t value1, const char *name2, size_t value2);
56 
57 }  // namespace bssl
58 
59 #endif  // BSSL_PKI_CERT_ERROR_PARAMS_H_
60