我打算从智能卡响应中解析BER-TLV格式来解释数据。
它类似于JACCAL,但在Objective-C或C++中
有没有人可以提供任何开源项目或参考资料来做这件事?
发布于 2012-12-01 03:21:22
这是一个解码ASN.1误码率格式的项目。https://github.com/chrisridd/asn1-dump/
主逻辑位于此文件中:https://github.com/chrisridd/asn1-dump/blob/master/berd.m
如果有足够的时间,在阅读标准:http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf http://luca.ntop.org/Teaching/Appunti/asn1.html之后,编写自己的解码器并不难
解码流程是这样的:读入标签、长度、值序列。
从标签中获取
- Data Class, usually be Universal(predefined type in standard like "Boolean","Sequence"...) and context-specific (to distinguish different field with same type).
- Primitive (like boolean and integer) or Constructed (usually is sequence). because constructed type can contains Primitive or Constructed type. maybe need recursive decoding.
- Tag Number, determine data types (boolean? integer? bitstring?)
- determine length of the contents to decode into (maybe need recursively decoding).
- length has two form (short and long). you'd better support both.
TLV值:要在当前级别中读取的实际值。如果这是一个构造的数据(如序列),该值将包含TLV的内部级别。
在标准(http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf)的末尾有一张图像显示了多个水平的TLV,也许可以更好地帮助您理解误码率。
在你读完标准后,最好的方法是: 1)找一些GUI查看器来查看一些BER证书文件,以熟悉它。搜索"ASN.1查看器“查找。2)开始查看代码https://github.com/chrisridd/asn1-dump/blob/master/berd.m
发布于 2012-11-25 22:08:49
tlve如何?http://tlve.sourceforge.net/
苹果的Tokend似乎也很有用:http://www.opensource.apple.com/source/Tokend/Tokend-36720/PIV/TLV.cpp
sourceforge上的jayacard是另一个处理这个问题的项目,现在看起来已经被抛弃了,但来源在这里:http://www.codeforge.com/read/7149/tlv.c__html
https://stackoverflow.com/questions/13487992
复制相似问题