Commit 574170ce authored by Josh Ji's avatar Josh Ji

add ShareName.java, delete getSecret() in SharePIN.java

add byte[] birthDay,expiryDay in PassportApplet.java
parent 403136aa
......@@ -40,7 +40,7 @@ import javacardx.crypto.Cipher;
*
* @version $Revision$
*/
public class PassportApplet extends Applet implements ISO7816, SharePIN {
public class PassportApplet extends Applet implements ISO7816, SharePIN, ShareName {
static byte volatileState[];
static byte persistentState;
......@@ -139,6 +139,8 @@ public class PassportApplet extends Applet implements ISO7816, SharePIN {
private byte[] ssc;
private byte[] documentNumber;
private byte[] birthDay;
private byte[] expiryDay;
private FileSystem fileSystem;
......@@ -550,6 +552,12 @@ public class PassportApplet extends Applet implements ISO7816, SharePIN {
(short) 0, docNumberLength);
documentNumber[docNumberLength] = PassportInit.checkDigit(documentNumber,(short)0, docNumberLength);
birthDay = new byte[birthLength];
Util.arrayCopyNonAtomic(buffer, birthOffset, birthDay, (short)0, birthLength);
expiryDay = new byte[expiryLength];
Util.arrayCopyNonAtomic(buffer, expiryOffset, expiryDay, (short)0, expiryLength);
short keySeed_offset = passportInit.computeKeySeed(buffer, docNumberOffset,
docNumberLength, birthOffset, birthLength, expiryOffset, expiryLength);
......@@ -1109,15 +1117,14 @@ public class PassportApplet extends Applet implements ISO7816, SharePIN {
}
byte[] sharedPIN = new byte[]{'t','e','s','t','p','i','n',};
final short sharedSecret = (short)87;
byte[] sharedPIN;
@Override
public Shareable getShareableInterfaceObject(AID aid, byte b) {
if(aid.equals(new byte[]{(byte)0xa0,(byte)0x00,(byte)0x00,(byte)0x06,(byte)0x47,(byte)0x2f,(byte)0x00,(byte)0x01}, (short)0, (byte)0)){
return this;
}
return this;
return null;
}
@Override
......@@ -1129,12 +1136,35 @@ public class PassportApplet extends Applet implements ISO7816, SharePIN {
@Override
public short getSharedPIN(byte[] apduBuffer, short offset) {
Util.arrayCopy(sharedPIN, (short)0 , apduBuffer, offset, (short) sharedPIN.length );
return (short)sharedPIN.length;
if(sharedPIN != null) {
Util.arrayCopy(sharedPIN, (short) 0, apduBuffer, offset, (short) sharedPIN.length);
return (short)(offset+sharedPIN.length);
}else{
if (birthDay != null && birthDay.length != 0) {
sharedPIN = new byte[birthDay.length];
Util.arrayCopy(birthDay, (short) 0, sharedPIN, (short)0, (short) birthDay.length);
Util.arrayCopy(sharedPIN, (short) 0, apduBuffer, offset, (short) sharedPIN.length);
return (short) (offset+sharedPIN.length);
} else {
return (short) -1;
}
}
}
@Override
public void setName(byte[] apduBuffer, short offset, short length) {
// ICAO 9303 part 10, DG1 TD3 format, field:"Name of holder" offset:5 length:39
if(length < (short)39)
Util.arrayCopy(apduBuffer, offset, fileSystem.getFile(FileSystem.EF_DG1_FID), (short)5, length);
else
Util.arrayCopy(apduBuffer, offset, fileSystem.getFile(FileSystem.EF_DG1_FID), (short)5, (short)39);
}
@Override
public short getSecret() {
return sharedSecret;
public short getName(byte[] apduBuffer, short offset) {
// ICAO 9303 part 10, DG1 TD3 format, field:"Name of holder" offset:5 length:39
Util.arrayCopy(fileSystem.getFile(FileSystem.EF_DG1_FID), (short)5, apduBuffer, offset, (short)39);
return (short)(offset+39);
}
}
package josh.passport;
import javacard.framework.Shareable;
public interface ShareName extends Shareable {
void setName(byte[] apduBuffer, short offset, short length);
short getName(byte[] apduBuffer, short offset);
}
......@@ -5,6 +5,4 @@ import javacard.framework.Shareable;
public interface SharePIN extends Shareable {
void setSharedPIN(byte[] apduBuffer, short offset, short length);
short getSharedPIN(byte[] apduBuffer, short offset);
short getSecret();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment