Example #1
0
        public override byte[] Unwrap(GPResponse response)
        {
            if (rmac)
            {
                if (response.ResponseData.Length < 8)
                {
                    throw new Exception("Wrong response length (too short).");
                }
                int respLen = response.ResponseData.Length - 8;
                rMac.Write(respLen);
                rMac.Write(response.ResponseData, 0, respLen);
                rMac.Write(response.SW1);
                rMac.Write(response.SW2);

                ricv = Mac_des_3des(sessionKeys.GetKey(KeySessionType.RMAC), Pad80(rMac.ToByteArray(), 8), ricv);

                byte[] actualMac = new byte[8];
                Array.Copy(response.ResponseData, respLen, actualMac, 0, 8);
                if (!Arrays.AreEqual(ricv, actualMac))
                {
                    throw new Exception("RMAC invalid.");
                }
                ByteArrayOutputStream o = new ByteArrayOutputStream();
                o.Write(response.ResponseData, 0, respLen);
                o.Write(response.SW1);
                o.Write(response.SW2);
                return(o.ToByteArray());
            }
            return(response.ResponseData);
        }
Example #2
0
 public override byte[] Unwrap(GPResponse response)
 {
     return(response.ResponseData);
 }
Example #3
0
 public abstract byte[] Unwrap(GPResponse response);