class PKCS11::Slot
Each slot corresponds to a physical reader or other device interface. It may contain a token.
Public Instance Methods
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
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
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
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
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
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
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
The slot handle. @return [Integer]
# File lib/pkcs11/slot.rb, line 16 def to_int @slot end