Botan 3.14.1
Crypto and TLS for C&
tpm2_algo_mappings.h
Go to the documentation of this file.
1/*
2* TPM 2 algorithm mappings
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_ALGORITHM_MAPPINGS_H_
10#define BOTAN_TPM2_ALGORITHM_MAPPINGS_H_
11
12#include <botan/types.h>
13
14#include <optional>
15#include <string>
16#include <string_view>
17#include <utility>
18
19#include <tss2/tss2_tpm2_types.h>
20
21namespace Botan {
22
23class OID;
24
25}
26
27namespace Botan::TPM2 {
28
29[[nodiscard]] std::optional<TPM2_ALG_ID> asymmetric_algorithm_botan_to_tss2(std::string_view algo_name) noexcept;
30
31/**
32 * @returns a TPMI_ALG_HASH value if the @p hash_name is known,
33 * otherwise std::nullopt
34 */
35[[nodiscard]] std::optional<TPMI_ALG_HASH> hash_algo_botan_to_tss2(std::string_view hash_name) noexcept;
36
37/**
38 * @returns a TPMI_ALG_HASH value if the @p hash_name is known,
39 * otherwise throws Lookup_Error
40 */
41[[nodiscard]] TPMI_ALG_HASH get_tpm2_hash_type(std::string_view hash_name);
42
43/**
44 * @returns a Botan hash name string if the @p hash_id value is known,
45 * otherwise std::nullopt
46 */
47[[nodiscard]] std::optional<std::string> hash_algo_tss2_to_botan(TPMI_ALG_HASH hash_id);
48
49/**
50 * @returns a Botan hash name string if the @p hash_id value is known,
51 * otherwise throws Invalid_State
52 */
53[[nodiscard]] std::string get_botan_hash_name(TPM2_ALG_ID hash_id);
54
55[[nodiscard]] std::optional<std::string> block_cipher_tss2_to_botan(TPMI_ALG_SYM cipher_id, TPM2_KEY_BITS key_bits);
56
57[[nodiscard]] std::optional<std::pair<TPMI_ALG_SYM, TPM2_KEY_BITS>> block_cipher_botan_to_tss2(
58 std::string_view cipher_name) noexcept;
59
60[[nodiscard]] std::optional<std::string> cipher_mode_tss2_to_botan(TPMI_ALG_SYM_MODE mode_id);
61
62[[nodiscard]] std::optional<std::string> curve_id_tss2_to_botan(TPMI_ECC_CURVE mode_id);
63
64[[nodiscard]] std::optional<size_t> curve_id_order_byte_size(TPMI_ECC_CURVE curve_id);
65
66[[nodiscard]] std::optional<TPM2_ECC_CURVE> get_tpm2_curve_id(const OID& curve_oid);
67
68[[nodiscard]] std::optional<TPMI_ALG_SYM_MODE> cipher_mode_botan_to_tss2(std::string_view mode_name) noexcept;
69
70/**
71 * @returns a Botan cipher mode name string if the @p cipher_id, @p key_bits and
72 * @p mode_name are known, otherwise std::nullopt
73 */
74[[nodiscard]] std::optional<std::string> cipher_tss2_to_botan(TPMT_SYM_DEF cipher_def);
75
76[[nodiscard]] std::optional<TPMT_SYM_DEF> cipher_botan_to_tss2(std::string_view algo_name);
77
78[[nodiscard]] TPMT_SYM_DEF get_tpm2_sym_cipher_spec(std::string_view algo_name);
79
80[[nodiscard]] std::optional<TPMI_ALG_SIG_SCHEME> rsa_signature_padding_botan_to_tss2(
81 std::string_view padding_name) noexcept;
82
83[[nodiscard]] std::optional<TPMT_SIG_SCHEME> rsa_signature_scheme_botan_to_tss2(std::string_view name);
84
85[[nodiscard]] std::optional<TPMI_ALG_ASYM_SCHEME> rsa_encryption_padding_botan_to_tss2(std::string_view name) noexcept;
86
87[[nodiscard]] std::optional<TPMT_RSA_DECRYPT> rsa_encryption_scheme_botan_to_tss2(std::string_view padding);
88
89} // namespace Botan::TPM2
90
91#endif
const char * name
Definition ffi_tls.h:59
std::optional< TPMT_SIG_SCHEME > rsa_signature_scheme_botan_to_tss2(std::string_view name)
std::optional< TPMI_ALG_SIG_SCHEME > rsa_signature_padding_botan_to_tss2(std::string_view padding_name) noexcept
std::optional< TPMI_ALG_ASYM_SCHEME > rsa_encryption_padding_botan_to_tss2(std::string_view 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 > cipher_mode_tss2_to_botan(TPMI_ALG_SYM_MODE mode_id)
std::optional< size_t > curve_id_order_byte_size(TPMI_ECC_CURVE curve_id)
std::optional< TPMT_SYM_DEF > cipher_botan_to_tss2(std::string_view algo_name)
std::optional< TPMT_RSA_DECRYPT > rsa_encryption_scheme_botan_to_tss2(std::string_view padding)
std::optional< std::string > hash_algo_tss2_to_botan(TPMI_ALG_HASH hash_id)
std::optional< std::string > curve_id_tss2_to_botan(TPMI_ECC_CURVE mode_id)
std::optional< TPMI_ALG_HASH > hash_algo_botan_to_tss2(std::string_view hash_name) noexcept
TPMI_ALG_HASH get_tpm2_hash_type(std::string_view hash_name)
std::optional< TPM2_ECC_CURVE > get_tpm2_curve_id(const OID &curve_oid)
std::optional< std::string > block_cipher_tss2_to_botan(TPMI_ALG_SYM cipher_id, TPM2_KEY_BITS key_bits)
std::optional< std::string > cipher_tss2_to_botan(TPMT_SYM_DEF cipher_def)
std::optional< TPM2_ALG_ID > asymmetric_algorithm_botan_to_tss2(std::string_view algo_name) noexcept
TPMT_SYM_DEF get_tpm2_sym_cipher_spec(std::string_view algo_name)
std::optional< TPMI_ALG_SYM_MODE > cipher_mode_botan_to_tss2(std::string_view mode_name) noexcept
std::string get_botan_hash_name(TPM2_ALG_ID hash_id)