/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Bytes, Crypto, Key, MlDsa } from "@matter/general"; import { CertificatePublicKey, CertificateSignature } from "./CertificateSignature.js"; import { Unsigned } from "./common.js"; import { MatterCertificate } from "./definitions/base.js"; import { CertificateExtension } from "./definitions/operational.js"; /** * Abstract definition of a X.509 certificate that can be signed and converted to ASN.1 DER format. * It also provides two static methods to create a certificate signing request (CSR) and to extract the public key * from a CSR. */ export declare abstract class Certificate { #private; constructor(cert: CT | Unsigned); get cert(): Unsigned; get isSigned(): boolean; /** * Get the signature of the certificate. * If the certificate is not signed, it throws a CertificateError. */ get signature(): CertificateSignature; /** * Set the signature of the certificate. * If the certificate is already signed, it throws a CertificateError. */ set signature(signature: CertificateSignature); /** * Sign the certificate using the provided crypto and key. * * The key must match the signature algorithm the certificate declares: an EC key for ecdsa-with-SHA256, an ML-DSA * key of the parameter set in {@link MatterCertificate.mlDsaSignature} otherwise. It throws a CertificateError if * the certificate is already signed. */ sign(crypto: Crypto, key: JsonWebKey | MlDsa.PrivateKey): Promise; /** * The certificate's public key, tagged by algorithm. * * @throws CertificateError if the key algorithm is not supported * @throws KeyInputError if an EC key is malformed */ get publicKey(): CertificatePublicKey; /** * Verify the issuer's signature over this certificate with the issuer's public key. * * @throws CertificateError if the signature algorithm is not supported, or the issuer's key algorithm cannot * have produced this certificate's signature * @throws CryptoVerifyError if the signature does not verify * @throws KeyInputError if the issuer key is malformed * @see {@link https://csrc.nist.gov/pubs/fips/204/final FIPS 204} for ML-DSA */ verifySignature(crypto: Crypto, issuerKey: CertificatePublicKey): Promise; /** * Serialize as signed DER. * * If no signature is present, throws an error. */ asSignedDer(): AllowSharedBufferSource; /** * Serialize as DER without signature. */ asUnsignedDer(): Bytes; /** * Convert the extensions of the certificate to ASN.1 DER format. */ extensionsToAsn1(extensions: CertificateExtension): { [field: string]: any; }; } /** * Extract a VendorID or ProductID encoded via the "fallback method" (Matter spec 6.2.2.2): the * prefix `Mvid:`/`Mpid:` followed by 4 uppercase hexadecimal characters, anywhere within a * `commonName`. Returns the leftmost correctly-encoded value, or `undefined` if the prefix is * absent. Throws if the prefix appears but no correctly-encoded value exists (spec 6.2.2.2.1). */ export declare function parseMatterFallbackVidPid(commonName: string, prefix: "Mvid:" | "Mpid:"): number | undefined; export declare namespace Certificate { /** * Create a Certificate Signing Request (CSR) in ASN.1 DER format. */ function createCertificateSigningRequest(crypto: Crypto, key: Key): Promise; /** These extensions are minimum required for all Matter certificates. */ const REQUIRED_PAA_EXTENSIONS: string[]; /** These extensions are usually required for all Matter certificates, beside a PAA. */ const REQUIRED_EXTENSIONS: string[]; interface ParseOptions { /** * Raise the size limit to the one for ML-DSA attestation certificates (PQC Phase 1). Traditional certificates * stay bound to 600 bytes either way, and no ML-DSA certificate fits in 600 bytes, so without this option * ML-DSA is rejected. */ postQuantum?: boolean; } /** * Parse an ASN.1/DER encoded certificate into the internal format. * This extracts the certificate data without the signature. */ function parseAsn1Certificate(encodedCert: Bytes, requiredExtensions?: string[], options?: ParseOptions): MatterCertificate; /** * Extract the public key from a Certificate Signing Request (CSR) in ASN.1 DER format. */ function getPublicKeyFromCsr(crypto: Crypto, encodedCsr: Bytes): Promise; } //# sourceMappingURL=Certificate.d.ts.map