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