class PKCS11::Slot

Each slot corresponds to a physical reader or other device interface. It may contain a token.

Public Instance Methods

C_CloseAllSessions() click to toggle source

Closes all sessions an application has with a token. @return [PKCS11::Slot]

# File lib/pkcs11/slot.rb, line 96
def C_CloseAllSessions
  @pk.C_CloseAllSessions(@slot)
  self
end
Also aliased as: close_all_sessions
C_GetMechanismInfo(mechanism) click to toggle source

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

@param [Integer, Symbol] mechanism @return [CK_MECHANISM_INFO]

# File lib/pkcs11/slot.rb, line 52
def C_GetMechanismInfo(mechanism)
  @pk.C_GetMechanismInfo(@slot, string_to_handle('CKM_', mechanism))
end
Also aliased as: mechanism_info
C_GetMechanismList() click to toggle source

C_GetMechanismList is used to obtain a list of mechanism types supported by a token. @return [Array<PKCS11::CKM_*>]

# File lib/pkcs11/slot.rb, line 42
def C_GetMechanismList
  @pk.C_GetMechanismList(@slot)
end
Also aliased as: mechanisms
C_GetSlotInfo() click to toggle source

Obtains information about a particular slot in the system. @return [PKCS11::CK_SLOT_INFO]

# File lib/pkcs11/slot.rb, line 28
def C_GetSlotInfo
  @pk.C_GetSlotInfo(@slot)
end
Also aliased as: info
C_GetTokenInfo() click to toggle source

Obtains information about a particular token in the system. @return [PKCS11::CK_TOKEN_INFO]

# File lib/pkcs11/slot.rb, line 35
def C_GetTokenInfo
  @pk.C_GetTokenInfo(@slot)
end
Also aliased as: token_info
C_InitToken(pin, label) click to toggle source

Initializes a token. @param [String] pin is the SO's initial PIN @param [String] label is the label of the token (max 32-byte).

The standard allows PIN values to contain any valid UTF8 character, but the token may impose subset restrictions. @return [PKCS11::Slot]

# File lib/pkcs11/slot.rb, line 64
def C_InitToken(pin, label)
  @pk.C_InitToken(@slot, pin, label.ljust(32, " "))
  self
end
Also aliased as: init_token
C_OpenSession(flags=CKF_SERIAL_SESSION) { |sess| ... } click to toggle source

Opens a Session between an application and a token in a particular slot.

@param [Integer] flags indicates the type of session. Default is read-only,

use <tt>CKF_SERIAL_SESSION | CKF_RW_SESSION</tt> for read-write session.
  • If called with block, yields the block with the session and closes the session when the is finished.

  • If called without block, returns the session object.

@return [PKCS11::Session]

# File lib/pkcs11/slot.rb, line 79
def C_OpenSession(flags=CKF_SERIAL_SESSION)
  nr = @pk.C_OpenSession(@slot, flags)
  sess = Session.new @pk, nr
  if block_given?
    begin
      yield sess
    ensure
      sess.close
    end
  else
    sess
  end
end
Also aliased as: open
close_all_sessions()
Alias for: C_CloseAllSessions
info()
Alias for: C_GetSlotInfo
init_token(pin, label)
Alias for: C_InitToken
mechanism_info(mechanism)
Alias for: C_GetMechanismInfo
mechanisms()
Alias for: C_GetMechanismList
open(flags=CKF_SERIAL_SESSION)
Alias for: C_OpenSession
to_i()
Alias for: to_int
to_int() click to toggle source

The slot handle. @return [Integer]

# File lib/pkcs11/slot.rb, line 16
def to_int
  @slot
end
Also aliased as: to_i
token_info()
Alias for: C_GetTokenInfo