import { A as AbstractSymmetricCrypt } from '../abstract-symmetric-crypt-C3ASlnxn.js';

declare class OpenSSL extends AbstractSymmetricCrypt {
    static readonly METHOD: number;
    protected method: string;
    protected algo: string;
    protected options: number;
    protected ivLengths: {
        [key: string]: number;
    };
    constructor(method?: string, algo?: string);
    key(password: string, salt?: string): Buffer;
    protected getIv(): string;
    protected getIvLength(): number;
    encryptWithKey(data: string, key: Buffer): string;
    decryptWithKey(payload: Buffer, key: Buffer): Buffer;
    protected decode(input: Buffer, method: string, key: Buffer, iv: Buffer, tag?: Buffer): Buffer;
}

/**
 * OpenSSL-based symmetric cryptography
 *
 */
declare class OpenSSLAEAD extends OpenSSL {
    static readonly METHOD: number;
    protected tagLength: number;
    constructor();
    /**
     * Decrypt using key
     *
     * @param string payload       Content to decrypt
     * @param string key           Decryption key
     * @param string aad           Additional authentication data
     * @return string               Decrypted payload
     * @throws DecryptError
     */
    decryptWithKey(payload: Buffer, key: Buffer, aad?: string): Buffer;
}

/**
 * Sodium-based symmetric cryptography
 */
declare class Secretbox extends AbstractSymmetricCrypt {
    static readonly METHOD = 257;
    /**
     * Generates secretbox key from password and salt
     */
    key(password: string, salt?: string | null): Buffer;
    /**
     * Encrypt using key
     * @param string data	Content to encrypt
     * @param string key	Encryption key
     * @return string		Encrypted payload
     * @throws InternalError
     */
    encryptWithKey(data: string, key: Buffer): string;
    /**
     * Decrypt using key
     * @param string payload	Content to decrypt
     * @param string key       Decryption key
     * @return string           Decrypted payload
     * @throws DecryptError
     * @throws InternalError
     */
    decryptWithKey(payload: Buffer, key: Buffer): Buffer;
}

type CryptType = "OpenSSL" | "OpenSSLAEAD" | "Secretbox";
declare class CryptFactory {
    /**
     * Returns Crypt instance
     * @param string $name
     * @return OpenSSL|Secretbox
     */
    static create(name: CryptType | string | Buffer): OpenSSL | OpenSSLAEAD | Secretbox;
    /**
     * Returns Crypt instance based on payload header
     * @param string $payload
     * @return OpenSSL|Secretbox
     */
    static createFromPayload(payload: Buffer): OpenSSL | OpenSSLAEAD | Secretbox;
    /**
     * Returns Crypt instance based on algorithm/library combination ID
     * @param int $code
     * @return object
     */
    static createFromId(code: number): OpenSSL | OpenSSLAEAD | Secretbox;
}

declare class AbstractAsymmetricCrypt {
    protected static LABELS: Record<number, string | null>;
    /**
     * Compacts PEM key for storage
     * @param {string} key PEM formatted key
     * @returns {string} compacted key data
     */
    protected static compactPem(key: string): Buffer;
    /**
     * Expands compacted data to PEM format
     * @param {string} data compacted key data
     * @param {number} lineLength line length for PEM encoding (default 64)
     * @returns {string} PEM formatted key
     */
    static expandPem(data: string, lineLength?: number): string;
    protected static parsePem(key: string): {
        label: string;
        data: Buffer;
    };
    /**
     * Builds PEM format from key data
     * @param {string} data key data
     * @param {string} label key label
     * @param {number} lineLength line length for PEM encoding (default 64)
     * @returns {string} PEM formatted key
     */
    protected static encodePem(data: string, label: string | null, lineLength?: number): string;
}

declare class AsymmetricOpenSSL extends AbstractAsymmetricCrypt {
    protected algo: string;
    protected options: number;
    constructor(algo?: string);
    /**
     * Verify signature
     * @param data The string of data used to generate the signature previously
     * @param signature A raw binary string
     * @param publicKey OpenSSL asymmetric key
     * @return boolean
     * @throws VerifyError
     */
    verify(data: string, signature: string, publicKey: string): boolean;
    /**
     * Generate signature
     * @param data The string of data you wish to sign
     * @param privateKey OpenSSL asymmetric key
     * @return string Computed signature
     */
    sign(data: string, privateKey: string): Buffer;
    /**
     * Create EC keypair
     * @param curveName Curve name
     * @return Compacted private key
     */
    static createEcPrivateKey(curveName?: string): Buffer;
    /**
     * Retrieve public key in PEM format from compacted private key
     * @param data Compacted key
     * @return Public key in PEM format
     */
    static getPublicKeyPem(data: string): string;
}

interface CryptErrorInterface {
}

declare class DecryptError extends Error implements CryptErrorInterface {
}

declare class EncryptError extends Error implements CryptErrorInterface {
}

declare class KeyError extends Error implements CryptErrorInterface {
}

declare class CryptParseError extends Error implements CryptErrorInterface {
}

export { AbstractAsymmetricCrypt, AbstractSymmetricCrypt, AsymmetricOpenSSL, type CryptErrorInterface, CryptFactory, CryptParseError, type CryptType, DecryptError, EncryptError, KeyError, OpenSSL, OpenSSLAEAD, Secretbox };
