import { RawMap } from './map'; import { Key, type MACer } from './key'; /** * HMACKey implements the HMAC message authentication code algorithm for COSE, * as defined in RFC 9053. Use it with {@link Mac0Message} or {@link MacMessage}. * * Construction signature: `generate(alg, kid?)`, but note that `fromSecret` * takes the algorithm as its SECOND argument: `fromSecret(secret, alg, kid?)`. * This ordering differs from the other key types — see the key-construction * cheat sheet in `docs/agent-guide.md`. * * @example * ```ts * const key = HMACKey.generate(iana.AlgorithmHMAC_256_256) * const cose = new Mac0Message(payload).toBytes(key) * Mac0Message.fromBytes(key, cose) * ``` * * @see https://datatracker.ietf.org/doc/html/rfc9053#name-hash-based-message-authenti */ export declare class HMACKey extends Key implements MACer { /** Decodes a COSE_Key from CBOR bytes into an HMACKey. */ static fromBytes(data: Uint8Array): HMACKey; /** * Generates a new random HMAC key for the given algorithm. * * @param alg - The HMAC algorithm, e.g. `iana.AlgorithmHMAC_256_256`, * `iana.AlgorithmHMAC_384_384`, or `iana.AlgorithmHMAC_512_512`. * @param kid - Optional key id. */ static generate(alg: number, kid?: T): HMACKey; /** * Imports an HMAC key from raw bytes. * * Note: unlike the other key types, the algorithm is the SECOND parameter * (not the kid). The secret length must match the algorithm: HMAC 256/64 and * 256/256 = 32 bytes, 384/384 = 48 bytes, 512/512 = 64 bytes. * * @param secret - The raw HMAC key bytes. * @param alg - The HMAC algorithm, e.g. `iana.AlgorithmHMAC_256_256`. * @param kid - Optional key id. */ static fromSecret(secret: Uint8Array, alg: number, kid?: T): HMACKey; constructor(kv?: RawMap); getSecretKey(): Uint8Array; mac(message: Uint8Array, op?: number | string): Uint8Array; }