使用 Omnikey 5022 读取 PACS(原始韦根)数据

Posted

技术标签:

【中文标题】使用 Omnikey 5022 读取 PACS(原始韦根)数据【英文标题】:Reading PACS (raw Wiegand) data with Omnikey 5022 【发布时间】:2019-07-01 10:32:37 【问题描述】:

我正在开发一个连接到 HID Omnikey 5022 读卡器的 Java 应用程序。我需要的是读取 PACS 位(原始韦根数据)。

我对这个问题有完全相同的问题,我也可以使用 PACS Probe 应用程序查看数据:

How to read Smart Card data

不幸的是,提供的答案对我不起作用。

这是我从 PACS Probe 中得到的:

读卡器:HID Global OMNIKEY 5022 智能卡读卡器 0 卡类型:PicoPass 32KS (8x2 + 16) 卡序列号(CSN、UID):32966202F8FF12E0(十六进制) PACS 位(原始韦根)数据:000000310BC53938(十六进制)

我已经尝试过我在 Omnikey 5023 指南中找到的命令,令人惊讶的是它返回了一些数据,但这不是我需要的。

那个命令是:

commandAPDU = new CommandAPDU(new byte[]  (byte) 0xFF, (byte) 0x70, (byte) 0x07, (byte) 0x6B, (byte) 0x07,
                (byte) 0xA0, (byte) 0x05, (byte) 0xBE, (byte) 0x03, (byte) 0x80, (byte) 0x01, (byte) 0x04, (byte) 0x00 ); // Read PACS 5023

它返回这个:

9E020003 // 我需要 000000310BC53938

感谢任何帮助,因为我是智能卡开发的新手。 提前致谢。

【问题讨论】:

【参考方案1】:

您从阅读器获得的响应 APDU 是不受支持的专有命令的错误代码。

您需要安全会话才能使用 OMNIKEY 5022 或 OMNIKEY 5023 读卡器访问 PACS 位数据。

除非您有适合此阅读器的文档,否则我可能会坚持使用卡序列号(UID、CSN)并使用 PC/SC(或 pcsclite)的 Java 包装器来连接阅读器和卡。

然后发出(通过 SCardTransmit(FFCA0000 APDU) 以获取来自https://PACSprobe.com 的示例输出中显示的 UID (32966202F8FF12E0)

对于 Java:使用 smartcardio 库。这是原生 PC/SC 的一个很好的包装器

将安全通道协议移植到 Java 需要大量工作。调用第三方库可能更容易。

【讨论】:

嗨,马克,感谢您的回答。我已经在使用 smartcardio lib。我已经可以使用该库获得 UID 和 ATR,但坚持其中一个对我来说不是选项,因为我们需要只能在 PACS 位中找到的设施代码 (FAC) 和卡号 (CN)。我也可以成功进入和退出透明会话。我唯一需要的是 PACS 位,5022 阅读器文档中没有记录。感谢您为我指明正确的方向。【参考方案2】:

我能够使用 javax.smartcardio,并使用如下代码获取韦根数据。最后您可以看到打印的设施代码和卡号。

TerminalFactory terminalFactory = TerminalFactory.getDefault();

CardTerminals cardTerminals = terminalFactory.terminals();

List<CardTerminal> terminalList = cardTerminals.list();

CardTerminal cardTerminal = terminalList.get(0);
cardTerminal.waitForCardPresent(10 * 1000); // wait 10 seconds
Card card = cardTerminal.connect("*");
System.out.println("Card: " + card);
CardChannel channel = card.getBasicChannel();

byte[] aid =  (byte) 0xA0, (byte) 0x05, (byte) 0xA1, (byte) 0x03, (byte) 0x80, (byte) 0x01, (byte) 0x04 ;
CommandAPDU apdu = new CommandAPDU(0xFF, (byte) 112, (byte) 7, (byte) 107, aid, 256);
ResponseAPDU r = channel.transmit(apdu);
byte[] bytesOut = r.getBytes();

int num1 = (int) bytesOut[3];
if (bytesOut.length - 6 != num1)
System.out.println("problem");

int numberOfBitsShifted = (int) bytesOut[4];
int num2 = num1 - 1;

byte[] newBytesArr = Arrays.copyOfRange(bytesOut, 5, 5 + num2);
if (newBytesArr.length != num2)
    System.out.println("problem");

ByteBuffer wrapped = ByteBuffer.wrap(newBytesArr);
int num = wrapped.getInt();
int first26 = num >> 6;
int withoutParity = first26 >> 1;

int cardNumber = withoutParity & 0xffff;
int facilityCode = (withoutParity >> 16) & 0xff;

System.out.println(facilityCode);
System.out.println(cardNumber);

【讨论】:

以上是关于使用 Omnikey 5022 读取 PACS(原始韦根)数据的主要内容,如果未能解决你的问题,请参考以下文章

DICOM医学图像处理:WEB PACS初谈

DICOM医学图像处理:WEB PACS初谈

如何访问 Omnikey 3121 智能卡读卡器

json 我的OmniKey搜索https://github.com/marioestrada/safari-omnikey

用于超轻型 C 的 Omnikey 5X21 APDU 写入命令

如何从 HID omnikey 获取智能卡的 TAR