@@ -61,111 +61,3 @@ where
6161 }
6262 }
6363}
64-
65- #[ cfg( test) ]
66- mod tests {
67- use super :: * ;
68- use crate :: config:: KeylimeConfig ;
69- use keylime:: agent_data:: AgentData ;
70- use keylime:: algorithms:: {
71- EncryptionAlgorithm , HashAlgorithm , SignAlgorithm ,
72- } ;
73- use keylime:: hash_ek;
74- use std:: convert:: TryFrom ;
75- use tss_esapi:: {
76- handles:: KeyHandle ,
77- interface_types:: algorithm:: AsymmetricAlgorithm ,
78- interface_types:: resource_handles:: Hierarchy ,
79- structures:: { Auth , PublicBuffer } ,
80- traits:: Marshall ,
81- Context ,
82- } ;
83-
84- #[ tokio:: test]
85- #[ cfg( feature = "testing" ) ]
86- async fn test_agent_data ( ) -> Result < ( ) > {
87- let _mutex = tpm:: testing:: lock_tests ( ) . await ;
88- let mut config = KeylimeConfig :: default ( ) ;
89-
90- let mut ctx = tpm:: Context :: new ( ) ?;
91-
92- let tpm_encryption_alg = EncryptionAlgorithm :: try_from (
93- config. agent . tpm_encryption_alg . as_str ( ) ,
94- ) ?;
95-
96- let tpm_hash_alg =
97- HashAlgorithm :: try_from ( config. agent . tpm_hash_alg . as_str ( ) )
98- . expect ( "Failed to get hash algorithm" ) ;
99-
100- let tpm_signing_alg =
101- SignAlgorithm :: try_from ( config. agent . tpm_signing_alg . as_str ( ) )
102- . expect ( "Failed to get signing algorithm" ) ;
103-
104- let ek_result = ctx
105- . create_ek ( tpm_encryption_alg, None )
106- . expect ( "Failed to create EK" ) ;
107-
108- let ek_hash = hash_ek:: hash_ek_pubkey ( ek_result. public )
109- . expect ( "Failed to get pubkey" ) ;
110-
111- let ak = ctx. create_ak (
112- ek_result. key_handle ,
113- tpm_hash_alg,
114- tpm_encryption_alg,
115- tpm_signing_alg,
116- ) ?;
117-
118- let agent_data_test = AgentData :: create (
119- tpm_hash_alg,
120- tpm_signing_alg,
121- & ak,
122- ek_hash. as_bytes ( ) ,
123- ) ?;
124-
125- let valid = AgentData :: valid (
126- & agent_data_test,
127- tpm_hash_alg,
128- tpm_signing_alg,
129- ek_hash. as_bytes ( ) ,
130- ) ;
131-
132- assert ! ( valid) ;
133-
134- // Cleanup created keys
135- let ak_handle = ctx. load_ak ( ek_result. key_handle , & ak) ?;
136- ctx. flush_context ( ak_handle. into ( ) ) ;
137- ctx. flush_context ( ek_result. key_handle . into ( ) ) ;
138-
139- Ok ( ( ) )
140- }
141-
142- #[ tokio:: test]
143- #[ cfg( feature = "testing" ) ]
144- async fn test_hash ( ) -> Result < ( ) > {
145- use keylime:: agent_data;
146- use keylime:: hash_ek;
147-
148- let _mutex = tpm:: testing:: lock_tests ( ) . await ;
149- let mut config = KeylimeConfig :: default ( ) ;
150-
151- let mut ctx = tpm:: Context :: new ( ) ?;
152-
153- let tpm_encryption_alg = EncryptionAlgorithm :: try_from (
154- config. agent . tpm_encryption_alg . as_str ( ) ,
155- )
156- . expect ( "Failed to get encryption algorithm" ) ;
157-
158- let ek_result = ctx
159- . create_ek ( tpm_encryption_alg, None )
160- . expect ( "Failed to create EK" ) ;
161-
162- let result = hash_ek:: hash_ek_pubkey ( ek_result. public ) ;
163-
164- assert ! ( result. is_ok( ) ) ;
165-
166- // Cleanup created keys
167- ctx. flush_context ( ek_result. key_handle . into ( ) ) ;
168-
169- Ok ( ( ) )
170- }
171- }
0 commit comments