Implementing of javacardx.biometry
Posted: Tue Aug 23, 2016 6:26 am
Hello everyone,
I want to implement javacardx.biometry.OwnerBioTemplate interface. I wrote the sample code that compile and convert to by JCDK 2.2.2. When i want to load and install to the card by GPShell i get the error code 0x6438 (Imported package not found). But when i comment the " implements OwnerBioTemplate" and "implements SharedBioTemplate", the applet load and install to the card successfully.
the sample code is:
import javacard.framework.*;
import javacardx.biometry.*;
public class bioServerApplet extends Applet implements SharedBioTemplate {
public final static byte CLA = (byte)0xCF;
public final static byte INS_ENROLL = (byte)0x10;
public final static byte MATCH_TRY_LIMIT = (byte)5;
private OwnerBioTemplate impl;
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new bioServerApplet(bArray,bOffset,bLength);
}
private bioServerApplet(byte[] bArray, short bOffset, byte bLength) {
register(bArray, bOffset, bLength);
byte aidLen = bArray[bOffset];
if (aidLen== (byte)0){
register();
} else {
register(bArray, (short)(bOffset+1), aidLen);
}
impl = BioBuilder.buildBioTemplate(BioBuilder.PASSWORD,MATCH_TRY_LIMIT);
}
public void process(APDU apdu){
}
public void enrollData(APDU apdu){
byte []buffer = apdu.getBuffer();
short bytesRead = apdu.setIncomingAndReceive();
impl.init(buffer, ISO7816.OFFSET_CDATA, bytesRead);
impl.doFinal();
//enrollment complete
}
//--- the nethods below implement the SharedBioTemplate interface
public boolean isInitialized(){
return impl.isInitialized();
// return true;
}
public boolean isValidated(){
return impl.isValidated();
//return true;
}
public void reset(){
impl.reset();
}
public byte getTriesRemaining(){
return impl.getTriesRemaining();
//return (byte) 0x33;
}
public byte getBioType(){
return impl.getBioType();
//return (byte) 0x33;
}
public short getVersion(byte[] dest, short offset){
return impl.getVersion(dest,offset);
//return (short) 33;
}
public short getPublicTemplateData(short publicOffset, byte[] dest,
short destOffset,
short length) throws BioException{
return impl.getPublicTemplateData(publicOffset,dest,destOffset,length);
//return (short) 33;
}
public short initMatch(byte[] candidate, short offset, short length)
throws BioException{
return impl.initMatch(candidate,offset,length);
//return (short) 33;
}
public short match(byte[] candidate, short offset, short length)
throws BioException{
return impl.match(candidate,offset,length);
//return (short) 33;
}
}
the OwnerBioTemplate implementation is:
import javacardx.biometry.*;
public class OwnerBioTemplateImpl implements OwnerBioTemplate{
public void init(byte[] bytes, short s, short s1) throws BioException {
}
public void update(byte[] bytes, short s, short s1) throws BioException {
}
public void doFinal() throws BioException {
}
public void resetUnblockAndSetTryLimit(byte b) throws BioException {
}
public boolean isInitialized() {
return true;
}
public boolean isValidated() {
return true;
}
public void reset() {
}
public byte getTriesRemaining() {
return 0x33;
}
public byte getBioType() {
return 0x33;
}
public short getVersion(byte[] bytes, short s) {
return 33;
}
public short getPublicTemplateData(short s, byte[] bytes, short s1, short s2) throws BioException {
return 33;
}
public short initMatch(byte[] bytes, short s, short s1) throws BioException {
return 33;
}
public short match(byte[] bytes, short s, short s1) throws BioException {
return 33;
}
}
install -file bio.cap -instParam 00 -priv 00 -AID A00000030500001000 -pkgAID A00
0000305 -instAID A00000030500001000
Command --> 80E602001805A00000030508A0000000030000000006EF04C60204100000
Wrapped command --> 84E602002005A00000030508A0000000030000000006EF04C602041000B6
F6AE609D69F16C00
Response <-- 009000
Command --> 80E80000EFC482040201000FDECAFFED010204000105A00000030502001F000F001F
000D001F0032007B0103000A0025000001AB00000000000003010004001F03000107A00000006200
01020107A0000000620202030107A000000062010103000D0109A00000030500001000003D06007B
02800000FF00010D00000008000B000E001100140018001C001F00240029002E0033003881000906
050B090A07080C0D81010D06050B090A07080C0D01020304438203010001070B0000007B007E009C
00A600B000BA00C400CE00DA00E900F68100090A090F0D0E0B0C10118202008102090A090F0D0E0B
0C101107010300011018
Wrapped command --> 84E80000F7C482040201000FDECAFFED010204000105A00000030502001F
000F001F000D001F0032007B0103000A0025000001AB00000000000003010004001F03000107A000
0000620001020107A0000000620202030107A000000062010103000D0109A0000003050000100000
3D06007B02800000FF00010D00000008000B000E001100140018001C001F00240029002E00330038
81000906050B090A07080C0D81010D06050B090A07080C0D01020304438203010001070B0000007B
007E009C00A600B000BA00C400CE00DA00E900F68100090A090F0D0E0B0C10118202008102090A09
0F0D0E0B0C10110701030001101892A80583FE545E26
Response <-- 6438
load() returns 0x80206438 (Unknown ISO7816 error: 0x6438)
Anyone can help me to solve my problem?
I want to implement javacardx.biometry.OwnerBioTemplate interface. I wrote the sample code that compile and convert to by JCDK 2.2.2. When i want to load and install to the card by GPShell i get the error code 0x6438 (Imported package not found). But when i comment the " implements OwnerBioTemplate" and "implements SharedBioTemplate", the applet load and install to the card successfully.
the sample code is:
import javacard.framework.*;
import javacardx.biometry.*;
public class bioServerApplet extends Applet implements SharedBioTemplate {
public final static byte CLA = (byte)0xCF;
public final static byte INS_ENROLL = (byte)0x10;
public final static byte MATCH_TRY_LIMIT = (byte)5;
private OwnerBioTemplate impl;
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new bioServerApplet(bArray,bOffset,bLength);
}
private bioServerApplet(byte[] bArray, short bOffset, byte bLength) {
register(bArray, bOffset, bLength);
byte aidLen = bArray[bOffset];
if (aidLen== (byte)0){
register();
} else {
register(bArray, (short)(bOffset+1), aidLen);
}
impl = BioBuilder.buildBioTemplate(BioBuilder.PASSWORD,MATCH_TRY_LIMIT);
}
public void process(APDU apdu){
}
public void enrollData(APDU apdu){
byte []buffer = apdu.getBuffer();
short bytesRead = apdu.setIncomingAndReceive();
impl.init(buffer, ISO7816.OFFSET_CDATA, bytesRead);
impl.doFinal();
//enrollment complete
}
//--- the nethods below implement the SharedBioTemplate interface
public boolean isInitialized(){
return impl.isInitialized();
// return true;
}
public boolean isValidated(){
return impl.isValidated();
//return true;
}
public void reset(){
impl.reset();
}
public byte getTriesRemaining(){
return impl.getTriesRemaining();
//return (byte) 0x33;
}
public byte getBioType(){
return impl.getBioType();
//return (byte) 0x33;
}
public short getVersion(byte[] dest, short offset){
return impl.getVersion(dest,offset);
//return (short) 33;
}
public short getPublicTemplateData(short publicOffset, byte[] dest,
short destOffset,
short length) throws BioException{
return impl.getPublicTemplateData(publicOffset,dest,destOffset,length);
//return (short) 33;
}
public short initMatch(byte[] candidate, short offset, short length)
throws BioException{
return impl.initMatch(candidate,offset,length);
//return (short) 33;
}
public short match(byte[] candidate, short offset, short length)
throws BioException{
return impl.match(candidate,offset,length);
//return (short) 33;
}
}
the OwnerBioTemplate implementation is:
import javacardx.biometry.*;
public class OwnerBioTemplateImpl implements OwnerBioTemplate{
public void init(byte[] bytes, short s, short s1) throws BioException {
}
public void update(byte[] bytes, short s, short s1) throws BioException {
}
public void doFinal() throws BioException {
}
public void resetUnblockAndSetTryLimit(byte b) throws BioException {
}
public boolean isInitialized() {
return true;
}
public boolean isValidated() {
return true;
}
public void reset() {
}
public byte getTriesRemaining() {
return 0x33;
}
public byte getBioType() {
return 0x33;
}
public short getVersion(byte[] bytes, short s) {
return 33;
}
public short getPublicTemplateData(short s, byte[] bytes, short s1, short s2) throws BioException {
return 33;
}
public short initMatch(byte[] bytes, short s, short s1) throws BioException {
return 33;
}
public short match(byte[] bytes, short s, short s1) throws BioException {
return 33;
}
}
install -file bio.cap -instParam 00 -priv 00 -AID A00000030500001000 -pkgAID A00
0000305 -instAID A00000030500001000
Command --> 80E602001805A00000030508A0000000030000000006EF04C60204100000
Wrapped command --> 84E602002005A00000030508A0000000030000000006EF04C602041000B6
F6AE609D69F16C00
Response <-- 009000
Command --> 80E80000EFC482040201000FDECAFFED010204000105A00000030502001F000F001F
000D001F0032007B0103000A0025000001AB00000000000003010004001F03000107A00000006200
01020107A0000000620202030107A000000062010103000D0109A00000030500001000003D06007B
02800000FF00010D00000008000B000E001100140018001C001F00240029002E0033003881000906
050B090A07080C0D81010D06050B090A07080C0D01020304438203010001070B0000007B007E009C
00A600B000BA00C400CE00DA00E900F68100090A090F0D0E0B0C10118202008102090A090F0D0E0B
0C101107010300011018
Wrapped command --> 84E80000F7C482040201000FDECAFFED010204000105A00000030502001F
000F001F000D001F0032007B0103000A0025000001AB00000000000003010004001F03000107A000
0000620001020107A0000000620202030107A000000062010103000D0109A0000003050000100000
3D06007B02800000FF00010D00000008000B000E001100140018001C001F00240029002E00330038
81000906050B090A07080C0D81010D06050B090A07080C0D01020304438203010001070B0000007B
007E009C00A600B000BA00C400CE00DA00E900F68100090A090F0D0E0B0C10118202008102090A09
0F0D0E0B0C10110701030001101892A80583FE545E26
Response <-- 6438
load() returns 0x80206438 (Unknown ISO7816 error: 0x6438)
Anyone can help me to solve my problem?