public void RestoreSE(SecurityEnvironmentComponent comp, byte id)
        {
            if (context.CurrentSecurityEntironmentDF == null)
            {
                throw new ISO7816Exception(Error.ConditionsOfUseNotSatisfied);
            }
            byte keyClss = BSOClass.Unspecified;

            switch (comp)
            {
            case SecurityEnvironmentComponent.CDS:
                keyClss = BSOClass.PSO;
                break;

            case SecurityEnvironmentComponent.CON:
                keyClss = BSOClass.PSO;
                break;

            case SecurityEnvironmentComponent.TEST:
                keyClss = BSOClass.Test;
                break;

            default:
                throw new ISO7816Exception(Error.InternalError);
            }
            context.SEcomponents[comp] = context.CurDF.GetChildBSO(Util.ToUShort(keyClss, id));
        }
 public BSO GetEnvironmentKey(SecurityEnvironmentComponent component)
 {
     if (context.CurrentSecurityEntironmentDF == null)
     {
         return(null);
     }
     if (context.SEcomponents.ContainsKey(component))
     {
         return(context.SEcomponents[component]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 public byte GetComponent(SecurityEnvironmentComponent comp) {
     switch (comp) { 
         case SecurityEnvironmentComponent.CDS:
             if (Data != null && Data.Length >= 2)
                 return Data[1];
             else
                 return 0x00;
         case SecurityEnvironmentComponent.CON:
             if (Data != null && Data.Length >= 4)
                 return Data[3];
             else
                 return 0x00;
         case SecurityEnvironmentComponent.TEST:
             if (Data != null && Data.Length >= 5)
                 return Data[4];
             else
                 return 0x00;
         default:
             throw new ISO7816Exception(Error.InternalError);
     }
 }
Exemplo n.º 4
0
        public byte GetComponent(SecurityEnvironmentComponent comp)
        {
            switch (comp)
            {
            case SecurityEnvironmentComponent.CDS:
                if (Data != null && Data.Length >= 2)
                {
                    return(Data[1]);
                }
                else
                {
                    return(0x00);
                }

            case SecurityEnvironmentComponent.CON:
                if (Data != null && Data.Length >= 4)
                {
                    return(Data[3]);
                }
                else
                {
                    return(0x00);
                }

            case SecurityEnvironmentComponent.TEST:
                if (Data != null && Data.Length >= 5)
                {
                    return(Data[4]);
                }
                else
                {
                    return(0x00);
                }

            default:
                throw new ISO7816Exception(Error.InternalError);
            }
        }
Exemplo n.º 5
0
        public virtual byte[] processCommand(Apdu apdu)
        {
            CardContext context = handler.Context;

            if (apdu.P1 != 0xf3 &&
                apdu.P1 != 0xf1)
            {
                return(Error.P1OrP2NotValid);
            }
            if (apdu.P1 == 0xf3)
            {
                var se = context.CurDF.GetChildSE(apdu.P2, true);
                if (se == null)
                {
                    return(Error.RecordNotFound);
                }
                if (!handler.IsVerifiedAC(se, SE_AC.AC_RESTORE))
                {
                    return(Error.SecurityStatusNotSatisfied);
                }
                handler.RestoreSE(se);
            }
            else if (apdu.P1 == 0xf1)
            {
                TLV    se = new TLV(apdu.Data);
                byte[] id = se[0x83];
                if (id == null)
                {
                    id = se[0x84];
                }
                if (id == null)
                {
                    return(Error.DataFieldNotValid);
                }
                if (id.Length != 1)
                {
                    return(Error.DataFieldNotValid);
                }
                SecurityEnvironmentComponent comp = 0;
                switch (apdu.P2)
                {
                case 0xb8:
                    comp = SecurityEnvironmentComponent.CON;
                    break;

                case 0xa4:
                    comp = SecurityEnvironmentComponent.TEST;
                    break;

                case 0xb6:
                    comp = SecurityEnvironmentComponent.CDS;
                    break;

                default:
                    return(Error.P1OrP2NotValid);
                }
                if (comp == 0)
                {
                    return(Error.P1OrP2NotValid);
                }
                handler.RestoreSE(comp, id[0]);
            }
            return(Error.Ok);
        }
Exemplo n.º 6
0
 public BSO GetEnvironmentKey(SecurityEnvironmentComponent component) 
 {
     if (context.CurrentSecurityEntironmentDF == null)
         return null;
     if (context.SEcomponents.ContainsKey(component))
         return context.SEcomponents[component];
     else
         return null;
 }
Exemplo n.º 7
0
 public void RestoreSE(SecurityEnvironmentComponent comp,byte id)
 {
     if (context.CurrentSecurityEntironmentDF==null)
         throw new ISO7816Exception(Error.ConditionsOfUseNotSatisfied);
     byte keyClss=BSOClass.Unspecified;
     switch (comp) { 
         case SecurityEnvironmentComponent.CDS:
             keyClss = BSOClass.PSO;
             break;
         case SecurityEnvironmentComponent.CON:
             keyClss = BSOClass.PSO;
             break;
         case SecurityEnvironmentComponent.TEST:
             keyClss = BSOClass.Test;
             break;
         default:
             throw new ISO7816Exception(Error.InternalError);
     }
     context.SEcomponents[comp] = context.CurDF.GetChildBSO(Util.ToUShort(keyClss,id));
 }