TclPKCS11 r24 (See the current copy)

RSA's Public Key Cryptographic Standard #11 for Tcl

Downloads


Information

  ::pki::pkcs11::loadmodule <filename>                       -> handle
  ::pki::pkcs11::unloadmodule <handle>                       -> true/false
  ::pki::pkcs11::listslots  <handle>                         -> list: slotId label flags
  ::pki::pkcs11::listcerts  <handle> <slotId>                -> list: keylist
  ::pki::pkcs11::encrypt <mode> <input> <keylist>            -> data
  ::pki::pkcs11::decrypt <mode> <input> <keylist>            -> data
  ::pki::pkcs11::login <handle> <slotId> <password>          -> true/false
  ::pki::pkcs11::logout <handle> <slotId>                    -> true/false

Simple Example

 package require pki
 package require pki::pkcs11

 set handle [pki::pkcs11::loadmodule /usr/lib/pkcs11/libcackey.so]

 pki::pkcs11::login $handle $slotId 123456

 set slots [pki::pkcs11::listslots $handle]
 set slotId [lindex $slots 0 0]

 set certs [pki::pkcs11::listcerts $handle $slotId]
 set cert [lindex $certs 0]

 set plain "TestMsg"

 set cipher [pki::encrypt -binary -pub -- $plain $cert]
 set check  [pki::decrypt -binary -priv -- $cipher $cert]

 puts "Plain: $plain"
 puts "Check: $check"