示例#1
0
        public GPKeySet GetSessionKeys(int scp, byte[] kdd, params byte[][] args)
        {
            GPKeySet cardKeys = staticKeys;

            if (diversifier != Diversification.NONE)
            {
                cardKeys = Diversify(staticKeys, kdd, diversifier, scp);
            }

            System.Diagnostics.Debug.WriteLine(String.Format("card manager keys are diversified from kmc: {0}", Formatting.ByteArrayToHexString(master.GetValue())));
            System.Diagnostics.Debug.WriteLine(String.Format("diversified card keys: {0}", cardKeys.ToString()));

            GPKeySet sessionKeys;

            if (scp == 1)
            {
                if (args.Length != 2)
                {
                    throw new Exception("SCP01 requires host challenge and card challenge");
                }
                sessionKeys = DeriveSessionKeysSCP01(cardKeys, args[0], args[1]);
            }
            else if (scp == 2)
            {
                if (args.Length != 1)
                {
                    throw new Exception("SCP02 requires sequence");
                }
                sessionKeys = DeriveSessionKeysSCP02(cardKeys, args[0], false);
            }
            else if (scp == 3)
            {
                if (args.Length != 2)
                {
                    throw new Exception("SCP03 requires host challenge and card challenge");
                }
                sessionKeys = DeriveSessionKeysSCP03(cardKeys, args[0], args[1]);
            }
            else
            {
                throw new Exception("Dont know how to handle: " + scp);
            }
            System.Diagnostics.Debug.WriteLine(String.Format("session keys: {0}", sessionKeys.ToString()));
            return(sessionKeys);
        }
示例#2
0
 private GPPlaintextKeys(GPKeySet keys, Diversification div)
 {
     staticKeys  = keys;
     diversifier = div;
     System.Diagnostics.Debug.WriteLine(String.Format("static keys: {0}", staticKeys.ToString()));
 }