Commit b11b5040 authored by Josh Ji's avatar Josh Ji

code review

getName from PassportApplet
parent 313e68ad
......@@ -38,7 +38,7 @@ javacard{
aid 'A0000006472F0001'
}
dependencies{
local {// 這邊的路徑建議用絕對路徑
local {// 這邊的路徑建議用絕對路徑,用相對路徑gradle找得到,但build的時候找不到
exps 'C:\\Users\\josh2\\Documents\\GitLab\\EID\\Fido2Applet\\lib\\javacard\\applet.exp'
jar 'C:\\Users\\josh2\\Documents\\GitLab\\EID\\Fido2Applet\\lib\\javacard\\applet.exp\\passport.jar'
}
......
No preview for this file type
This diff is collapsed.
......@@ -329,7 +329,7 @@ public class CTAP2 extends Applet implements ExtendedLength {
case ID_SECRET_GET_CX: // 0x51
getCx(apdu, tempVars[3]);
break;
case ID_SECRET_GET_PUKX_CX:
case ID_SECRET_GET_PUKX_CX: // 0x52
getPuKxCx(apdu, tempVars[3]);
break;
case ID_SECRET_DUMP_ALL: // 0x5F
......
......@@ -7,6 +7,7 @@ import javacard.security.KeyBuilder;
import javacard.security.MessageDigest;
import javacardx.crypto.Cipher;
import josh.passport.ShareName;
import josh.passport.SharePIN;
/**
......@@ -189,18 +190,22 @@ public class IDSecret {
// encoder.encodeByteString(hmac, (short)0, (short)hmac.length );
// tempBufferLength = generateExtensions();
// testSharedObjects(apduBuffer);
encoder.encodeTextString(Utf8Strings.UTF8_TEMP, (short)0, (short)Utf8Strings.UTF8_TEMP.length);
encoder.encodeByteString(tempBuffer, (short)0, (short)tempBuffer.length);
return encoder.getCurrentOffset();
}
private void testSharedPIN(byte[] apduBuffer){
private void testSharedObjects(byte[] apduBuffer){
byte[] aid = new byte[]{(byte)0xa0,(byte)0x00,(byte)0x00,(byte)0x02,(byte)0x47,(byte)0x10,(byte)0x01};
AID passportAID = JCSystem.lookupAID(aid, (short)0,(byte)aid.length);
SharePIN sharePIN = (SharePIN) JCSystem.getAppletShareableInterfaceObject(passportAID,(byte)0x00);
ShareName shareName = (ShareName) JCSystem.getAppletShareableInterfaceObject(passportAID,(byte)0x00);
short length = 0;
byte[] sharedPIN = new byte[]{'h','e','l','l','o','_','j','o','s','h'};
......@@ -208,14 +213,25 @@ public class IDSecret {
try{
if(sharePIN != null) {
//must use apdu buffer to transmit and receive data
sharePIN.setSharedPIN(apduBuffer, (short)0, (short)sharedPIN.length );
// sharePIN.setSharedPIN(apduBuffer, (short)0, (short)sharedPIN.length );
length = sharePIN.getSharedPIN(apduBuffer, (short) 0);
Util.arrayCopy(apduBuffer, (short)0, tempBuffer, (short)0, length );
//this will fail
// sharePIN.getSharedPIN(tempBuffer, (short)0);
if(length < 0)
pushTempBuffer(new byte[]{'n','o','_','P','I','N'}, (short)0, (short)6);
else
pushTempBuffer(apduBuffer, (short)0, length);
}else{
pushTempBuffer(new byte[]{'P','N'}, (short)0, (short)2);
}
if(shareName != null){
length = shareName.getName(apduBuffer, (short)0);
if(length < 0)
pushTempBuffer(new byte[]{'n','o','_','N','A','M','E'}, (short)0, (short)7);
else
pushTempBuffer(apduBuffer, (short)0, length);
}else{
pushTempBuffer(new byte[]{'N','N'}, (short)0, (short)2);
}
}catch (Exception e){
tempBuffer[0] = 'a';
}
......
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