public void getSMKeys(Apdu apdu, out BSO sigIn, out BSO encIn, out BSO sigOut, out BSO encOut)
        {
            sigOut = null;
            encOut = null;

            BSO key = null;

            if (apdu.P1 == 0x80 && apdu.P2 == 0x86)
            {
                key = handler.GetEnvironmentKey(SecurityEnvironmentComponent.CON);
            }
            else if (apdu.P1 == 0x86 && apdu.P2 == 0x80)
            {
                key = handler.GetEnvironmentKey(SecurityEnvironmentComponent.CON);
            }
            else if (apdu.P1 == 0x9E && apdu.P2 == 0x9A)
            {
                key = handler.GetEnvironmentKey(SecurityEnvironmentComponent.CDS);
            }


            encIn  = handler.getSMKey(key, BSO_SM.SM_ENC_USE);
            sigIn  = handler.getSMKey(key, BSO_SM.SM_SIG_USE);
            encOut = handler.getSMKey(key, BSO_SM.SM_ENC_USE_OUT);
            sigOut = handler.getSMKey(key, BSO_SM.SM_SIG_USE_OUT);
        }
Example #2
0
        public void getSMKeys(Apdu apdu, out BSO sigIn, out BSO encIn, out BSO sigOut, out BSO encOut)
        {
            CardContext context = handler.Context;

            sigIn  = null;
            encIn  = null;
            sigOut = null;
            encOut = null;

            ushort pinId = (ushort)(apdu.P2 & 0x7f);
            BSO    pin   = null;

            if (pinId != 0)
            {
                bool backTrack = (apdu.P2 & 0x80) != 0;
                if (backTrack)
                {
                    pin = context.CurDF.GetChildBSO(pinId, backTrack);
                }
                else
                {
                    pin = context.CurDF.Owner.MasterFile.GetChildBSO(pinId, false);
                }
            }
            else
            {
                pin = handler.GetEnvironmentKey(SecurityEnvironmentComponent.TEST);
            }

            if (pin == null)
            {
                throw new ISO7816Exception(Error.FileNotFound);
            }

            encIn = handler.getSMKey(pin, BSO_SM.SM_ENC_USE);
            sigIn = handler.getSMKey(pin, BSO_SM.SM_SIG_USE);
        }