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 NET_CERT_PKI_CERT_ERROR_PARAMS_H_ 6 #define NET_CERT_PKI_CERT_ERROR_PARAMS_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "net/base/net_export.h" 12 13 namespace net { 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 NET_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 NET_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1Der( 42 const char* name, 43 const der::Input& der); 44 45 // Same as CreateCertErrorParams1Der() but has a second DER blob. 46 NET_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2Der( 47 const char* name1, 48 const der::Input& der1, 49 const char* name2, 50 const der::Input& der2); 51 52 // Creates a parameter object that holds a single size_t value. |name| is used 53 // when pretty-printing the parameters. 54 NET_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1SizeT( 55 const char* name, 56 size_t value); 57 58 // Same as CreateCertErrorParams1SizeT() but has a second size_t. 59 NET_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2SizeT( 60 const char* name1, 61 size_t value1, 62 const char* name2, 63 size_t value2); 64 65 } // namespace net 66 67 #endif // NET_CERT_PKI_CERT_ERROR_PARAMS_H_ 68