/** * ECC crypto codec for OPC UA 1.05.07 SecurityPolicies EccNistP256 / EccNistP384. * * Implements Part 6 §6.8.1 Secure Channel Handshake primitives using WebCrypto only: * - Ephemeral ECDH P-256 / P-384 key pairs (ClientNonce / ServerNonce = x||y) * - ECDH shared secret (IKM = x-coordinate, zero-padded big-endian) * - HKDF-style Extract + Expand with HMAC-SHA256 / HMAC-SHA384 (RFC 5869 as repeated in spec) * - ECDSA-SHA256 / ECDSA-SHA384 sign / verify (raw r||s, 64 / 96 bytes) * * Curves intentionally limited to NIST P-256 / P-384: these are the only ECC * curves from the 1.05 policies that WebCrypto supports. Brainpool and * Curve25519/Curve448 throw UNSUPPORTED (see assertEccCurveSupported). * * SCOPE: channel crypto primitives (ephemeral/ECDH/HKDF/ECDSA + symmetric * key derivation) plus client OPN wiring in `client_secure_channel_layer` * (sign-only OPN, ephemeral nonces, ECDH + renewal XOR). Server-side OPN * emission and EccEncryptedSecret UserTokens remain follow-ups. */ export type EccCurve = 'P-256' | 'P-384'; export type EccHash = 'SHA-256' | 'SHA-384'; export interface EccPolicyParams { curve: EccCurve; hash: EccHash; /** coordinate length in bytes: 32 for P-256, 48 for P-384 */ coordLength: number; /** ephemeral public key (nonce) length x||y */ nonceLength: number; /** ECDSA asymmetric signature length r||s (64 P-256, 96 P-384) */ asymmetricSignatureLength: number; /** symmetric HMAC signature length (32 SHA-256, 48 SHA-384) */ signatureLength: number; symmetricEncryptionAlgorithm: 'AES-128-CBC' | 'AES-256-CBC'; derivedSignatureKeyLength: number; derivedEncryptionKeyLength: number; encryptingBlockSize: number; } export declare const EccNistP256_Params: EccPolicyParams; export declare const EccNistP384_Params: EccPolicyParams; export declare function paramsForCurve(curve: EccCurve): EccPolicyParams; /** * Only NIST curves are supported via WebCrypto. Everything else from Part 7 * (BrainpoolP256r1/P384r1, Curve25519/Curve448) throws here so callers fail fast. */ export declare function assertEccCurveSupported(curve: string): asserts curve is EccCurve; /** Generate a fresh ephemeral ECDH key pair (one per OpenSecureChannel). */ export declare function generateEphemeralKeyPair(curve: EccCurve): Promise; /** * Export ECDH public key as OPC UA nonce: x||y zero-padded big-endian. * Uses JWK export (x/y base64url) to avoid DER parsing. */ export declare function exportEphemeralPublicKey(publicKey: CryptoKey, curve: EccCurve): Promise; /** Import a peer nonce (x||y) as an ECDH public key for deriveBits. */ export declare function importEphemeralPublicKey(nonce: Uint8Array, curve: EccCurve): Promise; /** * ECDH shared secret (IKM). WebCrypto deriveBits for ECDH returns exactly the * x-coordinate zero-padded big-endian, which is what Part 6 §6.8.1 requires. */ export declare function deriveSharedSecretIKM(privateKey: CryptoKey, peerPublicKey: CryptoKey, curve: EccCurve): Promise; /** ServerSalt = L | UTF8("opcua-server") | ServerNonce | ClientNonce */ export declare function buildServerSalt(derivedMaterialLength: number, serverNonce: Uint8Array, clientNonce: Uint8Array): Uint8Array; /** ClientSalt = L | UTF8("opcua-client") | ClientNonce | ServerNonce */ export declare function buildClientSalt(derivedMaterialLength: number, clientNonce: Uint8Array, serverNonce: Uint8Array): Uint8Array; /** Step 2: PRK = HMAC-Hash(Salt, IKM) */ export declare function eccExtract(salt: Uint8Array, ikm: Uint8Array, hash: EccHash): Promise; /** Step 3: OKM = T(1)|T(2)|... truncated to L, Info = Salt */ export declare function eccExpand(prk: Uint8Array, info: Uint8Array, length: number, hash: EccHash): Promise; export interface EccDerivedKeyMaterial { signingKey: Uint8Array; encryptingKey: Uint8Array; initializationVector: Uint8Array; } /** * Derive one direction (client OR server) of key material. * When Sign-only is used, pass encryptingKeyLength=0 and ivLength=0 per §6.8.1. */ export declare function deriveEccKeyMaterial(salt: Uint8Array, ikm: Uint8Array, derivedMaterialLength: number, signingKeyLength: number, encryptingKeyLength: number, ivLength: number, hash: EccHash): Promise; export interface EccChannelKeys { clientKeys: EccDerivedKeyMaterial; serverKeys: EccDerivedKeyMaterial; } /** Full channel derivation: client keys from ClientSalt, server keys from ServerSalt. */ export declare function computeEccChannelKeys(clientNonce: Uint8Array, serverNonce: Uint8Array, ikm: Uint8Array, params: EccPolicyParams): Promise; /** Renewal linking (§6.8.1): new IKM = old IKM XOR fresh IKM. */ export declare function xorIkmsForRenewal(oldIkm: Uint8Array, freshIkm: Uint8Array): Uint8Array; export declare function ecdsaSign(data: Uint8Array | ArrayBuffer | ArrayBufferView, privateKey: CryptoKey, hash: EccHash): Promise; export declare function ecdsaVerify(data: Uint8Array | ArrayBuffer | ArrayBufferView, signature: Uint8Array | ArrayBuffer | ArrayBufferView, publicKey: CryptoKey, hash: EccHash): Promise; //# sourceMappingURL=ecc.d.ts.map