1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! PKE (Public Key Engine) driver for WS63.
//!
//! The PKE peripheral accelerates modular arithmetic operations used in:
//! - RSA (modular exponentiation)
//! - ECC (elliptic curve point operations)
//! - SM2 (Chinese national standard ECC)
use crate::peripherals::Pke;
/// PKE driver.
pub struct PkeDriver<'d> {
_pke: Pke<'d>,
}
/// PKE operation type.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PkeOp {
/// Modular exponentiation (RSA).
ModExp,
/// ECC point multiplication.
EccPointMul,
/// ECC point addition.
EccPointAdd,
/// ECC point verification.
EccPointVerify,
}
impl<'d> PkeDriver<'d> {
/// Create a new PKE driver.
pub fn new(pke: Pke<'d>) -> Self {
Self { _pke: pke }
}
#[allow(dead_code)]
fn regs(&self) -> &'static ws63_pac::pke::RegisterBlock {
// SAFETY: PAC peripheral pointer is a static physical MMIO address, always valid
unsafe { &*Pke::ptr() }
}
/// Enable the PKE peripheral.
pub fn enable(&mut self) {}
/// Disable the PKE peripheral.
pub fn disable(&mut self) {}
/// Check if the engine is busy.
pub fn is_busy(&self) -> bool {
false
}
}