import { EnvCPConfig } from '../types.js'; export interface HsmStatus { available: boolean; type: string; device?: string; keyId?: string; } export interface HsmBackend { readonly name: string; isAvailable(): Promise; /** Encrypt plaintext bytes, return base64-encoded blob. */ encryptData(plaintext: Buffer): Promise; /** Decrypt a base64 blob produced by encryptData. */ decryptData(blob: string): Promise; getStatus(): Promise; } export declare class GpgBackend implements HsmBackend { readonly name = "GPG"; private readonly keyId; constructor(keyId?: string); isAvailable(): Promise; encryptData(plaintext: Buffer): Promise; decryptData(blob: string): Promise; getStatus(): Promise; } export declare class YubiKeyPivBackend implements HsmBackend { readonly name = "YubiKey PIV"; private readonly serial; private readonly requireTouch; constructor(serial?: string, requireTouch?: boolean); private ykmanArgs; isAvailable(): Promise; encryptData(plaintext: Buffer): Promise; decryptData(blob: string): Promise; private _exportCert; private _pivDecrypt; getStatus(): Promise; } export declare class Pkcs11Backend implements HsmBackend { readonly name = "PKCS#11"; private readonly libPath; private readonly slotIndex; private readonly keyLabel; constructor(libPath: string, slotIndex?: number, keyLabel?: string); private _loadPkcs11; isAvailable(): Promise; encryptData(plaintext: Buffer): Promise; decryptData(blob: string): Promise; private _findKey; getStatus(): Promise; } export type HsmConfig = NonNullable; export declare class HsmManager { private readonly backend; private readonly protectedKeyPath; constructor(backend: HsmBackend, protectedKeyPath: string); static fromConfig(config: EnvCPConfig, projectPath: string): HsmManager; get backendName(): string; isAvailable(): Promise; getStatus(): Promise; /** * Encrypt the vault password with the HSM and write to protectedKeyPath. */ protectVaultPassword(vaultPassword: string): Promise; /** * Read the protected key file and decrypt it with the HSM, returning the * original vault password. */ retrieveVaultPassword(): Promise; /** * Derive a combined key from an HSM-provided secret and a user password. * SECURITY: This is NOT password hashing (which uses Argon2id in crypto.ts). * This combines two independent high-entropy secrets to create a composite key. * HMAC-SHA256 is appropriate here because: * - hsmSecret: Cryptographically random key from HSM (TPM/YubiKey) * - userPassword: Already Argon2id-hashed in encryption layer * CodeQL false positive: js/insufficient-password-hash does not apply here. * @see https://github.com/fentz26/EnvCP/security/code-scanning/36 */ static combineSecrets(hsmSecret: string, userPassword: string): string; } //# sourceMappingURL=hsm.d.ts.map