Skip to content

Commit

Permalink
Fix RSA multiplication (math is hard)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham committed Nov 30, 2023
1 parent 069e16d commit df8a53e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions esp-hal-common/src/rsa/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ impl<'d> Rsa<'d> {
self.rsa.x_mem(0).as_ptr() as *mut u32,
N,
);
write_bytes(self.rsa.x_mem(0).as_ptr().add(N * 4), 0, N * 4);
write_bytes(self.rsa.x_mem(0).as_ptr().add(N), 0, N);
}

unsafe fn write_multi_operand_b<const N: usize>(&mut self, operand_b: &[u32; N]) {
write_bytes(self.rsa.z_mem(0).as_ptr(), 0, N * 4);
write_bytes(self.rsa.z_mem(0).as_ptr(), 0, N);
copy_nonoverlapping(
operand_b.as_ptr(),
self.rsa.z_mem(0).as_ptr().add(N * 4) as *mut u32,
self.rsa.z_mem(0).as_ptr().add(N) as *mut u32,
N,
);
}
Expand Down
2 changes: 1 addition & 1 deletion esp-hal-common/src/rsa/esp32cX.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<'d> Rsa<'d> {
unsafe fn write_multi_operand_b<const N: usize>(&mut self, operand_b: &[u32; N]) {
copy_nonoverlapping(
operand_b.as_ptr(),
self.rsa.z_mem(0).as_ptr().add(N * 4) as *mut u32,
self.rsa.z_mem(0).as_ptr().add(N) as *mut u32,
N,
);
}
Expand Down
2 changes: 1 addition & 1 deletion esp-hal-common/src/rsa/esp32sX.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'d> Rsa<'d> {
unsafe fn write_multi_operand_b<const N: usize>(&mut self, operand_b: &[u32; N]) {
copy_nonoverlapping(
operand_b.as_ptr(),
self.rsa.z_mem(0).as_ptr().add(N * 4) as *mut u32,
self.rsa.z_mem(0).as_ptr().add(N) as *mut u32,
N,
);
}
Expand Down

0 comments on commit df8a53e

Please sign in to comment.