tss_esapi/attributes/
algorithm.rs

1// Copyright 2021 Contributors to the Parsec project.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::tss2_esys::TPMA_ALGORITHM;
5use bitfield::bitfield;
6
7bitfield! {
8    /// Bitfield representing the algorithm attributes.
9    #[derive(Copy, Clone, Eq, PartialEq)]
10    pub struct AlgorithmAttributes(TPMA_ALGORITHM);
11    impl Debug;
12
13    pub asymmetric, _: 0;
14    pub symmetric, _: 1;
15    pub hash, _: 2;
16    pub object, _: 3;
17    // 7:4 Reserved
18    pub signing, _: 8;
19    pub encrypting, _: 9;
20    pub method, _: 10;
21    // 31:11 Reserved
22}
23
24impl From<TPMA_ALGORITHM> for AlgorithmAttributes {
25    fn from(tpma_algorithm: TPMA_ALGORITHM) -> Self {
26        AlgorithmAttributes(tpma_algorithm)
27    }
28}
29
30impl From<AlgorithmAttributes> for TPMA_ALGORITHM {
31    fn from(algorithm_attributes: AlgorithmAttributes) -> Self {
32        algorithm_attributes.0
33    }
34}