Provides information about a session

Hierarchy (view full)

Constructors

Properties

deviceError: number

An error code defined by the cryptographic device. Used for errors not covered by Cryptoki

flags: number

Bit flags that define the type of session

handle: Buffer

ID of PKCS#11 object

lib: PKCS11

PKCS#11 module

slot: Slot

Slot

state: number

The state of the session

Methods

  • Removes all session objects

    Returns number

    The number of destroyed objects

  • Closes a session between an application and a token

    Returns void

  • creates a new object

    • Only session objects can be created during a read-only session.
    • Only public objects can be created unless the normal user is logged in.

    Parameters

    Returns SessionObject

    The new instance of SessionObject

  • Creates the decryption operation

    Parameters

    • alg: MechanismType

      The decryption mechanism

    • key: Key

      The decryption key

    • OptionalblockSize: number

      Block size in bytes

    Returns Decipher

    The decryption operation

  • Derives a key from a base key

    Parameters

    Returns SecretKey

    Derived key

  • Derives a key from a base key

    Parameters

    • alg: MechanismType

      Key derivation mech

    • baseKey: Key

      Base key

    • template: ITemplate

      New key template

    • callback: Callback<Error, Key>

      Async callback function with derived key

    Returns void

  • Removes all session objects matched to template

    Parameters

    Returns number

    The number of destroyed objects

  • Removes the specified session object

    Parameters

    Returns number

    The number of destroyed objects

  • Removes all session objects

    Returns number

    The number of destroyed objects

  • Generates a secret key or set of domain parameters, creating a new object.

    Parameters

    • mechanism: MechanismType

      Generation mechanism

    • Optionaltemplate: ITemplate

      Template for the new key or set of domain parameters

    Returns SecretKey

    The secret key

  • Generates a secret key or set of domain parameters, creating a new object.

    Parameters

    • mechanism: MechanismType

      Generation mechanism

    • template: ITemplate

      Template for the new key or set of domain parameters

    • callback: Callback<Error, SecretKey>

      Async callback with generated key

    Returns void

  • Generates an asymmetric key pair

    Parameters

    Returns IKeyPair

    The generated key pair

  • Generates an asymmetric key pair

    Parameters

    • mechanism: MechanismType

      Generation mechanism

    • publicTemplate: ITemplate

      The public key template

    • privateTemplate: ITemplate

      The private key template

    • callback: Callback<Error, IKeyPair>

      Async callback with generated key pair

    Returns void

  • Generates random data

    Parameters

    • size: number

      Amount of bytes to generate

    Returns Buffer

    New byte array

  • Returns object from session by handle

    Type Parameters

    Parameters

    • handle: Buffer

      handle of object

    Returns null | T

    The session object or null

  • Obtains a copy of the cryptographic operations state of a session, encoded as a string of bytes

    Returns Buffer

  • Initializes the normal user's PIN

    Parameters

    • pin: string

      the normal user's PIN

    Returns void

  • Logs a user into a token

    Parameters

    • pin: string

      the user's PIN.

      • This standard allows PIN values to contain any valid UTF8 character, but the token may impose subset restrictions
    • userType: UserType = UserType.USER

      the user type. Default is UserType.USER

    Returns void

  • logs a user out from a token

    Returns void

  • Restores the cryptographic operations state of a session from a string of bytes obtained with getOperationState

    Parameters

    • state: Buffer

      the saved state

    • encryptionKey: number = 0

      holds key which will be used for an ongoing encryption or decryption operation in the restored session (or 0 if no encryption or decryption key is needed, either because no such operation is ongoing in the stored session or because all the necessary key information is present in the saved state)

    • authenticationKey: number = 0

      holds a handle to the key which will be used for an ongoing signature, MACing, or verification operation in the restored session (or 0 if no such key is needed, either because no such operation is ongoing in the stored session or because all the necessary key information is present in the saved state)

    Returns void

  • modifies the PIN of the user who is logged in

    Parameters

    • oldPin: string

      The old PIN

    • newPin: string

      The new PIN

    Returns void

  • Unwraps (decrypts) a wrapped key

    Parameters

    • alg: MechanismType

      Unwrapping mechanism

    • unwrappingKey: Key

      Unwrapping key

    • wrappedKey: Buffer

      Wrapped key

    • template: ITemplate

      New key template

    Returns Key

    Unwrapped key

  • Parameters

    Returns void

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

    Parameters

    Returns Buffer

    Wrapped key

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

    Parameters

    • alg: MechanismType

      Wrapping mechanism

    • wrappingKey: Key

      Wrapping key

    • key: Key

      Key to be wrapped

    • callback: Callback<Error, Buffer>

      Async callback function with wrapped key

    Returns void