ssp 0.5.4

Messages and related types for implementing the SSP/eSSP serial communication protocol
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use pbkdf2::pbkdf2_hmac_array;
use sha2::Sha256;

const PBKDF_ITER: u32 = 4096;

/// Seed for the CSPRNG.
///
/// This seed should be reasonably random itself.
pub type Seed = [u8; 32];

/// Creates a seed from data and a nonce.
///
/// Extends any entropy present in `data` and `nonce` by running many iterations of the
/// [PBKDF2](https://docs.rs/pbkdf2/latest) algorithm.
pub fn seed(data: &[u8], salt: &[u8]) -> Seed {
    pbkdf2_hmac_array::<Sha256, 32>(data, salt, PBKDF_ITER)
}