Bugfixes: Fixed import error and incorrect method call

git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@475 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
oepen
2011-08-01 14:32:04 +00:00
parent e33544452f
commit 2c78e4ff64
2 changed files with 11 additions and 8 deletions

View File

@@ -622,21 +622,21 @@ if __name__ == "__main__":
card_crypto = binascii.a2b_hex("".join("8A D4 A9 2D 9B 6B 24 E0".split()))
session_key = get_session_key(default_key, host_chal, card_chal)
print "Session-Key: ", utils.hexdump(session_key)
print "Session-Key: ", hexdump(session_key)
print verify_card_cryptogram(session_key, host_chal, card_chal, card_crypto)
host_crypto = calculate_host_cryptogram(session_key, card_chal, host_chal)
print "Host-Crypto: ", utils.hexdump( host_crypto )
print "Host-Crypto: ", hexdump( host_crypto )
external_authenticate = binascii.a2b_hex("".join("84 82 01 00 10".split())) + host_crypto
print utils.hexdump(calculate_MAC(session_key, external_authenticate))
print hexdump(calculate_MAC(session_key, external_authenticate))
too_short = binascii.a2b_hex("".join("89 45 19 BF".split()))
padded = append_padding("DES3-ECB", too_short)
print "Padded data: " + utils.hexdump(padded)
print "Padded data: " + hexdump(padded)
unpadded = strip_padding("DES3-ECB", padded)
print "Without padding: " + utils.hexdump(unpadded)
print "Without padding: " + hexdump(unpadded)
teststring = "DEADBEEFistatsyksdvhihewohfwoehcowc8hw8rogfq8whv75tsgohsav8wress"
foo = append_padding("AES", teststring)

View File

@@ -644,14 +644,14 @@ class Secure_Messaging(object):
SM_Class["CRYPTOGRAM_PLAIN_TLV_INCLUDING_SM_ODD"]):
#The Cryptogram includes SM objects.
#We decrypt them and parse the objects.
plain = decipher(tag, 0x80, value)
plain = self.decipher(tag, 0x80, value)
#TODO: Need Le = length
return_data.append(self.parse_SM_CAPDU(plain, header_authentication))
elif tag in (SM_Class["CRYPTOGRAM_PLAIN_TLV_NO_SM"],
SM_Class["CRYPTOGRAM_PLAIN_TLV_NO_SM_ODD"]):
#The Cryptogram includes BER-TLV enconded plaintext.
#We decrypt them and return the objects.
plain = decipher(tag, 0x80, value)
plain = self.decipher(tag, 0x80, value)
return_data.append(plain)
elif tag in (SM_Class["CRYPTOGRAM_PADDING_INDICATOR"],
SM_Class["CRYPTOGRAM_PADDING_INDICATOR_ODD"]):
@@ -1004,14 +1004,17 @@ class Secure_Messaging(object):
#Private key
d = PublicKey.__getstate__()['d']
elif cipher == "DSA":
#Public key
#DSAParams
p = str(PublicKey.__getstate__()['p'])
q = str(PublicKey.__getstate__()['q'])
g = str(PublicKey.__getstate__()['g'])
#Public key
y = str(PublicKey.__getstate__()['y'])
#TODO: Actual encoding
#Private key
x = str(PublicKey.__getstate__()['x'])
#Add more algorithms here
if p1 & 0x02 == 0x02:
return SW["NORMAL"], result