Skip to content

Commit

Permalink
Add INS_GET_PRIV instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
dufkan committed Jul 18, 2021
1 parent 52cc7cc commit 20018eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion applet/src/main/java/applet/Consts.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class Consts {
public static final byte CLA_ED25519 = (byte) 0x00;
public static final byte INS_KEYGEN = (byte) 0xD0;
public static final byte INS_SIGN = (byte) 0xD1;
public static final byte INS_SETUP = (byte) 0xD2;
public static final byte INS_GET_PRIV = (byte) 0xD2;

public final static short SW_Exception = (short) 0xff01;
public final static short SW_ArrayIndexOutOfBoundsException = (short) 0xff02;
Expand Down
5 changes: 5 additions & 0 deletions applet/src/main/java/applet/MainApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public void process(APDU apdu) {
case Consts.INS_SIGN:
sign(apdu);
break;

case Consts.INS_GET_PRIV:
Util.arrayCopyNonAtomic(privateKey.as_byte_array(), (short) 0, apdu.getBuffer(), (short) 0, (short) 32);
apdu.setOutgoingAndSend((short) 0, (short) 32);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
Expand Down
2 changes: 2 additions & 0 deletions applet/src/test/java/tests/AppletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class AppletTest extends BaseTest {
public AppletTest() {
// Change card type here if you want to use physical card
setCardType(CardType.JCARDSIMLOCAL);
setSimulateStateful(true);
}

@BeforeAll
Expand Down Expand Up @@ -61,6 +62,7 @@ public void keygen_and_sign() throws Exception {
final CardManager cm = connect();

byte[] pubkeyBytes = keygen(cm);
cm.transmit(new CommandAPDU(Consts.CLA_ED25519, Consts.INS_GET_PRIV, 0, 0));

for(int j = 0; j < 256; ++j) {
byte[] data = new byte[32];
Expand Down

0 comments on commit 20018eb

Please sign in to comment.