Class PKCS11

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

Constructors

  • Creates an instance of PKCS11

    Parameters

    • OptionallibPath: string

      The path to PKCS#11 library

    Returns PKCS11

Properties

libPath: string

Library path

Methods

  • Closes all sessions with a token

    Parameters

    • slot: Buffer

      The token's slot

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Closes a session between an application and a token

    Parameters

    • session: Buffer

      The session's handle

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Copies an object, creating a new object for the copy

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Creates a new object

    Parameters

    • session: Buffer

      The session's handle

    • template: Template

      The object's template

    Returns Buffer

    A new object's handle

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Decrypts encrypted data in a single part

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data with decrypted message

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Decrypts encrypted data in a single part

    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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Decrypts encrypted data in a single part

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data with decrypted message

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns 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 Promise<Buffer>

    Sliced digested data

  • Finishes a multiple-part decryption operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last part of output data

    Returns Buffer

    Sliced output data with decrypted final block

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • 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

  • Initializes a decryption operation

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The decryption mechanism

    • key: Buffer

      Handle of decryption key

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • continues a multiple-part decryption operation

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data with decrypted block

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns 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 Promise<Buffer>

    Sliced verified data

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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, hKey): void
        • Parameters

          • error: Error
          • hKey: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Destroys an object

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Digests data in a single part

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Digests data in a single part

    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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Digests data in a single part

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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 Buffer

    Sliced encrypted data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • 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

  • Finishes a multiple-part message-digesting operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • Finishes a multiple-part message-digesting operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data

  • Initializes a message-digesting operation

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Digesting mechanism

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Continues a multiple-part message-digesting operation by digesting the value of a secret key

    Parameters

    • session: Buffer

      The session's handle

    • key: Buffer

      The handle of the secret key to be digested

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • continues a multiple-part message-digesting operation operation, by digesting the value of a secret key as part of the data already digested

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Encrypts single-part data

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data with encrypted message

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Encrypts single-part data

    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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Encrypts single-part data

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data with encrypted message

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Finishes a multiple-part encryption operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last output data

    Returns Buffer

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • Finishes a multiple-part encryption operation

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Last output data

    Returns Promise<Buffer>

    Sliced output data

  • Initializes an encryption operation

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      The encryption mechanism

    • key: Buffer

      Handle of encryption key

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Continues a multiple-part encryption operation

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Indicates that an application is done with the Cryptoki library

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    Parameters

    • session: Buffer

      The session's handle

    Returns null | Buffer

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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Finishes a search for token and session objects

    Parameters

    • session: Buffer

      The session's handle

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Initializes a search for token and session objects that match a template

    Parameters

    • session: Buffer

      The session's handle

    • template: Template

      Attribute values to match

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Generates a secret key, creating a new key object

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Generates a secret key, creating a new key object

    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, key): void
        • Parameters

          • error: Error
          • key: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Generates a secret key, creating a new key object

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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, keys): void
        • Parameters

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Generates random data

    Parameters

    • session: Buffer

      The session's handle

    • buf: Buffer

      Init buffer

    Returns Buffer

    The random data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Obtains the value of one or more object attributes

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    Parameters

    • slot: Buffer

      ID of the token's slot

    • mech: number

      Type of mechanism

    Returns MechanismInfo

    Information about mechanism

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Obtains a list of mechanism types supported by a token

    Parameters

    • slot: Buffer

      ID of token's slot

    Returns number[]

    A list of mechanism types

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Gets the size of an object in bytes

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    Returns number

    Size of an object in bytes

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Obtains information about a particular slot in the system

    Parameters

    • slot: Buffer

      The ID of the slot

    Returns SlotInfo

    Information about a slot

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Obtains a list of slots in the system

    Parameters

    • OptionaltokenPresent: boolean

      Only slots with tokens?

    Returns Buffer[]

    Array of slot IDs

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Obtains information about a particular token in the system

    Parameters

    • slot: Buffer

      ID of the token's slot

    Returns TokenInfo

    Information about a token

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Initializes the normal user's PIN

    Parameters

    • session: Buffer

      The session's handle

    • Optionalpin: string

      The normal user's PIN

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Initializes a token

    Parameters

    • slot: Buffer

      ID of the token's slot

    • Optionalpin: string

      The SO's initial PIN

    • Optionallabel: string

    Returns string

    32-byte token label (blank padded)

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Initializes the Cryptoki library

    Parameters

    • Optionaloptions: 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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Logs a user into a token

    Parameters

    • session: Buffer

      The session's handle

    • userType: number

      The user type

    • Optionalpin: string

      The user's PIN

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Logs a user out from a token

    Parameters

    • session: Buffer

      The session's handle

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Opens a session between an application and a token

    Parameters

    • slot: Buffer

      The slot's ID

    • flags: number

      From CK_SESSION_INFO

    Returns Buffer

    Session handle

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Mixes additional seed material into the token's random number generator

    Parameters

    • session: Buffer

      The session's handle

    • buf: Buffer

      The seed material

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Modifies the value of one or more object attributes

    Parameters

    • session: Buffer

      The session's handle

    • object: Buffer

      The object's handle

    • template: Template

      Specifies attrs and values

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Modifies the PIN of the user who is logged in

    Parameters

    • session: Buffer

      The session's handle

    • oldPin: string

      The old PIN

    • newPin: string

      The new PIN

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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

    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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Promise<Buffer>

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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 Buffer

    Sliced encrypted data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • 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

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

    Parameters

    • session: Buffer

      The session's handle

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, data): void
        • Parameters

          • error: Error
          • data: Buffer

          Returns void

    Returns void

  • 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

  • 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

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Signature mechanism

    • key: Buffer

      Handle of signature key

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Signs data in a single operation, where the data can be recovered from the signature

    Parameters

    • session: Buffer
    • inData: Buffer

      Incoming data

    • outData: Buffer

      Output data

    Returns Buffer

    Sliced output data

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Initializes a signature operation, where the data can be recovered from the signature

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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, key): void
        • Parameters

          • error: Error
          • key: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • signature: Buffer

      Signature to verify

    Returns boolean

    Verification result

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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

    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, verify): void
        • Parameters

          • error: Error
          • verify: boolean

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    • signature: Buffer

      Signature to verify

    Returns Promise<boolean>

    Verification result

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    Parameters

    • session: Buffer

      The session's handle

    • signature: Buffer

      Signature to verify

    Returns boolean

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • 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, verify): void
        • Parameters

          • error: Error
          • verify: boolean

          Returns void

    Returns void

  • 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

  • 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)

    Parameters

    • session: Buffer

      The session's handle

    • mechanism: Mechanism

      Verification mechanism

    • key: Buffer

      Verification key

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Verifies a signature in a single-part operation, where the data is recovered from the signature

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Initializes a signature verification operation, where the data is recovered from the signature

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Continues a multiple-part verification operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature

    Parameters

    • session: Buffer

      The session's handle

    • inData: Buffer

      Incoming data

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Waits for a slot event, such as token insertion or token removal, to occur.

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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, wrappedKey): void
        • Parameters

          • error: Error
          • wrappedKey: Buffer

          Returns void

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

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

    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

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs

  • Loads dynamic library with PKCS#11 interface

    Parameters

    • path: string

      The path to PKCS#11 library

    Returns void

    NativeError if native error occurs

    Pkcs11Error if Cryptoki error occurs