GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfPkcs11Token Class

    Namespace:
    GemBox.Pdf.Security
    Assembly:
    GemBox.Pdf.dll

    Represents the logical view of a cryptographic device defined by Cryptoki.

    Various objects can be stored on a token. These include data, certificates and keys.

    important

    Stored objects can be accessed and cryptographic functions performed only after the session (a logical connection between an application and a token) is opened. The PdfPkcs11Token implicitly opens the session when required, and reuses the opened session until the PdfPkcs11Token is disposed.

    The session can be opened only on the thread the PdfPkcs11Token was created on. To open a session on another thread, Clone() the PdfPkcs11Token, use the clone with its own session, and dispose the clone.

    PdfPkcs11Token associates a single session with itself because Cryptoki doesn't guarantee that a particular object on a token has a handle which is fixed for the lifetime of the object; however, if a particular session can use a particular handle to access a particular object, then that session will continue to be able to use that handle to access that object as long as the session continues to exist, the object continues to exist, and the object continues to be accessible to the session. PdfPkcs11Token uses object handles to access private keys, public keys, and certificates contained on the token in order to build the DigitalIds and, therefore, this must be done in the scope of a single session.

    • C#
    • VB.NET
    public sealed class PdfPkcs11Token : IDisposable
    Public NotInheritable Class PdfPkcs11Token
        Implements IDisposable
    Inheritance:
    System.Object
    PdfPkcs11Token
    Implements
    System.IDisposable

    Properties

    DigitalIds

    Gets the digital IDs contained on this token.

    • C#
    • VB.NET
    public IList<PdfPkcs11DigitalId> DigitalIds { get; }
    Public ReadOnly Property DigitalIds As IList(Of PdfPkcs11DigitalId)
    Property Value
    System.Collections.Generic.IList<PdfPkcs11DigitalId>

    The digital IDs contained on this token.

    Model

    Gets the model of the device.

    • C#
    • VB.NET
    public string Model { get; }
    Public ReadOnly Property Model As String
    Property Value
    System.String

    The model of the device.

    ModuleManufacturerId

    Gets the ID of the device manufacturer.

    • C#
    • VB.NET
    public string ModuleManufacturerId { get; }
    Public ReadOnly Property ModuleManufacturerId As String
    Property Value
    System.String

    The ID of the device manufacturer.

    SerialNumber

    Gets the serial number of the device.

    • C#
    • VB.NET
    public string SerialNumber { get; }
    Public ReadOnly Property SerialNumber As String
    Property Value
    System.String

    The serial number of the device.

    TokenLabel

    Gets the application-defined label, assigned during token initialization.

    • C#
    • VB.NET
    public string TokenLabel { get; }
    Public ReadOnly Property TokenLabel As String
    Property Value
    System.String

    The application-defined label, assigned during token initialization.

    Methods

    Clone()

    Clones the PdfPkcs11Token so that the returned clone can rebuild its DigitalIds using its own session on another thread. For more information about Cryptoki sessions, read the documentation of the PdfPkcs11Token class.

    important

    After you are finished using the cloned PdfPkcs11Token make sure you dispose it so that its associated session is closed.

    • C#
    • VB.NET
    public PdfPkcs11Token Clone()
    Public Function Clone As PdfPkcs11Token
    Returns
    PdfPkcs11Token

    The clone of the PdfPkcs11Token whose session can be used on another thread.

    Login(String)

    Logs a user into a token.

    • C#
    • VB.NET
    public void Login(string pin)
    Public Sub Login(pin As String)
    Parameters
    pin
    System.String

    The user's Personal Identification Number (PIN).

    Remarks

    Since all sessions an application has with a token have a shared login state, Login(String) only needs to be called for one of the sessions (source). If the PdfPkcs11Token is going to be used from multiple threads concurrently, then there should be one master PdfPkcs11Token on which the Login(String) should be called once and PdfPkcs11Token instances returned by the Clone() method on the master PdfPkcs11Token should be used in each thread.

    See Also
    5.6.8 C_Login
    Workflow in the multithreaded application

    Logout()

    Logs a user out from a token.

    • C#
    • VB.NET
    public void Logout()
    Public Sub Logout
    See Also
    5.6.10 C_Logout

    ToString()

    Returns a System.String that represents this PdfPkcs11Module instance.

    • C#
    • VB.NET
    public override string ToString()
    Public Overrides Function ToString As String
    Returns
    System.String

    A System.String that represents this PdfPkcs11Module instance.

    Overrides
    System.Object.ToString()
    Remarks

    This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).

    Implements

    System.IDisposable

    Examples

    PKCS#11 (Cryptoki) digital signature example
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.