Skip to content

Commit

Permalink
Add security enhancement for OCPP 1.6
Browse files Browse the repository at this point in the history
This commit adds support for the security enhancements in OCPP 1.6
as defined by the OCA[0]

[0]: https://www.openchargealliance.org/news/enhanced-security-for-ocpp-16/
  • Loading branch information
villekr authored Jun 27, 2021
1 parent 41d4a16 commit 10996e2
Show file tree
Hide file tree
Showing 26 changed files with 927 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ venv.bak/
.mypy_cache/

.idea/*

### OSX ###
*.DS_Store
71 changes: 71 additions & 0 deletions ocpp/v16/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
Reason,
ResetType,
UpdateType,
CertificateUse,
Log,
UploadLogStatus,
)

# Most types of CALL messages can originate from only 1 source, either
Expand All @@ -38,6 +41,11 @@ class CancelReservationPayload:
reservation_id: int


@dataclass
class CertificateSignedPayload:
certificate_chain: str


@dataclass
class ChangeAvailabilityPayload:
connector_id: int
Expand All @@ -63,6 +71,17 @@ class ClearChargingProfilePayload:
stack_level: Optional[int] = None


@dataclass
class DeleteCertificatePayload:
certificate_hash_data: Dict


@dataclass
class ExtendedTriggerMessagePayload:
requested_message: MessageTrigger
connector_id: Optional[int] = None


@dataclass
class GetCompositeSchedulePayload:
connector_id: int
Expand All @@ -84,11 +103,31 @@ class GetDiagnosticsPayload:
stop_time: Optional[str] = None


@dataclass
class GetInstalledCertificateIdsPayload:
certificate_type: CertificateUse


@dataclass
class GetLocalListVersionPayload:
pass


@dataclass
class GetLogPayload:
log: Dict
log_type: Log
request_id: int
retries: Optional[int] = None
retry_interval: Optional[int] = None


@dataclass
class InstallCertificatePayload:
certificate_type: CertificateUse
certificate: str


@dataclass
class RemoteStartTransactionPayload:
id_tag: str
Expand Down Expand Up @@ -128,6 +167,14 @@ class SetChargingProfilePayload:
cs_charging_profiles: Dict


@dataclass
class SignedUpdateFirmwarePayload:
request_id: int
firmware: Dict
retries: Optional[int] = None
retry_interval: Optional[int] = None


@dataclass
class TriggerMessagePayload:
requested_message: MessageTrigger
Expand Down Expand Up @@ -183,13 +230,37 @@ class HeartbeatPayload:
pass


@dataclass
class LogStatusNotificationPayload:
status: UploadLogStatus
request_id: int


@dataclass
class MeterValuesPayload:
connector_id: int
meter_value: List = field(default_factory=list)
transaction_id: Optional[int] = None


@dataclass
class SecurityEventNotificationPayload:
type: str
timestamp: str
tech_info: Optional[str]


@dataclass
class SignCertificatePayload:
csr: str


@dataclass
class SignedFirmwareStatusNotificationPayload:
status: FirmwareStatus
request_id: int


@dataclass
class StartTransactionPayload:
connector_id: int
Expand Down
64 changes: 64 additions & 0 deletions ocpp/v16/call_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
TriggerMessageStatus,
UpdateStatus,
UnlockStatus,
CertificateSignedStatus,
CertificateStatus,
DeleteCertificateStatus,
GenericStatus,
GetInstalledCertificateStatus,
LogStatus,
UpdateFirmwareStatus
)

# Most types of CALLRESULT messages can originate from only 1 source, either
Expand Down Expand Up @@ -63,6 +70,21 @@ class HeartbeatPayload:
current_time: str


@dataclass
class LogStatusNotificationPayload:
pass


@dataclass
class SecurityEventNotificationPayload:
pass


@dataclass
class SignCertificatePayload:
status: GenericStatus


@dataclass
class MeterValuesPayload:
pass
Expand Down Expand Up @@ -93,6 +115,11 @@ class CancelReservationPayload:
status: CancelReservationStatus


@dataclass
class CertificateSignedPayload:
status: CertificateSignedStatus


@dataclass
class ChangeAvailabilityPayload:
status: AvailabilityStatus
Expand All @@ -113,6 +140,22 @@ class ClearChargingProfilePayload:
status: ClearChargingProfileStatus


@dataclass
class DeleteCertificatePayload:
status: DeleteCertificateStatus


@dataclass
class ExtendedTriggerMessagePayload:
status: TriggerMessageStatus


@dataclass
class GetInstalledCertificateIdsPayload:
status: GetInstalledCertificateStatus
certificate_hash_data: Optional[List] = None


@dataclass
class GetCompositeSchedulePayload:
status: GetCompositeScheduleStatus
Expand All @@ -137,6 +180,17 @@ class GetLocalListVersionPayload:
list_version: int


@dataclass
class GetLogPayload:
status: LogStatus
filename: Optional[str] = None


@dataclass
class InstallCertificatePayload:
status: CertificateStatus


@dataclass
class RemoteStartTransactionPayload:
status: RemoteStartStopStatus
Expand Down Expand Up @@ -167,6 +221,16 @@ class SetChargingProfilePayload:
status: ChargingProfileStatus


@dataclass
class SignedFirmwareStatusNotificationPayload:
pass


@dataclass
class SignedUpdateFirmwarePayload:
status: UpdateFirmwareStatus


@dataclass
class TriggerMessagePayload:
status: TriggerMessageStatus
Expand Down
Loading

0 comments on commit 10996e2

Please sign in to comment.