mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-06 20:41:11 +00:00
stash a version of the XousEngine25519 trait in case we want it later
This commit is contained in:
parent
0b0cda3118
commit
0b748f6365
3 changed files with 19 additions and 10 deletions
14
Cargo.toml
14
Cargo.toml
|
|
@ -52,15 +52,23 @@ packed_simd = { version = "0.3.4", package = "packed_simd_2", features = ["into_
|
|||
zeroize = { version = "1", default-features = false }
|
||||
rand = { version = "0.7", default-features = false, features = [] }
|
||||
fiat-crypto = { version = "0.1.6", optional = true}
|
||||
xous-engine-25519 = {path="../xous-engine-25519"}
|
||||
engine-25519 = {path = "../xous-core/services/engine-25519"}
|
||||
|
||||
# 1. eliminate xous-engine-25519 crate
|
||||
# 2. engine-25519 refers to a "0.1.0"
|
||||
# 3. patch engine-25519 with a workspace patch in Xous
|
||||
# 4. make a betrusted-soc accelerated feature configuration
|
||||
# 5. make engine-25519 dependency only used when the betrusted-soc feature is specified
|
||||
# 6. test that cargo test still works in `std`
|
||||
|
||||
# Betrusted/Precursor dependency set
|
||||
engine-25519 = {version = "0.1.0", optional = true}
|
||||
[dependencies.engine25519-as]
|
||||
#git="https://github.com/betrusted-io/engine25519-as.git"
|
||||
#rev="0bafc1ff8f58b66189d8c2f9ab7046cbbef77e6e"
|
||||
path="../engine25519-as"
|
||||
default-features = false
|
||||
features = []
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
nightly = ["subtle/nightly"]
|
||||
|
|
@ -81,5 +89,7 @@ simd_backend = ["nightly", "u64_backend", "packed_simd"]
|
|||
# DEPRECATED: this is now an alias for `simd_backend` and may be removed
|
||||
# in some future release.
|
||||
avx2_backend = ["simd_backend"]
|
||||
# the betrusted backend uses the curve25519 hardware accelerator in betrusted-soc
|
||||
betrusted = ["engine-25519", "engine25519-as"]
|
||||
|
||||
[workspace]
|
||||
|
|
@ -67,7 +67,7 @@ pub(crate) mod macros;
|
|||
#[macro_use]
|
||||
extern crate engine25519_as;
|
||||
extern crate rand;
|
||||
extern crate xous_engine_25519;
|
||||
extern crate engine_25519;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// curve25519-dalek public modules
|
||||
|
|
|
|||
|
|
@ -293,14 +293,14 @@ pub fn differential_add_and_double(
|
|||
Q.W = t17; // W_{Q'} = U_D * 4 (W_P U_Q - U_P W_Q)^2
|
||||
}
|
||||
|
||||
fn copy_to_rf(bytes: [u8; 32], register: usize, rf: &mut [u32; xous_engine_25519::RF_SIZE_IN_U32]) {
|
||||
fn copy_to_rf(bytes: [u8; 32], register: usize, rf: &mut [u32; engine_25519::RF_SIZE_IN_U32]) {
|
||||
use core::convert::TryInto;
|
||||
for (byte, rf_dst) in bytes.chunks_exact(4).zip(rf[register * 8..(register+1)*8].iter_mut()) {
|
||||
*rf_dst = u32::from_le_bytes(byte.try_into().expect("chunks_exact failed us"));
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_from_rf(register: usize, rf: &[u32; xous_engine_25519::RF_SIZE_IN_U32]) -> [u8; 32] {
|
||||
fn copy_from_rf(register: usize, rf: &[u32; engine_25519::RF_SIZE_IN_U32]) -> [u8; 32] {
|
||||
let mut ret: [u8; 32] = [0; 32];
|
||||
|
||||
for (src, dst) in rf[register*8 .. (register+1)*8].iter().zip(ret.chunks_exact_mut(4).into_iter()) {
|
||||
|
|
@ -398,16 +398,15 @@ pub fn differential_add_and_double_hw(
|
|||
|
||||
fin // finish execution
|
||||
);
|
||||
//let mut engine = xous_engine_25519::XousEngine25519::new();
|
||||
let mut engine = engine_25519::Engine25519::new();
|
||||
|
||||
let mut job = xous_engine_25519::Job {
|
||||
let mut job = engine_25519::Job {
|
||||
id: None,
|
||||
ucode: [0; 1024],
|
||||
uc_len: mcode.len() as u32,
|
||||
uc_start: 0,
|
||||
window: Some(0),
|
||||
rf: [0; xous_engine_25519::RF_SIZE_IN_U32],
|
||||
rf: [0; engine_25519::RF_SIZE_IN_U32],
|
||||
};
|
||||
|
||||
for (&src, dst) in mcode.iter().zip(job.ucode.iter_mut()) {
|
||||
|
|
@ -593,13 +592,13 @@ impl<'a, 'b> Mul<&'b Scalar> for &'a MontgomeryPoint {
|
|||
fin // finish execution
|
||||
);
|
||||
let mut engine = engine_25519::Engine25519::new();
|
||||
let mut job = xous_engine_25519::Job {
|
||||
let mut job = engine_25519::Job {
|
||||
id: None,
|
||||
ucode: [0; 1024],
|
||||
uc_len: mcode.len() as u32,
|
||||
uc_start: 0,
|
||||
window: Some(0),
|
||||
rf: [0; xous_engine_25519::RF_SIZE_IN_U32],
|
||||
rf: [0; engine_25519::RF_SIZE_IN_U32],
|
||||
};
|
||||
|
||||
for (&src, dst) in mcode.iter().zip(job.ucode.iter_mut()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue