def test_sign_1(self, card): digestinfo = rsa_keys.compute_digestinfo(PLAIN_TEXT1) try: r = card.cmd_pso(0x9e, 0x9a, digestinfo) except ValueError as e: r = e.args[0] assert r == "6982"
def test_sign_auth_1(self, card): digestinfo = rsa_keys.compute_digestinfo(PLAIN_TEXT1) r = card.cmd_internal_authenticate(digestinfo) sig = rsa_keys.compute_signature(2, digestinfo) sig_bytes = sig.to_bytes(int((sig.bit_length() + 7) / 8), byteorder='big') assert r == sig_bytes
def test_sign_1(self, card): digestinfo = rsa_keys.compute_digestinfo(PLAIN_TEXT1) r = card.cmd_pso(0x9e, 0x9a, digestinfo) sig = rsa_keys.compute_signature(0, digestinfo) sig_bytes = sig.to_bytes(int((sig.bit_length() + 7) / 8), byteorder='big') assert r == sig_bytes
def test_signature_authkey(card): msg = b"Sign me please to authenticate" pk = card.cmd_get_public_key(3) pk_info = (pk[9:9 + 256], pk[9 + 256 + 2:9 + 256 + 2 + 3]) digest = rsa_keys.compute_digestinfo(msg) sig = int(hexlify(card.cmd_internal_authenticate(digest)), 16) r = rsa_keys.verify_signature(pk_info, digest, sig) assert r
def test_signature_sigkey(card): msg = b"Sign me please" pk = card.cmd_get_public_key(1) pk_info = (pk[9:9 + 256], pk[9 + 256 + 2:9 + 256 + 2 + 3]) digest = rsa_keys.compute_digestinfo(msg) sig = int(hexlify(card.cmd_pso(0x9e, 0x9a, digest)), 16) r = rsa_keys.verify_signature(pk_info, digest, sig) assert r
def set_msg(content_str_repr): msg = ast.literal_eval(content_str_repr) scc.digestinfo = rsa_keys.compute_digestinfo(msg)
def test_sign_auth_1(card): digestinfo = rsa_keys.compute_digestinfo(PLAIN_TEXT1) r = card.cmd_internal_authenticate(digestinfo) sig = rsa_keys.compute_signature(2, digestinfo) sig_bytes = sig.to_bytes(int((sig.bit_length()+7)/8), byteorder='big') assert r == sig_bytes
def test_sign_1(card): digestinfo = rsa_keys.compute_digestinfo(PLAIN_TEXT1) r = card.cmd_pso(0x9e, 0x9a, digestinfo) sig = rsa_keys.compute_signature(0, digestinfo) sig_bytes = sig.to_bytes(int((sig.bit_length()+7)/8), byteorder='big') assert r == sig_bytes