fidl_fuchsia_security_keymint/
fidl_fuchsia_security_keymint.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_security_keymint__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct AdminMarker;
16
17impl fidl::endpoints::ProtocolMarker for AdminMarker {
18    type Proxy = AdminProxy;
19    type RequestStream = AdminRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = AdminSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.security.keymint.Admin";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for AdminMarker {}
26pub type AdminDeleteAllKeysResult = Result<(), DeleteError>;
27
28pub trait AdminProxyInterface: Send + Sync {
29    type DeleteAllKeysResponseFut: std::future::Future<Output = Result<AdminDeleteAllKeysResult, fidl::Error>>
30        + Send;
31    fn r#delete_all_keys(&self) -> Self::DeleteAllKeysResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct AdminSynchronousProxy {
36    client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for AdminSynchronousProxy {
41    type Proxy = AdminProxy;
42    type Protocol = AdminMarker;
43
44    fn from_channel(inner: fidl::Channel) -> Self {
45        Self::new(inner)
46    }
47
48    fn into_channel(self) -> fidl::Channel {
49        self.client.into_channel()
50    }
51
52    fn as_channel(&self) -> &fidl::Channel {
53        self.client.as_channel()
54    }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl AdminSynchronousProxy {
59    pub fn new(channel: fidl::Channel) -> Self {
60        let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
61        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
62    }
63
64    pub fn into_channel(self) -> fidl::Channel {
65        self.client.into_channel()
66    }
67
68    /// Waits until an event arrives and returns it. It is safe for other
69    /// threads to make concurrent requests while waiting for an event.
70    pub fn wait_for_event(
71        &self,
72        deadline: zx::MonotonicInstant,
73    ) -> Result<AdminEvent, fidl::Error> {
74        AdminEvent::decode(self.client.wait_for_event(deadline)?)
75    }
76
77    /// Deletes all keymint-managed keys that rely on TEE state. For example, keys tagged with
78    /// `Tag::ROLLBACK_RESISTANCE` may be rendered unusable due to bumping a securely managed
79    /// anti-rollback counter or keys tagged with `Tag::USER_SECURE_ID` may be rendered unusable
80    /// due to securely stored user ID bindings. The precise set of affected keys depends on the
81    /// TEE implementation supporting keymint.
82    pub fn r#delete_all_keys(
83        &self,
84        ___deadline: zx::MonotonicInstant,
85    ) -> Result<AdminDeleteAllKeysResult, fidl::Error> {
86        let _response = self.client.send_query::<
87            fidl::encoding::EmptyPayload,
88            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, DeleteError>,
89        >(
90            (),
91            0x7865f60b70087392,
92            fidl::encoding::DynamicFlags::empty(),
93            ___deadline,
94        )?;
95        Ok(_response.map(|x| x))
96    }
97}
98
99#[cfg(target_os = "fuchsia")]
100impl From<AdminSynchronousProxy> for zx::NullableHandle {
101    fn from(value: AdminSynchronousProxy) -> Self {
102        value.into_channel().into()
103    }
104}
105
106#[cfg(target_os = "fuchsia")]
107impl From<fidl::Channel> for AdminSynchronousProxy {
108    fn from(value: fidl::Channel) -> Self {
109        Self::new(value)
110    }
111}
112
113#[cfg(target_os = "fuchsia")]
114impl fidl::endpoints::FromClient for AdminSynchronousProxy {
115    type Protocol = AdminMarker;
116
117    fn from_client(value: fidl::endpoints::ClientEnd<AdminMarker>) -> Self {
118        Self::new(value.into_channel())
119    }
120}
121
122#[derive(Debug, Clone)]
123pub struct AdminProxy {
124    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
125}
126
127impl fidl::endpoints::Proxy for AdminProxy {
128    type Protocol = AdminMarker;
129
130    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
131        Self::new(inner)
132    }
133
134    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
135        self.client.into_channel().map_err(|client| Self { client })
136    }
137
138    fn as_channel(&self) -> &::fidl::AsyncChannel {
139        self.client.as_channel()
140    }
141}
142
143impl AdminProxy {
144    /// Create a new Proxy for fuchsia.security.keymint/Admin.
145    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
146        let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
147        Self { client: fidl::client::Client::new(channel, protocol_name) }
148    }
149
150    /// Get a Stream of events from the remote end of the protocol.
151    ///
152    /// # Panics
153    ///
154    /// Panics if the event stream was already taken.
155    pub fn take_event_stream(&self) -> AdminEventStream {
156        AdminEventStream { event_receiver: self.client.take_event_receiver() }
157    }
158
159    /// Deletes all keymint-managed keys that rely on TEE state. For example, keys tagged with
160    /// `Tag::ROLLBACK_RESISTANCE` may be rendered unusable due to bumping a securely managed
161    /// anti-rollback counter or keys tagged with `Tag::USER_SECURE_ID` may be rendered unusable
162    /// due to securely stored user ID bindings. The precise set of affected keys depends on the
163    /// TEE implementation supporting keymint.
164    pub fn r#delete_all_keys(
165        &self,
166    ) -> fidl::client::QueryResponseFut<
167        AdminDeleteAllKeysResult,
168        fidl::encoding::DefaultFuchsiaResourceDialect,
169    > {
170        AdminProxyInterface::r#delete_all_keys(self)
171    }
172}
173
174impl AdminProxyInterface for AdminProxy {
175    type DeleteAllKeysResponseFut = fidl::client::QueryResponseFut<
176        AdminDeleteAllKeysResult,
177        fidl::encoding::DefaultFuchsiaResourceDialect,
178    >;
179    fn r#delete_all_keys(&self) -> Self::DeleteAllKeysResponseFut {
180        fn _decode(
181            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
182        ) -> Result<AdminDeleteAllKeysResult, fidl::Error> {
183            let _response = fidl::client::decode_transaction_body::<
184                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, DeleteError>,
185                fidl::encoding::DefaultFuchsiaResourceDialect,
186                0x7865f60b70087392,
187            >(_buf?)?;
188            Ok(_response.map(|x| x))
189        }
190        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AdminDeleteAllKeysResult>(
191            (),
192            0x7865f60b70087392,
193            fidl::encoding::DynamicFlags::empty(),
194            _decode,
195        )
196    }
197}
198
199pub struct AdminEventStream {
200    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
201}
202
203impl std::marker::Unpin for AdminEventStream {}
204
205impl futures::stream::FusedStream for AdminEventStream {
206    fn is_terminated(&self) -> bool {
207        self.event_receiver.is_terminated()
208    }
209}
210
211impl futures::Stream for AdminEventStream {
212    type Item = Result<AdminEvent, fidl::Error>;
213
214    fn poll_next(
215        mut self: std::pin::Pin<&mut Self>,
216        cx: &mut std::task::Context<'_>,
217    ) -> std::task::Poll<Option<Self::Item>> {
218        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
219            &mut self.event_receiver,
220            cx
221        )?) {
222            Some(buf) => std::task::Poll::Ready(Some(AdminEvent::decode(buf))),
223            None => std::task::Poll::Ready(None),
224        }
225    }
226}
227
228#[derive(Debug)]
229pub enum AdminEvent {}
230
231impl AdminEvent {
232    /// Decodes a message buffer as a [`AdminEvent`].
233    fn decode(
234        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
235    ) -> Result<AdminEvent, fidl::Error> {
236        let (bytes, _handles) = buf.split_mut();
237        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
238        debug_assert_eq!(tx_header.tx_id, 0);
239        match tx_header.ordinal {
240            _ => Err(fidl::Error::UnknownOrdinal {
241                ordinal: tx_header.ordinal,
242                protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
243            }),
244        }
245    }
246}
247
248/// A Stream of incoming requests for fuchsia.security.keymint/Admin.
249pub struct AdminRequestStream {
250    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
251    is_terminated: bool,
252}
253
254impl std::marker::Unpin for AdminRequestStream {}
255
256impl futures::stream::FusedStream for AdminRequestStream {
257    fn is_terminated(&self) -> bool {
258        self.is_terminated
259    }
260}
261
262impl fidl::endpoints::RequestStream for AdminRequestStream {
263    type Protocol = AdminMarker;
264    type ControlHandle = AdminControlHandle;
265
266    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
267        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
268    }
269
270    fn control_handle(&self) -> Self::ControlHandle {
271        AdminControlHandle { inner: self.inner.clone() }
272    }
273
274    fn into_inner(
275        self,
276    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
277    {
278        (self.inner, self.is_terminated)
279    }
280
281    fn from_inner(
282        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
283        is_terminated: bool,
284    ) -> Self {
285        Self { inner, is_terminated }
286    }
287}
288
289impl futures::Stream for AdminRequestStream {
290    type Item = Result<AdminRequest, fidl::Error>;
291
292    fn poll_next(
293        mut self: std::pin::Pin<&mut Self>,
294        cx: &mut std::task::Context<'_>,
295    ) -> std::task::Poll<Option<Self::Item>> {
296        let this = &mut *self;
297        if this.inner.check_shutdown(cx) {
298            this.is_terminated = true;
299            return std::task::Poll::Ready(None);
300        }
301        if this.is_terminated {
302            panic!("polled AdminRequestStream after completion");
303        }
304        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
305            |bytes, handles| {
306                match this.inner.channel().read_etc(cx, bytes, handles) {
307                    std::task::Poll::Ready(Ok(())) => {}
308                    std::task::Poll::Pending => return std::task::Poll::Pending,
309                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
310                        this.is_terminated = true;
311                        return std::task::Poll::Ready(None);
312                    }
313                    std::task::Poll::Ready(Err(e)) => {
314                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
315                            e.into(),
316                        ))));
317                    }
318                }
319
320                // A message has been received from the channel
321                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
322
323                std::task::Poll::Ready(Some(match header.ordinal {
324                    0x7865f60b70087392 => {
325                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
326                        let mut req = fidl::new_empty!(
327                            fidl::encoding::EmptyPayload,
328                            fidl::encoding::DefaultFuchsiaResourceDialect
329                        );
330                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
331                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
332                        Ok(AdminRequest::DeleteAllKeys {
333                            responder: AdminDeleteAllKeysResponder {
334                                control_handle: std::mem::ManuallyDrop::new(control_handle),
335                                tx_id: header.tx_id,
336                            },
337                        })
338                    }
339                    _ => Err(fidl::Error::UnknownOrdinal {
340                        ordinal: header.ordinal,
341                        protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
342                    }),
343                }))
344            },
345        )
346    }
347}
348
349/// Provides administrative operations for key management.
350#[derive(Debug)]
351pub enum AdminRequest {
352    /// Deletes all keymint-managed keys that rely on TEE state. For example, keys tagged with
353    /// `Tag::ROLLBACK_RESISTANCE` may be rendered unusable due to bumping a securely managed
354    /// anti-rollback counter or keys tagged with `Tag::USER_SECURE_ID` may be rendered unusable
355    /// due to securely stored user ID bindings. The precise set of affected keys depends on the
356    /// TEE implementation supporting keymint.
357    DeleteAllKeys { responder: AdminDeleteAllKeysResponder },
358}
359
360impl AdminRequest {
361    #[allow(irrefutable_let_patterns)]
362    pub fn into_delete_all_keys(self) -> Option<(AdminDeleteAllKeysResponder)> {
363        if let AdminRequest::DeleteAllKeys { responder } = self { Some((responder)) } else { None }
364    }
365
366    /// Name of the method defined in FIDL
367    pub fn method_name(&self) -> &'static str {
368        match *self {
369            AdminRequest::DeleteAllKeys { .. } => "delete_all_keys",
370        }
371    }
372}
373
374#[derive(Debug, Clone)]
375pub struct AdminControlHandle {
376    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
377}
378
379impl fidl::endpoints::ControlHandle for AdminControlHandle {
380    fn shutdown(&self) {
381        self.inner.shutdown()
382    }
383
384    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
385        self.inner.shutdown_with_epitaph(status)
386    }
387
388    fn is_closed(&self) -> bool {
389        self.inner.channel().is_closed()
390    }
391    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
392        self.inner.channel().on_closed()
393    }
394
395    #[cfg(target_os = "fuchsia")]
396    fn signal_peer(
397        &self,
398        clear_mask: zx::Signals,
399        set_mask: zx::Signals,
400    ) -> Result<(), zx_status::Status> {
401        use fidl::Peered;
402        self.inner.channel().signal_peer(clear_mask, set_mask)
403    }
404}
405
406impl AdminControlHandle {}
407
408#[must_use = "FIDL methods require a response to be sent"]
409#[derive(Debug)]
410pub struct AdminDeleteAllKeysResponder {
411    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
412    tx_id: u32,
413}
414
415/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
416/// if the responder is dropped without sending a response, so that the client
417/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
418impl std::ops::Drop for AdminDeleteAllKeysResponder {
419    fn drop(&mut self) {
420        self.control_handle.shutdown();
421        // Safety: drops once, never accessed again
422        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
423    }
424}
425
426impl fidl::endpoints::Responder for AdminDeleteAllKeysResponder {
427    type ControlHandle = AdminControlHandle;
428
429    fn control_handle(&self) -> &AdminControlHandle {
430        &self.control_handle
431    }
432
433    fn drop_without_shutdown(mut self) {
434        // Safety: drops once, never accessed again due to mem::forget
435        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
436        // Prevent Drop from running (which would shut down the channel)
437        std::mem::forget(self);
438    }
439}
440
441impl AdminDeleteAllKeysResponder {
442    /// Sends a response to the FIDL transaction.
443    ///
444    /// Sets the channel to shutdown if an error occurs.
445    pub fn send(self, mut result: Result<(), DeleteError>) -> Result<(), fidl::Error> {
446        let _result = self.send_raw(result);
447        if _result.is_err() {
448            self.control_handle.shutdown();
449        }
450        self.drop_without_shutdown();
451        _result
452    }
453
454    /// Similar to "send" but does not shutdown the channel if an error occurs.
455    pub fn send_no_shutdown_on_err(
456        self,
457        mut result: Result<(), DeleteError>,
458    ) -> Result<(), fidl::Error> {
459        let _result = self.send_raw(result);
460        self.drop_without_shutdown();
461        _result
462    }
463
464    fn send_raw(&self, mut result: Result<(), DeleteError>) -> Result<(), fidl::Error> {
465        self.control_handle.inner.send::<fidl::encoding::ResultType<
466            fidl::encoding::EmptyStruct,
467            DeleteError,
468        >>(
469            result,
470            self.tx_id,
471            0x7865f60b70087392,
472            fidl::encoding::DynamicFlags::empty(),
473        )
474    }
475}
476
477#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
478pub struct SealingKeysMarker;
479
480impl fidl::endpoints::ProtocolMarker for SealingKeysMarker {
481    type Proxy = SealingKeysProxy;
482    type RequestStream = SealingKeysRequestStream;
483    #[cfg(target_os = "fuchsia")]
484    type SynchronousProxy = SealingKeysSynchronousProxy;
485
486    const DEBUG_NAME: &'static str = "fuchsia.security.keymint.SealingKeys";
487}
488impl fidl::endpoints::DiscoverableProtocolMarker for SealingKeysMarker {}
489pub type SealingKeysCreateSealingKeyResult = Result<Vec<u8>, CreateError>;
490pub type SealingKeysSealResult = Result<Vec<u8>, SealError>;
491pub type SealingKeysUnsealResult = Result<Vec<u8>, UnsealError>;
492pub type SealingKeysUpgradeSealingKeyResult = Result<Vec<u8>, UpgradeError>;
493pub type SealingKeysDeleteSealingKeyResult = Result<(), DeleteError>;
494
495pub trait SealingKeysProxyInterface: Send + Sync {
496    type CreateSealingKeyResponseFut: std::future::Future<Output = Result<SealingKeysCreateSealingKeyResult, fidl::Error>>
497        + Send;
498    fn r#create_sealing_key(&self, key_info: &[u8]) -> Self::CreateSealingKeyResponseFut;
499    type SealResponseFut: std::future::Future<Output = Result<SealingKeysSealResult, fidl::Error>>
500        + Send;
501    fn r#seal(&self, key_info: &[u8], key_blob: &[u8], secret: &[u8]) -> Self::SealResponseFut;
502    type UnsealResponseFut: std::future::Future<Output = Result<SealingKeysUnsealResult, fidl::Error>>
503        + Send;
504    fn r#unseal(
505        &self,
506        key_info: &[u8],
507        key_blob: &[u8],
508        sealed_secret: &[u8],
509    ) -> Self::UnsealResponseFut;
510    type UpgradeSealingKeyResponseFut: std::future::Future<Output = Result<SealingKeysUpgradeSealingKeyResult, fidl::Error>>
511        + Send;
512    fn r#upgrade_sealing_key(
513        &self,
514        key_info: &[u8],
515        key_blob: &[u8],
516    ) -> Self::UpgradeSealingKeyResponseFut;
517    type DeleteSealingKeyResponseFut: std::future::Future<Output = Result<SealingKeysDeleteSealingKeyResult, fidl::Error>>
518        + Send;
519    fn r#delete_sealing_key(&self, key_blob: &[u8]) -> Self::DeleteSealingKeyResponseFut;
520}
521#[derive(Debug)]
522#[cfg(target_os = "fuchsia")]
523pub struct SealingKeysSynchronousProxy {
524    client: fidl::client::sync::Client,
525}
526
527#[cfg(target_os = "fuchsia")]
528impl fidl::endpoints::SynchronousProxy for SealingKeysSynchronousProxy {
529    type Proxy = SealingKeysProxy;
530    type Protocol = SealingKeysMarker;
531
532    fn from_channel(inner: fidl::Channel) -> Self {
533        Self::new(inner)
534    }
535
536    fn into_channel(self) -> fidl::Channel {
537        self.client.into_channel()
538    }
539
540    fn as_channel(&self) -> &fidl::Channel {
541        self.client.as_channel()
542    }
543}
544
545#[cfg(target_os = "fuchsia")]
546impl SealingKeysSynchronousProxy {
547    pub fn new(channel: fidl::Channel) -> Self {
548        let protocol_name = <SealingKeysMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
549        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
550    }
551
552    pub fn into_channel(self) -> fidl::Channel {
553        self.client.into_channel()
554    }
555
556    /// Waits until an event arrives and returns it. It is safe for other
557    /// threads to make concurrent requests while waiting for an event.
558    pub fn wait_for_event(
559        &self,
560        deadline: zx::MonotonicInstant,
561    ) -> Result<SealingKeysEvent, fidl::Error> {
562        SealingKeysEvent::decode(self.client.wait_for_event(deadline)?)
563    }
564
565    /// Generates a new sealing key to seal and unseal secrets.
566    ///
567    /// |key_info| is information to be cryptographically bound to the returned key.
568    ///   * The client will have to supply it in all uses (other than key deletion) of the returned
569    ///     key.
570    ///   * It serves two purposes: (1) internally by the key manager to identify the key owner and
571    ///     (2) as a password to mitigate potential attacks from the key manager and as well as
572    ///     other clients.
573    ///   * It is recommended to include sufficient entropy in it (using it as a password) to
574    ///     mitigage potential attacks from the secure world (the key manager's execution
575    ///     environment) or from other clients.
576    ///   * It is acceptible to pass a constant if deriving and persisting a password is too
577    ///     cumbersome and the client fully trust the secure world and there are not many other
578    ///     clients.
579    ///
580    /// The client is responsible for persisting both |key_info| and the returned |key_blob|.
581    /// The key blob is encrypted with a TEE-private key. It is guaranteed to be unique for each
582    /// call (even with the same key info). It can be stored in unsecure storage.
583    ///
584    /// Returns:
585    ///   * The sealing key if everything worked.
586    ///   * FAILED_CREATE if the key creation failed, e.g., the |key_info| was empty.
587    pub fn r#create_sealing_key(
588        &self,
589        mut key_info: &[u8],
590        ___deadline: zx::MonotonicInstant,
591    ) -> Result<SealingKeysCreateSealingKeyResult, fidl::Error> {
592        let _response = self.client.send_query::<
593            SealingKeysCreateSealingKeyRequest,
594            fidl::encoding::ResultType<SealingKeysCreateSealingKeyResponse, CreateError>,
595        >(
596            (key_info,),
597            0x5a191cbb6a8081bc,
598            fidl::encoding::DynamicFlags::empty(),
599            ___deadline,
600        )?;
601        Ok(_response.map(|x| x.key_blob))
602    }
603
604    /// Seals a secret using a sealing key identified by its info and blob:
605    ///   * The key info has to match the one supplied when generating the sealing key.
606    ///
607    /// Note that the secret may be a key itself. It has no bearing on the seal operation.
608    ///
609    /// Returns:
610    ///   * The sealed secret if everything worked.
611    ///   * KEY_REQUIRES_UPGRADE if keymint indicates that the sealing key requires upgrade.
612    ///   * FAILED_SEAL if the sealing failed for another reason, e.g., sealing key info or blob
613    ///     mismatch.
614    pub fn r#seal(
615        &self,
616        mut key_info: &[u8],
617        mut key_blob: &[u8],
618        mut secret: &[u8],
619        ___deadline: zx::MonotonicInstant,
620    ) -> Result<SealingKeysSealResult, fidl::Error> {
621        let _response = self.client.send_query::<
622            SealingKeysSealRequest,
623            fidl::encoding::ResultType<SealingKeysSealResponse, SealError>,
624        >(
625            (key_info, key_blob, secret,),
626            0x10d41255013918d1,
627            fidl::encoding::DynamicFlags::empty(),
628            ___deadline,
629        )?;
630        Ok(_response.map(|x| x.sealed_secret))
631    }
632
633    /// Unseals a sealed secret using a sealing key identified by its info and blob:
634    ///   * The key info has to match the one supplied when generating the sealing key.
635    ///   * The key blob has to match the one used to seal the secret.
636    ///
637    /// Note that the secret may be a key itself. It has no bearing on the unseal operation.
638    ///
639    /// Returns:
640    ///   * The unsealed secret if everything worked.
641    ///   * KEY_REQUIRES_UPGRADE if keymint indicates that the sealing key requires upgrade.
642    ///   * FAILED_UNSEAL if the unsealing failed for another reason, e.g., sealing key info or blob
643    ///     mismatch.
644    pub fn r#unseal(
645        &self,
646        mut key_info: &[u8],
647        mut key_blob: &[u8],
648        mut sealed_secret: &[u8],
649        ___deadline: zx::MonotonicInstant,
650    ) -> Result<SealingKeysUnsealResult, fidl::Error> {
651        let _response = self.client.send_query::<
652            SealingKeysUnsealRequest,
653            fidl::encoding::ResultType<SealingKeysUnsealResponse, UnsealError>,
654        >(
655            (key_info, key_blob, sealed_secret,),
656            0x7037d75ecb579c83,
657            fidl::encoding::DynamicFlags::empty(),
658            ___deadline,
659        )?;
660        Ok(_response.map(|x| x.unsealed_secret))
661    }
662
663    /// Upgrades a sealing key that has been deemed out-of-date by keymint. The sealing key to
664    /// upgrade is identified by its info and blob:
665    ///   * The key info has to match the one supplied when generating the sealing key.
666    ///   * The key blob has to match the blob returned when generating the sealing key.
667    ///
668    /// Note that after upgrading a key, both the old key and new key will be occupying limited key
669    /// storage in keymint. This means that clients can unintentionally exhaust key storage in two
670    /// ways:
671    /// * Upgrading a key and failing to delete the old key after upgrade.
672    /// * Successfully upgrading a key, failing to persist the new key, and later (e.g., after a
673    ///   reboot) upgrading the key again.
674    ///
675    /// Both of the above missteps on the part of the client will "waste" one key slot in keymint,
676    /// and repeated missteps (e.g., a boot loop that upgrades a key, fails to persist the new key,
677    /// then reboots) can exhaust available key storage. Clients are responsible for old (upgraded)
678    /// keys and persisting new (result of a successful key upgrade) to ensure that key slots are
679    /// not wasted.
680    ///
681    ///  Returns
682    ///   * The upgraded key blob if everything worked.
683    ///   * FAILED_UPGRADE if the upgrade failed.
684    pub fn r#upgrade_sealing_key(
685        &self,
686        mut key_info: &[u8],
687        mut key_blob: &[u8],
688        ___deadline: zx::MonotonicInstant,
689    ) -> Result<SealingKeysUpgradeSealingKeyResult, fidl::Error> {
690        let _response = self.client.send_query::<
691            SealingKeysUpgradeSealingKeyRequest,
692            fidl::encoding::ResultType<SealingKeysUpgradeSealingKeyResponse, UpgradeError>,
693        >(
694            (key_info, key_blob,),
695            0x68584c5a799181e7,
696            fidl::encoding::DynamicFlags::empty(),
697            ___deadline,
698        )?;
699        Ok(_response.map(|x| x.key_blob))
700    }
701
702    /// Deletes a sealing key from keymint.
703    ///
704    /// This operation should be used to delete old (upgraded) keys.
705    ///
706    /// Returns
707    ///  * Nothing if everything worked.
708    ///  * FAILED_DELETE if deletion failed.
709    pub fn r#delete_sealing_key(
710        &self,
711        mut key_blob: &[u8],
712        ___deadline: zx::MonotonicInstant,
713    ) -> Result<SealingKeysDeleteSealingKeyResult, fidl::Error> {
714        let _response = self.client.send_query::<
715            SealingKeysDeleteSealingKeyRequest,
716            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, DeleteError>,
717        >(
718            (key_blob,),
719            0xad65bae761e8c3,
720            fidl::encoding::DynamicFlags::empty(),
721            ___deadline,
722        )?;
723        Ok(_response.map(|x| x))
724    }
725}
726
727#[cfg(target_os = "fuchsia")]
728impl From<SealingKeysSynchronousProxy> for zx::NullableHandle {
729    fn from(value: SealingKeysSynchronousProxy) -> Self {
730        value.into_channel().into()
731    }
732}
733
734#[cfg(target_os = "fuchsia")]
735impl From<fidl::Channel> for SealingKeysSynchronousProxy {
736    fn from(value: fidl::Channel) -> Self {
737        Self::new(value)
738    }
739}
740
741#[cfg(target_os = "fuchsia")]
742impl fidl::endpoints::FromClient for SealingKeysSynchronousProxy {
743    type Protocol = SealingKeysMarker;
744
745    fn from_client(value: fidl::endpoints::ClientEnd<SealingKeysMarker>) -> Self {
746        Self::new(value.into_channel())
747    }
748}
749
750#[derive(Debug, Clone)]
751pub struct SealingKeysProxy {
752    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
753}
754
755impl fidl::endpoints::Proxy for SealingKeysProxy {
756    type Protocol = SealingKeysMarker;
757
758    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
759        Self::new(inner)
760    }
761
762    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
763        self.client.into_channel().map_err(|client| Self { client })
764    }
765
766    fn as_channel(&self) -> &::fidl::AsyncChannel {
767        self.client.as_channel()
768    }
769}
770
771impl SealingKeysProxy {
772    /// Create a new Proxy for fuchsia.security.keymint/SealingKeys.
773    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
774        let protocol_name = <SealingKeysMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
775        Self { client: fidl::client::Client::new(channel, protocol_name) }
776    }
777
778    /// Get a Stream of events from the remote end of the protocol.
779    ///
780    /// # Panics
781    ///
782    /// Panics if the event stream was already taken.
783    pub fn take_event_stream(&self) -> SealingKeysEventStream {
784        SealingKeysEventStream { event_receiver: self.client.take_event_receiver() }
785    }
786
787    /// Generates a new sealing key to seal and unseal secrets.
788    ///
789    /// |key_info| is information to be cryptographically bound to the returned key.
790    ///   * The client will have to supply it in all uses (other than key deletion) of the returned
791    ///     key.
792    ///   * It serves two purposes: (1) internally by the key manager to identify the key owner and
793    ///     (2) as a password to mitigate potential attacks from the key manager and as well as
794    ///     other clients.
795    ///   * It is recommended to include sufficient entropy in it (using it as a password) to
796    ///     mitigage potential attacks from the secure world (the key manager's execution
797    ///     environment) or from other clients.
798    ///   * It is acceptible to pass a constant if deriving and persisting a password is too
799    ///     cumbersome and the client fully trust the secure world and there are not many other
800    ///     clients.
801    ///
802    /// The client is responsible for persisting both |key_info| and the returned |key_blob|.
803    /// The key blob is encrypted with a TEE-private key. It is guaranteed to be unique for each
804    /// call (even with the same key info). It can be stored in unsecure storage.
805    ///
806    /// Returns:
807    ///   * The sealing key if everything worked.
808    ///   * FAILED_CREATE if the key creation failed, e.g., the |key_info| was empty.
809    pub fn r#create_sealing_key(
810        &self,
811        mut key_info: &[u8],
812    ) -> fidl::client::QueryResponseFut<
813        SealingKeysCreateSealingKeyResult,
814        fidl::encoding::DefaultFuchsiaResourceDialect,
815    > {
816        SealingKeysProxyInterface::r#create_sealing_key(self, key_info)
817    }
818
819    /// Seals a secret using a sealing key identified by its info and blob:
820    ///   * The key info has to match the one supplied when generating the sealing key.
821    ///
822    /// Note that the secret may be a key itself. It has no bearing on the seal operation.
823    ///
824    /// Returns:
825    ///   * The sealed secret if everything worked.
826    ///   * KEY_REQUIRES_UPGRADE if keymint indicates that the sealing key requires upgrade.
827    ///   * FAILED_SEAL if the sealing failed for another reason, e.g., sealing key info or blob
828    ///     mismatch.
829    pub fn r#seal(
830        &self,
831        mut key_info: &[u8],
832        mut key_blob: &[u8],
833        mut secret: &[u8],
834    ) -> fidl::client::QueryResponseFut<
835        SealingKeysSealResult,
836        fidl::encoding::DefaultFuchsiaResourceDialect,
837    > {
838        SealingKeysProxyInterface::r#seal(self, key_info, key_blob, secret)
839    }
840
841    /// Unseals a sealed secret using a sealing key identified by its info and blob:
842    ///   * The key info has to match the one supplied when generating the sealing key.
843    ///   * The key blob has to match the one used to seal the secret.
844    ///
845    /// Note that the secret may be a key itself. It has no bearing on the unseal operation.
846    ///
847    /// Returns:
848    ///   * The unsealed secret if everything worked.
849    ///   * KEY_REQUIRES_UPGRADE if keymint indicates that the sealing key requires upgrade.
850    ///   * FAILED_UNSEAL if the unsealing failed for another reason, e.g., sealing key info or blob
851    ///     mismatch.
852    pub fn r#unseal(
853        &self,
854        mut key_info: &[u8],
855        mut key_blob: &[u8],
856        mut sealed_secret: &[u8],
857    ) -> fidl::client::QueryResponseFut<
858        SealingKeysUnsealResult,
859        fidl::encoding::DefaultFuchsiaResourceDialect,
860    > {
861        SealingKeysProxyInterface::r#unseal(self, key_info, key_blob, sealed_secret)
862    }
863
864    /// Upgrades a sealing key that has been deemed out-of-date by keymint. The sealing key to
865    /// upgrade is identified by its info and blob:
866    ///   * The key info has to match the one supplied when generating the sealing key.
867    ///   * The key blob has to match the blob returned when generating the sealing key.
868    ///
869    /// Note that after upgrading a key, both the old key and new key will be occupying limited key
870    /// storage in keymint. This means that clients can unintentionally exhaust key storage in two
871    /// ways:
872    /// * Upgrading a key and failing to delete the old key after upgrade.
873    /// * Successfully upgrading a key, failing to persist the new key, and later (e.g., after a
874    ///   reboot) upgrading the key again.
875    ///
876    /// Both of the above missteps on the part of the client will "waste" one key slot in keymint,
877    /// and repeated missteps (e.g., a boot loop that upgrades a key, fails to persist the new key,
878    /// then reboots) can exhaust available key storage. Clients are responsible for old (upgraded)
879    /// keys and persisting new (result of a successful key upgrade) to ensure that key slots are
880    /// not wasted.
881    ///
882    ///  Returns
883    ///   * The upgraded key blob if everything worked.
884    ///   * FAILED_UPGRADE if the upgrade failed.
885    pub fn r#upgrade_sealing_key(
886        &self,
887        mut key_info: &[u8],
888        mut key_blob: &[u8],
889    ) -> fidl::client::QueryResponseFut<
890        SealingKeysUpgradeSealingKeyResult,
891        fidl::encoding::DefaultFuchsiaResourceDialect,
892    > {
893        SealingKeysProxyInterface::r#upgrade_sealing_key(self, key_info, key_blob)
894    }
895
896    /// Deletes a sealing key from keymint.
897    ///
898    /// This operation should be used to delete old (upgraded) keys.
899    ///
900    /// Returns
901    ///  * Nothing if everything worked.
902    ///  * FAILED_DELETE if deletion failed.
903    pub fn r#delete_sealing_key(
904        &self,
905        mut key_blob: &[u8],
906    ) -> fidl::client::QueryResponseFut<
907        SealingKeysDeleteSealingKeyResult,
908        fidl::encoding::DefaultFuchsiaResourceDialect,
909    > {
910        SealingKeysProxyInterface::r#delete_sealing_key(self, key_blob)
911    }
912}
913
914impl SealingKeysProxyInterface for SealingKeysProxy {
915    type CreateSealingKeyResponseFut = fidl::client::QueryResponseFut<
916        SealingKeysCreateSealingKeyResult,
917        fidl::encoding::DefaultFuchsiaResourceDialect,
918    >;
919    fn r#create_sealing_key(&self, mut key_info: &[u8]) -> Self::CreateSealingKeyResponseFut {
920        fn _decode(
921            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
922        ) -> Result<SealingKeysCreateSealingKeyResult, fidl::Error> {
923            let _response = fidl::client::decode_transaction_body::<
924                fidl::encoding::ResultType<SealingKeysCreateSealingKeyResponse, CreateError>,
925                fidl::encoding::DefaultFuchsiaResourceDialect,
926                0x5a191cbb6a8081bc,
927            >(_buf?)?;
928            Ok(_response.map(|x| x.key_blob))
929        }
930        self.client.send_query_and_decode::<
931            SealingKeysCreateSealingKeyRequest,
932            SealingKeysCreateSealingKeyResult,
933        >(
934            (key_info,),
935            0x5a191cbb6a8081bc,
936            fidl::encoding::DynamicFlags::empty(),
937            _decode,
938        )
939    }
940
941    type SealResponseFut = fidl::client::QueryResponseFut<
942        SealingKeysSealResult,
943        fidl::encoding::DefaultFuchsiaResourceDialect,
944    >;
945    fn r#seal(
946        &self,
947        mut key_info: &[u8],
948        mut key_blob: &[u8],
949        mut secret: &[u8],
950    ) -> Self::SealResponseFut {
951        fn _decode(
952            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
953        ) -> Result<SealingKeysSealResult, fidl::Error> {
954            let _response = fidl::client::decode_transaction_body::<
955                fidl::encoding::ResultType<SealingKeysSealResponse, SealError>,
956                fidl::encoding::DefaultFuchsiaResourceDialect,
957                0x10d41255013918d1,
958            >(_buf?)?;
959            Ok(_response.map(|x| x.sealed_secret))
960        }
961        self.client.send_query_and_decode::<SealingKeysSealRequest, SealingKeysSealResult>(
962            (key_info, key_blob, secret),
963            0x10d41255013918d1,
964            fidl::encoding::DynamicFlags::empty(),
965            _decode,
966        )
967    }
968
969    type UnsealResponseFut = fidl::client::QueryResponseFut<
970        SealingKeysUnsealResult,
971        fidl::encoding::DefaultFuchsiaResourceDialect,
972    >;
973    fn r#unseal(
974        &self,
975        mut key_info: &[u8],
976        mut key_blob: &[u8],
977        mut sealed_secret: &[u8],
978    ) -> Self::UnsealResponseFut {
979        fn _decode(
980            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
981        ) -> Result<SealingKeysUnsealResult, fidl::Error> {
982            let _response = fidl::client::decode_transaction_body::<
983                fidl::encoding::ResultType<SealingKeysUnsealResponse, UnsealError>,
984                fidl::encoding::DefaultFuchsiaResourceDialect,
985                0x7037d75ecb579c83,
986            >(_buf?)?;
987            Ok(_response.map(|x| x.unsealed_secret))
988        }
989        self.client.send_query_and_decode::<SealingKeysUnsealRequest, SealingKeysUnsealResult>(
990            (key_info, key_blob, sealed_secret),
991            0x7037d75ecb579c83,
992            fidl::encoding::DynamicFlags::empty(),
993            _decode,
994        )
995    }
996
997    type UpgradeSealingKeyResponseFut = fidl::client::QueryResponseFut<
998        SealingKeysUpgradeSealingKeyResult,
999        fidl::encoding::DefaultFuchsiaResourceDialect,
1000    >;
1001    fn r#upgrade_sealing_key(
1002        &self,
1003        mut key_info: &[u8],
1004        mut key_blob: &[u8],
1005    ) -> Self::UpgradeSealingKeyResponseFut {
1006        fn _decode(
1007            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1008        ) -> Result<SealingKeysUpgradeSealingKeyResult, fidl::Error> {
1009            let _response = fidl::client::decode_transaction_body::<
1010                fidl::encoding::ResultType<SealingKeysUpgradeSealingKeyResponse, UpgradeError>,
1011                fidl::encoding::DefaultFuchsiaResourceDialect,
1012                0x68584c5a799181e7,
1013            >(_buf?)?;
1014            Ok(_response.map(|x| x.key_blob))
1015        }
1016        self.client.send_query_and_decode::<
1017            SealingKeysUpgradeSealingKeyRequest,
1018            SealingKeysUpgradeSealingKeyResult,
1019        >(
1020            (key_info, key_blob,),
1021            0x68584c5a799181e7,
1022            fidl::encoding::DynamicFlags::empty(),
1023            _decode,
1024        )
1025    }
1026
1027    type DeleteSealingKeyResponseFut = fidl::client::QueryResponseFut<
1028        SealingKeysDeleteSealingKeyResult,
1029        fidl::encoding::DefaultFuchsiaResourceDialect,
1030    >;
1031    fn r#delete_sealing_key(&self, mut key_blob: &[u8]) -> Self::DeleteSealingKeyResponseFut {
1032        fn _decode(
1033            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1034        ) -> Result<SealingKeysDeleteSealingKeyResult, fidl::Error> {
1035            let _response = fidl::client::decode_transaction_body::<
1036                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, DeleteError>,
1037                fidl::encoding::DefaultFuchsiaResourceDialect,
1038                0xad65bae761e8c3,
1039            >(_buf?)?;
1040            Ok(_response.map(|x| x))
1041        }
1042        self.client.send_query_and_decode::<
1043            SealingKeysDeleteSealingKeyRequest,
1044            SealingKeysDeleteSealingKeyResult,
1045        >(
1046            (key_blob,),
1047            0xad65bae761e8c3,
1048            fidl::encoding::DynamicFlags::empty(),
1049            _decode,
1050        )
1051    }
1052}
1053
1054pub struct SealingKeysEventStream {
1055    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1056}
1057
1058impl std::marker::Unpin for SealingKeysEventStream {}
1059
1060impl futures::stream::FusedStream for SealingKeysEventStream {
1061    fn is_terminated(&self) -> bool {
1062        self.event_receiver.is_terminated()
1063    }
1064}
1065
1066impl futures::Stream for SealingKeysEventStream {
1067    type Item = Result<SealingKeysEvent, fidl::Error>;
1068
1069    fn poll_next(
1070        mut self: std::pin::Pin<&mut Self>,
1071        cx: &mut std::task::Context<'_>,
1072    ) -> std::task::Poll<Option<Self::Item>> {
1073        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1074            &mut self.event_receiver,
1075            cx
1076        )?) {
1077            Some(buf) => std::task::Poll::Ready(Some(SealingKeysEvent::decode(buf))),
1078            None => std::task::Poll::Ready(None),
1079        }
1080    }
1081}
1082
1083#[derive(Debug)]
1084pub enum SealingKeysEvent {}
1085
1086impl SealingKeysEvent {
1087    /// Decodes a message buffer as a [`SealingKeysEvent`].
1088    fn decode(
1089        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1090    ) -> Result<SealingKeysEvent, fidl::Error> {
1091        let (bytes, _handles) = buf.split_mut();
1092        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1093        debug_assert_eq!(tx_header.tx_id, 0);
1094        match tx_header.ordinal {
1095            _ => Err(fidl::Error::UnknownOrdinal {
1096                ordinal: tx_header.ordinal,
1097                protocol_name: <SealingKeysMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1098            }),
1099        }
1100    }
1101}
1102
1103/// A Stream of incoming requests for fuchsia.security.keymint/SealingKeys.
1104pub struct SealingKeysRequestStream {
1105    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1106    is_terminated: bool,
1107}
1108
1109impl std::marker::Unpin for SealingKeysRequestStream {}
1110
1111impl futures::stream::FusedStream for SealingKeysRequestStream {
1112    fn is_terminated(&self) -> bool {
1113        self.is_terminated
1114    }
1115}
1116
1117impl fidl::endpoints::RequestStream for SealingKeysRequestStream {
1118    type Protocol = SealingKeysMarker;
1119    type ControlHandle = SealingKeysControlHandle;
1120
1121    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1122        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1123    }
1124
1125    fn control_handle(&self) -> Self::ControlHandle {
1126        SealingKeysControlHandle { inner: self.inner.clone() }
1127    }
1128
1129    fn into_inner(
1130        self,
1131    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1132    {
1133        (self.inner, self.is_terminated)
1134    }
1135
1136    fn from_inner(
1137        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1138        is_terminated: bool,
1139    ) -> Self {
1140        Self { inner, is_terminated }
1141    }
1142}
1143
1144impl futures::Stream for SealingKeysRequestStream {
1145    type Item = Result<SealingKeysRequest, fidl::Error>;
1146
1147    fn poll_next(
1148        mut self: std::pin::Pin<&mut Self>,
1149        cx: &mut std::task::Context<'_>,
1150    ) -> std::task::Poll<Option<Self::Item>> {
1151        let this = &mut *self;
1152        if this.inner.check_shutdown(cx) {
1153            this.is_terminated = true;
1154            return std::task::Poll::Ready(None);
1155        }
1156        if this.is_terminated {
1157            panic!("polled SealingKeysRequestStream after completion");
1158        }
1159        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1160            |bytes, handles| {
1161                match this.inner.channel().read_etc(cx, bytes, handles) {
1162                    std::task::Poll::Ready(Ok(())) => {}
1163                    std::task::Poll::Pending => return std::task::Poll::Pending,
1164                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1165                        this.is_terminated = true;
1166                        return std::task::Poll::Ready(None);
1167                    }
1168                    std::task::Poll::Ready(Err(e)) => {
1169                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1170                            e.into(),
1171                        ))));
1172                    }
1173                }
1174
1175                // A message has been received from the channel
1176                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1177
1178                std::task::Poll::Ready(Some(match header.ordinal {
1179                    0x5a191cbb6a8081bc => {
1180                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1181                        let mut req = fidl::new_empty!(
1182                            SealingKeysCreateSealingKeyRequest,
1183                            fidl::encoding::DefaultFuchsiaResourceDialect
1184                        );
1185                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SealingKeysCreateSealingKeyRequest>(&header, _body_bytes, handles, &mut req)?;
1186                        let control_handle = SealingKeysControlHandle { inner: this.inner.clone() };
1187                        Ok(SealingKeysRequest::CreateSealingKey {
1188                            key_info: req.key_info,
1189
1190                            responder: SealingKeysCreateSealingKeyResponder {
1191                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1192                                tx_id: header.tx_id,
1193                            },
1194                        })
1195                    }
1196                    0x10d41255013918d1 => {
1197                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1198                        let mut req = fidl::new_empty!(
1199                            SealingKeysSealRequest,
1200                            fidl::encoding::DefaultFuchsiaResourceDialect
1201                        );
1202                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SealingKeysSealRequest>(&header, _body_bytes, handles, &mut req)?;
1203                        let control_handle = SealingKeysControlHandle { inner: this.inner.clone() };
1204                        Ok(SealingKeysRequest::Seal {
1205                            key_info: req.key_info,
1206                            key_blob: req.key_blob,
1207                            secret: req.secret,
1208
1209                            responder: SealingKeysSealResponder {
1210                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1211                                tx_id: header.tx_id,
1212                            },
1213                        })
1214                    }
1215                    0x7037d75ecb579c83 => {
1216                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1217                        let mut req = fidl::new_empty!(
1218                            SealingKeysUnsealRequest,
1219                            fidl::encoding::DefaultFuchsiaResourceDialect
1220                        );
1221                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SealingKeysUnsealRequest>(&header, _body_bytes, handles, &mut req)?;
1222                        let control_handle = SealingKeysControlHandle { inner: this.inner.clone() };
1223                        Ok(SealingKeysRequest::Unseal {
1224                            key_info: req.key_info,
1225                            key_blob: req.key_blob,
1226                            sealed_secret: req.sealed_secret,
1227
1228                            responder: SealingKeysUnsealResponder {
1229                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1230                                tx_id: header.tx_id,
1231                            },
1232                        })
1233                    }
1234                    0x68584c5a799181e7 => {
1235                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1236                        let mut req = fidl::new_empty!(
1237                            SealingKeysUpgradeSealingKeyRequest,
1238                            fidl::encoding::DefaultFuchsiaResourceDialect
1239                        );
1240                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SealingKeysUpgradeSealingKeyRequest>(&header, _body_bytes, handles, &mut req)?;
1241                        let control_handle = SealingKeysControlHandle { inner: this.inner.clone() };
1242                        Ok(SealingKeysRequest::UpgradeSealingKey {
1243                            key_info: req.key_info,
1244                            key_blob: req.key_blob,
1245
1246                            responder: SealingKeysUpgradeSealingKeyResponder {
1247                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1248                                tx_id: header.tx_id,
1249                            },
1250                        })
1251                    }
1252                    0xad65bae761e8c3 => {
1253                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1254                        let mut req = fidl::new_empty!(
1255                            SealingKeysDeleteSealingKeyRequest,
1256                            fidl::encoding::DefaultFuchsiaResourceDialect
1257                        );
1258                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SealingKeysDeleteSealingKeyRequest>(&header, _body_bytes, handles, &mut req)?;
1259                        let control_handle = SealingKeysControlHandle { inner: this.inner.clone() };
1260                        Ok(SealingKeysRequest::DeleteSealingKey {
1261                            key_blob: req.key_blob,
1262
1263                            responder: SealingKeysDeleteSealingKeyResponder {
1264                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1265                                tx_id: header.tx_id,
1266                            },
1267                        })
1268                    }
1269                    _ => Err(fidl::Error::UnknownOrdinal {
1270                        ordinal: header.ordinal,
1271                        protocol_name:
1272                            <SealingKeysMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1273                    }),
1274                }))
1275            },
1276        )
1277    }
1278}
1279
1280/// Allows a client to generate sealing keys and then use these keys to seal and unseal secrets.
1281/// Sealed secrets are safe for offline storage.
1282///
1283/// Note that (un)seal is synonymous with (un)wrap, e.g., wrapping an encryption key is the same
1284/// as sealing an encryption key.
1285#[derive(Debug)]
1286pub enum SealingKeysRequest {
1287    /// Generates a new sealing key to seal and unseal secrets.
1288    ///
1289    /// |key_info| is information to be cryptographically bound to the returned key.
1290    ///   * The client will have to supply it in all uses (other than key deletion) of the returned
1291    ///     key.
1292    ///   * It serves two purposes: (1) internally by the key manager to identify the key owner and
1293    ///     (2) as a password to mitigate potential attacks from the key manager and as well as
1294    ///     other clients.
1295    ///   * It is recommended to include sufficient entropy in it (using it as a password) to
1296    ///     mitigage potential attacks from the secure world (the key manager's execution
1297    ///     environment) or from other clients.
1298    ///   * It is acceptible to pass a constant if deriving and persisting a password is too
1299    ///     cumbersome and the client fully trust the secure world and there are not many other
1300    ///     clients.
1301    ///
1302    /// The client is responsible for persisting both |key_info| and the returned |key_blob|.
1303    /// The key blob is encrypted with a TEE-private key. It is guaranteed to be unique for each
1304    /// call (even with the same key info). It can be stored in unsecure storage.
1305    ///
1306    /// Returns:
1307    ///   * The sealing key if everything worked.
1308    ///   * FAILED_CREATE if the key creation failed, e.g., the |key_info| was empty.
1309    CreateSealingKey { key_info: Vec<u8>, responder: SealingKeysCreateSealingKeyResponder },
1310    /// Seals a secret using a sealing key identified by its info and blob:
1311    ///   * The key info has to match the one supplied when generating the sealing key.
1312    ///
1313    /// Note that the secret may be a key itself. It has no bearing on the seal operation.
1314    ///
1315    /// Returns:
1316    ///   * The sealed secret if everything worked.
1317    ///   * KEY_REQUIRES_UPGRADE if keymint indicates that the sealing key requires upgrade.
1318    ///   * FAILED_SEAL if the sealing failed for another reason, e.g., sealing key info or blob
1319    ///     mismatch.
1320    Seal {
1321        key_info: Vec<u8>,
1322        key_blob: Vec<u8>,
1323        secret: Vec<u8>,
1324        responder: SealingKeysSealResponder,
1325    },
1326    /// Unseals a sealed secret using a sealing key identified by its info and blob:
1327    ///   * The key info has to match the one supplied when generating the sealing key.
1328    ///   * The key blob has to match the one used to seal the secret.
1329    ///
1330    /// Note that the secret may be a key itself. It has no bearing on the unseal operation.
1331    ///
1332    /// Returns:
1333    ///   * The unsealed secret if everything worked.
1334    ///   * KEY_REQUIRES_UPGRADE if keymint indicates that the sealing key requires upgrade.
1335    ///   * FAILED_UNSEAL if the unsealing failed for another reason, e.g., sealing key info or blob
1336    ///     mismatch.
1337    Unseal {
1338        key_info: Vec<u8>,
1339        key_blob: Vec<u8>,
1340        sealed_secret: Vec<u8>,
1341        responder: SealingKeysUnsealResponder,
1342    },
1343    /// Upgrades a sealing key that has been deemed out-of-date by keymint. The sealing key to
1344    /// upgrade is identified by its info and blob:
1345    ///   * The key info has to match the one supplied when generating the sealing key.
1346    ///   * The key blob has to match the blob returned when generating the sealing key.
1347    ///
1348    /// Note that after upgrading a key, both the old key and new key will be occupying limited key
1349    /// storage in keymint. This means that clients can unintentionally exhaust key storage in two
1350    /// ways:
1351    /// * Upgrading a key and failing to delete the old key after upgrade.
1352    /// * Successfully upgrading a key, failing to persist the new key, and later (e.g., after a
1353    ///   reboot) upgrading the key again.
1354    ///
1355    /// Both of the above missteps on the part of the client will "waste" one key slot in keymint,
1356    /// and repeated missteps (e.g., a boot loop that upgrades a key, fails to persist the new key,
1357    /// then reboots) can exhaust available key storage. Clients are responsible for old (upgraded)
1358    /// keys and persisting new (result of a successful key upgrade) to ensure that key slots are
1359    /// not wasted.
1360    ///
1361    ///  Returns
1362    ///   * The upgraded key blob if everything worked.
1363    ///   * FAILED_UPGRADE if the upgrade failed.
1364    UpgradeSealingKey {
1365        key_info: Vec<u8>,
1366        key_blob: Vec<u8>,
1367        responder: SealingKeysUpgradeSealingKeyResponder,
1368    },
1369    /// Deletes a sealing key from keymint.
1370    ///
1371    /// This operation should be used to delete old (upgraded) keys.
1372    ///
1373    /// Returns
1374    ///  * Nothing if everything worked.
1375    ///  * FAILED_DELETE if deletion failed.
1376    DeleteSealingKey { key_blob: Vec<u8>, responder: SealingKeysDeleteSealingKeyResponder },
1377}
1378
1379impl SealingKeysRequest {
1380    #[allow(irrefutable_let_patterns)]
1381    pub fn into_create_sealing_key(
1382        self,
1383    ) -> Option<(Vec<u8>, SealingKeysCreateSealingKeyResponder)> {
1384        if let SealingKeysRequest::CreateSealingKey { key_info, responder } = self {
1385            Some((key_info, responder))
1386        } else {
1387            None
1388        }
1389    }
1390
1391    #[allow(irrefutable_let_patterns)]
1392    pub fn into_seal(self) -> Option<(Vec<u8>, Vec<u8>, Vec<u8>, SealingKeysSealResponder)> {
1393        if let SealingKeysRequest::Seal { key_info, key_blob, secret, responder } = self {
1394            Some((key_info, key_blob, secret, responder))
1395        } else {
1396            None
1397        }
1398    }
1399
1400    #[allow(irrefutable_let_patterns)]
1401    pub fn into_unseal(self) -> Option<(Vec<u8>, Vec<u8>, Vec<u8>, SealingKeysUnsealResponder)> {
1402        if let SealingKeysRequest::Unseal { key_info, key_blob, sealed_secret, responder } = self {
1403            Some((key_info, key_blob, sealed_secret, responder))
1404        } else {
1405            None
1406        }
1407    }
1408
1409    #[allow(irrefutable_let_patterns)]
1410    pub fn into_upgrade_sealing_key(
1411        self,
1412    ) -> Option<(Vec<u8>, Vec<u8>, SealingKeysUpgradeSealingKeyResponder)> {
1413        if let SealingKeysRequest::UpgradeSealingKey { key_info, key_blob, responder } = self {
1414            Some((key_info, key_blob, responder))
1415        } else {
1416            None
1417        }
1418    }
1419
1420    #[allow(irrefutable_let_patterns)]
1421    pub fn into_delete_sealing_key(
1422        self,
1423    ) -> Option<(Vec<u8>, SealingKeysDeleteSealingKeyResponder)> {
1424        if let SealingKeysRequest::DeleteSealingKey { key_blob, responder } = self {
1425            Some((key_blob, responder))
1426        } else {
1427            None
1428        }
1429    }
1430
1431    /// Name of the method defined in FIDL
1432    pub fn method_name(&self) -> &'static str {
1433        match *self {
1434            SealingKeysRequest::CreateSealingKey { .. } => "create_sealing_key",
1435            SealingKeysRequest::Seal { .. } => "seal",
1436            SealingKeysRequest::Unseal { .. } => "unseal",
1437            SealingKeysRequest::UpgradeSealingKey { .. } => "upgrade_sealing_key",
1438            SealingKeysRequest::DeleteSealingKey { .. } => "delete_sealing_key",
1439        }
1440    }
1441}
1442
1443#[derive(Debug, Clone)]
1444pub struct SealingKeysControlHandle {
1445    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1446}
1447
1448impl fidl::endpoints::ControlHandle for SealingKeysControlHandle {
1449    fn shutdown(&self) {
1450        self.inner.shutdown()
1451    }
1452
1453    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1454        self.inner.shutdown_with_epitaph(status)
1455    }
1456
1457    fn is_closed(&self) -> bool {
1458        self.inner.channel().is_closed()
1459    }
1460    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1461        self.inner.channel().on_closed()
1462    }
1463
1464    #[cfg(target_os = "fuchsia")]
1465    fn signal_peer(
1466        &self,
1467        clear_mask: zx::Signals,
1468        set_mask: zx::Signals,
1469    ) -> Result<(), zx_status::Status> {
1470        use fidl::Peered;
1471        self.inner.channel().signal_peer(clear_mask, set_mask)
1472    }
1473}
1474
1475impl SealingKeysControlHandle {}
1476
1477#[must_use = "FIDL methods require a response to be sent"]
1478#[derive(Debug)]
1479pub struct SealingKeysCreateSealingKeyResponder {
1480    control_handle: std::mem::ManuallyDrop<SealingKeysControlHandle>,
1481    tx_id: u32,
1482}
1483
1484/// Set the the channel to be shutdown (see [`SealingKeysControlHandle::shutdown`])
1485/// if the responder is dropped without sending a response, so that the client
1486/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1487impl std::ops::Drop for SealingKeysCreateSealingKeyResponder {
1488    fn drop(&mut self) {
1489        self.control_handle.shutdown();
1490        // Safety: drops once, never accessed again
1491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1492    }
1493}
1494
1495impl fidl::endpoints::Responder for SealingKeysCreateSealingKeyResponder {
1496    type ControlHandle = SealingKeysControlHandle;
1497
1498    fn control_handle(&self) -> &SealingKeysControlHandle {
1499        &self.control_handle
1500    }
1501
1502    fn drop_without_shutdown(mut self) {
1503        // Safety: drops once, never accessed again due to mem::forget
1504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1505        // Prevent Drop from running (which would shut down the channel)
1506        std::mem::forget(self);
1507    }
1508}
1509
1510impl SealingKeysCreateSealingKeyResponder {
1511    /// Sends a response to the FIDL transaction.
1512    ///
1513    /// Sets the channel to shutdown if an error occurs.
1514    pub fn send(self, mut result: Result<&[u8], CreateError>) -> Result<(), fidl::Error> {
1515        let _result = self.send_raw(result);
1516        if _result.is_err() {
1517            self.control_handle.shutdown();
1518        }
1519        self.drop_without_shutdown();
1520        _result
1521    }
1522
1523    /// Similar to "send" but does not shutdown the channel if an error occurs.
1524    pub fn send_no_shutdown_on_err(
1525        self,
1526        mut result: Result<&[u8], CreateError>,
1527    ) -> Result<(), fidl::Error> {
1528        let _result = self.send_raw(result);
1529        self.drop_without_shutdown();
1530        _result
1531    }
1532
1533    fn send_raw(&self, mut result: Result<&[u8], CreateError>) -> Result<(), fidl::Error> {
1534        self.control_handle.inner.send::<fidl::encoding::ResultType<
1535            SealingKeysCreateSealingKeyResponse,
1536            CreateError,
1537        >>(
1538            result.map(|key_blob| (key_blob,)),
1539            self.tx_id,
1540            0x5a191cbb6a8081bc,
1541            fidl::encoding::DynamicFlags::empty(),
1542        )
1543    }
1544}
1545
1546#[must_use = "FIDL methods require a response to be sent"]
1547#[derive(Debug)]
1548pub struct SealingKeysSealResponder {
1549    control_handle: std::mem::ManuallyDrop<SealingKeysControlHandle>,
1550    tx_id: u32,
1551}
1552
1553/// Set the the channel to be shutdown (see [`SealingKeysControlHandle::shutdown`])
1554/// if the responder is dropped without sending a response, so that the client
1555/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1556impl std::ops::Drop for SealingKeysSealResponder {
1557    fn drop(&mut self) {
1558        self.control_handle.shutdown();
1559        // Safety: drops once, never accessed again
1560        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1561    }
1562}
1563
1564impl fidl::endpoints::Responder for SealingKeysSealResponder {
1565    type ControlHandle = SealingKeysControlHandle;
1566
1567    fn control_handle(&self) -> &SealingKeysControlHandle {
1568        &self.control_handle
1569    }
1570
1571    fn drop_without_shutdown(mut self) {
1572        // Safety: drops once, never accessed again due to mem::forget
1573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1574        // Prevent Drop from running (which would shut down the channel)
1575        std::mem::forget(self);
1576    }
1577}
1578
1579impl SealingKeysSealResponder {
1580    /// Sends a response to the FIDL transaction.
1581    ///
1582    /// Sets the channel to shutdown if an error occurs.
1583    pub fn send(self, mut result: Result<&[u8], SealError>) -> Result<(), fidl::Error> {
1584        let _result = self.send_raw(result);
1585        if _result.is_err() {
1586            self.control_handle.shutdown();
1587        }
1588        self.drop_without_shutdown();
1589        _result
1590    }
1591
1592    /// Similar to "send" but does not shutdown the channel if an error occurs.
1593    pub fn send_no_shutdown_on_err(
1594        self,
1595        mut result: Result<&[u8], SealError>,
1596    ) -> Result<(), fidl::Error> {
1597        let _result = self.send_raw(result);
1598        self.drop_without_shutdown();
1599        _result
1600    }
1601
1602    fn send_raw(&self, mut result: Result<&[u8], SealError>) -> Result<(), fidl::Error> {
1603        self.control_handle
1604            .inner
1605            .send::<fidl::encoding::ResultType<SealingKeysSealResponse, SealError>>(
1606                result.map(|sealed_secret| (sealed_secret,)),
1607                self.tx_id,
1608                0x10d41255013918d1,
1609                fidl::encoding::DynamicFlags::empty(),
1610            )
1611    }
1612}
1613
1614#[must_use = "FIDL methods require a response to be sent"]
1615#[derive(Debug)]
1616pub struct SealingKeysUnsealResponder {
1617    control_handle: std::mem::ManuallyDrop<SealingKeysControlHandle>,
1618    tx_id: u32,
1619}
1620
1621/// Set the the channel to be shutdown (see [`SealingKeysControlHandle::shutdown`])
1622/// if the responder is dropped without sending a response, so that the client
1623/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1624impl std::ops::Drop for SealingKeysUnsealResponder {
1625    fn drop(&mut self) {
1626        self.control_handle.shutdown();
1627        // Safety: drops once, never accessed again
1628        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1629    }
1630}
1631
1632impl fidl::endpoints::Responder for SealingKeysUnsealResponder {
1633    type ControlHandle = SealingKeysControlHandle;
1634
1635    fn control_handle(&self) -> &SealingKeysControlHandle {
1636        &self.control_handle
1637    }
1638
1639    fn drop_without_shutdown(mut self) {
1640        // Safety: drops once, never accessed again due to mem::forget
1641        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1642        // Prevent Drop from running (which would shut down the channel)
1643        std::mem::forget(self);
1644    }
1645}
1646
1647impl SealingKeysUnsealResponder {
1648    /// Sends a response to the FIDL transaction.
1649    ///
1650    /// Sets the channel to shutdown if an error occurs.
1651    pub fn send(self, mut result: Result<&[u8], UnsealError>) -> Result<(), fidl::Error> {
1652        let _result = self.send_raw(result);
1653        if _result.is_err() {
1654            self.control_handle.shutdown();
1655        }
1656        self.drop_without_shutdown();
1657        _result
1658    }
1659
1660    /// Similar to "send" but does not shutdown the channel if an error occurs.
1661    pub fn send_no_shutdown_on_err(
1662        self,
1663        mut result: Result<&[u8], UnsealError>,
1664    ) -> Result<(), fidl::Error> {
1665        let _result = self.send_raw(result);
1666        self.drop_without_shutdown();
1667        _result
1668    }
1669
1670    fn send_raw(&self, mut result: Result<&[u8], UnsealError>) -> Result<(), fidl::Error> {
1671        self.control_handle
1672            .inner
1673            .send::<fidl::encoding::ResultType<SealingKeysUnsealResponse, UnsealError>>(
1674                result.map(|unsealed_secret| (unsealed_secret,)),
1675                self.tx_id,
1676                0x7037d75ecb579c83,
1677                fidl::encoding::DynamicFlags::empty(),
1678            )
1679    }
1680}
1681
1682#[must_use = "FIDL methods require a response to be sent"]
1683#[derive(Debug)]
1684pub struct SealingKeysUpgradeSealingKeyResponder {
1685    control_handle: std::mem::ManuallyDrop<SealingKeysControlHandle>,
1686    tx_id: u32,
1687}
1688
1689/// Set the the channel to be shutdown (see [`SealingKeysControlHandle::shutdown`])
1690/// if the responder is dropped without sending a response, so that the client
1691/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1692impl std::ops::Drop for SealingKeysUpgradeSealingKeyResponder {
1693    fn drop(&mut self) {
1694        self.control_handle.shutdown();
1695        // Safety: drops once, never accessed again
1696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1697    }
1698}
1699
1700impl fidl::endpoints::Responder for SealingKeysUpgradeSealingKeyResponder {
1701    type ControlHandle = SealingKeysControlHandle;
1702
1703    fn control_handle(&self) -> &SealingKeysControlHandle {
1704        &self.control_handle
1705    }
1706
1707    fn drop_without_shutdown(mut self) {
1708        // Safety: drops once, never accessed again due to mem::forget
1709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1710        // Prevent Drop from running (which would shut down the channel)
1711        std::mem::forget(self);
1712    }
1713}
1714
1715impl SealingKeysUpgradeSealingKeyResponder {
1716    /// Sends a response to the FIDL transaction.
1717    ///
1718    /// Sets the channel to shutdown if an error occurs.
1719    pub fn send(self, mut result: Result<&[u8], UpgradeError>) -> Result<(), fidl::Error> {
1720        let _result = self.send_raw(result);
1721        if _result.is_err() {
1722            self.control_handle.shutdown();
1723        }
1724        self.drop_without_shutdown();
1725        _result
1726    }
1727
1728    /// Similar to "send" but does not shutdown the channel if an error occurs.
1729    pub fn send_no_shutdown_on_err(
1730        self,
1731        mut result: Result<&[u8], UpgradeError>,
1732    ) -> Result<(), fidl::Error> {
1733        let _result = self.send_raw(result);
1734        self.drop_without_shutdown();
1735        _result
1736    }
1737
1738    fn send_raw(&self, mut result: Result<&[u8], UpgradeError>) -> Result<(), fidl::Error> {
1739        self.control_handle.inner.send::<fidl::encoding::ResultType<
1740            SealingKeysUpgradeSealingKeyResponse,
1741            UpgradeError,
1742        >>(
1743            result.map(|key_blob| (key_blob,)),
1744            self.tx_id,
1745            0x68584c5a799181e7,
1746            fidl::encoding::DynamicFlags::empty(),
1747        )
1748    }
1749}
1750
1751#[must_use = "FIDL methods require a response to be sent"]
1752#[derive(Debug)]
1753pub struct SealingKeysDeleteSealingKeyResponder {
1754    control_handle: std::mem::ManuallyDrop<SealingKeysControlHandle>,
1755    tx_id: u32,
1756}
1757
1758/// Set the the channel to be shutdown (see [`SealingKeysControlHandle::shutdown`])
1759/// if the responder is dropped without sending a response, so that the client
1760/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1761impl std::ops::Drop for SealingKeysDeleteSealingKeyResponder {
1762    fn drop(&mut self) {
1763        self.control_handle.shutdown();
1764        // Safety: drops once, never accessed again
1765        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1766    }
1767}
1768
1769impl fidl::endpoints::Responder for SealingKeysDeleteSealingKeyResponder {
1770    type ControlHandle = SealingKeysControlHandle;
1771
1772    fn control_handle(&self) -> &SealingKeysControlHandle {
1773        &self.control_handle
1774    }
1775
1776    fn drop_without_shutdown(mut self) {
1777        // Safety: drops once, never accessed again due to mem::forget
1778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1779        // Prevent Drop from running (which would shut down the channel)
1780        std::mem::forget(self);
1781    }
1782}
1783
1784impl SealingKeysDeleteSealingKeyResponder {
1785    /// Sends a response to the FIDL transaction.
1786    ///
1787    /// Sets the channel to shutdown if an error occurs.
1788    pub fn send(self, mut result: Result<(), DeleteError>) -> Result<(), fidl::Error> {
1789        let _result = self.send_raw(result);
1790        if _result.is_err() {
1791            self.control_handle.shutdown();
1792        }
1793        self.drop_without_shutdown();
1794        _result
1795    }
1796
1797    /// Similar to "send" but does not shutdown the channel if an error occurs.
1798    pub fn send_no_shutdown_on_err(
1799        self,
1800        mut result: Result<(), DeleteError>,
1801    ) -> Result<(), fidl::Error> {
1802        let _result = self.send_raw(result);
1803        self.drop_without_shutdown();
1804        _result
1805    }
1806
1807    fn send_raw(&self, mut result: Result<(), DeleteError>) -> Result<(), fidl::Error> {
1808        self.control_handle.inner.send::<fidl::encoding::ResultType<
1809            fidl::encoding::EmptyStruct,
1810            DeleteError,
1811        >>(
1812            result,
1813            self.tx_id,
1814            0xad65bae761e8c3,
1815            fidl::encoding::DynamicFlags::empty(),
1816        )
1817    }
1818}
1819
1820mod internal {
1821    use super::*;
1822}