## GP11Slot GP11Slot — Represents a PKCS11 slot that can contain a token. |

## Synopsis

                        GP11MechanismInfo;
    void                gp11_mechanism_info_free            (GP11MechanismInfo *mech_info);
    typedef             GP11Mechanisms;
    #define             gp11_mechanisms_length              (a)
    #define             gp11_mechanisms_at                  (a, i)
    #define             gp11_mechanisms_free                (a)
    gboolean            gp11_mechanisms_check               (GP11Mechanisms *mechanisms,
                                                             ...);
                        GP11Slot;
    gboolean            gp11_slot_equal                     (gconstpointer slot1,
                                                             gconstpointer slot2);
    guint               gp11_slot_hash                      (gconstpointer slot);
    GP11Module*         gp11_slot_get_module                (GP11Slot *self);
    CK_SLOT_ID          gp11_slot_get_handle                (GP11Slot *self);
    GP11SlotInfo*       gp11_slot_get_info                  (GP11Slot *self);
    GP11TokenInfo*      gp11_slot_get_token_info            (GP11Slot *self);
    GP11Mechanisms*     gp11_slot_get_mechanisms            (GP11Slot *self);
    GP11MechanismInfo*  gp11_slot_get_mechanism_info        (GP11Slot *self,
                                                             gulong mech_type);
    gboolean            gp11_slot_has_flags                 (GP11Slot *self,
                                                             gulong flags);
    GP11Session*        gp11_slot_open_session              (GP11Slot *self,
                                                             gulong flags,
                                                             GError **err);
    GP11Session*        gp11_slot_open_session_full         (GP11Slot *self,
                                                             gulong flags,
                                                             GCancellable *cancellable,
                                                             GError **err);
    void                gp11_slot_open_session_async        (GP11Slot *self,
                                                             gulong flags,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GP11Session*        gp11_slot_open_session_finish       (GP11Slot *self,
                                                             GAsyncResult *result,
                                                             GError **err);
                        GP11SlotInfo;
    void                gp11_slot_info_free                 (GP11SlotInfo *slot_info);
                        GP11TokenInfo;
    void                gp11_token_info_free                (GP11TokenInfo *token_info);

## Object Hierarchy

      GObject
       +----GP11Slot

## Properties

      "handle"                   gulong                : Read / Write / Construct Only
      "module"                   GP11Module*           : Read / Write / Construct Only

## Description

A PKCS11 slot can contain a token. As an example, a slot might be a card reader, and the token the card. If the PKCS11 module is not a hardware driver, often the slot and token are equivalent.

## Details

### GP11MechanismInfo

    typedef struct {
    	gulong min_key_size;
    	gulong max_key_size;
    	gulong flags;
    } GP11MechanismInfo;

Represents information about a PKCS11 mechanism.

This is analogous to a CK_MECHANISM_INFO structure.

When you're done with this structure it should be released with `gp11_mechanism_info_free()`.

gulong `min_key_size`; | The minimum key size that can be used with this mechanism.
gulong `max_key_size`; | The maximum key size that can be used with this mechanism.
gulong `flags`; | Various PKCS11 flags that apply to this mechanism.

### gp11_mechanism_info_free ()

    void                gp11_mechanism_info_free            (GP11MechanismInfo *mech_info);

Free the GP11MechanismInfo and associated resources.

`mech_info` : | The mechanism info to free, or NULL.

### GP11Mechanisms

    typedef GArray GP11Mechanisms;

A set of GP11MechanismInfo structures.

### gp11_mechanisms_length()

    #define gp11_mechanisms_length(a)  	((a)->len)

Get the number of GP11MechanismInfo in the set.

`a` : | A GP11Mechanisms set.

### gp11_mechanisms_at()

    #define gp11_mechanisms_at(a, i) 	(g_array_index(a, CK_MECHANISM_TYPE, i))

Get a specific GP11MechanismInfo in a the set.

`a` : | A GP11Mechanisms set.
`i` : | The index of a GP11MechanismInfo.

### gp11_mechanisms_free()

    #define gp11_mechanisms_free(a)         (g_array_free(a, TRUE))

Free a GP11Mechanisms set.

`a` : | A GP11Mechanisms set.

### gp11_mechanisms_check ()

    gboolean            gp11_mechanisms_check               (GP11Mechanisms *mechanisms,
                                                             ...);

Check whether all the mechanism types are in the list.

The arguments should be a list of CKM_XXX mechanism types. The last argument should be GP11_INVALID.

`mechanisms` : | A list of mechanisms, perhaps retrieved from `gp11_slot_get_mechanisms()`.
`...` : |
Returns : | Whether the mechanism is in the list or not.

### GP11Slot

    typedef struct _GP11Slot GP11Slot;

Represents a PKCS11 slot.

### gp11_slot_equal ()

    gboolean            gp11_slot_equal                     (gconstpointer slot1,
                                                             gconstpointer slot2);

Checks equality of two slots. Two GP11Slot objects can point to the same underlying PKCS11 slot.

`slot1` : | A pointer to the first GP11Slot
`slot2` : | A pointer to the second GP11Slot
Returns : | TRUE if slot1 and slot2 are equal. FALSE if either is not a GP11Slot.

### gp11_slot_hash ()

    guint               gp11_slot_hash                      (gconstpointer slot);

Create a hash value for the GP11Slot.

This function is intended for easily hashing a GP11Slot to add to a GHashTable or similar data structure.

`slot` : | A pointer to a GP11Slot
Returns : | An integer that can be used as a hash value, or 0 if invalid.

### gp11_slot_get_module ()

    GP11Module*         gp11_slot_get_module                (GP11Slot *self);

Get the module that this slot is on.

`self` : | The slot to get the module for.
Returns : | The module, you must unreference this after you're done with it.

### gp11_slot_get_handle ()

    CK_SLOT_ID          gp11_slot_get_handle                (GP11Slot *self);

Get the raw PKCS11 handle of a slot.

`self` : | The slot to get the handle of.
Returns : | The raw handle.

### gp11_slot_get_info ()

    GP11SlotInfo*       gp11_slot_get_info                  (GP11Slot *self);

Get the information for this slot.

`self` : | The slot to get info for.
Returns : | The slot information. When done, use `gp11_slot_info_free()` to release it.

### gp11_slot_get_token_info ()

    GP11TokenInfo*      gp11_slot_get_token_info            (GP11Slot *self);

Get the token information for this slot.

`self` : | The slot to get info for.
Returns : | The token information. When done, use `gp11_token_info_free()` to release it.

### gp11_slot_get_mechanisms ()

    GP11Mechanisms*     gp11_slot_get_mechanisms            (GP11Slot *self);

Get the available mechanisms for this slot.

`self` : | The slot to get mechanisms for.
Returns : | A list of the mechanisms for this slot. Use `gp11_mechanisms_free()` when done with this.

### gp11_slot_get_mechanism_info ()

    GP11MechanismInfo*  gp11_slot_get_mechanism_info        (GP11Slot *self,
                                                             gulong mech_type);

Get information for the specified mechanism.

`self` : | The slot to get mechanism info from.
`mech_type` : | The mechanisms type to get info for.
Returns : | The mechanism information, or NULL if failed. Use `gp11_mechanism_info_free()` when done with it.

### gp11_slot_has_flags ()

    gboolean            gp11_slot_has_flags                 (GP11Slot *self,
                                                             gulong flags);

Check if the PKCS11 slot has the given flags.

`self` : | The GP11Slot object.
`flags` : | The flags to check.
Returns : | Whether one or more flags exist.

### gp11_slot_open_session ()

    GP11Session*        gp11_slot_open_session              (GP11Slot *self,
                                                             gulong flags,
                                                             GError **err);

Open a session on the slot. If the 'auto reuse' setting is set, then this may be a recycled session with the same flags.

This call may block for an indefinite period.

`self` : | The slot ot open a session on.
`flags` : | The flags to open a session with.
`err` : | A location to return an error, or NULL.
Returns : | A new session or NULL if an error occurs.

### gp11_slot_open_session_full ()

    GP11Session*        gp11_slot_open_session_full         (GP11Slot *self,
                                                             gulong flags,
                                                             GCancellable *cancellable,
                                                             GError **err);

Open a session on the slot. If the 'auto reuse' setting is set, then this may be a recycled session with the same flags.

This call may block for an indefinite period.

`self` : | The slot to open a session on.
`flags` : | The flags to open a session with.
`cancellable` : | Optional cancellation object, or NULL.
`err` : | A location to return an error, or NULL.
Returns : | A new session or NULL if an error occurs.

### gp11_slot_open_session_async ()

    void                gp11_slot_open_session_async        (GP11Slot *self,
                                                             gulong flags,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Open a session on the slot. If the 'auto reuse' setting is set, then this may be a recycled session with the same flags.

This call will return immediately and complete asynchronously.

`self` : | The slot to open a session on.
`flags` : | The flags to open a session with.
`cancellable` : | Optional cancellation object, or NULL.
`callback` : | Called when the operation completes.
`user_data` : | Data to pass to the callback.

### gp11_slot_open_session_finish ()

    GP11Session*        gp11_slot_open_session_finish       (GP11Slot *self,
                                                             GAsyncResult *result,
                                                             GError **err);

Get the result of an open session operation. If the 'auto reuse' setting is set, then this may be a recycled session with the same flags.

`self` : | The slot to open a session on.
`result` : | The result passed to the callback.
`err` : | A location to return an error or NULL.
Returns : | The new session or NULL if an error occurs.

### GP11SlotInfo

    typedef struct {
    	gchar *slot_description;
    	gchar *manufacturer_id;
    	gulong flags;
    	guint8 hardware_version_major;
    	guint8 hardware_version_minor;
    	guint8 firmware_version_major;
    	guint8 firmware_version_minor;
    } GP11SlotInfo;

Represents information about a PKCS11 slot.

This is analogous to a CK_SLOT_INFO structure, but the strings are far more usable.

When you're done with this structure it should be released with `gp11_slot_info_free()`.

gchar *`slot_description`; | Description of the slot.
gchar *`manufacturer_id`; | The manufacturer of this slot.
gulong `flags`; | Various PKCS11 flags that apply to this slot.
guint8 `hardware_version_major`; | The major version of the hardware.
guint8 `hardware_version_minor`; | The minor version of the hardware.
guint8 `firmware_version_major`; | The major version of the firmware.
guint8 `firmware_version_minor`; | The minor version of the firmware.

### gp11_slot_info_free ()

    void                gp11_slot_info_free                 (GP11SlotInfo *slot_info);

Free the GP11SlotInfo and associated resources.

`slot_info` : | The slot info to free, or NULL.

### GP11TokenInfo

    typedef struct {
    	gchar *label;
    	gchar *manufacturer_id;
    	gchar *model;
    	gchar *serial_number;
    	gulong flags;
    	glong max_session_count;
    	glong session_count;
    	glong max_rw_session_count;
    	glong rw_session_count;
    	glong max_pin_len;
    	glong min_pin_len;
    	glong total_public_memory;
    	glong free_public_memory;
    	glong total_private_memory;
    	glong free_private_memory;
    	guint8 hardware_version_major;
    	guint8 hardware_version_minor;
    	guint8 firmware_version_major;
    	guint8 firmware_version_minor;
    	gint64 utc_time;
    } GP11TokenInfo;

Represents information about a PKCS11 token.

This is analogous to a CK_TOKEN_INFO structure, but the strings are far more usable.

When you're done with this structure it should be released with `gp11_token_info_free()`.

gchar *`label`; | The displayable token label.
gchar *`manufacturer_id`; | The manufacturer of this slot.
gchar *`model`; | The token model number as a string.
gchar *`serial_number`; | The token serial number as a string.
gulong `flags`; | Various PKCS11 flags that apply to this token.
glong `max_session_count`; | The maximum number of sessions allowed on this token.
glong `session_count`; | The number of sessions open on this token.
glong `max_rw_session_count`; | The maximum number of read/write sessions allowed on this token.
glong `rw_session_count`; | The number of sessions open on this token.
glong `max_pin_len`; | The maximum length of a PIN for locking this token.
glong `min_pin_len`; | The minimum length of a PIN for locking this token.
glong `total_public_memory`; | The total amount of memory on this token for storing public objects.
glong `free_public_memory`; | The available amount of memory on this token for storing public objects.
glong `total_private_memory`; | The total amount of memory on this token for storing private objects.
glong `free_private_memory`; | The available amount of memory on this token for storing private objects.
guint8 `hardware_version_major`; | The major version of the hardware.
guint8 `hardware_version_minor`; | The minor version of the hardware.
guint8 `firmware_version_major`; | The major version of the firmware.
guint8 `firmware_version_minor`; | The minor version of the firmware.
gint64 `utc_time`; | If the token has a hardware clock, this is set to the number of seconds since the epoch.

### gp11_token_info_free ()

    void                gp11_token_info_free                (GP11TokenInfo *token_info);

Free the GP11TokenInfo and associated resources.

`token_info` : | The token info to free, or NULL.

## Property Details

### The `"handle"` property

      "handle"                   gulong                : Read / Write / Construct Only

The raw CK_SLOT_ID handle of this slot.

### The `"module"` property

      "module"                   GP11Module*           : Read / Write / Construct Only

The PKCS11 object that this slot is a part of.