当前位置: 首页>>代码示例>>Python>>正文


Python cmd.YHSM_Cmd类代码示例

本文整理汇总了Python中pyhsm.cmd.YHSM_Cmd的典型用法代码示例。如果您正苦于以下问题:Python YHSM_Cmd类的具体用法?Python YHSM_Cmd怎么用?Python YHSM_Cmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了YHSM_Cmd类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, stick, key=''):
     payload = pyhsm.util.input_validate_str(key, 'key', max_len = pyhsm.defines.YSM_MAX_KEY_SIZE)
     # typedef struct {
     #   uint8_t key[YSM_MAX_KEY_SIZE];      // Key store decryption key
     # } YSM_KEY_STORE_DECRYPT_REQ;
     packed = payload.ljust(pyhsm.defines.YSM_MAX_KEY_SIZE, chr(0x0))
     YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_KEY_STORE_DECRYPT, packed)
开发者ID:kalpeshd,项目名称:python-pyhsm,代码行数:7,代码来源:basic_cmd.py

示例2: __init__

 def __init__(self, stick, public_id, key_handle, aead, nonce = None):
     self.key_handle = pyhsm.util.input_validate_key_handle(key_handle)
     self.public_id = pyhsm.util.input_validate_nonce(public_id, pad = True)
     aead = pyhsm.util.input_validate_aead(aead, expected_len = pyhsm.defines.YSM_YUBIKEY_AEAD_SIZE)
     if nonce is None:
         # typedef struct {
         #   uint8_t publicId[YSM_PUBLIC_ID_SIZE]; // Public id (nonce)
         #   uint32_t keyHandle;                    // Key handle
         #   uint8_t aead[YSM_YUBIKEY_AEAD_SIZE];       // AEAD block
         # } YSM_DB_YUBIKEY_AEAD_STORE_REQ;
         fmt = "< %is I %is" % (pyhsm.defines.YSM_PUBLIC_ID_SIZE, \
                                    pyhsm.defines.YSM_YUBIKEY_AEAD_SIZE)
         packed = struct.pack(fmt, self.public_id, self.key_handle, aead)
         YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_DB_YUBIKEY_AEAD_STORE, packed)
     else:
         nonce = pyhsm.util.input_validate_nonce(nonce)
         # typedef struct {
         #   uint8_t publicId[YSM_PUBLIC_ID_SIZE]; // Public id
         #   uint32_t keyHandle;                    // Key handle
         #   uint8_t aead[YSM_YUBIKEY_AEAD_SIZE];       // AEAD block
         #   uint8_t nonce[YSM_AEAD_NONCE_SIZE];  // Nonce
         # } YSM_DB_YUBIKEY_AEAD_STORE2_REQ;
         fmt = "< %is I %is %is" % (pyhsm.defines.YSM_PUBLIC_ID_SIZE, \
                                        pyhsm.defines.YSM_YUBIKEY_AEAD_SIZE, \
                                        pyhsm.defines.YSM_AEAD_NONCE_SIZE)
         packed = struct.pack(fmt, self.public_id, self.key_handle, aead, nonce)
         YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_DB_YUBIKEY_AEAD_STORE2, packed)
开发者ID:SUNET,项目名称:python-pyhsm,代码行数:27,代码来源:db_cmd.py

示例3: __init__

 def __init__(self, stick):
     YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_SYSTEM_INFO_QUERY)
     self.version_major = 0
     self.version_minor = 0
     self.version_build = 0
     self.protocol_ver = 0
     self.system_uid = None
开发者ID:ThomasHabets,项目名称:python-pyhsm,代码行数:7,代码来源:basic_cmd.py

示例4: __init__

    def __init__(self, stick, payload=''):
        #define YHSM_MONITOR_EXIT        0x7f    // Exit to monitor (no response sent)
        #define YHSM_MONITOR_EXIT_MAGIC  0xbaadbeef
        #typedef struct {
        #  uint32_t magic;                     // Magic number for trigger
        #  uint32_t magicInv;                  // 1st complement of magic
        #} YHSM_MONITOR_EXIT_REQ;

        packed = struct.pack('<II', 0xbaadbeef, 0xffffffff - 0xbaadbeef)
        YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_MONITOR_EXIT, packed)
开发者ID:ThomasHabets,项目名称:python-pyhsm,代码行数:10,代码来源:debug_cmd.py

示例5: __init__

 def __init__(self, stick, num_bytes, offset = 0):
     self.offset = offset
     self.num_bytes = num_bytes
     # typedef struct {
     #   uint8_t offs;                       // Offset in buffer. Zero flushes/resets buffer first
     #   uint8_t numBytes;                   // Number of bytes to randomize
     # } YSM_BUFFER_RANDOM_LOAD_REQ;
     fmt = "B B"
     packed = struct.pack(fmt, self.offset, self.num_bytes)
     YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_BUFFER_RANDOM_LOAD, packed)
开发者ID:ThomasHabets,项目名称:python-pyhsm,代码行数:10,代码来源:buffer_cmd.py

示例6: __init__

    def __init__(self, stick, key_handle, data, flags = None, final = True, to_buffer = False):
        data = pyhsm.util.input_validate_str(data, 'data', max_len = pyhsm.defines.YSM_MAX_PKT_SIZE - 6)
        self.key_handle = pyhsm.util.input_validate_key_handle(key_handle)

        if flags != None:
            flags = pyhsm.util.input_validate_int(flags, 'flags', max_value=0xff)
        else:
            flags = pyhsm.defines.YSM_HMAC_SHA1_RESET
            if final:
                flags |= pyhsm.defines.YSM_HMAC_SHA1_FINAL
            if to_buffer:
                flags |= pyhsm.defines.YSM_HMAC_SHA1_TO_BUFFER

        self.final = final
        self.flags = flags
        packed = _raw_pack(self.key_handle, self.flags, data)
        YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_HMAC_SHA1_GENERATE, packed)
开发者ID:SUNET,项目名称:python-pyhsm,代码行数:17,代码来源:hmac_cmd.py

示例7: __init__

 def __init__(self, stick, nonce, key_handle, aead, cleartext):
     aead = pyhsm.util.input_validate_aead(aead)
     expected_ct_len = len(aead) - pyhsm.defines.YSM_AEAD_MAC_SIZE
     cleartext = pyhsm.util.input_validate_str(cleartext, 'cleartext', exact_len = expected_ct_len)
     self.nonce = pyhsm.util.input_validate_nonce(nonce, pad = True)
     self.key_handle = pyhsm.util.input_validate_key_handle(key_handle)
     data = cleartext + aead
     if len(data) > pyhsm.defines.YSM_MAX_PKT_SIZE - 10:
         raise pyhsm.exception.YHSM_InputTooLong(
             'cleartext+aead', pyhsm.defines.YSM_MAX_PKT_SIZE - 10, len(data))
     # typedef struct {
     #   uint8_t nonce[YSM_AEAD_NONCE_SIZE]; // Nonce (publicId for Yubikey AEADs)
     #   uint32_t keyHandle;                 // Key handle
     #   uint8_t numBytes;                   // Number of data bytes (cleartext + aead)
     #   uint8_t data[YSM_MAX_PKT_SIZE - 0x10]; // Data (cleartext + aead). Empty cleartext validates aead only
     # } YSM_AEAD_DECRYPT_CMP_REQ;
     fmt = "< %is I B %is" % (pyhsm.defines.YSM_AEAD_NONCE_SIZE, len(data))
     packed = struct.pack(fmt, self.nonce, key_handle, len(data), data)
     YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_AEAD_DECRYPT_CMP, packed)
开发者ID:rlishtaba,项目名称:python-pyhsm,代码行数:19,代码来源:aead_cmd.py

示例8: __init__

 def __init__(self, stick, command, payload):
     YHSM_Cmd.__init__(self, stick, command, payload)
开发者ID:SUNET,项目名称:python-pyhsm,代码行数:2,代码来源:aes_ecb_cmd.py


注:本文中的pyhsm.cmd.YHSM_Cmd类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。