ocpp-kit 0.5.0

Open Charge Point Protocol (OCPP 1.6J, 2.0.1, 2.1) toolkit for Rust: typed messages, OCPP-J framing, a sans-I/O protocol engine, and transports for charging stations, CSMS and local controllers.
Documentation
// @generated by `cargo xtask appendix` from the OCPP 1.6 Security Whitepaper, edition 4
// (2026-02-05), section 8.
//
// Only the interoperability surface is reproduced: names and criticality. The whitepaper's
// prose descriptions are not copied, and the whitepaper itself is not redistributed.
// DO NOT EDIT — re-run the generator instead.

//! The security events of the OCPP 1.6 Security Whitepaper, and which are critical.
//!
//! Section 8: "Security events that are critical should be pushed to the Central
//! System" with `SecurityEventNotification`. The names are 1.6's — `…AtCentralSystem`,
//! not 2.x's `…AtCsms` — and so is the criticality: `InvalidFirmwareSignature` is not
//! critical here, while it is in 2.x.

ocpp_enum! {
    /// A security event from the standardized list.
    ///
    /// The list is explicitly non-exhaustive: a vendor-specific event is carried in
    /// `UnknownValue`, and the specification asks that a standardized event be used
    /// wherever one matches.
    SecurityEvent {
        /// `FirmwareUpdated`.
        FirmwareUpdated = "FirmwareUpdated",
        /// `FailedToAuthenticateAtCentralSystem`.
        FailedToAuthenticateAtCentralSystem = "FailedToAuthenticateAtCentralSystem",
        /// `CentralSystemFailedToAuthenticate`.
        CentralSystemFailedToAuthenticate = "CentralSystemFailedToAuthenticate",
        /// `SettingSystemTime`.
        SettingSystemTime = "SettingSystemTime",
        /// `StartupOfTheDevice`.
        StartupOfTheDevice = "StartupOfTheDevice",
        /// `ResetOrReboot`.
        ResetOrReboot = "ResetOrReboot",
        /// `SecurityLogWasCleared`.
        SecurityLogWasCleared = "SecurityLogWasCleared",
        /// `ReconfigurationOfSecurityParameters`.
        ReconfigurationOfSecurityParameters = "ReconfigurationOfSecurityParameters",
        /// `MemoryExhaustion`.
        MemoryExhaustion = "MemoryExhaustion",
        /// `InvalidMessages`.
        InvalidMessages = "InvalidMessages",
        /// `AttemptedReplayAttacks`.
        AttemptedReplayAttacks = "AttemptedReplayAttacks",
        /// `TamperDetectionActivated`.
        TamperDetectionActivated = "TamperDetectionActivated",
        /// `InvalidFirmwareSignature`.
        InvalidFirmwareSignature = "InvalidFirmwareSignature",
        /// `InvalidFirmwareSigningCertificate`.
        InvalidFirmwareSigningCertificate = "InvalidFirmwareSigningCertificate",
        /// `InvalidCentralSystemCertificate`.
        InvalidCentralSystemCertificate = "InvalidCentralSystemCertificate",
        /// `InvalidChargePointCertificate`.
        InvalidChargePointCertificate = "InvalidChargePointCertificate",
        /// `InvalidTLSVersion`.
        InvalidTLSVersion = "InvalidTLSVersion",
        /// `InvalidTLSCipherSuite`.
        InvalidTLSCipherSuite = "InvalidTLSCipherSuite",
        /// `MaintenanceLoginAccepted`.
        MaintenanceLoginAccepted = "MaintenanceLoginAccepted",
        /// `MaintenanceLoginFailed`.
        MaintenanceLoginFailed = "MaintenanceLoginFailed",
        /// `DiscardedRenewedClientCertificate`.
        DiscardedRenewedClientCertificate = "DiscardedRenewedClientCertificate",
    }
}

impl SecurityEvent {
    /// Whether the event must be pushed to the CSMS as well as logged.
    ///
    /// A vendor-specific event is treated as critical: the safe default is to report it.
    #[must_use]
    #[allow(clippy::match_same_arms)]
    pub fn is_critical(&self) -> bool {
        match self {
            Self::FirmwareUpdated => true,
            Self::FailedToAuthenticateAtCentralSystem => false,
            Self::CentralSystemFailedToAuthenticate => false,
            Self::SettingSystemTime => true,
            Self::StartupOfTheDevice => true,
            Self::ResetOrReboot => true,
            Self::SecurityLogWasCleared => true,
            Self::ReconfigurationOfSecurityParameters => false,
            Self::MemoryExhaustion => true,
            Self::InvalidMessages => false,
            Self::AttemptedReplayAttacks => false,
            Self::TamperDetectionActivated => true,
            Self::InvalidFirmwareSignature => false,
            Self::InvalidFirmwareSigningCertificate => true,
            Self::InvalidCentralSystemCertificate => true,
            Self::InvalidChargePointCertificate => true,
            Self::InvalidTLSVersion => true,
            Self::InvalidTLSCipherSuite => true,
            Self::MaintenanceLoginAccepted => true,
            Self::MaintenanceLoginFailed => true,
            Self::DiscardedRenewedClientCertificate => true,
            Self::UnknownValue(_) => true,
        }
    }

    /// Every event the specification defines as critical.
    #[must_use]
    pub fn critical() -> alloc::vec::Vec<Self> {
        Self::VARIANTS
            .iter()
            .map(|name| Self::from_wire(name))
            .filter(Self::is_critical)
            .collect()
    }
}