Ellipticsecure PKCS11共享库的Python绑定
ehsm的Python项目详细描述
python libehsm是用于ellipticsecure pkcs11共享库的python包装器
注意,虽然包装器确实导出了一些pkcs 11 helper 函数它只执行部分操作-还有其他包装器 可与PKCS 11接口。
这个包装器的重点是导出bip32/比特币特定的函数。
安装
在此处下载并安装平台的本机共享库:https://ellipticsecure.com/downloads/
pip安装python libehsm
示例
使用存储在 mirkey或ehsm设备:
importehsmmirkey=ehsm.load_ehsm()# Get the available device slotsslots=mirkey.enumerate_slots()iflen(slots)>0:# Use the first available slotslot=slots[0]# Initialize the librarymirkey.init()try:session=mirkey.get_logged_in_rw_session(slot,b"testsu")found=mirkey.bip32_has_root_key(session)iffound:hash=bytes(32)# list of integers representing a bip32 path to the derived key# # ie. this is "m/0", "m" would be []indexes=[0]sig=mirkey.bip32_sign_data(session,hash,indexes)finally:mirkey.finalize()else:print"No devices found"
有关更多使用示例,请参见测试用例。