ws63-hal 0.2.0

Hardware Abstraction Layer for HiSilicon WS63 (RISC-V RV32IMFC_Zicsr)
Documentation
//! 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
    }
}