1 // Copyright 2016 The Chromium Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef BSSL_PKI_CERT_ERROR_PARAMS_H_ 16 #define BSSL_PKI_CERT_ERROR_PARAMS_H_ 17 18 #include <memory> 19 #include <string> 20 21 #include <openssl/base.h> 22 23 BSSL_NAMESPACE_BEGIN 24 25 namespace der { 26 class Input; 27 } 28 29 // CertErrorParams is a base class for describing extra parameters attached to 30 // a CertErrorNode. 31 // 32 // An example use for parameters is to identify the OID for an unconsumed 33 // critical extension. This parameter could then be pretty printed when 34 // diagnosing the error. 35 class OPENSSL_EXPORT CertErrorParams { 36 public: 37 CertErrorParams(); 38 39 CertErrorParams(const CertErrorParams &) = delete; 40 CertErrorParams &operator=(const CertErrorParams &) = delete; 41 42 virtual ~CertErrorParams(); 43 44 // Creates a representation of this parameter as a string, which may be 45 // used for pretty printing the error. 46 virtual std::string ToDebugString() const = 0; 47 }; 48 49 // Creates a parameter object that holds a copy of |der|, and names it |name| 50 // in debug string outputs. 51 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1Der( 52 const char *name, der::Input der); 53 54 // Same as CreateCertErrorParams1Der() but has a second DER blob. 55 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2Der( 56 const char *name1, der::Input der1, const char *name2, der::Input der2); 57 58 // Creates a parameter object that holds a single size_t value. |name| is used 59 // when pretty-printing the parameters. 60 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams1SizeT( 61 const char *name, size_t value); 62 63 // Same as CreateCertErrorParams1SizeT() but has a second size_t. 64 OPENSSL_EXPORT std::unique_ptr<CertErrorParams> CreateCertErrorParams2SizeT( 65 const char *name1, size_t value1, const char *name2, size_t value2); 66 67 BSSL_NAMESPACE_END 68 69 #endif // BSSL_PKI_CERT_ERROR_PARAMS_H_ 70