enable msg to be either string or bytes
This commit is contained in:
@@ -504,7 +504,7 @@ class VirtualICC(object):
|
|||||||
def __sendToVPICC(self, msg):
|
def __sendToVPICC(self, msg):
|
||||||
""" Send a message to the vpcd """
|
""" Send a message to the vpcd """
|
||||||
if isinstance(msg, str):
|
if isinstance(msg, str):
|
||||||
self.sock.sendall(struct.pack('!H', len(msg)) + msg.encode())
|
self.sock.sendall(struct.pack('!H', len(msg)) + bytes(map(ord,msg)))
|
||||||
else:
|
else:
|
||||||
self.sock.sendall(struct.pack('!H', len(msg)) + msg)
|
self.sock.sendall(struct.pack('!H', len(msg)) + msg)
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,10 @@ class RelayOS(SmartcardOS):
|
|||||||
|
|
||||||
def execute(self, msg):
|
def execute(self, msg):
|
||||||
# sendCommandAPDU() expects a list of APDU bytes
|
# sendCommandAPDU() expects a list of APDU bytes
|
||||||
apdu = map(ord, msg)
|
if isinstance(msg,str):
|
||||||
|
apdu = map(ord, msg)
|
||||||
|
else:
|
||||||
|
apdu = list(msg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rapdu, sw1, sw2 = self.session.sendCommandAPDU(apdu)
|
rapdu, sw1, sw2 = self.session.sendCommandAPDU(apdu)
|
||||||
|
|||||||
Reference in New Issue
Block a user