@@ -120,25 +120,26 @@ fn rotate_key_from_tee_device(device: Option<&CStr>, info: KeyInfo) -> Result<()
120
120
call_command ( device, & mut op, TaKeysafeCommand :: RotateHardwareDerivedKey )
121
121
}
122
122
123
- /// Gets a hardware derived key using the first device found in /svc/fuchsia.hardware. tee.Service .
123
+ /// Gets a hardware derived key using the first device found in /dev/class/ tee.
124
124
/// This is useful in early boot when other services may not be up.
125
125
pub async fn get_hardware_derived_key ( info : KeyInfo ) -> Result < Vec < u8 > , Error > {
126
- const TEE_SERVICE : & str = "/svc/fuchsia.hardware.tee.Service" ;
127
- const TEE_SERVICE_MEMBER : & str = "device_connector" ;
126
+ const DEV_CLASS_TEE : & str = "/dev/class/tee" ;
128
127
129
- let dir = fuchsia_fs:: directory:: open_in_namespace ( TEE_SERVICE , fuchsia_fs:: Flags :: empty ( ) ) ?;
128
+ let dir = fuchsia_fs:: directory:: open_in_namespace ( DEV_CLASS_TEE , fuchsia_fs:: Flags :: empty ( ) ) ?;
130
129
let mut stream = device_watcher:: watch_for_files ( & dir) . await ?;
131
130
let first = stream
132
131
. try_next ( )
133
132
. map_err ( Error :: from)
134
133
. on_timeout ( std:: time:: Duration :: from_secs ( 5 ) , || Err ( Error :: TeeDeviceWaitTimeout ) )
135
134
. await ?;
136
135
let first = first. ok_or_else ( || {
137
- Error :: TeeDeviceWaitFailure ( anyhow:: anyhow!( "'{TEE_SERVICE}' watcher closed unexpectedly" ) )
136
+ Error :: TeeDeviceWaitFailure ( anyhow:: anyhow!(
137
+ "'{DEV_CLASS_TEE}' watcher closed unexpectedly"
138
+ ) )
138
139
} ) ?;
139
140
let first = first. to_str ( ) . expect ( "paths are utf-8" ) ;
140
141
141
- let dev = format ! ( "{TEE_SERVICE }/{first}/{TEE_SERVICE_MEMBER }" ) ;
142
+ let dev = format ! ( "{DEV_CLASS_TEE }/{first}" ) ;
142
143
let dev = CString :: new ( dev) . expect ( "paths do not contain nul bytes" ) ;
143
144
get_key_from_tee_device ( Some ( & dev) , info)
144
145
}
@@ -149,25 +150,26 @@ pub async fn get_hardware_derived_key_from_service(info: KeyInfo) -> Result<Vec<
149
150
get_key_from_tee_device ( None , info)
150
151
}
151
152
152
- /// Rotates the hardware derived key from a tee device at /svc/fuchsia.hardware. tee.Service .
153
+ /// Rotates the hardware derived key from a tee device at the /dev/class/ tee.
153
154
/// This is useful in early boot when other services may not be up.
154
155
pub async fn rotate_hardware_derived_key ( info : KeyInfo ) -> Result < ( ) , Error > {
155
- const TEE_SERVICE : & str = "/svc/fuchsia.hardware.tee.Service" ;
156
- const TEE_SERVICE_MEMBER : & str = "device_connector" ;
156
+ const DEV_CLASS_TEE : & str = "/dev/class/tee" ;
157
157
158
- let dir = fuchsia_fs:: directory:: open_in_namespace ( TEE_SERVICE , fuchsia_fs:: Flags :: empty ( ) ) ?;
158
+ let dir = fuchsia_fs:: directory:: open_in_namespace ( DEV_CLASS_TEE , fuchsia_fs:: Flags :: empty ( ) ) ?;
159
159
let mut stream = device_watcher:: watch_for_files ( & dir) . await ?;
160
160
let first = stream
161
161
. try_next ( )
162
162
. map_err ( Error :: from)
163
163
. on_timeout ( std:: time:: Duration :: from_secs ( 5 ) , || Err ( Error :: TeeDeviceWaitTimeout ) )
164
164
. await ?;
165
165
let first = first. ok_or_else ( || {
166
- Error :: TeeDeviceWaitFailure ( anyhow:: anyhow!( "'{TEE_SERVICE}' watcher closed unexpectedly" ) )
166
+ Error :: TeeDeviceWaitFailure ( anyhow:: anyhow!(
167
+ "'{DEV_CLASS_TEE}' watcher closed unexpectedly"
168
+ ) )
167
169
} ) ?;
168
170
let first = first. to_str ( ) . expect ( "paths are utf-8" ) ;
169
171
170
- let dev = format ! ( "{TEE_SERVICE }/{first}/{TEE_SERVICE_MEMBER }" ) ;
172
+ let dev = format ! ( "{DEV_CLASS_TEE }/{first}" ) ;
171
173
let dev = CString :: new ( dev) . expect ( "paths do not contain nul bytes" ) ;
172
174
rotate_key_from_tee_device ( Some ( & dev) , info)
173
175
}
0 commit comments