uefi_specs/hyperv/
crypto.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Crypto types defined in `BiosInterface.h`
5
6use self::packed_nums::*;
7use crate::hyperv::common::EfiStatus64NoErrorBit;
8use open_enum::open_enum;
9use zerocopy::FromBytes;
10use zerocopy::Immutable;
11use zerocopy::IntoBytes;
12use zerocopy::KnownLayout;
13
14#[allow(non_camel_case_types)]
15mod packed_nums {
16    pub type u64_ne = zerocopy::U64<zerocopy::NativeEndian>;
17}
18
19open_enum! {
20    /// Command types for CRYPTO_COMMAND_DESCRIPTOR.
21    ///
22    /// These correlate with the semantics of the UEFI runtime variable services.
23    /// Note that all commands other than GET_RANDOM_NUMBER have been deprecated.
24    ///
25    /// MsvmPkg: `CRYPTO_COMMAND`
26    #[derive(IntoBytes, FromBytes, Immutable, KnownLayout)]
27    pub enum CryptoCommand: u32 {
28        COMPUTE_HASH = 0,
29        VERIFY_RSA_PKCS_1 = 1,
30        VERIFY_PKCS_7 = 2,
31        VERIFY_AUTHENTICODE = 3,
32        LOG_EVENT_DEPRECATED = 4,
33        GET_RANDOM_NUMBER = 5,
34    }
35}
36
37/// MsvmPkg: `CRYPTO_COMMAND_DESCRIPTOR`
38#[repr(C)]
39#[derive(Debug, Clone, Copy, IntoBytes, FromBytes, Immutable, KnownLayout)]
40pub struct CryptoCommandDescriptor {
41    pub command: CryptoCommand,
42    pub status: EfiStatus64NoErrorBit,
43}
44
45/// MsvmPkg: `CRYPTO_COMMAND_DESCRIPTOR`
46#[repr(C)]
47#[derive(Debug, IntoBytes, FromBytes, Immutable, KnownLayout)]
48pub struct CryptoGetRandomNumberParams {
49    pub buffer_address: u64_ne,
50    pub buffer_size: u32,
51}