示例#1
0
        public ElementaryFile(byte[] AID, CardReader cardReader, byte[] FileID)
        {
            TS.TraceI("Constructing ElementaryFile with AID \"{0}\" and FileID \"{1}\".", Helper.ByteArrayToString(AID), Helper.ByteArrayToString(FileID));
            this.AID        = AID;
            this.cardReader = cardReader;
            this.FileID     = FileID;

            try
            {
                this.Value = cardReader.ReadFile(AID, FileID);
            }
            catch (CardReaderException ex)
            {
                throw new ElementaryFileException(FileID, "Error reading EF.", ex);
            }

            if (this.Value == null)
            {
                throw new ElementaryFileException(FileID, string.Format("Error reading EF: AID = \"{0}\", FileID = \"{1}\".", Helper.ByteArrayToString(AID), Helper.ByteArrayToString(FileID)));
            }

            this.tagListEF = TLV.Parse(new MemoryStream(this.Value));
            TS.TraceI("Number of elements in EF: \"{0}\".", this.tagListEF.Count);
            TS.TraceI("ElementaryFile constructed.");
        }
示例#2
0
        public ElementaryFile(byte[] AID, CardReader cardReader, byte[] FileID)
        {
            TS.TraceI("Constructing ElementaryFile with AID \"{0}\" and FileID \"{1}\".", Helper.ByteArrayToString(AID), Helper.ByteArrayToString(FileID));
            this.AID = AID;
            this.cardReader = cardReader;
            this.FileID = FileID;

            try
            {
                this.Value = cardReader.ReadFile(AID, FileID);
            }
            catch (CardReaderException ex)
            {
                throw new ElementaryFileException(FileID, "Error reading EF.", ex);
            }

            if (this.Value == null)
            {
                throw new ElementaryFileException(FileID, string.Format("Error reading EF: AID = \"{0}\", FileID = \"{1}\".", Helper.ByteArrayToString(AID), Helper.ByteArrayToString(FileID)));
            }

            this.tagListEF = TLV.Parse(new MemoryStream(this.Value));
            TS.TraceI("Number of elements in EF: \"{0}\".", this.tagListEF.Count);
            TS.TraceI("ElementaryFile constructed.");
        }
示例#3
0
        public RegistrationA(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader)
            : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0xD0, 0x01 })
        {
            this.SetEncoding(this.GetTag("1,71|1,9F37").Value);

            this.A = this.DecodeString("1,71|1,81");                        // kenteken
            this.DocumentNumber = this.DecodeString("1,71|1,9F38");         // docNr
            this.C11            = this.DecodeString("1,71|1,A1|1,A2|1,83"); // naamHouder
            this.C12            = this.DecodeString("1,71|1,A1|1,A2|1,84"); // voorletters
            this.C13            = this.DecodeString("1,71|1,A1|1,A2|1,85"); // adresHouder
            this.C4             = this.DecodeString("1,71|1,A1|1,86");      // eigendom
            this.E = this.DecodeString("1,71|1,8A");                        // voertuigidentificatienr

            // Determine meldcode from the voertuigidentificatienr number (last 4 digits; digits!)
            this.A_Meldcode = EVR.Utils.Helper.ExtractMeldcode(this.E);

            this.D1 = this.DecodeString("1,71|1,A3|1,87");          // merk
            this.D2 = this.DecodeString("1,71|1,A3|1,88");          // type
            this.D3 = this.DecodeString("1,71|1,A3|1,89");          // handelsbenaming

            this.K  = this.DecodeString("1,71|1,8F");               // typegoedkeuringsnr
            this.F1 = this.DecodeString("1,71|1,A4|1,8B");          // techMaxMassa
            this.G  = this.DecodeString("1,71|1,8C");               // massaRijklaar
            this.S1 = this.DecodeString("1,71|1,A6|1,94");          // zitplaatsen
            this.S2 = this.DecodeString("1,71|1,A6|1,95");          // staanplaatsen
            this.P1 = this.DecodeString("1,71|1,A5|1,90");          // cilinderinhoud
            this.P2 = this.DecodeString("1,71|1,A5|1,91");          // vermogen
            this.P3 = this.DecodeString("1,71|1,A5|1,92");          // brandstofEU
            this.Q  = this.DecodeString("1,71|1,93");               // vermogenGedeeldRijklaar
        }
示例#4
0
        public RegistrationA(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader)
            : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0xD0, 0x01 })
        {
            this.SetEncoding(this.GetTag("1,71|1,9F37").Value);

            this.A = this.DecodeString("1,71|1,81");                // kenteken
            this.DocumentNumber = this.DecodeString("1,71|1,9F38"); // docNr
            this.C11 = this.DecodeString("1,71|1,A1|1,A2|1,83");    // naamHouder
            this.C12 = this.DecodeString("1,71|1,A1|1,A2|1,84");    // voorletters
            this.C13 = this.DecodeString("1,71|1,A1|1,A2|1,85");    // adresHouder
            this.C4 = this.DecodeString("1,71|1,A1|1,86");          // eigendom
            this.E = this.DecodeString("1,71|1,8A");                // voertuigidentificatienr

            // Determine meldcode from the voertuigidentificatienr number (last 4 digits; digits!)
            this.A_Meldcode = EVR.Utils.Helper.ExtractMeldcode(this.E);

            this.D1 = this.DecodeString("1,71|1,A3|1,87");          // merk
            this.D2 = this.DecodeString("1,71|1,A3|1,88");          // type
            this.D3 = this.DecodeString("1,71|1,A3|1,89");          // handelsbenaming

            this.K = this.DecodeString("1,71|1,8F");                // typegoedkeuringsnr
            this.F1 = this.DecodeString("1,71|1,A4|1,8B");          // techMaxMassa
            this.G = this.DecodeString("1,71|1,8C");                // massaRijklaar
            this.S1 = this.DecodeString("1,71|1,A6|1,94");          // zitplaatsen
            this.S2 = this.DecodeString("1,71|1,A6|1,95");          // staanplaatsen
            this.P1 = this.DecodeString("1,71|1,A5|1,90");          // cilinderinhoud
            this.P2 = this.DecodeString("1,71|1,A5|1,91");          // vermogen
            this.P3 = this.DecodeString("1,71|1,A5|1,92");          // brandstofEU
            this.Q = this.DecodeString("1,71|1,93");                // vermogenGedeeldRijklaar
        }
示例#5
0
 /*
  * Constructor when nog DS and Signature are stored for a registration (ie Registration C at the moment)
  */
 public Registration(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader, byte[] FileID)
     : base(AID, cardReader, FileID)
 {
     this.EFSOd = EFSOd;
     this.CSCA  = CSCA;
     CreateSignature();
     CreateDocumentSigner();
 }
示例#6
0
 /*
  * Constructor when nog DS and Signature are stored for a registration (ie Registration C at the moment)
  */
 public Registration(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader, byte[] FileID)
     : base(AID, cardReader,FileID)
 {
     this.EFSOd = EFSOd;
     this.CSCA = CSCA;
     CreateSignature();
     CreateDocumentSigner();
 }
示例#7
0
 public RegistrationB(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader, System.Text.Encoding encoding)
     : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0xD0, 0x11 })
 {
     this.CharacterSetEncoding = encoding;
     this.J = this.DecodeString("1,72|1,98");            // voertuigCategorie
     this.R = this.DecodeString("1,72|1,9F24");          // kleur
     this.V9 = this.DecodeString("1,72|1,B0|1,9F31");    // milKlasse
     this.F2 = this.DecodeString("1,72|1,A4|1,96");      // toegMaxMassa
     this.F3 = this.DecodeString("1,72|1,A4|1,97");      // toegMaxMassaComb
     this.T = this.DecodeString("1,72|1,9F25");          // maxSnelheid
     this.O1 = this.DecodeString("1,72|1,AE|1,9B");      // trailerBreaked
     this.O2 = this.DecodeString("1,72|1,AE|1,9C");      // trailerUnBreaked
 }
示例#8
0
 public RegistrationB(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader, System.Text.Encoding encoding)
     : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0xD0, 0x11 })
 {
     this.CharacterSetEncoding = encoding;
     this.J  = this.DecodeString("1,72|1,98");           // voertuigCategorie
     this.R  = this.DecodeString("1,72|1,9F24");         // kleur
     this.V9 = this.DecodeString("1,72|1,B0|1,9F31");    // milKlasse
     this.F2 = this.DecodeString("1,72|1,A4|1,96");      // toegMaxMassa
     this.F3 = this.DecodeString("1,72|1,A4|1,97");      // toegMaxMassaComb
     this.T  = this.DecodeString("1,72|1,9F25");         // maxSnelheid
     this.O1 = this.DecodeString("1,72|1,AE|1,9B");      // trailerBreaked
     this.O2 = this.DecodeString("1,72|1,AE|1,9C");      // trailerUnBreaked
 }
示例#9
0
        public RegistrationC(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader, Encoding encoding)
            : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0xD0, 0x21 })
        {
            this.CharacterSetEncoding = encoding;
            this.CVOVersion           = this.DecodeBinary("1,BF8700|1,9F8701");
            this.B1 = this.DecodeString("1,BF8700|1,BF8710|1,9F8711"); // firstReg
            this.B2 = this.DecodeString("1,BF8700|1,BF8710|1,9F8712"); // firstRegEU
            this.I  = this.DecodeString("1,BF8700|1,BF8710|1,9F8713"); // tenaamstelling

            TLV           zippedXMLsTLV = this.GetTag("1,BF8700|1,BF8703|1,9F8705");
            int           i             = 1;
            List <string> cvos          = new List <string>();

            while (zippedXMLsTLV != null)
            {
                cvos.Add(Helper.GUnzip2(zippedXMLsTLV.Value));

                i++;
                zippedXMLsTLV = this.GetTag(string.Format("1,BF8700|{0},BF8703|1,9F8705", i));
            }
            this.CVOs = cvos.ToArray();
        }
示例#10
0
        public RegistrationC(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader, Encoding encoding)
            : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0xD0, 0x21 })
        {
            this.CharacterSetEncoding = encoding;
            this.CVOVersion = this.DecodeBinary("1,BF8700|1,9F8701");
            this.B1 = this.DecodeString("1,BF8700|1,BF8710|1,9F8711"); // firstReg
            this.B2 = this.DecodeString("1,BF8700|1,BF8710|1,9F8712"); // firstRegEU
            this.I = this.DecodeString("1,BF8700|1,BF8710|1,9F8713"); // tenaamstelling

            TLV zippedXMLsTLV = this.GetTag("1,BF8700|1,BF8703|1,9F8705");
            int i = 1;
            List<string> cvos = new List<string>();

            while (zippedXMLsTLV != null)
            {
                cvos.Add(Helper.GUnzip2(zippedXMLsTLV.Value));

                i++;
                zippedXMLsTLV = this.GetTag(string.Format("1,BF8700|{0},BF8703|1,9F8705", i));
            }
            this.CVOs = cvos.ToArray();
        }
示例#11
0
 /*
  * Create a Signature object for the Registration B
  */
 public static EFSignature Create_Signature_B(byte[] AID, CardReader cardReader)
 {
     return new EFSignature(AID, cardReader, new byte[] { 0xE0, 0x11 });
 }
示例#12
0
 /*
  * Private constructor; use factory objects below
  */
 private EFSignature(byte[] AID, CardReader cardReader, byte[] FileID)
     : base(AID, cardReader, FileID)
 {
     Signature = this.GetTag("1,30|1,03");
 }
示例#13
0
 /*
  * Private constructor; use factory objects below
  */
 private EFSignature(byte[] AID, CardReader cardReader, byte[] FileID)
     : base(AID, cardReader, FileID)
 {
     Signature = this.GetTag("1,30|1,03");
 }
示例#14
0
文件: EFSOd.cs 项目: darko0201/eVR
        public EFSOd(byte[] AID, X509Certificate2 CSCA, CardReader cardReader)
            : base(AID, cardReader, new byte[] { 0x00, 0x1D })
        {
            this.CSCA = CSCA;

            TLV tag = null;

            //// Haal DS certificaat uit EF.SOd data
            //// DS Certificaat bevindt zich in de EF.SOd data onder:
            //// T:'30' (ContentInfo)
            ////      T:'A0' (Content)
            ////          T:'30' (SignedData)
            ////              T:'A0' (Certificates)
            ////                  V: '30 XX XX ... XX'
            ////                      (DS certificaat begint met tag '30')
            tag = this.GetTag("1,30|1,A0|1,30|1,A0");
            if (tag != null)
            {
                DSCertificate = new X509Certificate2(tag.Value);
            }

            ////      i. Haal handtekening en algoritme uit EF.SOd
            ////         De handtekening bevindt zich in de EF.SOd data onder:
            ////         T:'30' (ContentInfo)
            ////              T:'A0' (Content)
            ////                   T:'30' (SignedData)
            ////                        T:'31' (SignerInfos)
            ////                             T:'30' (signerInfo)
            ////                                  T:'04' (Signature)
            Signature = this.GetTag("1,30|1,A0|1,30|2,31|1,30|1,04");

            //// Het signedAttrs veld bevindt zich in de EF.SOd data onder:
            //// T:'30' (ContentInfo)
            ////      T:'A0' (Content)
            ////           T:'30' (SignedData)
            ////                T:'30' (SignerInfo)
            ////                     T:'A0' (signedAttrs)
            SignedAttrs = this.GetTag("1,30|1,A0|1,30|2,31|1,30|1,A0");

            ////         Het gebruikte algoritme is te vinden in de EF.SOd onder:
            ////         T:'30' (ContentInfo)
            ////              T:'A0' (Content)
            ////                   T:'30' (SignedData)
            ////                        T:'31' (SignerInfos)
            ////                             T:'30' (SignerInfo)
            ////                                  T:''30' (SignatureAlgorithm)
            ////                                        T:'06' (algorithm)
            tag = this.GetTag("1,30|1,A0|1,30|2,31|1,30|3,30|1,06");
            if (tag != null)
            {
                SignatureAlgorithm = new System.Security.Cryptography.Oid(EVR.Utils.Oid.Decode(tag.Value));
            }

            ////    Het hash algoritme bevindt zich in EF.SOd onder:
            ////    T:'30' (ContentInfo)
            ////         T:'A0' (Content)
            ////              T:'30' (SignedData)
            ////                   T:'31' (SignerInfos)
            ////                        T:'30' (SignerInfo)
            ////                             T:'30' (digestAlgorithm)
            ////                                  T:'06' (algorithm)
            tag = this.GetTag("1,30|1,A0|1,30|2,31|1,30|2,30|1,06");
            if (tag != null)
            {
                DigestAlgorithm = new System.Security.Cryptography.Oid(EVR.Utils.Oid.Decode(tag.Value));
            }

            //// vi Haal AttributeValue uit signedAttrs
            ////    Binnen signedAttrs bevindt de AttributeValue zich onder:
            ////    T:'30' (Attribute)
            ////         T:'31' (AttrValues)
            ////              T:'04' (AttributeValue)
            AttributeValue = this.GetTag("1,30|1,A0|1,30|2,31|1,30|1,A0|2,30|1,31|1,04");

            //// vii Haal eContent (=RDWidsSecurityObject) uit EF.SOd
            ////     eContent bevindt zich onder:
            ////     T:'30' (ContentInfo)
            ////          T:'A0' (Content)
            ////               T:'30' (SignedData)
            ////                    T:'30' (encapContentInfo)
            ////                         T:'A0' (explicit content)
            ////                              T:'04' (eContent)
            EContent = this.GetTag("1,30|1,A0|1,30|1,30|1,A0|1,04");
        }
示例#15
0
 /*
  * Create a Signature object for the Registration B
  */
 public static EFSignature Create_Signature_B(byte[] AID, CardReader cardReader)
 {
     return(new EFSignature(AID, cardReader, new byte[] { 0xE0, 0x11 }));
 }
示例#16
0
文件: EFAA.cs 项目: steffex/eVR
 public EFAA(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader)
     : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0x00, 0x0D })
 {
 }
示例#17
0
文件: EFSOd.cs 项目: steffex/eVR
        public EFSOd(byte[] AID, X509Certificate2 CSCA, CardReader cardReader)
            : base(AID, cardReader, new byte[] { 0x00, 0x1D })
        {
            this.CSCA = CSCA;

            TLV tag = null;

            //// Haal DS certificaat uit EF.SOd data
            //// DS Certificaat bevindt zich in de EF.SOd data onder:
            //// T:'30' (ContentInfo)
            ////      T:'A0' (Content)
            ////          T:'30' (SignedData)
            ////              T:'A0' (Certificates)
            ////                  V: '30 XX XX ... XX'
            ////                      (DS certificaat begint met tag '30')
            tag = this.GetTag("1,30|1,A0|1,30|1,A0");
            if (tag != null)
            {
                DSCertificate = new X509Certificate2(tag.Value);
            }

            ////      i. Haal handtekening en algoritme uit EF.SOd
            ////         De handtekening bevindt zich in de EF.SOd data onder:
            ////         T:'30' (ContentInfo)
            ////              T:'A0' (Content)
            ////                   T:'30' (SignedData)
            ////                        T:'31' (SignerInfos)
            ////                             T:'30' (signerInfo)
            ////                                  T:'04' (Signature)
            Signature = this.GetTag("1,30|1,A0|1,30|2,31|1,30|1,04");

            //// Het signedAttrs veld bevindt zich in de EF.SOd data onder:
            //// T:'30' (ContentInfo)
            ////      T:'A0' (Content)
            ////           T:'30' (SignedData)
            ////                T:'30' (SignerInfo)
            ////                     T:'A0' (signedAttrs)
            SignedAttrs = this.GetTag("1,30|1,A0|1,30|2,31|1,30|1,A0");

            ////         Het gebruikte algoritme is te vinden in de EF.SOd onder:
            ////         T:'30' (ContentInfo)
            ////              T:'A0' (Content)
            ////                   T:'30' (SignedData)
            ////                        T:'31' (SignerInfos)
            ////                             T:'30' (SignerInfo)
            ////                                  T:''30' (SignatureAlgorithm)
            ////                                        T:'06' (algorithm)
            tag = this.GetTag("1,30|1,A0|1,30|2,31|1,30|3,30|1,06");
            if (tag != null)
            {
                SignatureAlgorithm = new System.Security.Cryptography.Oid(EVR.Utils.Oid.Decode(tag.Value));
            }

            ////    Het hash algoritme bevindt zich in EF.SOd onder:
            ////    T:'30' (ContentInfo)
            ////         T:'A0' (Content)
            ////              T:'30' (SignedData)
            ////                   T:'31' (SignerInfos)
            ////                        T:'30' (SignerInfo)
            ////                             T:'30' (digestAlgorithm)
            ////                                  T:'06' (algorithm)
            tag = this.GetTag("1,30|1,A0|1,30|2,31|1,30|2,30|1,06");
            if (tag != null)
            {
                DigestAlgorithm = new System.Security.Cryptography.Oid(EVR.Utils.Oid.Decode(tag.Value));
            }

            //// vi Haal AttributeValue uit signedAttrs
            ////    Binnen signedAttrs bevindt de AttributeValue zich onder:
            ////    T:'30' (Attribute)
            ////         T:'31' (AttrValues)
            ////              T:'04' (AttributeValue)
            AttributeValue = this.GetTag("1,30|1,A0|1,30|2,31|1,30|1,A0|2,30|1,31|1,04");

            //// vii Haal eContent (=RDWidsSecurityObject) uit EF.SOd
            ////     eContent bevindt zich onder:
            ////     T:'30' (ContentInfo)
            ////          T:'A0' (Content)
            ////               T:'30' (SignedData)
            ////                    T:'30' (encapContentInfo)
            ////                         T:'A0' (explicit content)
            ////                              T:'04' (eContent)
            EContent = this.GetTag("1,30|1,A0|1,30|1,30|1,A0|1,04");
        }
示例#18
0
文件: EFAA.cs 项目: darko0201/eVR
 public EFAA(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader)
     : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0x00, 0x0D })
 {
 }