コード例 #1
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));
        }
コード例 #2
0
 public BSO GetEnvironmentKey(SecurityEnvironmentComponent component)
 {
     if (context.CurrentSecurityEntironmentDF == null)
     {
         return(null);
     }
     if (context.SEcomponents.ContainsKey(component))
     {
         return(context.SEcomponents[component]);
     }
     else
     {
         return(null);
     }
 }
コード例 #3
0
ファイル: SE.cs プロジェクト: sagar1589/Delta.Cryptography
 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);
     }
 }
コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #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;
 }
コード例 #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));
 }