Token interface

## Files

file | pkcs11h-token.h
| pkcs11-helper token interface.

## Classes

struct | pkcs11h_token_id_list_s
| Token identifier list. More...

## Typedefs

typedef struct pkcs11h_token_id_list_s * | pkcs11h_token_id_list_t
| Token identifier list.

## Functions

CK_RV | pkcs11h_token_freeTokenId (IN pkcs11h_token_id_t token_id)
| Free token_id object.
CK_RV | pkcs11h_token_duplicateTokenId (OUT pkcs11h_token_id_t *const to, IN const pkcs11h_token_id_t from)
| Duplicate token_id object.
PKCS11H_BOOL | pkcs11h_token_sameTokenId (IN const pkcs11h_token_id_t a, IN const pkcs11h_token_id_t b)
| Returns TRUE if same token id.
CK_RV | pkcs11h_token_logout (IN const pkcs11h_token_id_t token_id)
| Force logout.
CK_RV | pkcs11h_token_login (IN const pkcs11h_token_id_t token_id, IN const PKCS11H_BOOL readonly, IN const char *const pin)
| Force login, avoid hooks.
CK_RV | pkcs11h_token_ensureAccess (IN const pkcs11h_token_id_t token_id, IN void *const user_data, IN const unsigned mask_prompt)
| Ensure token is accessible.
CK_RV | pkcs11h_token_freeTokenIdList (IN const pkcs11h_token_id_list_t token_id_list)
| Free certificate_id list.
CK_RV | pkcs11h_token_enumTokenIds (IN const unsigned method, OUT pkcs11h_token_id_list_t *const p_token_id_list)
| Enumerate available tokens.
CK_RV | pkcs11h_token_serializeTokenId (OUT char *const sz, IN OUT size_t *max, IN const pkcs11h_token_id_t token_id)
| Serialize token_id into string.
CK_RV | pkcs11h_token_deserializeTokenId (OUT pkcs11h_token_id_t *p_token_id, IN const char *const sz)
| Deserialize token_id from string.

## Detailed Description

Token related functions.

## Function Documentation

## pkcs11h_token_deserializeTokenId()

CK_RV pkcs11h_token_deserializeTokenId | ( | OUT pkcs11h_token_id_t * | p_token_id,
|  | IN const char *const | sz )

Deserialize token_id from string.

Parameters

  p_token_id | id.
  sz | Input string.

Returns
  CK_RV.

Note
  Caller must free result.

See also
  pkcs11h_token_freeTokenId().

## pkcs11h_token_duplicateTokenId()

CK_RV pkcs11h_token_duplicateTokenId | ( | OUT pkcs11h_token_id_t *const | to,
|  | IN const pkcs11h_token_id_t | from )

Duplicate token_id object.

Parameters

  to | Target.
  from | Source.

Returns
  CK_RV.

See also
  pkcs11h_token_freeTokenId().

## pkcs11h_token_ensureAccess()

CK_RV pkcs11h_token_ensureAccess | ( | IN const pkcs11h_token_id_t | token_id,
|  | IN void *const | user_data,
|  | IN const unsigned | mask_prompt )

Ensure token is accessible.

Parameters

  token_id | Token id object.
  user_data | Optional user data, to be passed to hooks.
  mask_prompt | Allow prompt PKCS11H_PROMPT_MASK.

Returns
  CK_RV.

## pkcs11h_token_enumTokenIds()

CK_RV pkcs11h_token_enumTokenIds | ( | IN const unsigned | method,
|  | OUT pkcs11h_token_id_list_t *const | p_token_id_list )

Enumerate available tokens.

Parameters

  method | Enum method PKCS11H_ENUM_METHOD.
  p_token_id_list | List.

Returns
  CK_RV.

Note
  Caller must free result.

See also
  pkcs11h_token_freeTokenIdList().

## pkcs11h_token_freeTokenId()

CK_RV pkcs11h_token_freeTokenId | ( | IN pkcs11h_token_id_t | token_id | ) |

Free token_id object.

Parameters

  token_id | Token reference.

Returns
  CK_RV.

## pkcs11h_token_freeTokenIdList()

CK_RV pkcs11h_token_freeTokenIdList | ( | IN const pkcs11h_token_id_list_t | token_id_list | ) |

Free certificate_id list.

Parameters

  token_id_list | List.

Returns
  CK_RV.

## pkcs11h_token_login()

CK_RV pkcs11h_token_login | ( | IN const pkcs11h_token_id_t | token_id,
|  | IN const PKCS11H_BOOL | readonly,
|  | IN const char *const | pin )

Force login, avoid hooks.

Parameters

  token_id | Token to login into.
  readonly | Should session be readonly.
  pin | PIN to login, NULL for protected authentication.

Returns
  CK_RV.

## pkcs11h_token_logout()

CK_RV pkcs11h_token_logout | ( | IN const pkcs11h_token_id_t | token_id | ) |

Force logout.

Parameters

  token_id | Token to login into.

Returns
  CK_RV.

## pkcs11h_token_sameTokenId()

PKCS11H_BOOL pkcs11h_token_sameTokenId | ( | IN const pkcs11h_token_id_t | a,
|  | IN const pkcs11h_token_id_t | b )

Returns TRUE if same token id.

Parameters

  a | a.
  b | b.

Returns
  TRUE if same token identifier.

## pkcs11h_token_serializeTokenId()

CK_RV pkcs11h_token_serializeTokenId | ( | OUT char *const | sz,
|  | IN OUT size_t * | max,
|  | IN const pkcs11h_token_id_t | token_id )

Serialize token_id into string.

Parameters

  sz | Output string.
  max | Maximum string size.
  token_id | id to serialize

Returns
  CK_RV.

Note
  sz may be NULL to get size.

pkcs11-helper, Copyright (C) Alon Bar-Lev <alon.barlev@gmail.com> |