Class: PKCS11::Slot
- Inherits:
-
Object
- Object
- PKCS11::Slot
- Defined in:
- lib/pkcs11/slot.rb
Overview
Each slot corresponds to a physical reader or other device interface. It may contain a token.
Instance Method Summary collapse
-
#C_CloseAllSessions ⇒ PKCS11::Slot
(also: #close_all_sessions)
Closes all sessions an application has with a token.
-
#C_GetMechanismInfo(mechanism) ⇒ CK_MECHANISM_INFO
(also: #mechanism_info)
Obtains information about a particular mechanism possibly supported by a token.
-
#C_GetMechanismList ⇒ Array<PKCS11::CKM_*>
(also: #mechanisms)
C_GetMechanismList is used to obtain a list of mechanism types supported by a token.
-
#C_GetSlotInfo ⇒ PKCS11::CK_SLOT_INFO
(also: #info)
Obtains information about a particular slot in the system.
-
#C_GetTokenInfo ⇒ PKCS11::CK_TOKEN_INFO
(also: #token_info)
Obtains information about a particular token in the system.
-
#C_InitToken(pin, label) ⇒ PKCS11::Slot
(also: #init_token)
Initializes a token.
-
#C_OpenSession(flags = CKF_SERIAL_SESSION) ⇒ PKCS11::Session
(also: #open)
Opens a Session between an application and a token in a particular slot.
-
#to_int ⇒ Integer
(also: #to_i)
The slot handle.
Instance Method Details
#C_CloseAllSessions ⇒ PKCS11::Slot Also known as: close_all_sessions
Closes all sessions an application has with a token.
96 97 98 99 |
# File 'lib/pkcs11/slot.rb', line 96 def C_CloseAllSessions @pk.C_CloseAllSessions(@slot) self end |
#C_GetMechanismInfo(mechanism) ⇒ CK_MECHANISM_INFO Also known as: mechanism_info
Obtains information about a particular mechanism possibly supported by a token.
52 53 54 |
# File 'lib/pkcs11/slot.rb', line 52 def C_GetMechanismInfo(mechanism) @pk.C_GetMechanismInfo(@slot, string_to_handle('CKM_', mechanism)) end |
#C_GetMechanismList ⇒ Array<PKCS11::CKM_*> Also known as: mechanisms
C_GetMechanismList is used to obtain a list of mechanism types supported by a token.
42 43 44 |
# File 'lib/pkcs11/slot.rb', line 42 def C_GetMechanismList @pk.C_GetMechanismList(@slot) end |
#C_GetSlotInfo ⇒ PKCS11::CK_SLOT_INFO Also known as: info
Obtains information about a particular slot in the system.
28 29 30 |
# File 'lib/pkcs11/slot.rb', line 28 def C_GetSlotInfo @pk.C_GetSlotInfo(@slot) end |
#C_GetTokenInfo ⇒ PKCS11::CK_TOKEN_INFO Also known as: token_info
Obtains information about a particular token in the system.
35 36 37 |
# File 'lib/pkcs11/slot.rb', line 35 def C_GetTokenInfo @pk.C_GetTokenInfo(@slot) end |
#C_InitToken(pin, label) ⇒ PKCS11::Slot Also known as: init_token
Initializes a token. The standard allows PIN values to contain any valid UTF8 character, but the token may impose subset restrictions.
64 65 66 67 |
# File 'lib/pkcs11/slot.rb', line 64 def C_InitToken(pin, label) @pk.C_InitToken(@slot, pin, label.ljust(32, " ")) self end |
#C_OpenSession(flags = CKF_SERIAL_SESSION) ⇒ PKCS11::Session Also known as: open
Opens a Session between an application and a token in a particular slot.
-
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.
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# 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 |
#to_int ⇒ Integer Also known as: to_i
The slot handle.
16 17 18 |
# File 'lib/pkcs11/slot.rb', line 16 def to_int @slot end |