tpm2-rand 0.2.0

A simple TPM2-based random number generator
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 26.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 479.02 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 3s Average build duration of successful builds.
  • all releases: 1m 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • korewaChino github:fyralabs:crates-io-maintainer

tpm2-rand

This crate provides a simple rand generator that uses a TPM2 device to generate random numbers. It implements the rand_core::RngCore trait, allowing it to be used seamlessly with the rand ecosystem.

Features

It simply exposes the RNG functionality from the TPM2 device, That's it.

Usage

To use this crate, add the following to your Cargo.toml:

[dependencies]
tpm2-rand = "0"
tss-esapi = "7"

Then, you can use it in your code as follows:

use tpm2_rand::Tpm2Rand;
use tss_esapi::{
    Context,
    TctiNameConf,
};


let context = Context::new(TctiNameConf::from_environment_variable().unwrap()).unwrap();
let mut rng = Tpm2Rand::new(context).unwrap();
let random_bytes = rng.gen::<[u8; 32]>();
println!("Random bytes: {:?}", random_bytes);

You should check out tss-esapi documentation for more details on how to set up the TPM2 context and handle errors.

License

This crate is licensed under either the Apache License, Version 2.0, or the MIT License, at your option. See the LICENSE-APACHE and LICENSE-MIT files for details.