Updated on 2026-08-14

This commit is contained in:
Tangem 2018-07-07 00:58:19 +03:00
parent 28f58e8059
commit cb6678380f
10 changed files with 302 additions and 192 deletions

View file

@ -44,7 +44,7 @@ public class VerificationServerProtocol {
http.setRequestMethod("POST"); // PUT is another valid option
http.setDoOutput(true);
String sRequestBody = getGson().toJson(this);
String sRequestBody = getGson().toJson(this.command);
byte[] out = sRequestBody.getBytes(StandardCharsets.UTF_8);
int length = out.length;
@ -107,7 +107,7 @@ public class VerificationServerProtocol {
}
}
static class ResultItem {
public static class ResultItem {
public ResultItem(RequestItem request) {
CID = request.CID;
}
@ -117,15 +117,16 @@ public class VerificationServerProtocol {
public Boolean passed;
}
static class Answer extends CustomAnswer {
public static class Answer extends CustomAnswer {
public ResultItem[] results;
}
public Request prepare(TangemCard card)
public static Request prepare(TangemCard card)
{
Command c=new Command();
c.requests=new RequestItem[1];
c.requests[0].CID= Util.bytesToHex(card.getCID());
c.requests[0]=new RequestItem();
c.requests[0].CID=Util.bytesToHex(card.getCID());
c.requests[0].publicKey=Util.bytesToHex(card.getCardPublicKey());
return new Request(c,Answer.class);

View file

@ -4,10 +4,17 @@ import android.content.Context;
import android.nfc.tech.IsoDep;
import android.util.Log;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.tangem.domain.cardReader.CardProtocol;
import com.tangem.domain.cardReader.FW;
import com.tangem.domain.cardReader.NfcManager;
import com.tangem.domain.wallet.PINStorage;
import com.tangem.domain.wallet.TangemCard;
import com.tangem.util.Util;
import java.util.Arrays;
/**
* Created by dvol on 04.02.2018.
@ -59,23 +66,26 @@ public class VerifyCardTask extends Thread {
protocol.setPIN(PIN);
protocol.run_Read();
PINStorage.setLastUsedPIN(PIN);
mNotifications.OnReadProgress(protocol, 30);
mNotifications.OnReadProgress(protocol, 20);
if (isCancelled) return;
protocol.run_VerifyCard();
mNotifications.OnReadProgress(protocol, 60);
mNotifications.OnReadProgress(protocol, 50);
Log.i(TAG, "Manufacturer: " + protocol.getCard().getManufacturer().getOfficialName());
if (isCancelled) return;
if (protocol.getCard().getStatus() == TangemCard.Status.Loaded) {
protocol.run_CheckWalletWithSignatureVerify();
mNotifications.OnReadProgress(protocol, 90);
mNotifications.OnReadProgress(protocol, 80);
}
// if (isCancelled) return;
// if (protocol.getCard().getStatus() == TangemCard.Status.Loaded) {
// protocol.run_CheckWithSignatureVerify();
// }
if (isCancelled) return;
FW.VerifyCodeRecord record=FW.selectRandomVerifyCodeBlock(mCard.getFirmwareVersion());
if (isCancelled) return;
if( record!=null ) {
byte[] returnedDigest = protocol.run_VerifyCode(record.hashAlg, record.blockIndex, record.blockCount, record.challenge);
mCard.setCodeConfirmed(Arrays.equals(returnedDigest, record.digest));
}else{
mCard.setCodeConfirmed(null);
}
mNotifications.OnReadProgress(protocol, 90);
} catch (Exception e) {
e.printStackTrace();
protocol.setError(e);