import * as pkcs11 from "pkcs11js"; import * as core from "../core"; import { MechanismType } from "../mech"; import { Session } from "../session"; import { Key } from '../objects'; import * as types from '../types'; /** * Represents encryption operation * @example * ```js * // Encrypt multi-part data * * const alg = { * name: "AES_CBC_PAD", * params: session.generateRandom(16), // IV * }; * const cipher = session.createCipher(alg, secretKey); * let enc = cipher.update("Some message"); * enc = Buffer.concat([enc, cipher.final()]); * console.log(enc.toString("hex")); // 351a253df0d5bc9018afd7eed825ae9a * ``` * @example * ```js * // Encrypt single-part data * * const alg = { * name: "AES_CBC_PAD", * params: session.generateRandom(16), // IV * }; * const enc = session.createCipher(alg, secretKey) * .once("Some data", Buffer.alloc(1024)); * console.log(enc.toString("hex")); // 0a3335e0ec8b0265d6ca70d789649b94 * ``` */ export declare class Cipher extends core.BaseObject { /** * Session */ session: Session; /** * Creates a new instance of {@link Cipher} * @param session Session * @param alg The encryption mechanism * @param key The encrypting key * @param lib PKCS#11 library */ constructor(session: Session, alg: MechanismType, key: Key, lib: pkcs11.PKCS11); /** * Continues a multiple-part encryption operation * @param data Data to be encrypted * @returns Encrypted block */ update(data: types.CryptoData): Buffer; /** * Finishes a multiple-part encryption operation * @returns The final encrypted block */ final(): Buffer; /** * Encrypts single-part data * @param data Data to be encrypted * @param enc Allocated buffer for encrypted data */ once(data: types.CryptoData, enc: Buffer): Buffer; /** * Encrypts single-part data * @param data Data to be encrypted * @param enc Allocated buffer for encrypted data * @param cb Async callback function with encrypted data */ once(data: types.CryptoData, enc: Buffer, cb: (error: Error, data: Buffer) => void): void; /** * Initializes an encryption operation * @param alg The encryption mechanism * @param key The encryption key */ protected init(alg: MechanismType, key: Key): void; }