Skip to content
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 numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@

import org.globalplatform.upgrade.Element;

import com.android.javacard.keymaster.KMMasterKey;

import javacard.security.AESKey;

public class KMAESKey implements KMMasterKey {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,6 @@

import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;

public class KMAndroidSEApplet extends KMKeymasterApplet implements OnUpgradeListener {

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,15 +36,6 @@
import javacardx.crypto.AEADCipher;
import javacardx.crypto.Cipher;

import com.android.javacard.keymaster.KMAESKey;
import com.android.javacard.keymaster.KMAttestationKey;
import com.android.javacard.keymaster.KMECPrivateKey;
import com.android.javacard.keymaster.KMError;
import com.android.javacard.keymaster.KMException;
import com.android.javacard.keymaster.KMHmacKey;
import com.android.javacard.keymaster.KMMasterKey;
import com.android.javacard.keymaster.KMPreSharedKey;

public class KMAndroidSEProvider implements KMSEProvider {

// static final variables
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,11 +15,6 @@
*/
package com.android.javacard.keymaster;

import com.android.javacard.keymaster.KMAESKey;
import com.android.javacard.keymaster.KMByteBlob;
import com.android.javacard.keymaster.KMECPrivateKey;
import com.android.javacard.keymaster.KMMasterKey;

import javacard.framework.JCSystem;
import javacard.framework.Util;
import javacard.security.AESKey;
Expand DownExpand Up@@ -144,7 +139,6 @@ public class KMAttestationCertImpl implements KMAttestationCert {
private static byte verifiedState;
private static short verifiedHash;
private static short issuer;
private static short signPriv;

private KMAttestationCertImpl() {
}
Expand DownExpand Up@@ -187,7 +181,6 @@ private static void init() {
verifiedState = 0;
rsaCert = true;
deviceLocked = 0;
signPriv = 0;
}

@Override
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,11 +17,6 @@

import org.globalplatform.upgrade.Element;

import com.android.javacard.keymaster.KMAESKey;
import com.android.javacard.keymaster.KMAttestationCert;
import com.android.javacard.keymaster.KMAttestationKey;

import javacard.security.AESKey;
import javacard.security.ECPrivateKey;
import javacard.security.KeyPair;

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,8 +17,6 @@

import org.globalplatform.upgrade.Element;

import com.android.javacard.keymaster.KMPreSharedKey;

import javacard.security.HMACKey;

public class KMHmacKey implements KMPreSharedKey, KMComputedHmacKey {
Expand Down
32 changes: 14 additions & 18 deletions Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,6 @@ public class KMKeymasterApplet extends Applet implements AppletEvent, ExtendedLe
private static final byte CLA_ISO7816_NO_SM_NO_CHAN = (byte) 0x80;
private static final short KM_HAL_VERSION = (short) 0x4000;
private static final short MAX_AUTH_DATA_SIZE = (short) 512;
private static final short DERIVE_KEY_INPUT_SIZE = (short) 256;
private static final short POWER_RESET_MASK_FLAG = (short) 0x4000;
// Magic number version
public static final byte KM_MAGIC_NUMBER = (byte) 0x81;
Expand DownExpand Up@@ -89,6 +88,17 @@ public class KMKeymasterApplet extends Applet implements AppletEvent, ExtendedLe
private static final byte[] OEM_UNLOCK_VERIFICATION_LABEL = { // "Enable RMA"
0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x52, 0x4d, 0x41
};
// Attestation IDs
private static final short[] ATTEST_ID_TAGS = {
KMType.ATTESTATION_ID_BRAND,
KMType.ATTESTATION_ID_DEVICE,
KMType.ATTESTATION_ID_IMEI,
KMType.ATTESTATION_ID_MANUFACTURER,
KMType.ATTESTATION_ID_MEID,
KMType.ATTESTATION_ID_MODEL,
KMType.ATTESTATION_ID_PRODUCT,
KMType.ATTESTATION_ID_SERIAL
};


// Possible states of the applet.
Expand DownExpand Up@@ -811,7 +821,6 @@ private void processAddRngEntropyCmd(APDU apdu) {

private void processSetVersionAndPatchLevels(APDU apdu) {
receiveIncoming(apdu);
byte[] scratchPad = apdu.getBuffer();
// Argument 1 OS Version
tmpVariables[0] = KMInteger.exp();
// Argument 2 OS Patch level
Expand DownExpand Up@@ -991,8 +1000,6 @@ private void processProvisionAttestationKey(APDU apdu) {

private void processProvisionOEMRootPublicKeyCmd(APDU apdu) {
receiveIncoming(apdu);
// Re-purpose the apdu buffer as scratch pad.
byte[] scratchPad = apdu.getBuffer();
// Arguments
short keyparams = KMKeyParameters.exp();
short keyFormatPtr = KMEnum.instance(KMType.KEY_FORMAT);
Expand DownExpand Up@@ -1719,26 +1726,15 @@ private boolean isEmpty(byte[] buf, short offset, short len) {
// id values of both the requested parameters and the provisioned parameters
// then throw INVALID_TAG error.
private void addAttestationIds(KMAttestationCert cert) {
final short[] attTags =
new short[]{
KMType.ATTESTATION_ID_BRAND,
KMType.ATTESTATION_ID_DEVICE,
KMType.ATTESTATION_ID_IMEI,
KMType.ATTESTATION_ID_MANUFACTURER,
KMType.ATTESTATION_ID_MEID,
KMType.ATTESTATION_ID_MODEL,
KMType.ATTESTATION_ID_PRODUCT,
KMType.ATTESTATION_ID_SERIAL
};
byte index = 0;
short attIdTag;
short attIdTagValue;
short storedAttId;
while (index < (short) attTags.length) {
attIdTag = KMKeyParameters.findTag(KMType.BYTES_TAG, attTags[index], data[KEY_PARAMETERS]);
while (index < (short) ATTEST_ID_TAGS.length) {
attIdTag = KMKeyParameters.findTag(KMType.BYTES_TAG, ATTEST_ID_TAGS[index], data[KEY_PARAMETERS]);
if (attIdTag != KMType.INVALID_VALUE) {
attIdTagValue = KMByteTag.cast(attIdTag).getValue();
storedAttId = repository.getAttId(mapToAttId(attTags[index]));
storedAttId = repository.getAttId(mapToAttId(ATTEST_ID_TAGS[index]));
// Return CANNOT_ATTEST_IDS if Attestation IDs are not provisioned or
// Attestation IDs are deleted.
if (storedAttId == KMType.INVALID_VALUE ||
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,8 +16,6 @@

package com.android.javacard.keymaster;

import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.JCSystem;
import javacard.framework.Util;

Expand Down