/// <summary> /// Constructs a new EF_DG15 file. /// </summary> /// <param name="data">bytes of the EF_DG15 file</param> public DG15File(byte[] data) { dgNumber = 15; raw = new byte[data.Length]; Array.Copy(data, RawBytes, data.Length); MemoryStream dg15MemStream = new MemoryStream(data); BERTLVInputStream dg15Stream = new BERTLVInputStream(dg15MemStream); int tag = dg15Stream.readTag(); if (tag != IDGFile.EF_DG15_TAG) { throw new ArgumentException("Expected EF_DG15_TAG"); } int dg15Length = dg15Stream.readLength(); byte[] value = dg15Stream.readValue(); Asn1InputStream aIn = new Asn1InputStream(value); /*Asn1Sequence seq = (Asn1Sequence) aIn.ReadObject(); * string alg = ((DerSequence) seq[0])[0].ToString(); * byte[] publicKey = ((DerBitString)seq[1]).GetBytes();*/ SubjectPublicKeyInfo info = SubjectPublicKeyInfo.GetInstance(aIn.ReadObject()); PublicKey = RsaPublicKeyStructure.GetInstance(info.GetPublicKey()); }
/// <summary> /// Constructs a new EF_DG15 file. /// </summary> /// <param name="data">bytes of the EF_DG15 file</param> public DG15File(byte[] data) { dgNumber = 15; raw = new byte[data.Length]; Array.Copy(data, RawBytes, data.Length); MemoryStream dg15MemStream = new MemoryStream(data); BERTLVInputStream dg15Stream = new BERTLVInputStream(dg15MemStream); int tag = dg15Stream.readTag(); if (tag != IDGFile.EF_DG15_TAG) throw new ArgumentException("Expected EF_DG15_TAG"); int dg15Length = dg15Stream.readLength(); byte[] value = dg15Stream.readValue(); Asn1InputStream aIn = new Asn1InputStream(value); /*Asn1Sequence seq = (Asn1Sequence) aIn.ReadObject(); string alg = ((DerSequence) seq[0])[0].ToString(); byte[] publicKey = ((DerBitString)seq[1]).GetBytes();*/ SubjectPublicKeyInfo info = SubjectPublicKeyInfo.GetInstance(aIn.ReadObject()); PublicKey = RsaPublicKeyStructure.GetInstance(info.GetPublicKey()); }