Botan 3.7.1
Crypto and TLS for C&
|
Namespaces | |
namespace | detail |
Classes | |
class | AttributeWrapper |
class | Context |
struct | CryptoCallbackState |
class | EC_PrivateKey |
class | EC_PublicKey |
class | Error |
struct | esys_liberator |
class | HashFunction |
class | Object |
struct | ObjectAttributes |
struct | ObjectHandles |
class | ObjectSetter |
class | PrivateKey |
struct | PropMap |
struct | PublicInfo |
class | PublicKey |
class | RandomNumberGenerator |
class | RSA_PrivateKey |
class | RSA_PublicKey |
class | Session |
struct | SessionAttributes |
class | SessionBundle |
class | Signature_Operation |
class | Signature_Operation_Base |
struct | SignatureAlgorithmSelection |
class | Verification_Operation |
Concepts | |
concept | tpm2_buffer |
Typedefs | |
using | TPMA_SESSION = uint8_t |
template<typename T > | |
using | unique_esys_ptr = std::unique_ptr<T, esys_liberator> |
A unique pointer type for ESYS handles that automatically frees the handle. | |
Functions | |
constexpr auto | as_span (tpm2_buffer auto &data) |
Construct a std::span as a view into a TPM2 buffer. | |
constexpr auto | as_span (tpm2_buffer auto &data, size_t length) |
std::optional< TPM2_ALG_ID > | asymmetric_algorithm_botan_to_tss2 (std::string_view algo_name) noexcept |
std::optional< std::pair< TPMI_ALG_SYM, TPM2_KEY_BITS > > | block_cipher_botan_to_tss2 (std::string_view cipher_name) noexcept |
std::optional< std::string > | block_cipher_tss2_to_botan (TPMI_ALG_SYM cipher_id, TPM2_KEY_BITS key_bits) noexcept |
constexpr void | check_rc (std::string_view location, TSS2_RC rc) |
template<TSS2_RC... expected_errors> requires (sizeof...(expected_errors) > 0) | |
constexpr TSS2_RC | check_rc_expecting (std::string_view location, TSS2_RC rc) |
std::optional< TPMT_SYM_DEF > | cipher_botan_to_tss2 (std::string_view algo_name) |
std::optional< TPMI_ALG_SYM_MODE > | cipher_mode_botan_to_tss2 (std::string_view mode_name) noexcept |
std::optional< std::string > | cipher_mode_tss2_to_botan (TPMI_ALG_SYM_MODE mode_id) |
std::optional< std::string > | cipher_tss2_to_botan (TPMT_SYM_DEF cipher_def) noexcept |
template<concepts::resizable_byte_buffer OutT> | |
constexpr OutT | copy_into (const tpm2_buffer auto &data) |
template<tpm2_buffer T> | |
constexpr T | copy_into (std::span< const uint8_t > data) |
template<tpm2_buffer T> | |
constexpr void | copy_into (T &dest, std::span< const uint8_t > data) |
std::optional< size_t > | curve_id_order_byte_size (TPMI_ECC_CURVE curve_id) |
std::optional< std::string > | curve_id_tss2_to_botan (TPMI_ECC_CURVE mode_id) |
std::string | get_botan_hash_name (TPM2_ALG_ID hash_id) |
TSS2_RC | get_raw_rc (TSS2_RC rc) |
std::optional< TPM2_ECC_CURVE > | get_tpm2_curve_id (const OID &curve_oid) |
TPMI_ALG_HASH | get_tpm2_hash_type (std::string_view hash_name) |
TPMT_SYM_DEF | get_tpm2_sym_cipher_spec (std::string_view algo_name) |
std::optional< TPMI_ALG_HASH > | hash_algo_botan_to_tss2 (std::string_view hash_name) noexcept |
std::optional< std::string > | hash_algo_tss2_to_botan (TPMI_ALG_HASH hash_id) noexcept |
template<tpm2_buffer T> | |
constexpr T | init_empty () |
Create an empty TPM2 buffer of the given type. | |
template<tpm2_buffer T> | |
constexpr T | init_with_size (size_t length) |
Create a TPM2 buffer of a given type and length . | |
constexpr auto | out_persistent_handle (Object &object) |
constexpr auto | out_transient_handle (Object &object) |
template<typename MaskT , typename FieldPointerT > | |
PropMap (MaskT, FieldPointerT) -> PropMap< MaskT, FieldPointerT > | |
Deduction guide to simplify the creation of PropMap instances. | |
std::optional< TPMI_ALG_ASYM_SCHEME > | rsa_encryption_padding_botan_to_tss2 (std::string_view name) noexcept |
std::optional< TPMT_RSA_DECRYPT > | rsa_encryption_scheme_botan_to_tss2 (std::string_view padding) |
std::pair< BigInt, BigInt > | rsa_pubkey_components_from_tss2_public (const TPM2B_PUBLIC *public_area) |
std::optional< TPMI_ALG_SIG_SCHEME > | rsa_signature_padding_botan_to_tss2 (std::string_view padding_name) noexcept |
std::optional< TPMT_SIG_SCHEME > | rsa_signature_scheme_botan_to_tss2 (std::string_view name) |
void | set_crypto_callbacks (ESYS_CONTEXT *ctx, void *callback_state) |
bool | supports_botan_crypto_backend () noexcept |
std::unique_ptr< CryptoCallbackState > | use_botan_crypto_backend (ESYS_CONTEXT *context, const std::shared_ptr< Botan::RandomNumberGenerator > &rng) |
using Botan::TPM2::TPMA_SESSION = uint8_t |
Definition at line 20 of file tpm2_session.h.
using Botan::TPM2::unique_esys_ptr = std::unique_ptr<T, esys_liberator> |
A unique pointer type for ESYS handles that automatically frees the handle.
Definition at line 162 of file tpm2_util.h.
|
constexpr |
Construct a std::span as a view into a TPM2 buffer.
Definition at line 102 of file tpm2_util.h.
Referenced by as_span(), copy_into(), copy_into(), Botan::TPM2::PrivateKey::create_transient_from_template(), Botan::TPM2::Verification_Operation::is_valid_signature(), rsa_pubkey_components_from_tss2_public(), and Botan::TPM2::Signature_Operation::sign().
|
constexpr |
Set the size of data
to length
and construct a std::span as a view into data
Definition at line 108 of file tpm2_util.h.
References as_span(), and BOTAN_ASSERT_NOMSG.
|
inlinenodiscardnoexcept |
Definition at line 26 of file tpm2_algo_mappings.h.
Referenced by Botan::TPM2::Context::supports_algorithm().
|
inlinenodiscardnoexcept |
Definition at line 159 of file tpm2_algo_mappings.h.
Referenced by cipher_botan_to_tss2(), and Botan::TPM2::Context::supports_algorithm().
|
inlinenodiscardnoexcept |
Definition at line 120 of file tpm2_algo_mappings.h.
Referenced by cipher_tss2_to_botan().
|
constexpr |
Check the return code and throw an exception if some error occured.
TPM2::Error | if an error occured. |
Definition at line 54 of file tpm2_util.h.
Referenced by Botan::TPM2::Object::_public_info(), Botan::TPM2::Session::attributes(), Botan::TPM2::Session::authenticated_session(), check_rc_expecting(), Botan::TPM2::Context::create(), Botan::TPM2::Context::create(), Botan::TPM2::PrivateKey::create_transient_from_template(), Botan::TPM2::Context::evict(), Botan::TPM2::HashFunction::final_with_ticket(), Botan::TPM2::PrivateKey::load_transient(), Botan::TPM2::PublicKey::load_transient(), Botan::TPM2::Context::persist(), Botan::TPM2::Session::set_attributes(), set_crypto_callbacks(), Botan::TPM2::Signature_Operation::sign(), Botan::TPM2::Session::tpm_nonce(), and Botan::TPM2::Session::unauthenticated_session().
|
nodiscardconstexpr |
Check the return code and throw an exception if an unexpected error occured.
Errors that are listed in the expected_errors
parameter are considered expected and will not cause an exception to be thrown. Instead the error code is decoded and returned to the caller for further processing.
TPM2::Error | if an unexpected error occured. |
Definition at line 72 of file tpm2_util.h.
References check_rc(), and get_raw_rc().
Referenced by Botan::TPM2::Verification_Operation::is_valid_signature().
|
inlinenodiscard |
Definition at line 296 of file tpm2_algo_mappings.h.
References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), block_cipher_botan_to_tss2(), and cipher_mode_botan_to_tss2().
Referenced by get_tpm2_sym_cipher_spec(), and Botan::TPM2::Context::supports_algorithm().
|
inlinenodiscardnoexcept |
Definition at line 262 of file tpm2_algo_mappings.h.
Referenced by cipher_botan_to_tss2(), and Botan::TPM2::Context::supports_algorithm().
|
inlinenodiscard |
Definition at line 182 of file tpm2_algo_mappings.h.
Referenced by cipher_tss2_to_botan().
|
inlinenodiscardnoexcept |
cipher_id
, key_bits
and mode_name
are known, otherwise std::nullopt Definition at line 282 of file tpm2_algo_mappings.h.
References block_cipher_tss2_to_botan(), cipher_mode_tss2_to_botan(), and Botan::fmt().
|
constexpr |
Copy the content of the TPM2 buffer data
into a new resizable byte buffer of the user's choosing.
Definition at line 133 of file tpm2_util.h.
References as_span(), and Botan::copy_mem().
|
constexpr |
Create a TPM2 buffer from the provided data
, assuming that the provided data
is not larger than the capacity of the buffer type.
Definition at line 124 of file tpm2_util.h.
References copy_into(), and T.
|
constexpr |
Copy the data
into the TPM2 buffer dest
, assuming that the provided data
is not larger than the capacity of the buffer.
Definition at line 117 of file tpm2_util.h.
References as_span(), and Botan::copy_mem().
Referenced by copy_into(), Botan::TPM2::EC_PrivateKey::create_unrestricted_transient(), Botan::TPM2::RSA_PrivateKey::create_unrestricted_transient(), Botan::TPM2::PrivateKey::load_transient(), Botan::TPM2::Context::persist(), and Botan::TPM2::Session::tpm_nonce().
|
inlinenodiscard |
Definition at line 221 of file tpm2_algo_mappings.h.
|
inlinenodiscard |
Definition at line 199 of file tpm2_algo_mappings.h.
|
inlinenodiscard |
hash_id
value is known, otherwise throws Invalid_State Definition at line 112 of file tpm2_algo_mappings.h.
References hash_algo_tss2_to_botan().
Referenced by Botan::TPM2::HashFunction::name().
Definition at line 18 of file tpm2_error.cpp.
References Botan::fmt().
Referenced by check_rc_expecting().
|
inlinenodiscard |
Definition at line 240 of file tpm2_algo_mappings.h.
References Botan::OID::to_formatted_string().
Referenced by Botan::TPM2::EC_PrivateKey::create_unrestricted_transient().
|
inlinenodiscard |
hash_name
is known, otherwise throws Lookup_Error Definition at line 73 of file tpm2_algo_mappings.h.
References hash_algo_botan_to_tss2().
Referenced by Botan::TPM2::Session::authenticated_session(), and Botan::TPM2::Session::unauthenticated_session().
|
inlinenodiscard |
Definition at line 316 of file tpm2_algo_mappings.h.
References cipher_botan_to_tss2().
Referenced by Botan::TPM2::Session::authenticated_session(), and Botan::TPM2::Session::unauthenticated_session().
|
inlinenodiscardnoexcept |
hash_name
is known, otherwise std::nullopt Definition at line 47 of file tpm2_algo_mappings.h.
Referenced by get_tpm2_hash_type(), rsa_encryption_scheme_botan_to_tss2(), rsa_signature_scheme_botan_to_tss2(), and Botan::TPM2::Context::supports_algorithm().
|
inlinenodiscardnoexcept |
hash_id
value is known, otherwise std::nullopt Definition at line 85 of file tpm2_algo_mappings.h.
Referenced by get_botan_hash_name().
|
constexpr |
Create an empty TPM2 buffer of the given type.
Definition at line 152 of file tpm2_util.h.
References init_with_size().
Referenced by Botan::TPM2::EC_PrivateKey::create_unrestricted_transient(), Botan::TPM2::RSA_PrivateKey::create_unrestricted_transient(), Botan::TPM2::HashFunction::final_with_ticket(), and Botan::TPM2::Signature_Operation::sign().
|
constexpr |
Create a TPM2 buffer of a given type and length
.
Definition at line 142 of file tpm2_util.h.
References BOTAN_ASSERT_NOMSG, Botan::clear_bytes(), and T.
Referenced by init_empty().
|
constexpr |
Helper to set the persistent handle of an object from a TSS2 library function's out parameter.
Definition at line 223 of file tpm2_util.h.
Referenced by Botan::TPM2::Context::persist().
|
constexpr |
Helper to set the transient handle of an object from a TSS2 library function's out parameter.
Definition at line 217 of file tpm2_util.h.
Referenced by Botan::TPM2::Session::authenticated_session(), Botan::TPM2::PrivateKey::create_transient_from_template(), Botan::TPM2::PrivateKey::load_transient(), Botan::TPM2::PublicKey::load_transient(), Botan::TPM2::Context::persist(), and Botan::TPM2::Session::unauthenticated_session().
Botan::TPM2::PropMap | ( | MaskT | , |
FieldPointerT | ) -> PropMap< MaskT, FieldPointerT > |
Deduction guide to simplify the creation of PropMap instances.
|
inlinenodiscardnoexcept |
Definition at line 361 of file tpm2_algo_mappings.h.
References name.
Referenced by rsa_encryption_scheme_botan_to_tss2(), and Botan::TPM2::Context::supports_algorithm().
|
inlinenodiscard |
Definition at line 374 of file tpm2_algo_mappings.h.
References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), hash_algo_botan_to_tss2(), and rsa_encryption_padding_botan_to_tss2().
Referenced by Botan::TPM2::Context::supports_algorithm().
std::pair< BigInt, BigInt > Botan::TPM2::rsa_pubkey_components_from_tss2_public | ( | const TPM2B_PUBLIC * | public_blob | ) |
This helper function transforms a public_blob
in a TPM2B_PUBLIC* format into the functional components of an RSA public key. Namely, a pair of modulus and exponent as big integers.
public_blob | The public blob to decompose into RSA pubkey components |
Definition at line 29 of file tpm2_rsa.cpp.
References as_span(), BOTAN_ARG_CHECK, and BOTAN_ASSERT_NONNULL.
|
inlinenodiscardnoexcept |
Definition at line 324 of file tpm2_algo_mappings.h.
Referenced by rsa_signature_scheme_botan_to_tss2(), and Botan::TPM2::Context::supports_algorithm().
|
inlinenodiscard |
Definition at line 338 of file tpm2_algo_mappings.h.
References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), hash_algo_botan_to_tss2(), name, and rsa_signature_padding_botan_to_tss2().
Referenced by Botan::TPM2::Context::supports_algorithm().
void Botan::TPM2::set_crypto_callbacks | ( | ESYS_CONTEXT * | ctx, |
void * | callback_state ) |
Enable the Botan crypto callbacks for the given ESYS context.
The callbacks may maintain two types of state:
The runtime crypto backend is available since TSS2 4.0.0 and later. Explicit support for SM4 was added in TSS2 4.1.0.
Note that the callback implementations should be defensive in regard to the input parameters. All pointers should be checked for nullptr before being dereferenced. Some output parameters (e.g. out-buffer lengths) may be regarded as optional, and should be checked for nullptr before being written to.
Error code conventions:
Enable Botan's crypto callbacks in the TPM2-TSS for the given context
.
Not_Implemented | if the TPM2-TSS does not support crypto callbacks. |
Definition at line 861 of file tpm2_crypto_backend_impl.cpp.
References BOTAN_ASSERT_NONNULL, BOTAN_UNUSED, check_rc(), and init.
Referenced by use_botan_crypto_backend(), and Botan::TPM2::Context::~Context().
|
nodiscardnoexcept |
Checks if the TSS2 supports registering Botan's crypto backend at runtime. Older versions of the TSS2 do not support this feature ( 4.0.0).
Definition at line 23 of file tpm2_crypto_backend.cpp.
Referenced by Botan::TPM2::Context::supports_botan_crypto_backend().
|
nodiscard |
Enable Botan's crypto callbacks in the TPM2-TSS for the given ESYS_CONTEXT context
. Use this if you do not plan to use Botan's TPM wrapper (rooted in TPM2::Context) but still want to benefit from Botan's TPM crypto backend. Otherwise, use TPM2::Context::use_botan_crypto_backend().
This replaces all cryptographic functionality required for the communication with the TPM by Botan's implementations. The TSS2 would otherwise use OpenSSL or mbedTLS.
Note that the provided rng
should not be dependent on the TPM and that the returned pointer to the CryptoCallbackState must be kept alive as long as the associated ESYS_CONTEXT is valid and used.
context | the ESYS_CONTEXT pointer to register the crypto backend on |
rng | the (independent) random number generator to be used |
Not_Implemented | if the TPM2-TSS does not support crypto callbacks. |
Definition at line 16 of file tpm2_crypto_backend.cpp.
References set_crypto_callbacks().
Referenced by botan_tpm2_enable_crypto_backend(), and Botan::TPM2::Context::use_botan_crypto_backend().