Skip to main content

Module credentials

Module credentials 

Source
Expand description

The rules a Charging Station’s HTTP Basic password must follow, per version.

Pure checks with no dependencies, so the station blocks can refuse a credential they could not present without pulling in the transport. The password type itself, which zeroizes and generates, is transport::BasicAuthPassword (feature tokio).

  • 1.6 AuthorizationKey: “Minimal 16-bytes long … Hexadecimal represented (20 bytes maximum, represented as a string of up to 40 hexadecimal digits)” (1.6 Security Whitepaper ed. 4, A00.FR.205). The decoded octets are the password.
  • 2.x BasicAuthPassword: “a randomly chosen passwordString … consisting of minimum 16 and a maximum as defined by the maxLimit of configuration variable BasicAuthPassword, which must be at least 40 characters and at most 64” (A00.FR.205), where passwordString “can only contain characters from the following character set: a-z, A-Z, 0-9, ‘*’, ‘-’, ‘_’, ‘=’, ‘:’, ‘+’, ‘|’, ‘@’, ‘.’” (Part 2 §2.1.4, primitive datatypes).
use ocpp_kit::credentials::{self, CredentialError};

assert!(credentials::check_password("a-sixteen-char-pw", 40).is_ok());
assert_eq!(
    credentials::check_password("sixteen-chars-ok!", 40),
    Err(CredentialError::Character('!'))
);
assert_eq!(credentials::authorization_key_octets("00112233445566778899AABBCCDDEEFF")?.len(), 16);

Enums§

CredentialError
Why a credential was rejected.

Constants§

AUTHORIZATION_KEY_MAX_BYTES
The longest 1.6 AuthorizationKey, in octets (Security Whitepaper A00.FR.205).
AUTHORIZATION_KEY_MIN_BYTES
The shortest 1.6 AuthorizationKey, in octets (Security Whitepaper A00.FR.205).
BASIC_AUTH_INTEROPERABLE_MAX_LEN
The smallest maxLimit a CSMS may configure for BasicAuthPassword (A00.FR.205).
BASIC_AUTH_MAX_LEN
The longest BasicAuthPassword OCPP 2.x can define.
BASIC_AUTH_MIN_LEN
The shortest BasicAuthPassword OCPP 2.x allows (A00.FR.205).
PASSWORD_STRING_CHARSET
Every character a 2.x passwordString may contain (Part 2 §2.1.4), 71 in all.

Functions§

authorization_key_octets
Decodes a 1.6 AuthorizationKey into the password octets: hexadecimal (either case, surrounding whitespace ignored), AUTHORIZATION_KEY_MIN_BYTES to AUTHORIZATION_KEY_MAX_BYTES octets.
check_password
Checks a 2.x BasicAuthPassword: BASIC_AUTH_MIN_LEN..=max_len characters, every one a passwordString character.