mods to get hardware integration to actually work.

This commit is contained in:
bunnie 2020-08-21 01:37:10 +08:00
parent 247c8ca2b7
commit eb45d338ee
3 changed files with 14 additions and 5 deletions

View file

@ -48,9 +48,11 @@ serde = { version = "1.0", default-features = false, optional = true, features =
packed_simd = { version = "0.3", features = ["into_bits"], optional = true }
zeroize = { version = "1", default-features = false }
engine25519-as = { path="../engine25519-as", default-features = false, features = [] }
rand = { version = "0.7" }
rand = { version = "0.7", default-features = false, features = [] }
volatile = "0.2.6"
pac = { path = "../../../../sim_support/rust/pac" }
#pac = { path = "../../../../sim_support/rust/pac" } # used in test simulation environment, need to figure out how to make a switch for this
betrusted-pac = { path = "../betrusted-pac" }
#pac = { package = "betrusted-pac" }
[features]
nightly = ["subtle/nightly"]

View file

@ -65,7 +65,7 @@ pub(crate) mod macros;
extern crate engine25519_as;
extern crate rand;
extern crate volatile;
extern crate pac;
extern crate betrusted_pac;
//------------------------------------------------------------------------
// curve25519-dalek public modules

View file

@ -296,7 +296,7 @@ pub fn differential_add_and_double_hw(
affine_PmQ: &FieldElement,
) {
use volatile::Volatile;
let p = unsafe { pac::Peripherals::steal() };
let p = unsafe { betrusted_pac::Peripherals::steal() };
let mcode = assemble_engine25519!(
start:
// P.U in %20
@ -443,9 +443,16 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a MontgomeryPoint {
copy_to_rf(x1.W.to_bytes(), 28);
copy_to_rf(affine_u.to_bytes(), 24);
copy_to_rf(scalar.bytes, 31);
// load the number 254 into the loop index register
copy_to_rf([
254, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
], 19);
use volatile::Volatile;
let p = unsafe { pac::Peripherals::steal() };
let p = unsafe { betrusted_pac::Peripherals::steal() };
let mcode = assemble_engine25519!(
start:
// P.U in %20