]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
refactor(crypto): modernize crypto APIs and harden certificate handling
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 7 Apr 2026 22:30:11 +0000 (00:30 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 7 Apr 2026 22:30:11 +0000 (00:30 +0200)
commit66d6967de66c742f8db1a9ea1e81f1a5c56c2ff7
treec1d38c7140793655e166108f75ea5b237f7b2297
parent05820aae196f01dcee2cdf82dbbbcdde69841d4a
refactor(crypto): modernize crypto APIs and harden certificate handling

- Migrate createHash() to crypto.hash() one-shot API (Node.js 22+)
- Migrate createSign() to crypto.sign() one-shot API
- Add derLength() bounds check for lengths > 0xFFFF
- Change CertificatePrivateKey persistence to Ephemeral
- Add logger.debug in deriveSigningMethodFromPublicKeyHex catch block
- Harden validateCertificatePath with async realpath for symlink
  protection (falls back to resolve for not-yet-created paths)
- Add X.509 chain validation in validateCertificateX509: verify issuer
  linkage and signatures for all certificates, validate validity
  period for entire chain (not just leaf), document leaf-first ordering
- Implement RFC 6960 §4.1.1 compliant issuerNameHash via DER issuer
  extraction from certificate raw bytes (extractDerIssuer)
- Move DER parsing functions (readDerLength, skipDerElement,
  extractDerIssuer) to Asn1DerUtils with proper JSDoc
- Rename readDerTagLength to readDerLength for accuracy
- Add unit tests for DER parsing functions and chain validation
- Add real CA + leaf certificate test fixtures
src/charging-station/Helpers.ts
src/charging-station/ocpp/2.0/Asn1DerUtils.ts
src/charging-station/ocpp/2.0/OCPP20CertificateManager.ts
src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts
src/charging-station/ocpp/OCPPSignedMeterDataGenerator.ts
src/charging-station/ocpp/OCPPSignedMeterValueUtils.ts
src/types/ocpp/2.0/Variables.ts
tests/charging-station/ocpp/2.0/Asn1DerUtils.test.ts
tests/charging-station/ocpp/2.0/OCPP20CertificateManager.test.ts
tests/charging-station/ocpp/2.0/OCPP20CertificateTestData.ts