声明: 本文所有code除摘自网络的已注明出处外,都是本人在个人时间进行练习的代码,系本人个人书写,没有copy自任何出处, 也与IBM, Eclipse, 以及任何其他组织无关,本人也不对其主张任何权利.
1. 如何判断一张卡是否被lock?
- 下面的字段不为空
RoamingInformationCard/InformationCardMetaData/PinDigest
2. 如何解锁?
2.1. 用户输入PIN code, 检测用户输入
String password = "12345678";
try {
byte[] byte_pw = password.getBytes("UTF-16LE");
MessageDigest md = MessageDigest.getInstance("SHA1");
md.update(byte_pw);
byte[] input_digest = md.digest();
byte[] stored_digest = ((PersonalCard)card).getPinDigest();
boolean equalsTo = true;
for(int i=0; i<input_digest.length; i++){
if(input_digest[i] != stored_digest[i]){
equalsTo = false;
}
}
System.out.println("User input a " + (equalsTo ? "correct": "invalid") + " PIN code");
第二步:从正确的密码导出key
从PIN code倒出key, 倒出算法为PBKDF1 (RFC-2898).
输入参数:
Salt - MasterKey字段的第1-16字节 (0字节为version num)
Count - MasterKey字段的第17-20字节
Key length - 32 octets
Hash function - SHA-256
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
sha256.update(byte_pw);
sha256.update(salt);
byte[] digestBytes = sha256.digest();
for (int i = 1; i < 1000; i++) {
sha256.update(digestBytes);
digestBytes = sha256.digest();
}
sha256.reset();
第三步: AES的Sample程序(来自
http://java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html)
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(128); // 192 and 256 bits may not be available
// Generate the secret key specs.
SecretKey skey = kgen.generateKey();
byte[] raw = skey.getEncoded();
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
// Instantiate the cipher
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted =
cipher.doFinal((args.length == 0 ?
"This is just an example" : args[0]).getBytes());
System.out.println("encrypted string: " + asHex(encrypted));
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] original =
cipher.doFinal(encrypted);
String originalString = new String(original);
System.out.println("Original string: " +
originalString + " " + asHex(original));
分享到:
相关推荐
Information Card的实现与改进,周海静,章洋,标识元系统以其安全性和可扩展性被应用在身份管理系统中。作为标识元系统的具体实现,Information Card框架以卡文件来表示数字身份标��
Pin Information for the Cyclone® II EP2C8 & EP2C8A Devices
Microsoft Symbol and Type Information/CodeView Debugging Information
描述了Alter公司的Cyclone系列器件EP1C6的管教信息
Samsung MCP Memory Code Information.
Salzburg Card Information
ASCII(American Standard Code for Information Interchange,美国信息互换标准代码,ASCⅡ)是基于拉丁字母的一套电脑编码系统。它主要用于显示现代英语和其他西欧语言。它是现今最通用的单字节编码系统,并等同于...
ASCII码,对于涉及程序设计人来说是必定要掌握的东西,电脑的处理也是也ASCII码为基础,所以本资源重不重要自己估量
Data Visualization Representing Information on Modern Web_Code 源码 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
有关epcis的文档(pdf) 已经相关的ppt文件
ISO/IEC 18004 Information technology — Automatic identification and data capture techniques — Bar code symbology — QR Code
Altera_Pin Information for the Cyclone:registered: IV EP4CE22 Device
Information security management, Part 1: Code of practice for information security management. It is identical with ISO/IEC 17799:2000, Information technology—Code of practice for information ...
VB实现文档信息提取技术代码VB code to achieve the document information extraction
vc编程实现解析文件全路径信息代码vc programming code parsing file full path information
DDI(Display Driver IC) Code Information.pdf
I started this utility to get some basic information about the hardware. After that I have received some emails from some of our fellow programmers, who are frequent visitors of this site, asking to ...
For more information about Jam, including a copy of the Jam Byte-Code compiler and additional documentation go to: http://www.jamisp.com/. Where Can I Learn More About Support for this Jam Player? ...
the customer is identified by inserting a plastic ATM card with a magnetic stripe or a plastic smartcard with a chip, that contains a unique card number and some security information, such as an ...
read system PCI、memmory、smbus、smbios、io...