Tpm2 policy calc
tpm2_policy_calc ¶
A module containing classes used to calculate TPM 2.0 policies.
PolicyHasher ¶
An object used to hash TPM 2.0 policies with a specified hash.
__init__ ¶
__init__(hash_type: str) -> PolicyHasher
Init the hasher with the specified hash.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hash_type |
str
|
sha256 or sha384 |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Invalid hash type |
PolicyTreeOr ¶
Object representing an OR junction in a policy tree.
__init__ ¶
__init__(
components: Union[
PolicyTreeAnd, PolicyTreeOr, PolicyTreeSolo
],
) -> PolicyTreeOr
Inits the policy tree junction with a list of connected components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
components |
list
|
list of components |
required |
Raises:
Type | Description |
---|---|
ValueError
|
More then 8 connections |
get_policy_buffer ¶
get_policy_buffer(
hash_obj: Union[
PolicyTreeAnd, PolicyTreeOr, PolicyTreeSolo
],
) -> bytes
Creates and returns a buffer representing the policy.
get_policy ¶
get_policy(
hash_obj: Union[
PolicyTreeAnd, PolicyTreeOr, PolicyTreeSolo
],
) -> int
Returns a hashed policy buffer.
PolicyTreeAnd ¶
Object representing an AND junction in a policy tree.
__init__ ¶
__init__(
components: list[
Union[PolicyTreeAnd, PolicyTreeOr, PolicyTreeSolo]
],
) -> PolicyTreeAnd
Inits the policy tree junction with a list of connected components.
get_policy ¶
get_policy(
hash_obj: Union[
PolicyTreeAnd, PolicyTreeOr, PolicyTreeSolo
],
) -> bytes
Returns a hashed policy buffer.
PolicyTreeSolo ¶
This object should only be used to put a single policy claim under an OR.
__init__ ¶
__init__(
policy_obj: Union[
PolicyTreeAnd, PolicyTreeOr, PolicyTreeSolo
],
) -> PolicyTreeSolo
Inits the policy tree junction.
get_policy_buffer ¶
get_policy_buffer(
hash_obj: Union[
PolicyTreeAnd, PolicyTreeOr, PolicyTreeSolo
],
) -> bytes
Creates and returns a buffer representing the policy.
get_policy ¶
get_policy(
hash_obj: Union[PolicyTreeAnd, PolicyTreeOr],
) -> int
Returns a hashed policy buffer.
PolicyLocality ¶
Policy Primitive to describe a single assertion to create complex assertions.
calc_bitfield_from_list ¶
calc_bitfield_from_list(localities: list[int]) -> int
Calculate the bitfield from a list of localities.
get_buffer_for_digest ¶
get_buffer_for_digest() -> str
Serializes the primitive.
Returns:
Type | Description |
---|---|
str
|
string representing packed data as bytes (i.e. b'\x01\x00\x03') |
PolicyCommandCode ¶
Policy Primitive to describe a Command code.
__init__ ¶
__init__(
command_code_string: Optional[str] = None,
) -> PolicyCommandCode
Init with the requested command code string.
get_buffer_for_digest ¶
get_buffer_for_digest() -> str
Serializes the primitive.
Returns:
Type | Description |
---|---|
str
|
string representing packed data as bytes (i.e. b'\x01\x00\x03') |