Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javacard key mint 200 master with factory attestation t0 fix #247

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void handleDeviceBooted() {
@Override
public void process(APDU apdu) {
try {
receiveLen[0] = apdu.setIncomingAndReceive();
handleDeviceBooted();
// If this is select applet apdu which is selecting this applet then return
if (apdu.isISOInterindustryCLA()) {
Expand Down Expand Up @@ -490,7 +491,7 @@ private void processProvisionAttestationKey(APDU apdu) {

private void processProvisionAttestationCertDataCmd(APDU apdu) {
byte[] srcBuffer = apdu.getBuffer();
short recvLen = apdu.setIncomingAndReceive();
short recvLen = receiveLen[0];
short srcOffset = apdu.getOffsetCdata();
short bufferLength = apdu.getIncomingLength();
short bufferStartOffset = repository.allocReclaimableMemory(bufferLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void handleDeviceBooted() {
@Override
public void process(APDU apdu) {
try {
receiveLen[0] = apdu.setIncomingAndReceive();
handleDeviceBooted();
// If this is select applet apdu which is selecting this applet then return
if (apdu.isISOInterindustryCLA()) {
Expand Down Expand Up @@ -486,7 +487,7 @@ private void processProvisionAttestationKey(APDU apdu) {

private void processProvisionAttestationCertDataCmd(APDU apdu) {
byte[] srcBuffer = apdu.getBuffer();
short recvLen = apdu.setIncomingAndReceive();
short recvLen = receiveLen[0];
short srcOffset = apdu.getOffsetCdata();
short bufferLength = apdu.getIncomingLength();
short bufferStartOffset = repository.allocReclaimableMemory(bufferLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public class KMKeymasterApplet extends Applet implements AppletEvent, ExtendedLe
protected static short[] tmpVariables;
protected static short[] data;
protected static byte[] wrappingKey;
protected static short[] receiveLen;

/**
* Registers this applet.
Expand All @@ -311,6 +312,7 @@ protected KMKeymasterApplet(KMSEProvider seImpl) {
tmpVariables =
JCSystem.makeTransientShortArray(TMP_VARIABLE_ARRAY_SIZE, JCSystem.CLEAR_ON_DESELECT);
wrappingKey = JCSystem.makeTransientByteArray((short)(WRAPPING_KEY_SIZE+1), JCSystem.CLEAR_ON_RESET);
receiveLen = JCSystem.makeTransientShortArray((short) 1, JCSystem.CLEAR_ON_RESET);
resetWrappingKey();
opTable = new KMOperationState[MAX_OPERATIONS_COUNT];
short index = 0;
Expand Down Expand Up @@ -916,7 +918,7 @@ public void sendOutgoing(APDU apdu, KMAttestationCert cert, short certStart, sho
*/
public static short receiveIncoming(APDU apdu, short reqExp) {
byte[] srcBuffer = apdu.getBuffer();
short recvLen = apdu.setIncomingAndReceive();
short recvLen = receiveLen[0];
short srcOffset = apdu.getOffsetCdata();
// TODO add logic to handle the extended length buffer. In this case the memory can be reused
// from extended buffer.
Expand Down