Bouls
Bouls

Reputation: 29

PACE – GENERIC MAPPING implementation in java for android

I am currently working on a project where I need to translate a C# method to code compatible with Android . Unfortunately, I am facing some difficulties and would like to know if anyone is familiar with android and apdu and cryptography

Here is the method in question in c#:

public PaceKeys initiatePaceGenMapping()
{
    this.sendSelectApplet();
    PaceKeys paceKeys = new PaceKeys();
    // Paramètres du domaine pour la courbe ECC-NIST 256
    X9ECParameters curve = SecNamedCurves.GetByName("secp256r1");
    // Utilisation des paramètres déjà connus
    Org.BouncyCastle.Math.BigInteger prime = new Org.BouncyCastle.Math.BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16);
    Org.BouncyCastle.Math.BigInteger a = new Org.BouncyCastle.Math.BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", 16);
    Org.BouncyCastle.Math.BigInteger order = new Org.BouncyCastle.Math.BigInteger("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", 16);
    Org.BouncyCastle.Math.BigInteger b = new Org.BouncyCastle.Math.BigInteger("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", 16);
    Org.BouncyCastle.Math.BigInteger G_X = new Org.BouncyCastle.Math.BigInteger("6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", 16);
    Org.BouncyCastle.Math.BigInteger G_Y = new Org.BouncyCastle.Math.BigInteger("4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", 16);
    Org.BouncyCastle.Math.EC.ECPoint basePoint = curve.Curve.CreatePoint(G_X, G_Y);

    ECDomainParameters domainParams = new ECDomainParameters(curve.Curve, basePoint, order, curve.H, curve.GetSeed());

    //  •   Read EF.DIR and EF.CardAccess (applet capabilities)
    string selectEF_F000 = executeCommandeSec("00A40000023F00");
    if (string.Equals(selectEF_F000, "9000"))
    {
        string selectEF_CardAccess = executeCommandeSec("00a4020c02011c");
        if (string.Equals(selectEF_CardAccess, "9000"))
        {
            string readBinaryCardAccess1 = executeCommandeSec("00b0000005");
            string readBinaryCardAccess2 = executeCommandeSec("00b000055b");

//  •   Select algorithm (INS 22)
string setMSE = executeCommandeSec("0022c1a412800a04007f0007020204020283010384010c");
if (string.Equals(setMSE, "9000"))
{
//  •   The host requests PACE for authentication, possibly giving a preference : 
 string paceAuthenticationREQUEST = executeCommandeSec("10860000027c0000");
//  •   The card responds with a 128-bit (16 byte) random number (nonce) encrypted with PACE_nonce_AES128key  : 7C 12 80 10 <encrypted_nonce>
int startIndex = paceAuthenticationREQUEST.IndexOf("7C128010") + "7C128010".Length;
   // Trouver l'index de fin de la sous-chaîne
  int endIndex = paceAuthenticationREQUEST.IndexOf("9000", startIndex);

 // Extraire la sous-chaîne : representant Key: z - encrypted nonce (z [PACE])
  string encryptedNonce = paceAuthenticationREQUEST.Substring(startIndex, endIndex - startIndex);

 //  the host decrypts the 128-bit nonce with PACE_nonce_AES128key derived from user input as described above
                byte[] bytesEncryptedNonce = StringUtils.ToByteArray(encryptedNonce);

  // Key: K - derived key from shared secret : trouver la clé dérivée du PIN
  string derivedKeySH = calculerSHA1("3132333400000003");
byte[] bytesDerivedKeySH = StringUtils.ToByteArray(derivedKeySH);

//  •   [decrypt nonce nonce]
byte[] bytesDecryptedNonce = decryptAES(bytesEncryptedNonce, bytesDerivedKeySH);
string decryptedNonce = byteToHexStr(bytesDecryptedNonce);
  Org.BouncyCastle.Math.BigInteger nonce = new Org.BouncyCastle.Math.BigInteger(decryptedNonce, 16);

 //  •  [generate random number as private key SKPCD for DHKA]           
  SecureRandom random = new SecureRandom();

  int randomNumber = random.NextInt();
Console.WriteLine("Nombre aléatoire : " + randomNumber);

Org.BouncyCastle.Math.BigInteger SKPCD = new Org.BouncyCastle.Math.BigInteger(domainParams.Curve.Order.BitLength, random).Mod(domainParams.Curve.Order);
Console.WriteLine("Secrete Key SKPCD : " + SKPCD);
 // •   [calculate ephermeral PKPCD = BasePoint G * SKPCD]
 Org.BouncyCastle.Math.EC.ECPoint PKPCD = domainParams.G.Multiply(SKPCD).Normalize();
 Console.WriteLine("Public Key PKPCD du terminal: " + PKPCD);
// Convertir les coordonnées X et Y en hexadécimal
 /* string PKPCDXHex = PKPCD.XCoord.ToBigInteger().ToString(16);
 string PKPCDYHex = PKPCD.YCoord.ToBigInteger().ToString(16);*/

 // Convertir les coordonnées X et Y en hexadécimal
  byte[] PKPCDXBytes = PKPCD.XCoord.ToBigInteger().ToByteArrayUnsigned();
   byte[] PKPCDYBytes = PKPCD.YCoord.ToBigInteger().ToByteArrayUnsigned();
 string PKPCDXHex = BitConverter.ToString(PKPCDXBytes).Replace("-", "");
  string PKPCDYHex = BitConverter.ToString(PKPCDYBytes).Replace("-", "");

//  •   Send PKPCD and Receive PKPICC from card
 string requestPKicc = "10860000457C43814104" + PKPCDXHex + PKPCDYHex + "00";
string reponsePKicc = executeCommandeSec(requestPKicc);

 // Définir les positions de début et de fin de la sous-chaîne
int entete = 10; // Après les 4 premiers octets
 int sw = reponsePKicc.Length - 4; // Avant les 4 derniers octets

  // Extraire la sous-chaîne
  reponsePKicc = reponsePKicc.Substring(entete, sw - entete);

 string PKICCXHex = reponsePKicc.Substring(0, reponsePKicc.Length / 2);
  string PKICCYHex = reponsePKicc.Substring(reponsePKicc.Length / 2);

 Org.BouncyCastle.Math.EC.ECPoint PKPICC = curve.Curve.CreatePoint(new Org.BouncyCastle.Math.BigInteger(PKICCXHex, 16), new Org.BouncyCastle.Math.BigInteger(PKICCYHex, 16));
                Console.WriteLine("Public Key PKICC de la carte: " + PKPICC);
                //  •   [build shared secret: H = PKPICC * SKPCD = G * SKPICC * SKPCD]
                Org.BouncyCastle.Math.EC.ECPoint H = PKPICC.Multiply(SKPCD).Normalize();
                Console.WriteLine("Secret Partagé H : " + H);
                //  •   [build new base point:] :  Gmap = G * s + H = G * s + G * SKPICC * SKPCD = G * (s + SKPICC * SKPCD)
                Org.BouncyCastle.Math.EC.ECPoint Gmap = basePoint.Multiply(nonce); Gmap = Gmap.Add(H).Normalize();
                Console.WriteLine("Nouveau Point de base Gmap : " + Gmap);
                //  •   [generate random number as private key SKPCD,map for DHKA]            
                Org.BouncyCastle.Math.BigInteger SKPCDMap = new Org.BouncyCastle.Math.BigInteger(Gmap.Curve.Order.BitLength, random).Mod(Gmap.Curve.Order);
                Console.WriteLine("Nouvel clé secrete SKPCDMap : " + SKPCDMap);

                //  •   [calculate ephermeral PKPCD,map = BasePoint Gmap * SKPCD,map]
                Org.BouncyCastle.Math.EC.ECPoint PKPCDMap = Gmap.Multiply(SKPCDMap).Normalize();
                Console.WriteLine("Nouvelle clé publique éphémère  PKPCDMap du terminal : " + PKPCDMap);

                // Convertir les coordonnées X et Y en hexadécimal
                string PKPCDMapXHex = PKPCDMap.XCoord.ToBigInteger().ToString(16);
                string PKPCDMapYHex = PKPCDMap.YCoord.ToBigInteger().ToString(16);

                //  •   Send PKPCD,map and Receive PKPICC,map from card
                string requestPKpcdmap = "10860000457c43834104" + PKPCDMapXHex + PKPCDMapYHex + "00";
                string responsePKpcdmap = executeCommandeSec(requestPKpcdmap);                       
                sw = responsePKpcdmap.Length - 4;

 
  // Extraire la sous-chaîne
  if (responsePKpcdmap.Length > 4)
  {
 responsePKpcdmap = responsePKpcdmap.Substring(entete, sw - entete);

string PKICCMapXHex = responsePKpcdmap.Substring(0, responsePKpcdmap.Length / 2);
string PKICCMapYHex = responsePKpcdmap.Substring(responsePKpcdmap.Length / 2);

Org.BouncyCastle.Math.EC.ECPoint PKPICCMap = curve.Curve.CreatePoint(new Org.BouncyCastle.Math.BigInteger(PKICCMapXHex, 16), new Org.BouncyCastle.Math.BigInteger(PKICCMapYHex, 16));
 Console.WriteLine("Nouvelle clé publique éphémère  de la puce PKPICCMap : " + PKPICCMap);
 // •   [build Hmap = PKPICC,map * SKPCD,map = Gmap * SKPICC,map * SKPCD,map]
Org.BouncyCastle.Math.EC.ECPoint Hmap = PKPICCMap.Multiply(SKPCDMap).Normalize();
byte[] HmapBytes = StringUtils.ToByteArray(Hmap.XCoord.ToBigInteger().ToString(16));

// •    Derive session keys Kenc and Kmac  from Hmap
  string Kenc = calculerSHA1(Hmap.XCoord.ToBigInteger().ToString(16) + "00000001");
  string Kmac = calculerSHA1(Hmap.XCoord.ToBigInteger().ToString(16) + "00000002");
  Console.WriteLine("Clé encryption Kenc : " + Kenc);
  Console.WriteLine("Clé mac Kmac : " + Kmac);
  // •  Calculate token: TPICC = MAC(Kmac , PKPCD,map), TPCD = MAC(Kmac, PKPICC,map)

string PKICCMap = "04" + PKICCMapXHex + PKICCMapYHex;
string auth_token_host = calculateCMAC(Kmac, PKICCMap);
Console.WriteLine("Token d'authentification : " + auth_token_host);
string tpicc = executeCommandeSec("008600000c7c0a8508" + auth_token_host);
                    Console.WriteLine("Réponse tpicc : " + tpicc);
                    if (tpicc != null && tpicc.Length > 4)
                    {
                        sw = tpicc.Length - 4;
                        string auth_token_tpicc = tpicc.Substring(8, sw - 8);

                        paceKeys.keyMac = Kmac;
                        paceKeys.keyEnc = Kenc;
                        Console.WriteLine("Pace object : keyMac et keyEnc " + paceKeys.keyMac + " " + paceKeys.keyEnc);
                        if (paceKeys.keyMac != null || paceKeys.keyEnc != null)
                        {
                            sm = new SecureMessaging(StringUtils.ToByteArray(Kmac), StringUtils.ToByteArray(Kenc));
                            return paceKeys;
                        }
                        else
                        {
                            String VerifyPUK = executeCommande("00200089083132333435363738");
                            Console.WriteLine("Verify PUK :  " +VerifyPUK);
                            this.sendSelectApplet();
                            this.initiatePaceGenMapping();
                        }
                    }
                    else
                    {
                        String VerifyPUK = executeCommande("00200089083132333435363738");
                        Console.WriteLine("Verify PUK :  " + VerifyPUK);
                        this.sendSelectApplet();
                        this.initiatePaceGenMapping();
                    }
                }
                else
                {
                    String VerifyPUK = executeCommande("00200089083132333435363738");
                    Console.WriteLine("Verify PUK :  " + VerifyPUK);
                    this.sendSelectApplet();
                    this.initiatePaceGenMapping();
                }

            }

        }
    }
    return paceKeys;

}

This method works correctly on C#, it consists of exchanging keys between a terminal and a smart card. I can read secure smart cards with PACE GENERIC MAPPING.

Here is my android code i'm but i'm having an error when i have to send command authentication with the auth_token at the end :

// Further processing with the result
 return executeCommandeSecAsync("008600000c7c0a8508" + result);   

I'm having an 63Cx error apdu that mean the finded result is not good. The android code here :

@RequiresApi(api = Build.VERSION_CODES.N)
   public CompletableFuture<CompletableFuture<PaceKeys>> initiatePaceGenMapping() {
       return CompletableFuture.supplyAsync(() -> {
           try {
               this.sendSelectApplet();
           } catch (IOException e) {
               throw new RuntimeException(e);
           }

           PaceKeys paceKeys = new PaceKeys();
           // Parameters for ECC-NIST P-256 curve
           X9ECParameters curve = SECNamedCurves.getByName("secp256r1");
           // Use known parameters
           BigInteger prime = new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", 16);
           BigInteger a = new BigInteger("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", 16);
           BigInteger order = new BigInteger("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", 16);
           BigInteger b = new BigInteger("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", 16);
           BigInteger G_X = new BigInteger("6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", 16);
           BigInteger G_Y = new BigInteger("4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", 16);
           ECPoint basePoint = curve.getCurve().createPoint(G_X, G_Y);

           ECDomainParameters domainParams = new ECDomainParameters(curve.getCurve(), basePoint, order, curve.getH(), curve.getSeed());
           SecureRandom random = new SecureRandom();
           byte[] randomBytes = new byte[16];
           random.nextBytes(randomBytes);
           int randomNumber = random.nextInt();
           Log.d("Nombre aléatoire : ", String.valueOf(randomNumber));
           final BigInteger[] SKPCD = new BigInteger[1];
           final BigInteger[] nonce = new BigInteger[1];
           return executeCommandeSecAsync("00A40000023F00")
                   .thenCompose(selectEF_F000 -> {
                       if ("9000".equals(selectEF_F000)) {
                           return executeCommandeSecAsync("00a4020c02011c")
                                   .thenCompose(selectEF_CardAccess -> {
                                       if ("9000".equals(selectEF_CardAccess)) {
                                           return executeCommandeSecAsync("00b0000005")
                                                   .thenCompose(read_binary_1 -> executeCommandeSecAsync("00b000055b"))
                                                   .thenCompose(read_binary_2 -> executeCommandeSecAsync("0022c1a412800a04007f0007020204020283010384010c"));
                                       }
                                       return CompletableFuture.completedFuture(null);
                                   });
                       }
                       return CompletableFuture.completedFuture(null);
                   })
                   .thenCompose(setMSE -> {
                           return executeCommandeSecAsync("10860000027c0000")
                                   .thenCompose(paceAuthenticationREQUEST -> {
                                       int startIndex = paceAuthenticationREQUEST.indexOf("7C128010") + "7C128010".length();
                                       int endIndex = paceAuthenticationREQUEST.indexOf("9000", startIndex);
                                       String encryptedNonce = paceAuthenticationREQUEST.substring(startIndex, endIndex);

                                       byte[] bytesEncryptedNonce = StringUtils.toByteArray(encryptedNonce);

                                       String derivedKeySH = calculerSHA1("3132333400000003");
                                       byte[] bytesDerivedKeySH = StringUtils.toByteArray(derivedKeySH);

                                       byte[] bytesDecryptedNonce = decryptAES(bytesEncryptedNonce, bytesDerivedKeySH);
                                       String decryptedNonce = bytesToHex(bytesDecryptedNonce);
                                       nonce[0] = new BigInteger(decryptedNonce, 16);
                                       Log.d("Order Length", String.valueOf(order.bitLength()));
                                       SKPCD[0] = (new BigInteger(order.bitLength(), random)).mod(order);
                                       //SKPCD[0] = new BigInteger(domainParams.getCurve().getOrder().bitLength(), random).mod(domainParams.getCurve().getOrder());
                                       Log.d("Secrete Key SKPCD : ", String.valueOf(SKPCD[0]));

                                       ECPoint PKPCD = domainParams.getG().multiply(SKPCD[0]).normalize();
                                       Log.d("Public Key PKPCD du terminal: ", PKPCD.toString());
                                       String pkpcdX = String.format("%064x", PKPCD.getXCoord().toBigInteger());
                                       String pkpcdY = String.format("%064x", PKPCD.getYCoord().toBigInteger());

                                       Log.d("PKPCD X", pkpcdX);
                                       Log.d("PKPCD Y", pkpcdY);

                                       String requestPKicc = "10860000457C43814104" + pkpcdX + pkpcdY + "00";
                                       Log.d("requestPKicc", requestPKicc);
                                       //Log.d("PKPCD X", PKPCD.getXCoord().toBigInteger().toString(16));
                                       //Log.d("PKPCD Y", PKPCD.getYCoord().toBigInteger().toString(16));

                                       //String requestPKicc = "10860000457C43814104" + PKPCD.getXCoord().toBigInteger().toString(16) + PKPCD.getYCoord().toBigInteger().toString(16) + "00";
                                       return executeCommandeSecAsync(requestPKicc);
                                   });

                      // return CompletableFuture.completedFuture(null);
                   })
                   .thenCompose(reponsePKicc -> {
                       if (reponsePKicc != null) {
                           int entete = 10;
                           AtomicInteger sw = new AtomicInteger(reponsePKicc.length() - 4);

                           reponsePKicc = reponsePKicc.substring(entete, sw.get());

                           String PKICCXHex = reponsePKicc.substring(0, reponsePKicc.length() / 2);
                           String PKICCYHex = reponsePKicc.substring(reponsePKicc.length() / 2);
                           out.println("PKICCXHex");
                           out.println(PKICCXHex);
                           out.println("PKICCYHex");
                           out.println(PKICCYHex);

                           ECPoint PKPICC = curve.getCurve().createPoint(new BigInteger(PKICCXHex, 16), new BigInteger(PKICCYHex, 16));
                           Log.d("Public Key PKICC de la carte: ",PKPICC.toString());

                           ECPoint H = PKPICC.multiply(SKPCD[0]).normalize();
                           Log.d("Secret Partagé H : ", H.toString());

                           ECPoint Gmap = basePoint.multiply(nonce[0]);
                           Gmap = Gmap.add(H).normalize();
                           Log.d("Nouveau Point de base Gmap : ",Gmap.toString());
                            BigInteger SKPCDMap = new BigInteger(order.bitLength(), random).mod(order);
                           Log.d("Nouvel clé secrete SKPCDMap ",SKPCDMap.toString());

                           ECPoint PKPCDMap = Gmap.multiply(SKPCDMap).normalize();
                           Log.d("Nouvelle clé publique éphémère  PKPCDMap du terminal : ",PKPCDMap.toString());
                           String.format("%064x", PKPCDMap.getXCoord().toBigInteger());
                           String PKPCDMapXHex = String.format("%064x", PKPCDMap.getXCoord().toBigInteger());
                           String PKPCDMapYHex = String.format("%064x", PKPCDMap.getYCoord().toBigInteger());
                           out.println("PKPCDMapXHex");
                           out.println(PKPCDMapXHex);
                           out.println("PKPCDMapYHex");
                           out.println(PKPCDMapYHex);

                           String requestPKpcdmap = "10860000457c43834104" + PKPCDMapXHex + PKPCDMapYHex + "00";
                           return executeCommandeSecAsync(requestPKpcdmap)
                                   .thenCompose(responsePKpcdmap -> {
                                       out.println("responsePKpcdmap");
                                       out.println(responsePKpcdmap);
                                       sw.set(responsePKpcdmap.length() - 4);
       if (responsePKpcdmap.length() > 4) {
     responsePKpcdmap = responsePKpcdmap.substring(entete, sw.get());

                                           String PKICCMapXHex = responsePKpcdmap.substring(0, responsePKpcdmap.length() / 2);
                                           //PKICCMapXHex = String.format("%064s", PKICCMapXHex).replace(' ', '0');
                                           out.println("PKICCMapXHex");
                                           out.println(PKICCMapXHex);                                            String PKICCMapYHex = responsePKpcdmap.substring(responsePKpcdmap.length() / 2);
                                           //PKICCMapYHex = String.format("%064s", PKICCMapYHex).replace(' ', '0');
                                           out.println("PKICCMapYHex");
                                           out.println(PKICCMapYHex);                                            ECPoint PKPICCMap = curve.getCurve().createPoint(new BigInteger(PKICCMapXHex, 16), new BigInteger(PKICCMapYHex, 16));
                                           Log.d("Nouvelle clé publique éphémère  de la puce PKPICCMap : ",PKPICCMap.toString());
                                           ECPoint Hmap = PKPICCMap.multiply(SKPCDMap).normalize();
                                           byte[] HmapBytes = APDUScript.toBytes(Hmap.getXCoord().toBigInteger().toString(16));

String Kenc = calculerSHA1(Hmap.getXCoord().toBigInteger().toString(16) + "00000001");
                                           String Kmac = calculerSHA1(Hmap.getXCoord().toBigInteger().toString(16) + "00000002");
                                           Log.d("Clé encryption Kenc : ",Kenc);
                                           Log.d("Clé mac Kmac : ",Kmac);
                                           String PKICCMap = "04" + PKICCMapXHex + PKICCMapYHex;
return calculateCMACAsync(Kmac, PKICCMap)
      .thenCompose(result -> {
                                                       Log.d("Token d'authentification : ",result);
                                                       out.println("Async CMAC result: " + result);
                                                       // Further processing with the result
                                                       return executeCommandeSecAsync("008600000c7c0a8508" + result)
                                                               .thenCompose(tpicc -> {
                                                                   Log.d("Réponse tpicc : ",tpicc);
                                                                   out.println("tpicc");
                                                                   out.println(tpicc);
                                                                   if (tpicc != null && tpicc.length() > 4) {
                                                                       sw.set(tpicc.length() - 4);
                                                                       String auth_token_tpicc = tpicc.substring(8, sw.get() - 8);
                                                                       paceKeys.setKeyMac(Kmac);
                                                                       paceKeys.setKeyEnc(Kenc);
  sm = new SecureMessaging(APDUScript.toBytes(Kmac), APDUScript.toBytes(Kenc));
    return CompletableFuture.completedFuture(paceKeys);
} else {
     return CompletableFuture.supplyAsync(() -> {
                                                                           try {
                                                                               this.sendSelectApplet();
                                                                               return this.initiatePaceGenMapping().join();
                                                                           } catch (IOException e)             throw new RuntimeException(e);
}
 });
                                                                   }      });
      })
.exceptionally(ex -> {
                                                       out.println("Error calculating CMAC: " + ex.getMessage());
   throw new RuntimeException(ex);
   });
    } else {
                                           return CompletableFuture.supplyAsync(() -> {
        try {
                                                   this.sendSelectApplet();
                                                   return this.initiatePaceGenMapping().join();
   } catch (IOException e) {     throw new RuntimeException(e);
     }
         });   }
});
 }
                       return CompletableFuture.completedFuture(null);
                   })
                   .exceptionally(ex -> {
                       out.println("Error during PACE initialization: " + ex.getMessage());
                       throw new RuntimeException(ex);
                   })
                   .thenApply(v -> paceKeys);
       });
   }

The logs of java android :

Nombre aléatoire : -1847558116

Secrete Key SKPC : 99411499502711625067430159080481548425536475748688452040238473829264151654625

Public Key du terminal:(4ce7204130e3f76f17e5ae774e9c009cafb3c400efcf550e730694801b000,6e03acf31e71b3f7ef2504b4a0e8f7fbcb4a7412a73a90b7f671c46502c1,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)

Public Key... la carte:(37b27601450ba362e38a06e5a0bc3908a9acbf9f8928a0f8176ff677a0ec707e,22eee537e51b8e699626c506a6771c527bc5c4c2e12fc5390b12f969ce,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
 
Secret Partagé H :  (3b221aeb876b2abac34ff80a63a5215ba69a134b8e03c71f1369542ccf926940,63a1a906c4c1e7bb093c21e20f7f428e57a6f7533cc89176f4cf7941,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
 
Nouveau Point e ...ase Gmap :(f44b4690e6c385048180f0118048624333b915395e9b5903ca2028c2e2a7,2c4cb8426c801e1f004ab8ea1648a658bab315ca0c1c51abf45f20b6c3,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
 
Nouvel clé secrete SKPCMap 76590852103704156605428334633305874342709637479155542757479728567671409871647
 
Nouvelle c...terminal :(73eb533e3e635c15a949b9c882bc1177a850eaef3b4647c513a0effcbaf,67b4ffcf6442a594b2279eb8a59704a4771f1b4b9b231e568a9466ee5c5e,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)

Nouvelle c...KPICCMap :(8a38b72b61e73ae6ee975e87aa130f0072c087f7884bc597e3a6e3f805f00,67a20874760ffb87c3c6e9a5f2a91a3bb24930814657accab32cb493e87,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)

Clé encryption Kenc :  95aa6cf8cc62be22f51eef925ae559b
 
Clé mac Kmac :665f62a79e05bf6e6019279a61ec6
 
Token 'au...fication :4E609F36F2134355

Réponse tpicc :  63CE

And the log of c# part :

Nombre aléatoire : 546022152
Secrete Key SKPCD : 39056701917978664281168567963160392468908985681161446064353125940764560648281
Public Key PKPCD du terminal: (ce5e8881f7d4bd34a040ceb28d9861aeb39a344ce8400680f10e8431b99f8867,92921424adae9f5eec584acb454e7438aedb6fb444d484db5d7fa31057d281fe,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
10860000457C43814104CE5E8881F7D4BD34A040CEB28D9861AEB39A344CE8400680F10E8431B99F886792921424ADAE9F5EEC584ACB454E7438AEDB6FB444D484DB5D7FA31057D281FE00
Send=>10860000457C43814104CE5E8881F7D4BD34A040CEB28D9861AEB39A344CE8400680F10E8431B99F886792921424ADAE9F5EEC584ACB454E7438AEDB6FB444D484DB5D7FA31057D281FE00
Get<=7C438241047D7D6E0B0911D3C46ACD04FD2215B81FCCF680C4C0D292D73BC14831462E05FA4C34D4B103D4204904869C7E65FD486E140D8E0F4AF299C6D92BDCBAC63822729000

Public Key PKICC de la carte: (7d7d6e0b0911d3c46acd04fd2215b81fccf680c4c0d292d73bc14831462e05fa,4c34d4b103d4204904869c7e65fd486e140d8e0f4af299c6d92bdcbac6382272,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
Secret Partagé H : (3e3b4325eafe2d883511104512dc69fe6992a107a1d8491023ecd4901d3e8fb4,cab674f61a35ce386ffbf5d80878a7a354989af484c5280dff555048438f1697,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
Nouveau Point de base Gmap : (68b509b3d4e0c0ff1283e7b75248bbb9274c013a7b384e7b2567de05b3518f99,f2cb282078e1b5013328e33ce510faa7f7f390eac5873fe64a3e988846a8105d,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
Nouvel clé secrete SKPCDMap : 17651959506870056005865036021216596234247459902170306235233823787888641315788
Nouvelle clé publique éphémère  PKPCDMap du terminal : (cb1da777aceaa58d703f98de4e6948e77a5c7ef3cee210ee963fdf22413795dc,42b1bf02999a63b7464ffebd7ec44cb4aab2d1cc18db383b1b74e0aa7ced3872,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
10860000457c43834104cb1da777aceaa58d703f98de4e6948e77a5c7ef3cee210ee963fdf22413795dc42b1bf02999a63b7464ffebd7ec44cb4aab2d1cc18db383b1b74e0aa7ced387200
Send=>10860000457c43834104cb1da777aceaa58d703f98de4e6948e77a5c7ef3cee210ee963fdf22413795dc42b1bf02999a63b7464ffebd7ec44cb4aab2d1cc18db383b1b74e0aa7ced387200
Get<=7C43844104FE0236D14CBFC9F1F29C57070AA08AE4CDF6717D4724D8249B9BA5E8369821697E35BF1509527FD46BDA17E112B393DCC848C2C521F1CB2736B483ED3CEA56909000

Nouvelle clé publique éphémère  de la puce PKPICCMap : (fe0236d14cbfc9f1f29c57070aa08ae4cdf6717d4724d8249b9ba5e836982169,7e35bf1509527fd46bda17e112b393dcc848c2c521f1cb2736b483ed3cea5690,1,ffffffff00000001000000000000000000000000fffffffffffffffffffffffc)
Clé encryption Kenc : 8ce96e836836fe2162878d498cc91f26
Clé mac Kmac : 27b9ddf62e527adf8771c3f1c3de95e0
Token d'authentification : AFF6CCDC17A7752D
Send=>008600000c7c0a8508AFF6CCDC17A7752D
Get<=7C0A860812C243203402352F9000
Réponse tpicc : 7C0A860812C243203402352F9000

Upvotes: 0

Views: 87

Answers (0)

Related Questions