mirror of
https://github.com/saymrwulf/betrusted-curve25519-dalek-source.git
synced 2026-09-05 20:30:54 +00:00
edit test to include normalization after add
This commit is contained in:
parent
8091a73b80
commit
c8bd4211f6
2 changed files with 19 additions and 5 deletions
|
|
@ -64,3 +64,5 @@ 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"]
|
||||
|
||||
[workspace]
|
||||
22
src/field.rs
22
src/field.rs
|
|
@ -482,7 +482,10 @@ mod test {
|
|||
|
||||
let mcode = assemble_engine25519!(
|
||||
start:
|
||||
add %0, %1, %2
|
||||
add %2, %0, %1
|
||||
trd %3, %2
|
||||
sub %31, %2, %3
|
||||
fin
|
||||
);
|
||||
|
||||
let path = Path::new("test_vectors.bin");
|
||||
|
|
@ -490,15 +493,21 @@ mod test {
|
|||
|
||||
// insert machine code
|
||||
// Metadata record:
|
||||
// 0x0 [31 load address 16] [15 length of code 0]
|
||||
// 0x4 [31 N registers to load 27] [26 W window 23] [22 X number of vectors sets 0]
|
||||
// 0x8 [microcode] (variable length)
|
||||
// 0x0 0x56454354 "VECT" - indicates a valid vector set
|
||||
// 0x4 [31 load address 16] [15 length of code 0]
|
||||
// 0x8 [31 N registers to load 27] [26 W window 23] [22 X number of vectors sets 0]
|
||||
// 0xC [microcode] (variable length)
|
||||
// [ padding of 0x0 until 0x20 * align ]
|
||||
// 0x20*align [X test vectors]
|
||||
// Records can repeat, and each one represents a new test
|
||||
// End of records MUST end with a word that is NOT 0x56454354
|
||||
// This is because the ROM read can "wrap around" and the test will run forever
|
||||
// We use 0xFFFF_FFFF to indicate this
|
||||
// Convention:
|
||||
// Check result is always in r31
|
||||
// N Registers loaded starting at r0 into window W
|
||||
let mcode_len = mcode.len();
|
||||
let _ = file.write(&(0x5645_4354 as u32).to_le_bytes());
|
||||
let _ = file.write(&( ((0x0 & 0xFFFF << 16)
|
||||
| (mcode_len & 0xFFFF)
|
||||
) as u32)
|
||||
|
|
@ -514,7 +523,7 @@ mod test {
|
|||
}
|
||||
|
||||
// pad with 0's to a 256-bit stride
|
||||
for _ in 0..(8 - ((2 + mcode_len) % 8)) { // 2 words for metadata + code length
|
||||
for _ in 0..(8 - ((3 + mcode_len) % 8)) { // 3 words for metadata + code length
|
||||
let _ = file.write(&[0,0,0,0]); // write out 32-bit words of 0 (as array of u8)
|
||||
}
|
||||
|
||||
|
|
@ -522,5 +531,8 @@ mod test {
|
|||
write_helper(&mut file, a);
|
||||
write_helper(&mut file, b);
|
||||
write_helper(&mut file, q);
|
||||
|
||||
// end sequence
|
||||
let _ = file.write(&(0xFFFF_FFFF as u32).to_le_bytes());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue