import * as pkcs11 from "pkcs11js"; import * as core from "./core"; import { IParams } from "./keys/params"; import { MechanismEnum } from "./mech_enum"; import type { KeyGenMechanism } from "./objects"; /** * Structure that describes algorithm */ export interface IAlgorithm { /** * The algorithm name */ name: keyof typeof MechanismEnum | string | number; /** * The algorithm parameters */ params: Buffer | IParams | null; } export type MechanismType = MechanismEnum | KeyGenMechanism | IAlgorithm | keyof typeof MechanismEnum | string; /** * Bit flags specifying mechanism capabilities */ export declare enum MechanismFlag { /** * `true` if the mechanism is performed by the device; `false` if the mechanism is performed in software */ HW, /** * `true` if the mechanism can be used with encrypt function */ ENCRYPT, /** * `true` if the mechanism can be used with decrypt function */ DECRYPT, /** * `true` if the mechanism can be used with digest function */ DIGEST, /** * `true` if the mechanism can be used with sign function */ SIGN, /** * `true` if the mechanism can be used with sign recover function */ SIGN_RECOVER, /** * `true` if the mechanism can be used with verify function */ VERIFY, /** * `true` if the mechanism can be used with verify recover function */ VERIFY_RECOVER, /** * `true` if the mechanism can be used with geberate function */ GENERATE, /** * `true` if the mechanism can be used with generate key pair function */ GENERATE_KEY_PAIR, /** * `true` if the mechanism can be used with wrap function */ WRAP, /** * `true` if the mechanism can be used with unwrap function */ UNWRAP, /** * `true` if the mechanism can be used with derive function */ DERIVE } /** * Represents a PKCS#11 mechanism */ export declare class Mechanism extends core.HandleObject { /** * Returns string name from {@link MechanismEnum}. For unregistered mechanism returns string `unknown`. * To register a custom mechanism in {@link MechanismEnum} use {@link Mechanism.vendor} static function */ get name(): string; /** * Creates PKCS#11 mechanism structure from {@link MechanismType} * @param algorithm Mechanism type */ static create(algorithm: MechanismType): pkcs11.Mechanism; /** * Adds a vendor mechanisms to {@link MechanismEnum} from the specified file * @param jsonFile Path to JSON file with vendor mechanisms */ static vendor(jsonFile: string): void; /** * Adds a vendor mechanism to {@link MechanismEnum} * @param name Mechanism name * @param value Mechanism value */ static vendor(name: string, value: number): void; /** * The mechanism type number */ type: MechanismEnum; /** * The minimum size of the key for the mechanism * * _whether this is measured in bits or in bytes is mechanism-dependent_ */ minKeySize: number; /** * The maximum size of the key for the mechanism * * _whether this is measured in bits or in bytes is mechanism-dependent_ */ maxKeySize: number; /** * Bit flag specifying mechanism capabilities */ flags: number; /** * The ID of the token’s slot */ protected slotHandle: core.Handle; /** * Initializes the mechanism structure * @param type The type of mechanism * @param handle The ID of mechanism * @param slotHandle The ID of the token’s slot * @param lib PKCS#11 module */ constructor(type: number, handle: pkcs11.Handle, slotHandle: core.Handle, lib: pkcs11.PKCS11); /** * Retrieves information about mechanism and fills object fields */ protected getInfo(): void; } /** * Represents a collection of PKCS#11 mechanisms */ export declare class MechanismCollection extends core.Collection { /** * The ID of token's slot */ protected slotHandle: core.Handle; /** * Initialize a new instance of mechanism collection * @param items The list of mechanism types * @param slotHandle The ID of token's slot * @param lib PKCS#11 module */ constructor(items: number[], slotHandle: core.Handle, lib: pkcs11.PKCS11); /** * Returns item from collection by index * @param {number} index index of an element in the collection `[0..n]` */ items(index: number): Mechanism; /** * Tries to get Mechanism. Returns `null` if it's impossible to get mechanism * @param index index of an element in the collection `[0..n]` */ tryGetItem(index: number): Mechanism | null; }