Send full IMEI in ctxParams1 for AuthenticateServer APDU request
This commit is contained in:
parent
0d2bdb3868
commit
fba95a3a2c
|
@ -7,6 +7,7 @@ data class EuiccChannelInfo(
|
||||||
val slotId: Int,
|
val slotId: Int,
|
||||||
val cardId: Int,
|
val cardId: Int,
|
||||||
val name: String,
|
val name: String,
|
||||||
|
val imei: String,
|
||||||
val removable: Boolean,
|
val removable: Boolean,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ abstract class EuiccChannel(
|
||||||
val slotId = info.slotId
|
val slotId = info.slotId
|
||||||
val cardId = info.cardId
|
val cardId = info.cardId
|
||||||
val name = info.name
|
val name = info.name
|
||||||
|
val imei = info.imei
|
||||||
val removable = info.removable
|
val removable = info.removable
|
||||||
|
|
||||||
abstract val lpa: LocalProfileAssistant
|
abstract val lpa: LocalProfileAssistant
|
||||||
|
|
|
@ -66,6 +66,7 @@ class EuiccChannelManager(private val context: Context) {
|
||||||
uiccInfo.slotIndex,
|
uiccInfo.slotIndex,
|
||||||
uiccInfo.cardId,
|
uiccInfo.cardId,
|
||||||
"SIM ${uiccInfo.slotIndex}",
|
"SIM ${uiccInfo.slotIndex}",
|
||||||
|
tm.getImei(uiccInfo.slotIndex),
|
||||||
uiccInfo.isRemovable
|
uiccInfo.isRemovable
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.O
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun doDownloadProfile(server: String, code: String) = withContext(Dispatchers.IO) {
|
private suspend fun doDownloadProfile(server: String, code: String) = withContext(Dispatchers.IO) {
|
||||||
channel.lpa.downloadProfile("1\$${server}\$${code}", DownloadProgress().apply {
|
channel.lpa.downloadProfile("1\$${server}\$${code}", channel.imei, DownloadProgress().apply {
|
||||||
setProgressListener { _, _, percentage, _ ->
|
setProgressListener { _, _, percentage, _ ->
|
||||||
binding.progress.isIndeterminate = false
|
binding.progress.isIndeterminate = false
|
||||||
binding.progress.progress = (percentage * 100).toInt()
|
binding.progress.progress = (percentage * 100).toInt()
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.truphone.es9plus;
|
|
||||||
|
|
||||||
public class LpaUtils {
|
|
||||||
public static String generateCtxParams1() {
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@ public interface LocalProfileAssistant {
|
||||||
String setDefaultSMDP(String smdpAddress, Progress progress);
|
String setDefaultSMDP(String smdpAddress, Progress progress);
|
||||||
|
|
||||||
|
|
||||||
void downloadProfile(String matchingId, DownloadProgress progress) throws Exception;
|
void downloadProfile(String matchingId, String imei, DownloadProgress progress) throws Exception;
|
||||||
|
|
||||||
List<LocalProfileInfo> getProfiles();
|
List<LocalProfileInfo> getProfiles();
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,16 @@ public class ApduUtils {
|
||||||
return apdu.toString();
|
return apdu.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String generateCtxParams1(String matchingId, String imei) {
|
||||||
|
String tac = imei.substring(0, 8);
|
||||||
|
return ToTLV.toTLV("A0",
|
||||||
|
ToTLV.toTLV("80", matchingId) + ToTLV.toTLV("A1",
|
||||||
|
ToTLV.toTLV("80", tac) + ToTLV.toTLV("A1", "") + ToTLV.toTLV("82", imei + "F")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> authenticateServerApdu(String smdpSigned1, String smdpSignature1, String euiccCiPKIdToBeUsed,
|
public static List<String> authenticateServerApdu(String smdpSigned1, String smdpSignature1, String euiccCiPKIdToBeUsed,
|
||||||
String cert, String matchingId) {
|
String cert, String sctxParams1) {
|
||||||
String sctxParams1 = ToTLV.toTLV("A0", ToTLV.toTLV("80", matchingId) + ToTLV.toTLV("A1", ToTLV.toTLV("80", "35550607") + ToTLV.toTLV("A1", "")));
|
|
||||||
String data = ToTLV.toTLV("BF38", smdpSigned1 + smdpSignature1 + euiccCiPKIdToBeUsed + cert + sctxParams1);
|
String data = ToTLV.toTLV("BF38", smdpSigned1 + smdpSignature1 + euiccCiPKIdToBeUsed + cert + sctxParams1);
|
||||||
|
|
||||||
return subCommandData(data, len, false);
|
return subCommandData(data, len, false);
|
||||||
|
|
|
@ -17,11 +17,13 @@ class DownloadProfileWorker {
|
||||||
private final DownloadProgress progress;
|
private final DownloadProgress progress;
|
||||||
private final Es9PlusImpl es9Module;
|
private final Es9PlusImpl es9Module;
|
||||||
private String matchingId;
|
private String matchingId;
|
||||||
|
private final String imei;
|
||||||
private ApduTransmitter apduTransmitter;
|
private ApduTransmitter apduTransmitter;
|
||||||
|
|
||||||
DownloadProfileWorker(String matchingId, DownloadProgress progress, ApduChannel apduChannel, Es9PlusImpl es9Module) {
|
DownloadProfileWorker(String matchingId, String imei, DownloadProgress progress, ApduChannel apduChannel, Es9PlusImpl es9Module) {
|
||||||
|
|
||||||
this.matchingId = matchingId;
|
this.matchingId = matchingId;
|
||||||
|
this.imei = imei;
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
this.es9Module = es9Module;
|
this.es9Module = es9Module;
|
||||||
apduTransmitter = new ApduTransmitter(apduChannel);
|
apduTransmitter = new ApduTransmitter(apduChannel);
|
||||||
|
@ -59,7 +61,7 @@ class DownloadProfileWorker {
|
||||||
authenticatingPhaseWorker.getEuiccInfo(),
|
authenticatingPhaseWorker.getEuiccInfo(),
|
||||||
authenticatingPhaseWorker.getEuiccChallenge(matchingId));
|
authenticatingPhaseWorker.getEuiccChallenge(matchingId));
|
||||||
|
|
||||||
authenticatingPhaseWorker.initiateAuthentication(initialAuthenticationKeys);
|
authenticatingPhaseWorker.initiateAuthentication(initialAuthenticationKeys, matchingId, imei);
|
||||||
downloadAndInstallProfilePackage(initialAuthenticationKeys,
|
downloadAndInstallProfilePackage(initialAuthenticationKeys,
|
||||||
downloadPhaseWorker.prepareDownload(authenticatingPhaseWorker.authenticateClient(initialAuthenticationKeys,
|
downloadPhaseWorker.prepareDownload(authenticatingPhaseWorker.authenticateClient(initialAuthenticationKeys,
|
||||||
authenticatingPhaseWorker.authenticateWithEuicc(initialAuthenticationKeys))), downloadPhaseWorker);
|
authenticatingPhaseWorker.authenticateWithEuicc(initialAuthenticationKeys))), downloadPhaseWorker);
|
||||||
|
|
|
@ -74,10 +74,10 @@ public class LocalProfileAssistantImpl implements LocalProfileAssistant {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void downloadProfile(final String matchingId,
|
public void downloadProfile(final String matchingId, final String imei,
|
||||||
final DownloadProgress progress) throws Exception {
|
final DownloadProgress progress) throws Exception {
|
||||||
|
|
||||||
new DownloadProfileWorker(matchingId, progress, apduChannel, es9Module).run();
|
new DownloadProfileWorker(matchingId, imei, progress, apduChannel, es9Module).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.truphone.lpa.impl.download;
|
||||||
|
|
||||||
|
|
||||||
import com.truphone.es9plus.Es9PlusImpl;
|
import com.truphone.es9plus.Es9PlusImpl;
|
||||||
import com.truphone.es9plus.LpaUtils;
|
|
||||||
import com.truphone.es9plus.message.response.AuthenticateClientResp;
|
import com.truphone.es9plus.message.response.AuthenticateClientResp;
|
||||||
import com.truphone.es9plus.message.response.InitiateAuthenticationResp;
|
import com.truphone.es9plus.message.response.InitiateAuthenticationResp;
|
||||||
import com.truphone.lpa.apdu.ApduUtils;
|
import com.truphone.lpa.apdu.ApduUtils;
|
||||||
|
@ -126,7 +125,7 @@ public class AuthenticatingPhaseWorker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initiateAuthentication(InitialAuthenticationKeys initialAuthenticationKeys) {
|
public void initiateAuthentication(InitialAuthenticationKeys initialAuthenticationKeys, String matchingId, String imei) {
|
||||||
|
|
||||||
progress.stepExecuted(DOWNLOAD_PROFILE_INITIATE_AUTHENTICATION, "initiateAuthentication retrieving...");
|
progress.stepExecuted(DOWNLOAD_PROFILE_INITIATE_AUTHENTICATION, "initiateAuthentication retrieving...");
|
||||||
|
|
||||||
|
@ -142,14 +141,14 @@ public class AuthenticatingPhaseWorker {
|
||||||
setServerCertificate(initialAuthenticationKeys, initiateAuthenticationResp);
|
setServerCertificate(initialAuthenticationKeys, initiateAuthenticationResp);
|
||||||
setTransactionId(initialAuthenticationKeys, initiateAuthenticationResp);
|
setTransactionId(initialAuthenticationKeys, initiateAuthenticationResp);
|
||||||
setMatchingId(initialAuthenticationKeys);
|
setMatchingId(initialAuthenticationKeys);
|
||||||
setCtxParams1(initialAuthenticationKeys);
|
setCtxParams1(initialAuthenticationKeys, matchingId, imei);
|
||||||
|
|
||||||
progress.stepExecuted(DOWNLOAD_PROFILE_INITIATED_AUTHENTICATION, "initiateAuthentication initiated...");
|
progress.stepExecuted(DOWNLOAD_PROFILE_INITIATED_AUTHENTICATION, "initiateAuthentication initiated...");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCtxParams1(InitialAuthenticationKeys initialAuthenticationKeys) {
|
private void setCtxParams1(InitialAuthenticationKeys initialAuthenticationKeys, String matchingId, String imei) {
|
||||||
|
|
||||||
initialAuthenticationKeys.setCtxParams1(LpaUtils.generateCtxParams1());
|
initialAuthenticationKeys.setCtxParams1(ApduUtils.generateCtxParams1(matchingId, imei));
|
||||||
|
|
||||||
if (LogStub.getInstance().isDebugEnabled()) {
|
if (LogStub.getInstance().isDebugEnabled()) {
|
||||||
LogStub.getInstance().logDebug(LOG, LogStub.getInstance().getTag() + " - ctxParams1: " + initialAuthenticationKeys.getCtxParams1());
|
LogStub.getInstance().logDebug(LOG, LogStub.getInstance().getTag() + " - ctxParams1: " + initialAuthenticationKeys.getCtxParams1());
|
||||||
|
@ -276,7 +275,7 @@ public class AuthenticatingPhaseWorker {
|
||||||
String authenticateServerResponse = apduTransmitter.transmitApdus(ApduUtils.authenticateServerApdu(initialAuthenticationKeys.getServerSigned1(),
|
String authenticateServerResponse = apduTransmitter.transmitApdus(ApduUtils.authenticateServerApdu(initialAuthenticationKeys.getServerSigned1(),
|
||||||
initialAuthenticationKeys.getServerSignature1(),
|
initialAuthenticationKeys.getServerSignature1(),
|
||||||
initialAuthenticationKeys.getEuiccCiPKIdTobeUsed(), initialAuthenticationKeys.getServerCertificate(),
|
initialAuthenticationKeys.getEuiccCiPKIdTobeUsed(), initialAuthenticationKeys.getServerCertificate(),
|
||||||
initialAuthenticationKeys.getMatchingId()));
|
initialAuthenticationKeys.getCtxParams1()));
|
||||||
String encodedAuthenticateServerResponse = Base64.encodeBase64String(Util.hexStringToByteArray(authenticateServerResponse));
|
String encodedAuthenticateServerResponse = Base64.encodeBase64String(Util.hexStringToByteArray(authenticateServerResponse));
|
||||||
|
|
||||||
if (LogStub.getInstance().isDebugEnabled()) {
|
if (LogStub.getInstance().isDebugEnabled()) {
|
||||||
|
|
Loading…
Reference in a new issue