public CmsSignedDataParser(CmsTypedStream signedContent, Stream sigData) : base(sigData) { //IL_0130: Expected O, but got Unknown try { _signedContent = signedContent; _signedData = SignedDataParser.GetInstance(contentInfo.GetContent(16)); _digests = Platform.CreateHashtable(); _digestOids = new HashSet(); Asn1SetParser digestAlgorithms = _signedData.GetDigestAlgorithms(); IAsn1Convertible asn1Convertible; while ((asn1Convertible = digestAlgorithms.ReadObject()) != null) { AlgorithmIdentifier instance = AlgorithmIdentifier.GetInstance(asn1Convertible.ToAsn1Object()); try { string id = instance.Algorithm.Id; string digestAlgName = Helper.GetDigestAlgName(id); if (!_digests.Contains((object)digestAlgName)) { _digests.set_Item((object)digestAlgName, (object)Helper.GetDigestInstance(digestAlgName)); _digestOids.Add(id); } } catch (SecurityUtilityException) { } } ContentInfoParser encapContentInfo = _signedData.GetEncapContentInfo(); Asn1OctetStringParser asn1OctetStringParser = (Asn1OctetStringParser)encapContentInfo.GetContent(4); if (asn1OctetStringParser != null) { CmsTypedStream cmsTypedStream = new CmsTypedStream(encapContentInfo.ContentType.Id, asn1OctetStringParser.GetOctetStream()); if (_signedContent == null) { _signedContent = cmsTypedStream; } else { cmsTypedStream.Drain(); } } _signedContentType = ((_signedContent == null) ? encapContentInfo.ContentType : new DerObjectIdentifier(_signedContent.ContentType)); } catch (IOException val) { IOException val2 = val; throw new CmsException("io exception: " + ((global::System.Exception)(object) val2).get_Message(), (global::System.Exception)(object) val2); } }
public CmsSignedDataParser(CmsTypedStream signedContent, Stream sigData) : base(sigData) { try { this._signedContent = signedContent; this._signedData = SignedDataParser.GetInstance(this.contentInfo.GetContent(16)); this._digests = Platform.CreateHashtable(); this._digestOids = new HashSet(); Asn1SetParser digestAlgorithms = this._signedData.GetDigestAlgorithms(); IAsn1Convertible asn1Convertible; while ((asn1Convertible = digestAlgorithms.ReadObject()) != null) { AlgorithmIdentifier instance = AlgorithmIdentifier.GetInstance(asn1Convertible.ToAsn1Object()); try { string id = instance.ObjectID.Id; string digestAlgName = CmsSignedDataParser.Helper.GetDigestAlgName(id); if (!this._digests.Contains(digestAlgName)) { this._digests[digestAlgName] = CmsSignedDataParser.Helper.GetDigestInstance(digestAlgName); this._digestOids.Add(id); } } catch (SecurityUtilityException) { } } ContentInfoParser encapContentInfo = this._signedData.GetEncapContentInfo(); Asn1OctetStringParser asn1OctetStringParser = (Asn1OctetStringParser)encapContentInfo.GetContent(4); if (asn1OctetStringParser != null) { CmsTypedStream cmsTypedStream = new CmsTypedStream(encapContentInfo.ContentType.Id, asn1OctetStringParser.GetOctetStream()); if (this._signedContent == null) { this._signedContent = cmsTypedStream; } else { cmsTypedStream.Drain(); } } this._signedContentType = ((this._signedContent == null) ? encapContentInfo.ContentType : new DerObjectIdentifier(this._signedContent.ContentType)); } catch (IOException ex) { throw new CmsException("io exception: " + ex.Message, ex); } }
/** * base constructor * * @param signedContent the content that was signed. * @param sigData the signature object. */ public CmsSignedDataParser( CmsTypedStream signedContent, Stream sigData) : base(sigData) { try { this._signedContent = signedContent; this._signedData = SignedDataParser.GetInstance(this.contentInfo.GetContent(Asn1Tags.Sequence)); this._digests = Platform.CreateHashtable(); this._digestOids = new HashSet(); Asn1SetParser digAlgs = _signedData.GetDigestAlgorithms(); IAsn1Convertible o; while ((o = digAlgs.ReadObject()) != null) { AlgorithmIdentifier id = AlgorithmIdentifier.GetInstance(o.ToAsn1Object()); try { string digestOid = id.ObjectID.Id; string digestName = Helper.GetDigestAlgName(digestOid); if (!this._digests.Contains(digestName)) { this._digests[digestName] = Helper.GetDigestInstance(digestName); this._digestOids.Add(digestOid); } } catch (SecurityUtilityException) { // TODO Should do something other than ignore it } } // // If the message is simply a certificate chain message GetContent() may return null. // ContentInfoParser cont = _signedData.GetEncapContentInfo(); Asn1OctetStringParser octs = (Asn1OctetStringParser) cont.GetContent(Asn1Tags.OctetString); if (octs != null) { CmsTypedStream ctStr = new CmsTypedStream( cont.ContentType.Id, octs.GetOctetStream()); if (_signedContent == null) { this._signedContent = ctStr; } else { // // content passed in, need to read past empty encapsulated content info object if present // ctStr.Drain(); } } _signedContentType = _signedContent == null ? cont.ContentType : new DerObjectIdentifier(_signedContent.ContentType); } catch (IOException e) { throw new CmsException("io exception: " + e.Message, e); } if (_digests.Count < 1) { throw new CmsException("no digests could be created for message."); } }