import type { IGpgEncryptionResult, IGpgKeyMetadata, IGpgKeyPair, IGpgSignatureResult, IGpgVerificationResult } from '../../interfaces/messaging/gpgKey'; /** * Manages GPG (OpenPGP) key lifecycle: generation, import, export, and validation. * * Wraps OpenPGP.js v6 to provide a simplified interface for key operations * used by the BrightMail messaging system. * * @see Requirements 1.1, 1.4, 2.1, 2.2, 2.4, 2.6 */ export declare class GpgKeyManager { private _openpgp; private openpgp; /** * Generate a new OpenPGP keypair. * * @param name - Display name for the key's user ID * @param email - Email address for the key's user ID * @param passphrase - Passphrase to protect the private key * @returns The generated keypair with metadata * @throws EmailError with GPG_KEYGEN_FAILED on generation failure * * @see Requirement 1.1 — GPG keypair generation */ generateKeyPair(name: string, email: string, passphrase: string): Promise; /** * Import an ASCII-armored public key, validate structure, and extract metadata. * * @param armoredKey - ASCII-armored PGP public key block * @returns Metadata extracted from the imported key * @throws EmailError with GPG_INVALID_KEY if the key is malformed * * @see Requirement 2.2 — Import and validate ASCII-armored PGP public key */ importPublicKey(armoredKey: string): Promise; /** * Export a public key as ASCII armor, validating it first. * * @param publicKeyArmored - ASCII-armored PGP public key to export * @returns The validated ASCII-armored public key string * @throws EmailError with GPG_INVALID_KEY if the key is malformed * * @see Requirement 2.6 — Export GPG public key in ASCII armor format */ exportPublicKey(publicKeyArmored: string): Promise; /** * Validate that a string is a well-formed ASCII-armored PGP public key. * * @param armoredKey - The string to validate * @returns true if the string is a valid ASCII-armored PGP public key * * @see Requirement 2.4 — Reject malformed or empty key imports */ validatePublicKey(armoredKey: string): boolean; /** * Encrypt content for one or more recipients using their GPG public keys. * * @param content - The binary content to encrypt * @param recipientPublicKeysArmored - Array of ASCII-armored PGP public keys for each recipient * @returns The encrypted message in ASCII-armored OpenPGP format * @throws EmailError with GPG_ENCRYPT_FAILED on encryption failure * * @see Requirements 3.1, 3.4 — GPG encryption per OpenPGP standard (RFC 4880) */ encrypt(content: Uint8Array, recipientPublicKeysArmored: string[]): Promise; /** * Decrypt an OpenPGP encrypted message using a private key. * * @param encryptedMessage - The ASCII-armored OpenPGP encrypted message * @param privateKeyArmored - The ASCII-armored PGP private key * @param passphrase - The passphrase to unlock the private key * @returns The decrypted content as a Uint8Array * @throws EmailError with GPG_DECRYPT_FAILED on decryption failure * * @see Requirements 5.1, 5.5 — GPG decryption with private key */ decrypt(encryptedMessage: string, privateKeyArmored: string, passphrase: string): Promise; /** * Create a detached OpenPGP signature over the given content. * * @param content - The binary content to sign * @param privateKeyArmored - ASCII-armored PGP private key * @param passphrase - Passphrase to unlock the private key * @returns The detached signature and signer key ID * @throws EmailError with GPG_VERIFY_FAILED on signing failure * * @see Requirements 4.1, 4.2 — Detached OpenPGP signature production */ sign(content: Uint8Array, privateKeyArmored: string, passphrase: string): Promise; /** * Verify a detached OpenPGP signature against the given content. * * @param content - The binary content that was signed * @param signature - The detached ASCII-armored OpenPGP signature * @param signerPublicKeyArmored - ASCII-armored PGP public key of the expected signer * @returns Verification result with valid status, signerKeyId, and reason * @throws EmailError with GPG_VERIFY_FAILED on verification errors * * @see Requirements 5.2, 5.3, 5.4 — GPG signature verification */ verify(content: Uint8Array, signature: string, signerPublicKeyArmored: string): Promise; /** * Publish a GPG public key to an HKP keyserver. * * @param publicKeyArmored - ASCII-armored PGP public key to publish * @param keyserverUrl - Base URL of the HKP keyserver (e.g. "https://keys.openpgp.org") * @throws EmailError with GPG_KEYSERVER_ERROR on network or server failures * * @see Requirements 2.1 — Publish GPG public key to keyserver */ publishToKeyserver(publicKeyArmored: string, keyserverUrl: string): Promise; /** * Search an HKP keyserver for GPG public keys matching an email address. * * @param email - Email address to search for * @param keyserverUrl - Base URL of the HKP keyserver (e.g. "https://keys.openpgp.org") * @returns Array of ASCII-armored PGP public key blocks found * @throws EmailError with GPG_KEYSERVER_ERROR on network or server failures * * @see Requirements 2.3 — Search keyserver for public keys by email */ searchKeyserver(email: string, keyserverUrl: string): Promise; /** * Extract metadata from an OpenPGP key object. * * @param key - The parsed OpenPGP key * @returns Metadata including keyId, fingerprint, dates, userId, and algorithm */ private extractMetadata; } //# sourceMappingURL=gpgKeyManager.d.ts.map