Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PKCS11

A Structure which contains a Cryptoki version and each function in the Cryptoki API

Hierarchy

  • PKCS11

Index

Constructors

  • new PKCS11(libPath?: string): PKCS11
  • Creates an instance of PKCS11

    Parameters

    • Optional libPath: string

      The path to PKCS#11 library

    Returns PKCS11

Properties

libPath: string

Library path

Methods

  • C_CloseAllSessions(slot: Buffer): void
  • Closes all sessions with a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • slot: Buffer

      The token's slot

    Returns void

  • C_CloseSession(session: Buffer): void
  • Closes a session between an application and a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    Returns void

  • C_CopyObject(session: Buffer, object: Buffer, template: Template): Buffer
  • Copies an object, creating a new object for the copy

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    • template: Template

      Template for new object

    Returns Buffer

    A handle of copy

  • C_CreateObject(session: Buffer, template: Template): Buffer
  • Creates a new object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • template: Template

      The object's template

    Returns Buffer

    A new object's handle

  • C_Decrypt(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_Decrypt(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Decrypts encrypted data in a single part

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data with decrypted message

  • Decrypts encrypted data in a single part

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_DecryptAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Decrypts encrypted data in a single part

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data with decrypted message

  • C_DecryptDigestUpdate(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_DecryptDigestUpdate(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Continues a multiple-part decryption and digest operation (decrypting and digesting)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be decrypted and digested

    • outData: Buffer

      Digested data

    Returns Buffer

    Sliced digested data

  • Continues a multiple-part decryption and digest operation (decrypting and digesting)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be decrypted and digested

    • outData: Buffer

      Digested data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced digested data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_DecryptDigestUpdateAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Continues a multiple-part decryption and digest operation (decrypting and digesting)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be decrypted and digested

    • outData: Buffer

      Digested data

    Returns Promise<Buffer>

    Sliced digested data

  • C_DecryptFinal(session: Buffer, outData: Buffer): Buffer
  • C_DecryptFinal(session: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Finishes a multiple-part decryption operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last part of output data

    Returns Buffer

    Sliced output data with decrypted final block

  • Finishes a multiple-part decryption operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last part of output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data with decrypted final block

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_DecryptFinalAsync(session: Buffer, outData: Buffer): Promise<Buffer>
  • Finishes a multiple-part decryption operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last part of output data

    Returns Promise<Buffer>

    Sliced output data with decrypted final block

  • C_DecryptInit(session: Buffer, mechanism: Mechanism, key: Buffer): void
  • Initializes a decryption operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The decryption mechanism

    • key: Buffer

      Handle of decryption key

    Returns void

  • C_DecryptUpdate(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • continues a multiple-part decryption operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data with decrypted block

  • C_DecryptVerifyUpdate(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_DecryptVerifyUpdate(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Continues a multiple-part decryption and verification operation (decrypting and verifying)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be decrypted and verified

    • outData: Buffer

      Verified data

    Returns Buffer

    Sliced verified data

  • Continues a multiple-part decryption and verification operation (decrypting and verifying)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be decrypted and verified

    • outData: Buffer

      Verified data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced verified data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_DecryptVerifyUpdateAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Continues a multiple-part decryption and verification operation (decrypting and verifying)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be decrypted and verified

    • outData: Buffer

      Verified data

    Returns Promise<Buffer>

    Sliced verified data

  • C_DeriveKey(session: Buffer, mechanism: Mechanism, key: Buffer, template: Template): Buffer
  • C_DeriveKey(session: Buffer, mechanism: Mechanism, key: Buffer, template: Template, cb: (error: Error, hKey: Buffer) => void): void
  • Derives a key from a base key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The key derivation mechanism

    • key: Buffer

      The base key

    • template: Template

      The template for the new key

    Returns Buffer

    The derived key handle

  • Derives a key from a base key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The key derivation mechanism

    • key: Buffer

      The base key

    • template: Template

      The template for the new key

    • cb: (error: Error, hKey: Buffer) => void

      Async callback with the derived key handle

        • (error: Error, hKey: Buffer): void
        • Parameters

          • error: Error
          • hKey: Buffer

          Returns void

    Returns void

  • C_DeriveKeyAsync(session: Buffer, mechanism: Mechanism, key: Buffer, template: Template): Promise<Buffer>
  • Derives a key from a base key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The key derivation mechanism

    • key: Buffer

      The base key

    • template: Template

      The template for the new key

    Returns Promise<Buffer>

    The derived key handle

  • C_DestroyObject(session: Buffer, object: Buffer): void
  • Destroys an object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    Returns void

  • C_Digest(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_Digest(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Digests data in a single part

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

  • Digests data in a single part

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_DigestAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Digests data in a single part

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data

  • C_DigestEncryptUpdate(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_DigestEncryptUpdate(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Continues a multiple-part digest and encryption operation (digesting and encrypting)

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be digested and encrypted

    • outData: Buffer

      Encrypted data

    Returns Buffer

    Sliced encrypted data

  • Continues a multiple-part digest and encryption operation (digesting and encrypting)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be digested and encrypted

    • outData: Buffer

      Encrypted data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced encrypted data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_DigestEncryptUpdateAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Continues a multiple-part digest and encryption operation (digesting and encrypting)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be digested and encrypted

    • outData: Buffer

      Encrypted data

    Returns Promise<Buffer>

    Sliced encrypted data

  • C_DigestFinal(session: Buffer, outData: Buffer): Buffer
  • C_DigestFinal(session: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Finishes a multiple-part message-digesting operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

  • Finishes a multiple-part message-digesting operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_DigestFinalAsync(session: Buffer, outData: Buffer): Promise<Buffer>
  • Finishes a multiple-part message-digesting operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data

  • C_DigestInit(session: Buffer, mechanism: Mechanism): void
  • Initializes a message-digesting operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Digesting mechanism

    Returns void

  • C_DigestKey(session: Buffer, key: Buffer): void
  • Continues a multiple-part message-digesting operation by digesting the value of a secret key

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • key: Buffer

      The handle of the secret key to be digested

    Returns void

  • C_DigestUpdate(session: Buffer, inData: Buffer): void
  • continues a multiple-part message-digesting operation operation, by digesting the value of a secret key as part of the data already digested

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    Returns void

  • C_Encrypt(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_Encrypt(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Encrypts single-part data

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data with encrypted message

  • Encrypts single-part data

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_EncryptAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Encrypts single-part data

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data with encrypted message

  • C_EncryptFinal(session: Buffer, outData: Buffer): Buffer
  • C_EncryptFinal(session: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Finishes a multiple-part encryption operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last output data

    Returns Buffer

    Sliced output data

  • Finishes a multiple-part encryption operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_EncryptFinalAsync(session: Buffer, outData: Buffer): Promise<Buffer>
  • Finishes a multiple-part encryption operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last output data

    Returns Promise<Buffer>

    Sliced output data

  • C_EncryptInit(session: Buffer, mechanism: Mechanism, key: Buffer): void
  • Initializes an encryption operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The encryption mechanism

    • key: Buffer

      Handle of encryption key

    Returns void

  • C_EncryptUpdate(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • Continues a multiple-part encryption operation

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

  • C_Finalize(): void
  • Indicates that an application is done with the Cryptoki library

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Returns void

  • C_FindObjects(session: Buffer, maxObjectCount: number): Buffer[]
  • C_FindObjects(session: Buffer): null | Buffer
  • Continues a search for token and session objects that match a template, obtaining additional object handles

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • maxObjectCount: number

      The maximum number of object handles to be returned. Default value is 1.

    Returns Buffer[]

    List of handles

  • Continues a search for token and session objects that match a template, obtaining additional object handles

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    Returns null | Buffer

    Object's handle. If object is not found the result is null

  • C_FindObjectsFinal(session: Buffer): void
  • Finishes a search for token and session objects

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    Returns void

  • C_FindObjectsInit(session: Buffer, template: Template): void
  • Initializes a search for token and session objects that match a template

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • template: Template

      Attribute values to match

    Returns void

  • C_GenerateKey(session: Buffer, mechanism: Mechanism, template: Template): Buffer
  • C_GenerateKey(session: Buffer, mechanism: Mechanism, template: Template, cb: (error: Error, key: Buffer) => void): void
  • Generates a secret key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Key generation mechanism

    • template: Template

      Template for new key

    Returns Buffer

    The handle of the new key

  • Generates a secret key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Key generation mechanism

    • template: Template

      Template for new key

    • cb: (error: Error, key: Buffer) => void

      Async callback with handle of new key

        • (error: Error, key: Buffer): void
        • Parameters

          • error: Error
          • key: Buffer

          Returns void

    Returns void

  • C_GenerateKeyAsync(session: Buffer, mechanism: Mechanism, template: Template): Promise<Buffer>
  • Generates a secret key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The key generation mechanism

    • template: Template

      The template for the new key

    Returns Promise<Buffer>

    The handle of the new key

  • Generates a public-key/private-key pair, creating new key objects

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Key generation mechanism

    • publicTmpl: Template

      Template for public key

    • privateTmpl: Template

      Template for private key

    Returns KeyPair

    The pair of handles for private and public keys

  • Generates a public-key/private-key pair, creating new key objects

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Key generation mechanism

    • publicTmpl: Template

      Template for public key

    • privateTmpl: Template

      Template for private key

    • cb: (error: Error, keys: KeyPair) => void

      Async callback with handles for private and public keys

        • (error: Error, keys: KeyPair): void
        • Parameters

          Returns void

    Returns void

  • Generates a public-key/private-key pair, creating new key objects

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Key generation mechanism

    • publicTmpl: Template

      Template for public key

    • privateTmpl: Template

      Template for private key

    Returns Promise<KeyPair>

    Handles for private and public keys

  • C_GenerateRandom(session: Buffer, buf: Buffer): Buffer
  • Generates random data

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • buf: Buffer

      Init buffer

    Returns Buffer

    The random data

  • Obtains the value of one or more object attributes

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    • template: Template

      Specifies attrs; gets values

    Returns TemplateResult

    List of Attributes with values

  • Obtains information about a particular mechanism possibly supported by a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • slot: Buffer

      ID of the token's slot

    • mech: number

      Type of mechanism

    Returns MechanismInfo

    Information about mechanism

  • C_GetMechanismList(slot: Buffer): number[]
  • Obtains a list of mechanism types supported by a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • slot: Buffer

      ID of token's slot

    Returns number[]

    A list of mechanism types

  • C_GetObjectSize(session: Buffer, object: Buffer): number
  • Gets the size of an object in bytes

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    Returns number

    Size of an object in bytes

  • Obtains information about the session

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    Returns SessionInfo

    Receives session info

  • Obtains information about a particular slot in the system

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • slot: Buffer

      The ID of the slot

    Returns SlotInfo

    Information about a slot

  • C_GetSlotList(tokenPresent?: boolean): Buffer[]
  • Obtains a list of slots in the system

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • Optional tokenPresent: boolean

    Returns Buffer[]

    Array of slot IDs

  • Obtains information about a particular token in the system

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • slot: Buffer

      ID of the token's slot

    Returns TokenInfo

    Information about a token

  • C_InitPIN(session: Buffer, pin?: string): void
  • Initializes the normal user's PIN

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • Optional pin: string

      The normal user's PIN

    Returns void

  • C_InitToken(slot: Buffer, pin?: string, label?: string): string
  • Initializes a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • slot: Buffer

      ID of the token's slot

    • Optional pin: string
    • Optional label: string

    Returns string

    32-byte token label (blank padded)

  • Initializes the Cryptoki library

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • Optional options: InitializationOptions

      Initialization options Supports implementation of standard CK_C_INITIALIZE_ARGS and extended NSS format.

      • if options is null or empty, it calls native C_Initialize with NULL
      • if options doesn't have libraryParameters, it uses CK_C_INITIALIZE_ARGS structure
      • if options has libraryParameters, it uses extended NSS structure

    Returns void

  • C_Login(session: Buffer, userType: number, pin?: string): void
  • Logs a user into a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • userType: number

      The user type

    • Optional pin: string

    Returns void

  • C_Logout(session: Buffer): void
  • Logs a user out from a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    Returns void

  • C_OpenSession(slot: Buffer, flags: number): Buffer
  • Opens a session between an application and a token

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • slot: Buffer

      The slot's ID

    • flags: number

      From CK_SESSION_INFO

    Returns Buffer

    Session handle

  • C_SeedRandom(session: Buffer, buf: Buffer): void
  • Mixes additional seed material into the token's random number generator

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • buf: Buffer

      The seed material

    Returns void

  • C_SetAttributeValue(session: Buffer, object: Buffer, template: Template): void
  • Modifies the value of one or more object attributes

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    • template: Template

      Specifies attrs and values

    Returns void

  • C_SetPIN(session: Buffer, oldPin: string, newPin: string): void
  • Modifies the PIN of the user who is logged in

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • oldPin: string

      The old PIN

    • newPin: string

      The new PIN

    Returns void

  • C_Sign(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_Sign(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Signs (encrypts with private key) data in a single part, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

  • Signs (encrypts with private key) data in a single part, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_SignAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Signs (encrypts with private key) data in a single part, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data

  • C_SignEncryptUpdate(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • C_SignEncryptUpdate(session: Buffer, inData: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Continues a multiple-part signing and encryption operation (signing and encrypting)

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be signed and encrypted

    • outData: Buffer

      Encrypted data

    Returns Buffer

    Sliced encrypted data

  • Continues a multiple-part signing and encryption operation (signing and encrypting)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be signed and encrypted

    • outData: Buffer

      Encrypted data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced encrypted data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_SignEncryptUpdateAsync(session: Buffer, inData: Buffer, outData: Buffer): Promise<Buffer>
  • Continues a multiple-part signing and encryption operation (signing and encrypting)

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Data to be signed and encrypted

    • outData: Buffer

      Encrypted data

    Returns Promise<Buffer>

    Sliced encrypted data

  • C_SignFinal(session: Buffer, outData: Buffer): Buffer
  • C_SignFinal(session: Buffer, outData: Buffer, cb: (error: Error, data: Buffer) => void): void
  • Finishes a multiple-part signature operation, returning the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

  • Finishes a multiple-part signature operation, returning the signature

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    • cb: (error: Error, data: Buffer) => void

      Async callback with sliced output data

        • (error: Error, data: Buffer): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • C_SignFinalAsync(session: Buffer, outData: Buffer): Promise<Buffer>
  • Finishes a multiple-part signature operation, returning the signature

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data

  • C_SignInit(session: Buffer, mechanism: Mechanism, key: Buffer): void
  • initializes a signature (private key encryption) operation, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Signature mechanism

    • key: Buffer

      Handle of signature key

    Returns void

  • C_SignRecover(session: Buffer, inData: Buffer, outData: Buffer): Buffer
  • Signs data in a single operation, where the data can be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer
    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

  • C_SignRecoverInit(session: Buffer, mechanism: Mechanism, key: Buffer): void
  • Initializes a signature operation, where the data can be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The structure that specifies the signature mechanism

    • key: Buffer

      The handle of the signature key

    Returns void

  • C_SignUpdate(session: Buffer, inData: Buffer): void
  • Continues a multiple-part signature operation, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    Returns void

  • C_UnwrapKey(session: Buffer, mechanism: Mechanism, unwrappingKey: Buffer, wrappedKey: Buffer, template: Template): Buffer
  • C_UnwrapKey(session: Buffer, mechanism: Mechanism, unwrappingKey: Buffer, wrappedKey: Buffer, template: Template, cb: (error: Error, key: Buffer) => void): void
  • Unwraps (decrypts) a wrapped key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Unwrapping mechanism

    • unwrappingKey: Buffer

      Unwrapping key

    • wrappedKey: Buffer

      Wrapped key

    • template: Template

      New key template

    Returns Buffer

    The unwrapped key handle

  • Unwraps (decrypts) a wrapped key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Unwrapping mechanism

    • unwrappingKey: Buffer

      Unwrapping key

    • wrappedKey: Buffer

      Wrapped key

    • template: Template

      New key template

    • cb: (error: Error, key: Buffer) => void

      Async callback with new key handle

        • (error: Error, key: Buffer): void
        • Parameters

          • error: Error
          • key: Buffer

          Returns void

    Returns void

  • C_UnwrapKeyAsync(session: Buffer, mechanism: Mechanism, unwrappingKey: Buffer, wrappedKey: Buffer, template: Template): Promise<Buffer>
  • Unwraps (decrypts) a wrapped key, creating a new key object

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Unwrapping mechanism

    • unwrappingKey: Buffer

      Unwrapping key

    • wrappedKey: Buffer

      Wrapped key

    • template: Template

      New key template

    Returns Promise<Buffer>

    The unwrapped key handle

  • C_Verify(session: Buffer, inData: Buffer, signature: Buffer): boolean
  • C_Verify(session: Buffer, inData: Buffer, signature: Buffer, cb: (error: Error, verify: boolean) => void): void
  • Verifies a signature in a single-part operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • signature: Buffer

      Signature to verify

    Returns boolean

    Verification result

  • Verifies a signature in a single-part operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • signature: Buffer

      Signature to verify

    • cb: (error: Error, verify: boolean) => void

      Async callback with verification result

        • (error: Error, verify: boolean): void
        • Parameters

          • error: Error
          • verify: boolean

          Returns void

    Returns void

  • C_VerifyAsync(session: Buffer, inData: Buffer, signature: Buffer): Promise<boolean>
  • Verifies a signature in a single-part operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • signature: Buffer

      Signature to verify

    Returns Promise<boolean>

    Verification result

  • C_VerifyFinal(session: Buffer, signature: Buffer): boolean
  • C_VerifyFinal(session: Buffer, signature: Buffer, cb: (error: Error, verify: boolean) => void): void
  • Finishes a multiple-part verification operation, checking the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • signature: Buffer

      Signature to verify

    Returns boolean

  • Finishes a multiple-part verification operation, checking the signature

    Parameters

    • session: Buffer

      The session's handle

    • signature: Buffer

      Signature to verify

    • cb: (error: Error, verify: boolean) => void

      Async callback with verification result

        • (error: Error, verify: boolean): void
        • Parameters

          • error: Error
          • verify: boolean

          Returns void

    Returns void

  • C_VerifyFinalAsync(session: Buffer, signature: Buffer): Promise<boolean>
  • Finishes a multiple-part verification operation, checking the signature

    Parameters

    • session: Buffer

      The session's handle

    • signature: Buffer

      Signature to verify

    Returns Promise<boolean>

    Verification result

  • C_VerifyInit(session: Buffer, mechanism: Mechanism, key: Buffer): void
  • initializes a verification operation, where the signature is an appendix to the data, and plaintext cannot cannot be recovered from the signature (e.g. DSA)

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Verification mechanism

    • key: Buffer

      Verification key

    Returns void

  • C_VerifyRecover(session: Buffer, signature: Buffer, outData: Buffer): Buffer
  • Verifies a signature in a single-part operation, where the data is recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • signature: Buffer

      The signature to verify

    • outData: Buffer

      The allocated buffer for recovered data

    Returns Buffer

    The sliced output data with recovered data

  • C_VerifyRecoverInit(session: Buffer, mechanism: Mechanism, key: Buffer): void
  • Initializes a signature verification operation, where the data is recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The structure that specifies the verification mechanism

    • key: Buffer

      The handle of the verification key

    Returns void

  • C_VerifyUpdate(session: Buffer, inData: Buffer): void
  • Continues a multiple-part verification operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    Returns void

  • C_WaitForSlotEvent(flags: number): null | Buffer
  • Waits for a slot event, such as token insertion or token removal, to occur.

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • flags: number

      Determines whether or not the C_WaitForSlotEvent call blocks (i.e., waits for a slot event to occur); use CKF_DONT_BLOCK for no blocking call

    Returns null | Buffer

    The slot ID where the event occurred, if successful; null otherwise

  • C_WrapKey(session: Buffer, mechanism: Mechanism, wrappingKey: Buffer, key: Buffer, wrappedKey: Buffer): Buffer
  • C_WrapKey(session: Buffer, mechanism: Mechanism, wrappingKey: Buffer, key: Buffer, wrappedKey: Buffer, cb: (error: Error, wrappedKey: Buffer) => void): void
  • Wraps (i.e., encrypts) a key

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Wrapping mechanism

    • wrappingKey: Buffer

      Wrapping key

    • key: Buffer

      Key to be wrapped

    • wrappedKey: Buffer

      Init buffer for wrapped key

    Returns Buffer

    Sliced wrapped key

  • Wraps (i.e., encrypts) a key

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Wrapping mechanism

    • wrappingKey: Buffer

      Wrapping key

    • key: Buffer

      Key to be wrapped

    • wrappedKey: Buffer

      Init buffer for wrapped key

    • cb: (error: Error, wrappedKey: Buffer) => void

      Async callback with sliced wrapped key

        • (error: Error, wrappedKey: Buffer): void
        • Parameters

          • error: Error
          • wrappedKey: Buffer

          Returns void

    Returns void

  • C_WrapKeyAsync(session: Buffer, mechanism: Mechanism, wrappingKey: Buffer, key: Buffer, wrappedKey: Buffer): Promise<Buffer>
  • Wraps (i.e., encrypts) a key

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Wrapping mechanism

    • wrappingKey: Buffer

      Wrapping key

    • key: Buffer

      Key to be wrapped

    • wrappedKey: Buffer

      Init buffer for wrapped key

    Returns Promise<Buffer>

    Sliced wrapped key

  • close(): void
  • load(path: string): void
  • Loads dynamic library with PKCS#11 interface

    throws

    NativeError if native error occurs

    throws

    Pkcs11Error if Cryptoki error occurs

    Parameters

    • path: string

      The path to PKCS#11 library

    Returns void

Generated using TypeDoc