/// <summary> /// Decodes a ASN.1-encoded byte array that contains revoked certificate information to a collection. /// </summary> /// <param name="asn">ASN.1 that points to the beginning of the CRL entry collection structure.</param> /// <exception cref="Asn1InvalidTagException">The encoded data is not valid.</exception> /// <exception cref="ArgumentNullException">The <strong>rawData</strong> parameter is null reference.</exception> /// <remarks>This method removes any existing entries in the collection before decoding.</remarks> public void Decode(Asn1Reader asn) { if (asn == null) { throw new ArgumentNullException(nameof(asn)); } if (asn.Tag != 48) { throw new Asn1InvalidTagException(asn.Offset); } Int32 offset = asn.Offset; InternalList.Clear(); InternalList.Capacity = asn.GetNestedNodeCount(); if (!asn.MoveNext()) { throw new Asn1InvalidTagException(asn.Offset); } do { InternalList.Add(new X509CRLEntry(asn)); } while (asn.MoveNextSibling()); asn.Seek(offset); }
void decodePrivate(Byte[] rawData) { Asn1Reader asn = new Asn1Reader(rawData); if (asn.Tag != 48) { throw new ArgumentException("The data is invalid ASN message."); } if (asn.GetNestedNodeCount() > 10) { throw new ArgumentException("The data is too big."); } asn.MoveNext(); version = asn.GetPayload()[0]; if (!asn.MoveNext()) { } modulus = new BigInteger(getNormalizedArray(asn.GetPayload())); if (!asn.MoveNext()) { } pubExponent = new BigInteger(getNormalizedArray(asn.GetPayload())); if (!asn.MoveNext()) { } privateExponent = new BigInteger(getNormalizedArray(asn.GetPayload())); if (!asn.MoveNext()) { } prime1 = new BigInteger(getNormalizedArray(asn.GetPayload())); if (!asn.MoveNext()) { } prime2 = new BigInteger(getNormalizedArray(asn.GetPayload())); if (!asn.MoveNext()) { } exp1 = new BigInteger(getNormalizedArray(asn.GetPayload())); if (!asn.MoveNext()) { } exp2 = new BigInteger(getNormalizedArray(asn.GetPayload())); if (!asn.MoveNext()) { } coefficient = new BigInteger(getNormalizedArray(asn.GetPayload())); Type = KeyType.Private; RawData = rawData; }