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_ID_H_ 16 #define BSSL_PKI_CERT_ERROR_ID_H_ 17 18 #include <openssl/base.h> 19 20 BSSL_NAMESPACE_BEGIN 21 22 // Each "class" of certificate error/warning has its own unique ID. This is 23 // essentially like an error code, however the value is not stable. Under the 24 // hood these IDs are pointers and use the process's address space to ensure 25 // uniqueness. 26 // 27 // Equality of CertErrorId can be done using the == operator. 28 // 29 // To define new error IDs use the macro DEFINE_CERT_ERROR_ID(). 30 using CertErrorId = const void *; 31 32 // DEFINE_CERT_ERROR_ID() creates a CertErrorId given a non-null C-string 33 // literal. The string should be a textual name for the error which will appear 34 // when pretty-printing errors for debugging. It should be ASCII. 35 // 36 // TODO(crbug.com/634443): Implement this -- add magic to ensure that storage 37 // of identical strings isn't pool. 38 #define DEFINE_CERT_ERROR_ID(name, c_str_literal) \ 39 const CertErrorId name = c_str_literal 40 41 // Returns a debug string for a CertErrorId. In practice this returns the 42 // string literal given to DEFINE_CERT_ERROR_ID(), which is human-readable. 43 OPENSSL_EXPORT const char *CertErrorIdToDebugString(CertErrorId id); 44 45 BSSL_NAMESPACE_END 46 47 #endif // BSSL_PKI_CERT_ERROR_ID_H_ 48