0

我一直在研究 hid omnikey 5325 cl 并试图获得 ATR 值。我在 Ubuntu 上使用 pcscd 和 pyscard 库。系统使用 T0 协议自动获取 ATR,但我需要 RAW 返回。在使用helloprox或omnikey官方软件的windows上,我可以得到我需要的东西,但是在ubuntu上,即使我改变了协议但ATR没有改变。

这是我使用的代码:

class PrintObserver(CardObserver):

"""A simple card observer that is notified
when cards are inserted/removed from the system and
prints the list of cards
"""

def update(self, observable, actions):
    (addedcards, removedcards) = actions
    for card in addedcards:
       card.connection=card.createConnection()
       card.connection.connect(protocol=CardConnection.RAW_protocol)

    binary_atr=bin(int(toHexString(card.connection.getATR()).replace(" ",""), 16))

       binary_atr=binary_atr[len(binary_atr)-24:len(binary_atr)-1]
       print int(binary_atr,2)

    for card in removedcards:
        print "-Removed: ", toHexString(card.atr)


if __name__ == '__main__':
    cardmonitor = CardMonitor()
    cardobserver = PrintObserver()
    cardmonitor.addObserver(cardobserver)

#Get Ports
config=ConfigParser.ConfigParser()
config.read('../config.ini')
Read_Port=int(config.get('CardReaderSocketPorts','Read',0))
Write_Port=int(config.get('CardReaderSocketPorts','Write',0))

# Initialise socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = ('localhost', Read_Port)
return_address = ('localhost', Write_Port)
sock.bind(server_address)

while 1:
  message, address = sock.recvfrom(4096)
  if message:
    parsed_json=json.loads(message)

    #Single Line
    if parsed_json['set'].upper()=="Stop":
        sock.sendto('{"success":"True"}',return_address)        
        break


# don't forget to remove observer, or the
# monitor will poll forever...
cardmonitor.deleteObserver(cardobserver)
4

2 回答 2

0

一些可能会有所帮助的注意事项,即使它们没有添加到完整的答案中:

  • 您正在使用非接触式卡片或标签
  • 这些标签没有ATR,但取决于协议,例如 ATQB 或 ATS,它们的结构完全不同。
  • PCSC 是一个过时的软件概念,它严格要求ATR
  • 因此非接触式读卡器制造商必须根据从卡中获得的信息发明一种 ATR
  • 您的软件接收到的“ATR”是本发明的结果。
  • Omnikey 显然使用 Windows 注册表来控制发明过程,这显然是一种不可移植的方法。

所以我的建议是,联系 Omnikey 支持,如何从 Linux 开始。根据我的经验,他们是合作的。

于 2016-06-28T20:14:50.783 回答
0

联系 Omnikey 支持后,问题得到解决。正如在开发人员指南中一样,我正在寻找配置文件“/etc/cmrfid.ini”来更改代理格式。文件名改为“/etc/Omnikey.ini”

于 2016-06-30T10:46:14.090 回答