Separate RNG library (#470)

* seperates the RNG library

* fixes crypto tests

* adds rng256 workflow

* fixes formatting
This commit is contained in:
kaczmarczyck
2022-04-28 11:36:43 +02:00
committed by GitHub
parent 360efa4eaf
commit 4782d7e186
23 changed files with 96 additions and 26 deletions

View File

@@ -28,11 +28,11 @@ use alloc::str;
use alloc::string::String;
use alloc::vec::Vec;
use crypto::hmac::hmac_256;
use crypto::rng256::Rng256;
use crypto::sha256::Sha256;
use crypto::Hash256;
#[cfg(test)]
use enum_iterator::IntoEnumIterator;
use rng256::Rng256;
use subtle::ConstantTimeEq;
/// The prefix length of the PIN hash that is stored and compared.

View File

@@ -364,7 +364,7 @@ mod test {
use super::super::CtapState;
use super::*;
use crate::env::test::TestEnv;
use crypto::rng256::Rng256;
use rng256::Rng256;
const DUMMY_CHANNEL: Channel = Channel::MainHid([0x12, 0x34, 0x56, 0x78]);

View File

@@ -15,7 +15,7 @@
use crate::ctap::status_code::Ctap2StatusCode;
use alloc::vec::Vec;
use crypto::cbc::{cbc_decrypt, cbc_encrypt};
use crypto::rng256::Rng256;
use rng256::Rng256;
/// Wraps the AES256-CBC encryption to match what we need in CTAP.
pub fn aes256_cbc_encrypt(

View File

@@ -1226,8 +1226,8 @@ mod test {
cbor_array, cbor_bool, cbor_bytes, cbor_bytes_lit, cbor_false, cbor_int, cbor_null,
cbor_text, cbor_unsigned,
};
use crypto::rng256::Rng256;
use crypto::sha256::Sha256;
use rng256::Rng256;
#[test]
fn test_extract_unsigned() {

View File

@@ -77,10 +77,10 @@ use arrayref::array_ref;
use byteorder::{BigEndian, ByteOrder};
use core::convert::TryFrom;
use crypto::hmac::{hmac_256, verify_hmac_256};
use crypto::rng256::Rng256;
use crypto::sha256::Sha256;
use crypto::{ecdsa, Hash256};
use embedded_time::duration::Milliseconds;
use rng256::Rng256;
use sk_cbor as cbor;
use sk_cbor::cbor_map_options;

View File

@@ -23,9 +23,9 @@ use crypto::hkdf::hkdf_empty_salt_256;
#[cfg(test)]
use crypto::hmac::hmac_256;
use crypto::hmac::{verify_hmac_256, verify_hmac_256_first_128bits};
use crypto::rng256::Rng256;
use crypto::sha256::Sha256;
use crypto::Hash256;
use rng256::Rng256;
/// Implements common functions between existing PIN protocols for handshakes.
pub struct PinProtocol {

View File

@@ -30,8 +30,8 @@ use alloc::vec::Vec;
use arrayref::array_ref;
use core::cmp;
use core::convert::TryInto;
use crypto::rng256::Rng256;
use persistent_store::{fragment, StoreUpdate};
use rng256::Rng256;
use sk_cbor::cbor_array_vec;
/// Wrapper for master keys.
@@ -729,7 +729,7 @@ mod test {
use super::*;
use crate::ctap::data_formats::{PublicKeyCredentialSource, PublicKeyCredentialType};
use crate::env::test::TestEnv;
use crypto::rng256::Rng256;
use rng256::Rng256;
fn create_credential_source(
rng: &mut impl Rng256,

2
src/env/mod.rs vendored
View File

@@ -3,8 +3,8 @@ use crate::api::firmware_protection::FirmwareProtection;
use crate::api::upgrade_storage::UpgradeStorage;
use crate::ctap::status_code::Ctap2StatusCode;
use crate::ctap::Channel;
use crypto::rng256::Rng256;
use persistent_store::{Storage, Store};
use rng256::Rng256;
#[cfg(feature = "std")]
pub mod test;

2
src/env/test/mod.rs vendored
View File

@@ -4,11 +4,11 @@ use crate::api::firmware_protection::FirmwareProtection;
use crate::ctap::status_code::Ctap2StatusCode;
use crate::ctap::Channel;
use crate::env::{Env, UserPresence};
use crypto::rng256::Rng256;
use customization::TestCustomization;
use persistent_store::{BufferOptions, BufferStorage, Store};
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rng256::Rng256;
mod customization;
mod upgrade_storage;

2
src/env/tock/mod.rs vendored
View File

@@ -7,7 +7,6 @@ use crate::ctap::Channel;
use crate::env::{Env, UserPresence};
use core::cell::Cell;
use core::sync::atomic::{AtomicBool, Ordering};
use crypto::rng256::TockRng256;
use libtock_core::result::{CommandError, EALREADY};
use libtock_drivers::buttons::{self, ButtonState};
use libtock_drivers::console::Console;
@@ -15,6 +14,7 @@ use libtock_drivers::result::{FlexUnwrap, TockError};
use libtock_drivers::timer::Duration;
use libtock_drivers::{crp, led, timer, usb_ctap_hid};
use persistent_store::{StorageResult, Store};
use rng256::TockRng256;
mod storage;