5 Replies Latest reply: Mar 20, 2013 1:56 AM by 397691 RSS

    how do i confirm the static key in the SSD ?

    397691
      hello,I am the beginner in the java card app...

      when i try the INITIAZE UPDATE COMMAND , THE CARD Cryptogram can not verified to be correct.

      I am the the scp02 D,

      here is the code for calc the Cryptogram , is there any wrong ?

      or any one can tell me how to get the static key in the SSD ?

      Thanks very much!

      <code>
      IvParameterSpec params =
      new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});

      if (sessionSENC.length == 16) {
      byte[] temp = (byte[]) sessionSENC.clone();
      sessionSENC = new byte[24];
      System.arraycopy(temp, 0, sessionSENC, 0, temp.length);
      System.arraycopy(temp, 0, sessionSENC, 16, 8);
      }


      byte[] temp = null;
      SecretKey secretKey = new SecretKeySpec(sessionSENC, "DESede");

                Cipher cbcDES = Cipher.getInstance("DESede/CBC/NoPadding");
                cbcDES.init(Cipher.ENCRYPT_MODE, secretKey, params);
                
                temp = cbcDES.doFinal(data);

      byte[] signature = new byte[8];
      System.arraycopy(temp, temp.length - 8, signature, 0, signature.length);
      return signature;
      </code>
        • 1. Re: how do i confirm the static key in the SSD ?
          397691
          cmd<APDU case3 "CLA:00 INS:A4 P1:04 P2:00 Lc:0D Data:D3 92 10 00 69 01 4C 61 62 41 53 50 00">
          res<Response SW:90 00>
          cmd<APDU case3 "CLA:01 INS:A4 P1:04 P2:00 Lc:0D Data:D3 92 10 00 69 01 4C 61 62 41 53 50 00">
          res<Response SW:90 00>
          cmd<APDU case3 "CLA:80 INS:50 P1:27 P2:00 Lc:08 Data:01 02 03 04 05 06 07 08">
          res<Response SW:61 1C>
          cmd<APDU case2 "CLA:01 INS:C0 P1:00 P2:00 Le:1C">
          res<Response SW:90 00 Data:00 00 00 00 00 00 00 00 00 00 27 02 00 00 4B 0F B2 59 EC 54 8E 24 16 1F 48 D6 23 47>
          Res_Data<00 00 00 00 00 00 00 00 00 00 27 02 00 00 4B 0F B2 59 EC 54 8E 24 16 1F 48 D6 23 47>
          SCP02,key:27
          Session ENC: 50 B0 72 4B BA A6 D5 CC 43 85 AF 6C 7B 80 DA 22
          In_Data01 02 03 04 05 06 07 0800 00 4B 0F B2 59 EC 5480 00 00 00 00 00 00 00
          In_Data01 02 03 04 05 06 07 0800 00 4B 0F B2 59 EC 5480 00 00 00 00 00 00 00
          this : 7E D3 F5 1E 1A 61 06 FC
          card : 8E 24 16 1F 48 D6 23 47
          • 2. Re: how do i confirm the static key in the SSD ?
            safarmer
            Your code is not complete. Can you post a complete example (http://sscce.org/)? You can hard code the responses from the SD to make it easier to run the example.

            Also, can you post the keys used (or re-run with developer keys: 40414243...4d4e4f)?
            IvParameterSpec params =
            new IvParameterSpec(new byte[]{0, 0, 0, 0, 0, 0, 0, 0});
            
            if (sessionSENC.length == 16) {
            byte[] temp = (byte[]) sessionSENC.clone();
            sessionSENC = new byte[24];
            System.arraycopy(temp, 0, sessionSENC, 0, temp.length);
            System.arraycopy(temp, 0, sessionSENC, 16, 8);
            }
            
            
            byte[] temp = null;
            SecretKey secretKey = new SecretKeySpec(sessionSENC, "DESede");
            
                      Cipher cbcDES = Cipher.getInstance("DESede/CBC/NoPadding");
                      cbcDES.init(Cipher.ENCRYPT_MODE, secretKey, params);
                       
                      temp = cbcDES.doFinal(data);
            
            byte[] signature = new byte[8];
            System.arraycopy(temp, temp.length - 8, signature, 0, signature.length);
            return signature;
            • 3. Re: how do i confirm the static key in the SSD ?
              safarmer
              Here is an old thread that has other links that may help: Re: Global Platform- MACing MAC Retail

              - Shane
              • 4. Re: how do i confirm the static key in the SSD ?
                397691
                thanks very mach!