import { type BinaryLike, type ScryptOptions } from "node:crypto"; export type SymmetricCryptoAlgorithm = "aes-128-cbc" | "aes-128-ccm" | "aes-128-cfb" | "aes-128-cfb1" | "aes-128-cfb8" | "aes-128-ctr" | "aes-128-ecb" | "aes-128-gcm" | "aes-128-ocb" | "aes-128-ofb" | "aes-128-xts" | "aes-192-cbc" | "aes-192-ccm" | "aes-192-cfb" | "aes-192-cfb1" | "aes-192-cfb8" | "aes-192-ctr" | "aes-192-ecb" | "aes-192-gcm" | "aes-192-ocb" | "aes-192-ofb" | "aes-256-cbc" | "aes-256-ccm" | "aes-256-cfb" | "aes-256-cfb1" | "aes-256-cfb8" | "aes-256-ctr" | "aes-256-ecb" | "aes-256-gcm" | "aes-256-ocb" | "aes-256-ofb" | "aes-256-xts" | "aes128" | "aes192" | "aes256" | "aria-128-cbc" | "aria-128-ccm" | "aria-128-cfb" | "aria-128-cfb1" | "aria-128-cfb8" | "aria-128-ctr" | "aria-128-ecb" | "aria-128-gcm" | "aria-128-ofb" | "aria-192-cbc" | "aria-192-ccm" | "aria-192-cfb" | "aria-192-cfb1" | "aria-192-cfb8" | "aria-192-ctr" | "aria-192-ecb" | "aria-192-gcm" | "aria-192-ofb" | "aria-256-cbc" | "aria-256-ccm" | "aria-256-cfb" | "aria-256-cfb1" | "aria-256-cfb8" | "aria-256-ctr" | "aria-256-ecb" | "aria-256-gcm" | "aria-256-ofb" | "aria128" | "aria192" | "aria256" | "bf-cbc" | "bf-cfb" | "bf-ecb" | "camellia-128-cbc" | "camellia-128-cfb" | "camellia-128-cfb1" | "camellia-128-cfb8" | "camellia-128-ctr" | "camellia-128-ecb" | "camellia-128-ofb" | "camellia-192-cbc" | "camellia-192-cfb" | "camellia-192-cfb1" | "camellia-192-cfb8" | "camellia-192-ctr" | "camellia-192-ecb" | "camellia-192-ofb" | "camellia-256-cbc" | "camellia-256-cfb" | "camellia-256-cfb1" | "camellia-256-cfb8" | "camellia-256-ctr" | "camellia-256-ecb" | "camellia-256-ofb" | "camellia128" | "camellia192" | "camellia256" | "des-cbc" | "des-ecb" | "des-ede" | "des-ede-cbc" | "des-ede-cfb" | "des-ede-ecb" | "des-ede-ofb" | "des-ede3" | "des-ede3-cbc" | "des-ede3-cfb" | "des-ede3-cfb1" | "des-ede3-cfb8" | "des-ede3-ecb" | "des-ede3-ofb" | "des3" | "id-aes128-ccm" | "id-aes128-gcm" | "id-aes192-ccm" | "id-aes192-gcm" | "id-aes256-ccm" | "id-aes256-gcm" | "rc2-cbc" | "sm4" | "sm4-cbc" | "sm4-cfb" | "sm4-ctr" | "sm4-ecb" | "sm4-ofb"; /** * Determine whether the cipher algorithm is support with symmetric crypto. * @param {string} algorithm Algorithm of the cipher. * @returns {boolean} Determine result. */ export declare function isSymmetricCryptoAlgorithmSupport(algorithm: string): boolean; /** * Get the list of the symmetric crypto algorithms. * @returns {readonly string[]} */ export declare function getSymmetricCryptoAlgorithms(): readonly string[]; /** * Symmetric cryptor decrypt stream; Only able to create new instance from {@linkcode SymmetricCryptor.decryptStream}. */ export declare class SymmetricCryptorDecryptStream extends TransformStream { #private; get [Symbol.toStringTag](): string; /** * Initialize; Only able to create new instance from {@linkcode SymmetricCryptor.decryptStream}. * @param {symbol} s CPCEP symbol. */ private constructor(); } /** * Symmetric cryptor decrypt stream with authentication tag mode (i.e.: GCM mode, OCB mode); Only able to create new instance from {@linkcode SymmetricCryptor.decryptStream}. */ export declare class SymmetricCryptorDecryptStreamAuthTag extends TransformStream { #private; get [Symbol.toStringTag](): string; /** * Initialize; Only able to create new instance from {@linkcode SymmetricCryptor.decryptStream}. * @param {symbol} s CPCEP symbol. */ private constructor(); } /** * Symmetric cryptor decrypt stream with CCM mode; Only able to create new instance from {@linkcode SymmetricCryptor.decryptStream}. */ export declare class SymmetricCryptorDecryptStreamCCM extends TransformStream { #private; get [Symbol.toStringTag](): string; /** * Initialize; Only able to create new instance from {@linkcode SymmetricCryptor.decryptStream}. * @param {symbol} s CPCEP symbol. */ private constructor(); } /** * Symmetric cryptor encrypt stream; Only able to create new instance from {@linkcode SymmetricCryptor.encryptStream}. */ export declare class SymmetricCryptorEncryptStream extends TransformStream { #private; get [Symbol.toStringTag](): string; /** * Initialize; Only able to create new instance from {@linkcode SymmetricCryptor.encryptStream}. * @param {symbol} s CPCEP symbol. */ private constructor(); } /** * Symmetric cryptor encrypt stream with CCM mode; Only able to create new instance from {@linkcode SymmetricCryptor.encryptStream}. */ export declare class SymmetricCryptorEncryptStreamCCM extends TransformStream { #private; get [Symbol.toStringTag](): string; /** * Initialize; Only able to create new instance from {@linkcode SymmetricCryptor.encryptStream}. * @param {symbol} s CPCEP symbol. */ private constructor(); } export interface SymmetricCryptorOptions { /** * Algorithm of the symmetric crypto. * * Availability of the symmetric crypto algorithms are depend on the runtime, use {@linkcode getSymmetricCryptoAlgorithms} for the support symmetric crypto algorithms list. * @default {"aes-256-cbc"} */ algorithm?: SymmetricCryptoAlgorithm; /** * Salt of the scrypt. */ salt?: BinaryLike; /** * Options of the scrypt. */ scrypt?: ScryptOptions; } /** * Symmetric cryptor, a password based cryptor; Only able to create new instance from {@linkcode createSymmetricCryptor} or {@linkcode createSymmetricCryptorSync}. */ export declare class SymmetricCryptor { #private; get [Symbol.toStringTag](): string; /** * Initialize; Only able to create new instance from {@linkcode createSymmetricCryptor} or {@linkcode createSymmetricCryptorSync}. * @param {symbol} s CPCEP symbol. */ private constructor(); /** * Decrypt the data. * @param {Uint8Array} data Data that need to decrypt. * @returns {Uint8Array} The decrypted data. */ decrypt(data: Uint8Array): Uint8Array; /** * Create new instance of the symmetric cryptor decrypt stream to decrypt the data in the stream. * @returns {SymmetricCryptorDecryptStream | SymmetricCryptorDecryptStreamAuthTag | SymmetricCryptorDecryptStreamCCM} */ decryptStream(): SymmetricCryptorDecryptStream | SymmetricCryptorDecryptStreamAuthTag | SymmetricCryptorDecryptStreamCCM; /** * Encrypt the data. * @param {Uint8Array} data Data that need to encrypt. * @returns {Uint8Array} The encrypted data. */ encrypt(data: Uint8Array): Uint8Array; /** * Create new instance of the symmetric cryptor encrypt stream to encrypt the data in the stream. * @returns {SymmetricCryptorEncryptStream | SymmetricCryptorEncryptStreamCCM} */ encryptStream(): SymmetricCryptorEncryptStream | SymmetricCryptorEncryptStreamCCM; } /** * Create new instance of the {@link SymmetricCryptor symmetric cryptor}, asynchronously. * @param {BinaryLike} key Key. * @param {SymmetricCryptorOptions} [options={}] Options. * @returns {Promise} */ export declare function createSymmetricCryptor(key: BinaryLike, options?: SymmetricCryptorOptions): Promise; /** * Create new instance of the {@link SymmetricCryptor symmetric cryptor}, synchronously. * @param {BinaryLike} key Key. * @param {SymmetricCryptorOptions} [options={}] Options. * @returns {SymmetricCryptor} */ export declare function createSymmetricCryptorSync(key: BinaryLike, options?: SymmetricCryptorOptions): SymmetricCryptor; /** * Chain of the symmetric cryptors, multiple passwords based cryptor. */ export declare class SymmetricCryptorChain { #private; get [Symbol.toStringTag](): string; /** * Initialize. * @param {readonly SymmetricCryptor[]} cryptors Chain of the symmetric cryptors. */ constructor(cryptors: readonly SymmetricCryptor[]); /** * Decrypt the data. * @param {Uint8Array} data Data that need to decrypt. * @returns {Uint8Array} The decrypted data. */ decrypt(data: Uint8Array): Uint8Array; /** * Create new instance of the symmetric cryptor decrypt stream to decrypt the data in the stream. * @returns {TransformStream} */ decryptStream(): TransformStream; /** * Encrypt the data. * @param {Uint8Array} data Data that need to encrypt. * @returns {Uint8Array} The encrypted data. */ encrypt(data: Uint8Array): Uint8Array; /** * Create new instance of the symmetric cryptor encrypt stream to encrypt the data in the stream. * @returns {TransformStream} */ encryptStream(): TransformStream; }