ECDSA P-256 signing/verification for Matter CASE authentication.
Wraps Erlang's :crypto and :public_key modules.
Summary
Functions
Build a minimal PKCS#10 Certificate Signing Request (CSR) in DER format.
Convert a DER-encoded ECDSA signature to raw P1363 format (r || s).
Compute ECDH shared secret (P-256 x-coordinate, 32 bytes).
Generate a new P-256 keypair.
Extract the EC public key from a PKCS#10 CSR DER.
Convert a raw P1363 signature (r || s, 64 bytes) to DER format.
Build a minimal self-signed X.509 DER certificate.
Sign a message with ECDSA-SHA256 over P-256.
Sign a message with ECDSA-SHA256 over P-256.
Verify an ECDSA-SHA256 signature over P-256 (DER-encoded signature).
Verify an ECDSA-SHA256 signature in raw P1363 format (r || s, 64 bytes).
Functions
Build a minimal PKCS#10 Certificate Signing Request (CSR) in DER format.
Used during commissioning when chip-tool sends CSRRequest. The CSR contains the EC public key and is signed with the private key.
Convert a DER-encoded ECDSA signature to raw P1363 format (r || s).
For P-256, the output is always exactly 64 bytes.
Compute ECDH shared secret (P-256 x-coordinate, 32 bytes).
Generate a new P-256 keypair.
Returns {public_key, private_key} where:
- public_key is a 65-byte SEC1 uncompressed point (0x04 || x || y)
- private_key is a 32-byte scalar
Extract the EC public key from a PKCS#10 CSR DER.
Returns the 65-byte uncompressed SEC1 point (0x04 || x || y).
Convert a raw P1363 signature (r || s, 64 bytes) to DER format.
Build a minimal self-signed X.509 DER certificate.
Used during commissioning when chip-tool requests PAI/DAC certificates. With --bypass-attestation-verifier, chip-tool won't validate the content.
Sign a message with ECDSA-SHA256 over P-256.
Returns the DER-encoded signature.
Sign a message with ECDSA-SHA256 over P-256.
Returns the raw P1363 format signature (r || s, 64 bytes). Matter uses this format for attestation and NOCSR signatures.
Verify an ECDSA-SHA256 signature over P-256 (DER-encoded signature).
Verify an ECDSA-SHA256 signature in raw P1363 format (r || s, 64 bytes).
Matter CASE uses raw format. Converts to DER for Erlang's crypto module.