Skip to main content

Module xof_factory

Module xof_factory 

Source
Expand description

XOF factory for creating instances of algorithms that implement the XOF trait.

As with all Factory objects, this implements constructions from strings and defaults, and returns a XOFFactory object which itself implements the XOF trait as a pass-through to the underlying algorithm.

Example usage:

use bouncycastle_core::traits::XOF;
use bouncycastle_factory::AlgorithmFactory;
use bouncycastle_factory::xof_factory::XOFFactory;
use bouncycastle_sha3 as sha3;

let data: &[u8] = b"Hello, world!";

let mut h = XOFFactory::new(sha3::SHAKE128_NAME).unwrap();
h.absorb(data);
let output: Vec<u8> = h.squeeze(16);

You can equivalently invoke this by string instead of using the constant:

use bouncycastle_factory::AlgorithmFactory;
use bouncycastle_factory::xof_factory::XOFFactory;

let mut h = XOFFactory::new("SHAKE128");

Or, if you don’t particularly care which algorithm you get, you can use the configured default:

use bouncycastle_factory::AlgorithmFactory;
use bouncycastle_factory::xof_factory::XOFFactory;

let mut h = XOFFactory::default();

Enums§

XOFFactory

Constants§

DEFAULT_128BIT_XOF_NAME
DEFAULT_256BIT_XOF_NAME
DEFAULT_XOF_NAME