跳转到内容

std.os.uefi.protocol.rng

标准库Zig 0.17.0官方原文
源码std/os/uefi/protocol/rng.zig

第 1 行

std.os.uefi.protocol.rng.cc

别名

第 5 行

别名目标 std.os.uefi.cc

std.os.uefi.protocol.rng.Guid

别名

第 3 行

别名目标 std.os.uefi.Guid

std.os.uefi.protocol.rng.Rng

容器

第 8 行

随机数生成器协议

字段

_get_info: *const fn (*const Rng, *usize, [*]align(8) Guid) callconv(cc) Status
_get_rng: *const fn (*const Rng, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status

std.os.uefi.protocol.rng.Rng.algorithm_raw

常量

第 96 行

std.os.uefi.protocol.rng.Rng.algorithm_sp800_90_ctr_256

常量

第 72 行

std.os.uefi.protocol.rng.Rng.algorithm_sp800_90_hash_256

常量

第 56 行

std.os.uefi.protocol.rng.Rng.algorithm_sp800_90_hmac_256

常量

第 64 行

std.os.uefi.protocol.rng.Rng.algorithm_x9_31_3des

常量

第 80 行

std.os.uefi.protocol.rng.Rng.algorithm_x9_31_aes

常量

第 88 行

std.os.uefi.protocol.rng.Rng.getInfo

函数

第 25 行

返回随机数生成实现的信息。

pub fn getInfo(self: *const Rng, list: []align(8) Guid) GetInfoError![]align(8) Guid

参数

self: *const Rng
list: []align(8) Guid

错误

BufferTooSmall
DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.rng.Rng.GetInfoError

错误集合

第 12 行

错误

BufferTooSmall
DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.rng.Rng.getRNG

函数

第 37 行

使用默认或指定的随机数生成算法产生并返回随机值。

pub fn getRNG(self: *const Rng, algo: ?*align(8) const Guid, value: []u8) GetRNGError!void

参数

self: *const Rng
algo: ?*align(8) const Guid
value: []u8

错误

DeviceError
InvalidParameter
NotReady
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.rng.Rng.GetRNGError

错误集合

第 17 行

错误

DeviceError
InvalidParameter
NotReady
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.rng.Rng.guid

常量

第 48 行

std.os.uefi.protocol.rng.Status

别名

第 4 行

别名目标 std.os.uefi.Status

std.os.uefi.protocol.rng.std

别名

第 1 行

别名目标 std

std.os.uefi.protocol.rng.uefi

别名

第 2 行

别名目标 std.os.uefi

源码

std/os/uefi/protocol/rng.zig

const std = @import("std");
const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

/// 随机数生成器协议
pub const Rng = extern struct {
    _get_info: *const fn (*const Rng, *usize, [*]align(8) Guid) callconv(cc) Status,
    _get_rng: *const fn (*const Rng, ?*align(8) const Guid, usize, [*]u8) callconv(cc) Status,

    pub const GetInfoError = uefi.UnexpectedError || error{
        Unsupported,
        DeviceError,
        BufferTooSmall,
    };
    pub const GetRNGError = uefi.UnexpectedError || error{
        Unsupported,
        DeviceError,
        NotReady,
        InvalidParameter,
    };

    /// 返回随机数生成实现的信息。
    pub fn getInfo(self: *const Rng, list: []align(8) Guid) GetInfoError![]align(8) Guid {
        var len: usize = list.len;
        switch (self._get_info(self, &len, list.ptr)) {
            .success => return list[0..len],
            .unsupported => return error.Unsupported,
            .device_error => return error.DeviceError,
            .buffer_too_small => return error.BufferTooSmall,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 使用默认或指定的随机数生成算法产生并返回随机值。
    pub fn getRNG(self: *const Rng, algo: ?*align(8) const Guid, value: []u8) GetRNGError!void {
        switch (self._get_rng(self, algo, value.len, value.ptr)) {
            .success => {},
            .unsupported => return error.Unsupported,
            .device_error => return error.DeviceError,
            .not_ready => return error.NotReady,
            .invalid_parameter => return error.InvalidParameter,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    pub const guid align(8) = Guid{
        .time_low = 0x3152bca5,
        .time_mid = 0xeade,
        .time_high_and_version = 0x433d,
        .clock_seq_high_and_reserved = 0x86,
        .clock_seq_low = 0x2e,
        .node = [_]u8{ 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 },
    };
    pub const algorithm_sp800_90_hash_256 align(8) = Guid{
        .time_low = 0xa7af67cb,
        .time_mid = 0x603b,
        .time_high_and_version = 0x4d42,
        .clock_seq_high_and_reserved = 0xba,
        .clock_seq_low = 0x21,
        .node = [_]u8{ 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96 },
    };
    pub const algorithm_sp800_90_hmac_256 align(8) = Guid{
        .time_low = 0xc5149b43,
        .time_mid = 0xae85,
        .time_high_and_version = 0x4f53,
        .clock_seq_high_and_reserved = 0x99,
        .clock_seq_low = 0x82,
        .node = [_]u8{ 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7 },
    };
    pub const algorithm_sp800_90_ctr_256 align(8) = Guid{
        .time_low = 0x44f0de6e,
        .time_mid = 0x4d8c,
        .time_high_and_version = 0x4045,
        .clock_seq_high_and_reserved = 0xa8,
        .clock_seq_low = 0xc7,
        .node = [_]u8{ 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e },
    };
    pub const algorithm_x9_31_3des align(8) = Guid{
        .time_low = 0x63c4785a,
        .time_mid = 0xca34,
        .time_high_and_version = 0x4012,
        .clock_seq_high_and_reserved = 0xa3,
        .clock_seq_low = 0xc8,
        .node = [_]u8{ 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46 },
    };
    pub const algorithm_x9_31_aes align(8) = Guid{
        .time_low = 0xacd03321,
        .time_mid = 0x777e,
        .time_high_and_version = 0x4d3d,
        .clock_seq_high_and_reserved = 0xb1,
        .clock_seq_low = 0xc8,
        .node = [_]u8{ 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9 },
    };
    pub const algorithm_raw align(8) = Guid{
        .time_low = 0xe43176d7,
        .time_mid = 0xb6e8,
        .time_high_and_version = 0x4827,
        .clock_seq_high_and_reserved = 0xb7,
        .clock_seq_low = 0x84,
        .node = [_]u8{ 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 },
    };
};