本文整理汇总了Python中virtualsmartcard.CryptoUtils.get_cipher_blocklen方法的典型用法代码示例。如果您正苦于以下问题:Python CryptoUtils.get_cipher_blocklen方法的具体用法?Python CryptoUtils.get_cipher_blocklen怎么用?Python CryptoUtils.get_cipher_blocklen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类virtualsmartcard.CryptoUtils
的用法示例。
在下文中一共展示了CryptoUtils.get_cipher_blocklen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: encipher
# 需要导入模块: from virtualsmartcard import CryptoUtils [as 别名]
# 或者: from virtualsmartcard.CryptoUtils import get_cipher_blocklen [as 别名]
def encipher(self, p1, p2, data):
"""
Encipher data using key, algorithm, IV and Padding specified
by the current Security environment.
:returns: raw data (no TLV coding).
"""
algo = self.ct.algorithm
key = self.ct.key
if key == None or algo == None:
raise SwError(SW["ERR_CONDITIONNOTSATISFIED"])
else:
padded = vsCrypto.append_padding(vsCrypto.get_cipher_blocklen(algo), data)
crypted = vsCrypto.encrypt(algo, key, padded, self.ct.iv)
return crypted
示例2: external_authenticate
# 需要导入模块: from virtualsmartcard import CryptoUtils [as 别名]
# 或者: from virtualsmartcard.CryptoUtils import get_cipher_blocklen [as 别名]
def external_authenticate(self, p1, p2, data):
"""
Authenticate the terminal to the card. Check whether Terminal correctly
encrypted the given challenge or not
"""
if self.last_challenge is None:
raise SwError(SW["ERR_CONDITIONNOTSATISFIED"])
key = self._get_referenced_key(p1, p2)
if p1 == 0x00: #No information given
cipher = get_referenced_cipher(self.cipher)
else:
cipher = get_referenced_cipher(p1)
blocklen = vsCrypto.get_cipher_blocklen(cipher)
reference = vsCrypto.append_padding(blocklen, self.last_challenge)
reference = vsCrypto.encrypt(cipher, key, reference)
if(reference == data):
#Invalidate last challenge
self.last_challenge = None
return SW["NORMAL"], ""
else:
raise SwError(SW["WARN_NOINFO63"])