parsec_interface/operations_protobuf/
mod.rs

1// Copyright 2019 Contributors to the Parsec project.
2// SPDX-License-Identifier: Apache-2.0
3//! # Protobuf converter
4//!
5//! This module exposes the `ProtobufConverter` struct that implements the `Convert` trait.
6mod convert_psa_algorithm;
7mod convert_ping;
8mod convert_psa_generate_key;
9mod convert_psa_key_attributes;
10mod convert_psa_import_key;
11mod convert_psa_export_public_key;
12mod convert_psa_export_key;
13mod convert_psa_destroy_key;
14mod convert_psa_sign_hash;
15mod convert_psa_verify_hash;
16mod convert_psa_sign_message;
17mod convert_psa_verify_message;
18mod convert_psa_hash_compute;
19mod convert_psa_hash_compare;
20mod convert_list_providers;
21mod convert_list_opcodes;
22mod convert_list_authenticators;
23mod convert_list_keys;
24mod convert_list_clients;
25mod convert_delete_client;
26mod convert_psa_asymmetric_encrypt;
27mod convert_psa_asymmetric_decrypt;
28mod convert_psa_aead_encrypt;
29mod convert_psa_aead_decrypt;
30mod convert_psa_cipher_encrypt;
31mod convert_psa_cipher_decrypt;
32mod convert_psa_generate_random;
33mod convert_psa_raw_key_agreement;
34mod convert_can_do_crypto;
35mod convert_attest_key;
36mod convert_prepare_key_attestation;
37
38#[rustfmt::skip]
39#[allow(unused_qualifications, missing_copy_implementations, clippy::pedantic, clippy::module_inception, clippy::upper_case_acronyms, clippy::enum_variant_names)]
40mod generated_ops;
41
42use crate::operations::{Convert, NativeOperation, NativeResult};
43use crate::requests::{
44    request::RequestBody, response::ResponseBody, BodyType, Opcode, ResponseStatus, Result,
45};
46use generated_ops::attest_key as attest_key_proto;
47use generated_ops::can_do_crypto as can_do_crypto_proto;
48use generated_ops::delete_client as delete_client_proto;
49use generated_ops::list_authenticators as list_authenticators_proto;
50use generated_ops::list_clients as list_clients_proto;
51use generated_ops::list_keys as list_keys_proto;
52use generated_ops::list_opcodes as list_opcodes_proto;
53use generated_ops::list_providers as list_providers_proto;
54use generated_ops::ping as ping_proto;
55use generated_ops::prepare_key_attestation as prepare_key_attestation_proto;
56use generated_ops::psa_aead_decrypt as psa_aead_decrypt_proto;
57use generated_ops::psa_aead_encrypt as psa_aead_encrypt_proto;
58use generated_ops::psa_asymmetric_decrypt as psa_asymmetric_decrypt_proto;
59use generated_ops::psa_asymmetric_encrypt as psa_asymmetric_encrypt_proto;
60use generated_ops::psa_cipher_decrypt as psa_cipher_decrypt_proto;
61use generated_ops::psa_cipher_encrypt as psa_cipher_encrypt_proto;
62use generated_ops::psa_destroy_key as psa_destroy_key_proto;
63use generated_ops::psa_export_key as psa_export_key_proto;
64use generated_ops::psa_export_public_key as psa_export_public_key_proto;
65use generated_ops::psa_generate_key as psa_generate_key_proto;
66use generated_ops::psa_generate_random as psa_generate_random_proto;
67use generated_ops::psa_hash_compare as psa_hash_compare_proto;
68use generated_ops::psa_hash_compute as psa_hash_compute_proto;
69use generated_ops::psa_import_key as psa_import_key_proto;
70use generated_ops::psa_raw_key_agreement as psa_raw_key_agreement_proto;
71use generated_ops::psa_sign_hash as psa_sign_hash_proto;
72use generated_ops::psa_sign_message as psa_sign_message_proto;
73use generated_ops::psa_verify_hash as psa_verify_hash_proto;
74use generated_ops::psa_verify_message as psa_verify_message_proto;
75use generated_ops::ClearProtoMessage;
76use prost::Message;
77use std::convert::TryInto;
78
79macro_rules! wire_to_native {
80    ($body:expr, $proto_type:ty) => {{
81        let mut proto: $proto_type = Default::default();
82        if proto.merge($body).is_err() {
83            return Err(ResponseStatus::DeserializingBodyFailed);
84        }
85        proto.try_into()?
86    }};
87}
88
89macro_rules! native_to_wire {
90    ($native_msg:expr, $proto_type:ty) => {{
91        let mut proto: $proto_type = $native_msg.try_into()?;
92        let mut bytes = Vec::new();
93        if proto.encode(&mut bytes).is_err() {
94            proto.clear_message();
95            return Err(ResponseStatus::SerializingBodyFailed);
96        }
97        proto.clear_message();
98        bytes
99    }};
100}
101
102/// Implementation for a converter between protobuf-encoded bodies and native
103/// objects.
104#[derive(Copy, Clone, Debug)]
105pub struct ProtobufConverter;
106
107impl Convert for ProtobufConverter {
108    fn body_type(&self) -> BodyType {
109        BodyType::Protobuf
110    }
111
112    fn body_to_operation(&self, body: RequestBody, opcode: Opcode) -> Result<NativeOperation> {
113        match opcode {
114            Opcode::ListProviders => Ok(NativeOperation::ListProviders(wire_to_native!(
115                body.bytes(),
116                list_providers_proto::Operation
117            ))),
118            Opcode::ListOpcodes => Ok(NativeOperation::ListOpcodes(wire_to_native!(
119                body.bytes(),
120                list_opcodes_proto::Operation
121            ))),
122            Opcode::ListAuthenticators => Ok(NativeOperation::ListAuthenticators(wire_to_native!(
123                body.bytes(),
124                list_authenticators_proto::Operation
125            ))),
126            Opcode::ListKeys => Ok(NativeOperation::ListKeys(wire_to_native!(
127                body.bytes(),
128                list_keys_proto::Operation
129            ))),
130            Opcode::ListClients => Ok(NativeOperation::ListClients(wire_to_native!(
131                body.bytes(),
132                list_clients_proto::Operation
133            ))),
134            Opcode::DeleteClient => Ok(NativeOperation::DeleteClient(wire_to_native!(
135                body.bytes(),
136                delete_client_proto::Operation
137            ))),
138            Opcode::Ping => Ok(NativeOperation::Ping(wire_to_native!(
139                body.bytes(),
140                ping_proto::Operation
141            ))),
142            Opcode::PsaGenerateKey => Ok(NativeOperation::PsaGenerateKey(wire_to_native!(
143                body.bytes(),
144                psa_generate_key_proto::Operation
145            ))),
146            Opcode::PsaImportKey => Ok(NativeOperation::PsaImportKey(wire_to_native!(
147                body.bytes(),
148                psa_import_key_proto::Operation
149            ))),
150            Opcode::PsaExportPublicKey => Ok(NativeOperation::PsaExportPublicKey(wire_to_native!(
151                body.bytes(),
152                psa_export_public_key_proto::Operation
153            ))),
154            Opcode::PsaExportKey => Ok(NativeOperation::PsaExportKey(wire_to_native!(
155                body.bytes(),
156                psa_export_key_proto::Operation
157            ))),
158            Opcode::PsaDestroyKey => Ok(NativeOperation::PsaDestroyKey(wire_to_native!(
159                body.bytes(),
160                psa_destroy_key_proto::Operation
161            ))),
162            Opcode::PsaSignHash => Ok(NativeOperation::PsaSignHash(wire_to_native!(
163                body.bytes(),
164                psa_sign_hash_proto::Operation
165            ))),
166            Opcode::PsaVerifyHash => Ok(NativeOperation::PsaVerifyHash(wire_to_native!(
167                body.bytes(),
168                psa_verify_hash_proto::Operation
169            ))),
170            Opcode::PsaSignMessage => Ok(NativeOperation::PsaSignMessage(wire_to_native!(
171                body.bytes(),
172                psa_sign_message_proto::Operation
173            ))),
174            Opcode::PsaVerifyMessage => Ok(NativeOperation::PsaVerifyMessage(wire_to_native!(
175                body.bytes(),
176                psa_verify_message_proto::Operation
177            ))),
178            Opcode::PsaAsymmetricEncrypt => Ok(NativeOperation::PsaAsymmetricEncrypt(
179                wire_to_native!(body.bytes(), psa_asymmetric_encrypt_proto::Operation),
180            )),
181            Opcode::PsaAsymmetricDecrypt => Ok(NativeOperation::PsaAsymmetricDecrypt(
182                wire_to_native!(body.bytes(), psa_asymmetric_decrypt_proto::Operation),
183            )),
184            Opcode::PsaAeadEncrypt => Ok(NativeOperation::PsaAeadEncrypt(wire_to_native!(
185                body.bytes(),
186                psa_aead_encrypt_proto::Operation
187            ))),
188            Opcode::PsaAeadDecrypt => Ok(NativeOperation::PsaAeadDecrypt(wire_to_native!(
189                body.bytes(),
190                psa_aead_decrypt_proto::Operation
191            ))),
192            Opcode::PsaCipherEncrypt => Ok(NativeOperation::PsaCipherEncrypt(wire_to_native!(
193                body.bytes(),
194                psa_cipher_encrypt_proto::Operation
195            ))),
196            Opcode::PsaCipherDecrypt => Ok(NativeOperation::PsaCipherDecrypt(wire_to_native!(
197                body.bytes(),
198                psa_cipher_decrypt_proto::Operation
199            ))),
200            Opcode::PsaGenerateRandom => Ok(NativeOperation::PsaGenerateRandom(wire_to_native!(
201                body.bytes(),
202                psa_generate_random_proto::Operation
203            ))),
204            Opcode::PsaHashCompare => Ok(NativeOperation::PsaHashCompare(wire_to_native!(
205                body.bytes(),
206                psa_hash_compare_proto::Operation
207            ))),
208            Opcode::PsaHashCompute => Ok(NativeOperation::PsaHashCompute(wire_to_native!(
209                body.bytes(),
210                psa_hash_compute_proto::Operation
211            ))),
212            Opcode::PsaRawKeyAgreement => Ok(NativeOperation::PsaRawKeyAgreement(wire_to_native!(
213                body.bytes(),
214                psa_raw_key_agreement_proto::Operation
215            ))),
216            Opcode::CanDoCrypto => Ok(NativeOperation::CanDoCrypto(wire_to_native!(
217                body.bytes(),
218                can_do_crypto_proto::Operation
219            ))),
220            Opcode::AttestKey => Ok(NativeOperation::AttestKey(wire_to_native!(
221                body.bytes(),
222                attest_key_proto::Operation
223            ))),
224            Opcode::PrepareKeyAttestation => Ok(NativeOperation::PrepareKeyAttestation(
225                wire_to_native!(body.bytes(), prepare_key_attestation_proto::Operation),
226            )),
227        }
228    }
229
230    fn operation_to_body(&self, operation: NativeOperation) -> Result<RequestBody> {
231        match operation {
232            NativeOperation::ListProviders(operation) => Ok(RequestBody::from_bytes(
233                native_to_wire!(operation, list_providers_proto::Operation),
234            )),
235            NativeOperation::ListOpcodes(operation) => Ok(RequestBody::from_bytes(
236                native_to_wire!(operation, list_opcodes_proto::Operation),
237            )),
238            NativeOperation::ListAuthenticators(operation) => Ok(RequestBody::from_bytes(
239                native_to_wire!(operation, list_authenticators_proto::Operation),
240            )),
241            NativeOperation::ListKeys(operation) => Ok(RequestBody::from_bytes(native_to_wire!(
242                operation,
243                list_keys_proto::Operation
244            ))),
245            NativeOperation::ListClients(operation) => Ok(RequestBody::from_bytes(
246                native_to_wire!(operation, list_clients_proto::Operation),
247            )),
248            NativeOperation::DeleteClient(operation) => Ok(RequestBody::from_bytes(
249                native_to_wire!(operation, delete_client_proto::Operation),
250            )),
251            NativeOperation::Ping(operation) => Ok(RequestBody::from_bytes(native_to_wire!(
252                operation,
253                ping_proto::Operation
254            ))),
255            NativeOperation::PsaGenerateKey(operation) => Ok(RequestBody::from_bytes(
256                native_to_wire!(operation, psa_generate_key_proto::Operation),
257            )),
258            NativeOperation::PsaImportKey(operation) => Ok(RequestBody::from_bytes(
259                native_to_wire!(operation, psa_import_key_proto::Operation),
260            )),
261            NativeOperation::PsaExportPublicKey(operation) => Ok(RequestBody::from_bytes(
262                native_to_wire!(operation, psa_export_public_key_proto::Operation),
263            )),
264            NativeOperation::PsaExportKey(operation) => Ok(RequestBody::from_bytes(
265                native_to_wire!(operation, psa_export_key_proto::Operation),
266            )),
267            NativeOperation::PsaDestroyKey(operation) => Ok(RequestBody::from_bytes(
268                native_to_wire!(operation, psa_destroy_key_proto::Operation),
269            )),
270            NativeOperation::PsaSignHash(operation) => Ok(RequestBody::from_bytes(
271                native_to_wire!(operation, psa_sign_hash_proto::Operation),
272            )),
273            NativeOperation::PsaVerifyHash(operation) => Ok(RequestBody::from_bytes(
274                native_to_wire!(operation, psa_verify_hash_proto::Operation),
275            )),
276            NativeOperation::PsaSignMessage(operation) => Ok(RequestBody::from_bytes(
277                native_to_wire!(operation, psa_sign_message_proto::Operation),
278            )),
279            NativeOperation::PsaVerifyMessage(operation) => Ok(RequestBody::from_bytes(
280                native_to_wire!(operation, psa_verify_message_proto::Operation),
281            )),
282            NativeOperation::PsaAsymmetricEncrypt(operation) => Ok(RequestBody::from_bytes(
283                native_to_wire!(operation, psa_asymmetric_encrypt_proto::Operation),
284            )),
285            NativeOperation::PsaAsymmetricDecrypt(operation) => Ok(RequestBody::from_bytes(
286                native_to_wire!(operation, psa_asymmetric_decrypt_proto::Operation),
287            )),
288            NativeOperation::PsaAeadEncrypt(operation) => Ok(RequestBody::from_bytes(
289                native_to_wire!(operation, psa_aead_encrypt_proto::Operation),
290            )),
291            NativeOperation::PsaAeadDecrypt(operation) => Ok(RequestBody::from_bytes(
292                native_to_wire!(operation, psa_aead_decrypt_proto::Operation),
293            )),
294            NativeOperation::PsaCipherEncrypt(operation) => Ok(RequestBody::from_bytes(
295                native_to_wire!(operation, psa_cipher_encrypt_proto::Operation),
296            )),
297            NativeOperation::PsaCipherDecrypt(operation) => Ok(RequestBody::from_bytes(
298                native_to_wire!(operation, psa_cipher_decrypt_proto::Operation),
299            )),
300            NativeOperation::PsaGenerateRandom(operation) => Ok(RequestBody::from_bytes(
301                native_to_wire!(operation, psa_generate_random_proto::Operation),
302            )),
303            NativeOperation::PsaHashCompare(operation) => Ok(RequestBody::from_bytes(
304                native_to_wire!(operation, psa_hash_compare_proto::Operation),
305            )),
306            NativeOperation::PsaHashCompute(operation) => Ok(RequestBody::from_bytes(
307                native_to_wire!(operation, psa_hash_compute_proto::Operation),
308            )),
309            NativeOperation::PsaRawKeyAgreement(operation) => Ok(RequestBody::from_bytes(
310                native_to_wire!(operation, psa_raw_key_agreement_proto::Operation),
311            )),
312            NativeOperation::CanDoCrypto(operation) => Ok(RequestBody::from_bytes(
313                native_to_wire!(operation, can_do_crypto_proto::Operation),
314            )),
315            NativeOperation::AttestKey(operation) => Ok(RequestBody::from_bytes(native_to_wire!(
316                operation,
317                attest_key_proto::Operation
318            ))),
319            NativeOperation::PrepareKeyAttestation(operation) => Ok(RequestBody::from_bytes(
320                native_to_wire!(operation, prepare_key_attestation_proto::Operation),
321            )),
322        }
323    }
324
325    fn body_to_result(&self, body: ResponseBody, opcode: Opcode) -> Result<NativeResult> {
326        match opcode {
327            Opcode::ListProviders => Ok(NativeResult::ListProviders(wire_to_native!(
328                body.bytes(),
329                list_providers_proto::Result
330            ))),
331            Opcode::ListOpcodes => Ok(NativeResult::ListOpcodes(wire_to_native!(
332                body.bytes(),
333                list_opcodes_proto::Result
334            ))),
335            Opcode::ListAuthenticators => Ok(NativeResult::ListAuthenticators(wire_to_native!(
336                body.bytes(),
337                list_authenticators_proto::Result
338            ))),
339            Opcode::ListKeys => Ok(NativeResult::ListKeys(wire_to_native!(
340                body.bytes(),
341                list_keys_proto::Result
342            ))),
343            Opcode::ListClients => Ok(NativeResult::ListClients(wire_to_native!(
344                body.bytes(),
345                list_clients_proto::Result
346            ))),
347            Opcode::DeleteClient => Ok(NativeResult::DeleteClient(wire_to_native!(
348                body.bytes(),
349                delete_client_proto::Result
350            ))),
351            Opcode::Ping => Ok(NativeResult::Ping(wire_to_native!(
352                body.bytes(),
353                ping_proto::Result
354            ))),
355            Opcode::PsaGenerateKey => Ok(NativeResult::PsaGenerateKey(wire_to_native!(
356                body.bytes(),
357                psa_generate_key_proto::Result
358            ))),
359            Opcode::PsaImportKey => Ok(NativeResult::PsaImportKey(wire_to_native!(
360                body.bytes(),
361                psa_import_key_proto::Result
362            ))),
363            Opcode::PsaExportPublicKey => Ok(NativeResult::PsaExportPublicKey(wire_to_native!(
364                body.bytes(),
365                psa_export_public_key_proto::Result
366            ))),
367            Opcode::PsaExportKey => Ok(NativeResult::PsaExportKey(wire_to_native!(
368                body.bytes(),
369                psa_export_key_proto::Result
370            ))),
371            Opcode::PsaDestroyKey => Ok(NativeResult::PsaDestroyKey(wire_to_native!(
372                body.bytes(),
373                psa_destroy_key_proto::Result
374            ))),
375            Opcode::PsaSignHash => Ok(NativeResult::PsaSignHash(wire_to_native!(
376                body.bytes(),
377                psa_sign_hash_proto::Result
378            ))),
379            Opcode::PsaVerifyHash => Ok(NativeResult::PsaVerifyHash(wire_to_native!(
380                body.bytes(),
381                psa_verify_hash_proto::Result
382            ))),
383            Opcode::PsaSignMessage => Ok(NativeResult::PsaSignMessage(wire_to_native!(
384                body.bytes(),
385                psa_sign_message_proto::Result
386            ))),
387            Opcode::PsaVerifyMessage => Ok(NativeResult::PsaVerifyMessage(wire_to_native!(
388                body.bytes(),
389                psa_verify_message_proto::Result
390            ))),
391            Opcode::PsaAsymmetricEncrypt => Ok(NativeResult::PsaAsymmetricEncrypt(
392                wire_to_native!(body.bytes(), psa_asymmetric_encrypt_proto::Result),
393            )),
394            Opcode::PsaAsymmetricDecrypt => Ok(NativeResult::PsaAsymmetricDecrypt(
395                wire_to_native!(body.bytes(), psa_asymmetric_decrypt_proto::Result),
396            )),
397            Opcode::PsaAeadEncrypt => Ok(NativeResult::PsaAeadEncrypt(wire_to_native!(
398                body.bytes(),
399                psa_aead_encrypt_proto::Result
400            ))),
401            Opcode::PsaAeadDecrypt => Ok(NativeResult::PsaAeadDecrypt(wire_to_native!(
402                body.bytes(),
403                psa_aead_decrypt_proto::Result
404            ))),
405            Opcode::PsaCipherEncrypt => Ok(NativeResult::PsaCipherEncrypt(wire_to_native!(
406                body.bytes(),
407                psa_cipher_encrypt_proto::Result
408            ))),
409            Opcode::PsaCipherDecrypt => Ok(NativeResult::PsaCipherDecrypt(wire_to_native!(
410                body.bytes(),
411                psa_cipher_decrypt_proto::Result
412            ))),
413            Opcode::PsaGenerateRandom => Ok(NativeResult::PsaGenerateRandom(wire_to_native!(
414                body.bytes(),
415                psa_generate_random_proto::Result
416            ))),
417            Opcode::PsaHashCompare => Ok(NativeResult::PsaHashCompare(wire_to_native!(
418                body.bytes(),
419                psa_hash_compare_proto::Result
420            ))),
421            Opcode::PsaHashCompute => Ok(NativeResult::PsaHashCompute(wire_to_native!(
422                body.bytes(),
423                psa_hash_compute_proto::Result
424            ))),
425            Opcode::PsaRawKeyAgreement => Ok(NativeResult::PsaRawKeyAgreement(wire_to_native!(
426                body.bytes(),
427                psa_raw_key_agreement_proto::Result
428            ))),
429            Opcode::CanDoCrypto => Ok(NativeResult::CanDoCrypto(wire_to_native!(
430                body.bytes(),
431                can_do_crypto_proto::Result
432            ))),
433            Opcode::AttestKey => Ok(NativeResult::AttestKey(wire_to_native!(
434                body.bytes(),
435                attest_key_proto::Result
436            ))),
437            Opcode::PrepareKeyAttestation => Ok(NativeResult::PrepareKeyAttestation(
438                wire_to_native!(body.bytes(), prepare_key_attestation_proto::Result),
439            )),
440        }
441    }
442
443    fn result_to_body(&self, result: NativeResult) -> Result<ResponseBody> {
444        match result {
445            NativeResult::ListProviders(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
446                result,
447                list_providers_proto::Result
448            ))),
449            NativeResult::ListOpcodes(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
450                result,
451                list_opcodes_proto::Result
452            ))),
453            NativeResult::ListAuthenticators(result) => Ok(ResponseBody::from_bytes(
454                native_to_wire!(result, list_authenticators_proto::Result),
455            )),
456            NativeResult::ListKeys(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
457                result,
458                list_keys_proto::Result
459            ))),
460            NativeResult::ListClients(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
461                result,
462                list_clients_proto::Result
463            ))),
464            NativeResult::DeleteClient(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
465                result,
466                delete_client_proto::Result
467            ))),
468            NativeResult::Ping(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
469                result,
470                ping_proto::Result
471            ))),
472            NativeResult::PsaGenerateKey(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
473                result,
474                psa_generate_key_proto::Result
475            ))),
476            NativeResult::PsaImportKey(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
477                result,
478                psa_import_key_proto::Result
479            ))),
480            NativeResult::PsaExportPublicKey(result) => Ok(ResponseBody::from_bytes(
481                native_to_wire!(result, psa_export_public_key_proto::Result),
482            )),
483            NativeResult::PsaExportKey(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
484                result,
485                psa_export_key_proto::Result
486            ))),
487            NativeResult::PsaDestroyKey(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
488                result,
489                psa_destroy_key_proto::Result
490            ))),
491            NativeResult::PsaSignHash(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
492                result,
493                psa_sign_hash_proto::Result
494            ))),
495            NativeResult::PsaVerifyHash(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
496                result,
497                psa_verify_hash_proto::Result
498            ))),
499            NativeResult::PsaSignMessage(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
500                result,
501                psa_sign_message_proto::Result
502            ))),
503            NativeResult::PsaVerifyMessage(result) => Ok(ResponseBody::from_bytes(
504                native_to_wire!(result, psa_verify_message_proto::Result),
505            )),
506            NativeResult::PsaAsymmetricEncrypt(result) => Ok(ResponseBody::from_bytes(
507                native_to_wire!(result, psa_asymmetric_encrypt_proto::Result),
508            )),
509            NativeResult::PsaAsymmetricDecrypt(result) => Ok(ResponseBody::from_bytes(
510                native_to_wire!(result, psa_asymmetric_decrypt_proto::Result),
511            )),
512            NativeResult::PsaAeadEncrypt(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
513                result,
514                psa_aead_encrypt_proto::Result
515            ))),
516            NativeResult::PsaAeadDecrypt(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
517                result,
518                psa_aead_decrypt_proto::Result
519            ))),
520            NativeResult::PsaCipherEncrypt(result) => Ok(ResponseBody::from_bytes(
521                native_to_wire!(result, psa_cipher_encrypt_proto::Result),
522            )),
523            NativeResult::PsaCipherDecrypt(result) => Ok(ResponseBody::from_bytes(
524                native_to_wire!(result, psa_cipher_decrypt_proto::Result),
525            )),
526            NativeResult::PsaGenerateRandom(result) => Ok(ResponseBody::from_bytes(
527                native_to_wire!(result, psa_generate_random_proto::Result),
528            )),
529            NativeResult::PsaHashCompare(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
530                result,
531                psa_hash_compare_proto::Result
532            ))),
533            NativeResult::PsaHashCompute(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
534                result,
535                psa_hash_compute_proto::Result
536            ))),
537            NativeResult::PsaRawKeyAgreement(result) => Ok(ResponseBody::from_bytes(
538                native_to_wire!(result, psa_raw_key_agreement_proto::Result),
539            )),
540            NativeResult::CanDoCrypto(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
541                result,
542                can_do_crypto_proto::Result
543            ))),
544            NativeResult::AttestKey(result) => Ok(ResponseBody::from_bytes(native_to_wire!(
545                result,
546                attest_key_proto::Result
547            ))),
548            NativeResult::PrepareKeyAttestation(result) => Ok(ResponseBody::from_bytes(
549                native_to_wire!(result, prepare_key_attestation_proto::Result),
550            )),
551        }
552    }
553}