/** * PEM Format Utilities * * Utilities for working with PEM-formatted cryptographic keys. * Issue #1374 */ /** * Check if a string is in valid PEM format * * PEM format requires: * - A BEGIN header with a type (e.g., "-----BEGIN PUBLIC KEY-----") * - Base64-encoded content * - An END footer with matching type (e.g., "-----END PUBLIC KEY-----") * * @param input - String to check * @returns true if the string is valid PEM format, false otherwise */ export declare function isPemFormat(input: string): boolean; /** * Extract the type from a PEM-formatted string * * For example, extracts "PUBLIC KEY" from: * -----BEGIN PUBLIC KEY----- * ... * -----END PUBLIC KEY----- * * @param pem - PEM-formatted string * @returns The type string (e.g., "PUBLIC KEY", "PRIVATE KEY"), or null if not valid PEM */ export declare function extractPemType(pem: string): string | null; /** * Convert PEM-formatted string to raw bytes * * Extracts the base64 content from between the PEM headers and decodes it. * * @param pem - PEM-formatted string * @returns Raw bytes as Uint8Array * @throws Error if the input is not valid PEM format */ export declare function pemToBytes(pem: string): Uint8Array; /** * Convert raw bytes to PEM format * * Encodes the bytes as base64 and wraps with PEM headers. * Base64 content is wrapped at 64 characters per line per RFC 7468. * * @param bytes - Raw bytes to encode * @param type - PEM type (e.g., "PUBLIC KEY", "PRIVATE KEY") * @returns PEM-formatted string */ export declare function bytesToPem(bytes: Uint8Array, type: string): string; /** * Format a key fingerprint for display * * Converts to uppercase and groups into 4-character blocks separated by spaces. * For example: "abcd1234efgh5678" becomes "ABCD 1234 EFGH 5678" * * @param fingerprint - Raw fingerprint string (typically 40 hex characters) * @returns Formatted fingerprint string */ export declare function formatFingerprint(fingerprint: string): string;