don't print raw binary data

This commit is contained in:
Frank Morgner
2015-08-12 00:49:24 +02:00
parent 1b4139adff
commit 799894c83a

View File

@@ -44,44 +44,33 @@ class TestSmartcardSAM(unittest.TestCase):
def test_internal_authenticate(self):
sw, challenge = self.myCard.get_challenge(0x00, 0x00, "")
print("Before encryption: " + challenge)
blocklen = vsCrypto.get_cipher_blocklen("DES3-ECB")
padded = vsCrypto.append_padding(blocklen, challenge)
sw, result_data = self.myCard.internal_authenticate(0x00, 0x00, padded)
print("Internal Authenticate status code: %x" % sw)
self.assertEquals(sw, SW["NORMAL"])
def test_external_authenticate(self):
sw, challenge = self.myCard.get_challenge(0x00, 0x00, "")
print("Before encryption: " + challenge)
blocklen = vsCrypto.get_cipher_blocklen("DES3-ECB")
padded = vsCrypto.append_padding(blocklen, challenge)
sw, result_data = self.myCard.internal_authenticate(0x00, 0x00, padded)
sw, result_data = self.myCard.external_authenticate(0x00, 0x00, result_data)
print ("After external authenticate: " + result_data)
self.assertEquals(sw, SW["NORMAL"])
def test_security_environment(self):
print "Testvektor = %s" % self.password
hash = self.secEnv.hash(0x90, 0x80, self.password)
#The API should be changed so that the hash function returns SW_NORMAL
#print "SW after hashing = %s" % sw
print "Hash = %s" % hash
self.secEnv.ct.key = hash[:16]
crypted = self.secEnv.encipher(0x00, 0x00, self.password)
#The API should be changed so that the encipher function returns SW_NORMAL
#print "SW after encryption = %s" % sw
plain = self.secEnv.decipher(0x00, 0x00, crypted)
#The API should be changed so that the decipher function returns SW_NORMAL
#print "SW after decryption = %s" % sw
print "Testvektor after en- and deciphering: %s" % plain
#self.assertEqual(plain, self.password)
#secEnv.decipher doesn't strip padding. Should it?
self.secEnv.ct.algorithm = "RSA" #should this really be secEnv.ct? probably rather secEnv.dst
self.secEnv.dst.keylength = 1024
sw, pk = self.secEnv.generate_public_key_pair(0x00, 0x00, "")
#print "SW after keygen = %s" % swerror
#print "Public Key = %s" % pk
self.assertEquals(sw, SW["NORMAL"])
if __name__ == "__main__":