Botan 3.6.0
Crypto and TLS for C&
tpm2_error.h
Go to the documentation of this file.
1/*
2* TPM 2 error handling
3* (C) 2024 Jack Lloyd
4* (C) 2024 René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity GmbH, financed by LANCOM Systems GmbH
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_TPM2_ERROR_H_
10#define BOTAN_TPM2_ERROR_H_
11
12#include <botan/exceptn.h>
13
14/// Forward declaration of TSS2 type for convenience
15using TSS2_RC = uint32_t;
16
17namespace Botan::TPM2 {
18
20
21class BOTAN_PUBLIC_API(3, 6) Error final : public Exception {
22 public:
23 Error(std::string_view location, TSS2_RC rc);
24
25 ErrorType error_type() const noexcept override { return ErrorType::TPMError; }
26
27 TSS2_RC code() const { return m_rc; }
28
29 int error_code() const noexcept override {
30 // RC is uint32 but the maximum value is within int32 range as per tss2_common.h
31 return static_cast<int>(m_rc);
32 }
33
34 std::string error_message() const;
35
36 private:
37 TSS2_RC m_rc;
38};
39
40} // namespace Botan::TPM2
41
42#endif
ErrorType error_type() const noexcept override
Definition tpm2_error.h:25
TSS2_RC code() const
Definition tpm2_error.h:27
int error_code() const noexcept override
Definition tpm2_error.h:29
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
TSS2_RC get_raw_rc(TSS2_RC rc)
ErrorType
Definition exceptn.h:20
uint32_t TSS2_RC
Forward declaration of TSS2 type for convenience.
Definition tpm2_error.h:15