Inheritance: Org.BouncyCastle.Asn1.Asn1Encodable
		public override void PerformTest()
        {
            int dataGroupNumber = 1;
            Asn1OctetString dataHash = new DerOctetString(GenerateHash());
            DataGroupHash dg = new DataGroupHash(dataGroupNumber, dataHash);

            CheckConstruction(dg, dataGroupNumber, dataHash);

			try
			{
				DataGroupHash.GetInstance(null);
			}
			catch (Exception)
			{
				Fail("GetInstance() failed to handle null.");
			}

			try
            {
                DataGroupHash.GetInstance(new object());

				Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
		public LdsSecurityObject(
            AlgorithmIdentifier	digestAlgorithmIdentifier,
            DataGroupHash[]		datagroupHash)
        {
            this.digestAlgorithmIdentifier = digestAlgorithmIdentifier;
            this.datagroupHash = datagroupHash;

			CheckDatagroupHashSeqSize(datagroupHash.Length);
        }
        public LdsSecurityObject(
			AlgorithmIdentifier	digestAlgorithmIdentifier,
			DataGroupHash[]		datagroupHash,
			LdsVersionInfo		versionInfo)
        {
            this.version = new DerInteger(1);
            this.digestAlgorithmIdentifier = digestAlgorithmIdentifier;
            this.datagroupHash = datagroupHash;
            this.versionInfo = versionInfo;

            CheckDatagroupHashSeqSize(datagroupHash.Length);
        }
		private void CheckValues(
            DataGroupHash	dg,
            int				dataGroupNumber,
            Asn1OctetString	dataGroupHashValue)
        {
            if (dg.DataGroupNumber != dataGroupNumber)
            {
                Fail("group number don't match.");
            }

			if (!dg.DataGroupHashValue.Equals(dataGroupHashValue))
            {
                Fail("hash value don't match.");
            }
        }
		private void CheckConstruction(
            DataGroupHash dg,
            int dataGroupNumber,
            Asn1OctetString     dataGroupHashValue)
        {
            CheckValues(dg, dataGroupNumber, dataGroupHashValue);

			dg = DataGroupHash.GetInstance(dg);

			CheckValues(dg, dataGroupNumber, dataGroupHashValue);

			Asn1Sequence seq = (Asn1Sequence) Asn1Object.FromByteArray(
				dg.ToAsn1Object().GetEncoded());

			dg = DataGroupHash.GetInstance(seq);

			CheckValues(dg, dataGroupNumber, dataGroupHashValue);
        }
        public override void PerformTest()
        {
            AlgorithmIdentifier  algoId = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1);
            DataGroupHash[] datas = new DataGroupHash[2];

            datas[0] = new DataGroupHash(1, new DerOctetString(GenerateHash()));
            datas[1] = new DataGroupHash(2, new DerOctetString(GenerateHash()));

            LdsSecurityObject so = new LdsSecurityObject(algoId, datas);

			CheckConstruction(so, algoId, datas);

			LdsVersionInfo versionInfo = new LdsVersionInfo("Hello", "world");

			so = new LdsSecurityObject(algoId, datas, versionInfo);

			CheckConstruction(so, algoId, datas, versionInfo);

			try
			{
				LdsSecurityObject.GetInstance(null);
			}
			catch (Exception)
			{
				Fail("GetInstance() failed to handle null.");
			}

			try
            {
                LdsSecurityObject.GetInstance(new object());

                Fail("GetInstance() failed to detect bad object.");
            }
            catch (ArgumentException)
            {
                // expected
            }

			try
            {
				LdsSecurityObject.GetInstance(DerSequence.Empty);

				Fail("constructor failed to detect empty sequence.");
            }
            catch (ArgumentException)
            {
                // expected
            }

			try
            {
                new LdsSecurityObject(algoId, new DataGroupHash[1]);

				Fail("constructor failed to detect small DataGroupHash array.");
            }
            catch (ArgumentException)
            {
                // expected
            }

			try
            {
                new LdsSecurityObject(algoId, new DataGroupHash[LdsSecurityObject.UBDataGroups + 1]);

				Fail("constructor failed to out of bounds DataGroupHash array.");
            }
            catch (ArgumentException)
            {
                // expected
            }
        }
		private void CheckStatement(
            LdsSecurityObject	so,
            AlgorithmIdentifier	digestAlgorithmIdentifier,
            DataGroupHash[]		datagroupHash,
			LdsVersionInfo		versionInfo)
        {
            if (digestAlgorithmIdentifier != null)
            {
                if (!so.DigestAlgorithmIdentifier.Equals(digestAlgorithmIdentifier))
                {
                    Fail("ids don't match.");
                }
            }
            else if (so.DigestAlgorithmIdentifier != null)
            {
                Fail("digest algorithm Id found when none expected.");
            }

			if (datagroupHash != null)
            {
                DataGroupHash[] datas = so.GetDatagroupHash();

                for (int i = 0; i != datas.Length; i++)
                {
                    if (!datagroupHash[i].Equals(datas[i]))
                    {
                        Fail("name registration authorities don't match.");
                    }
                }
            }
            else if (so.GetDatagroupHash() != null)
            {
                Fail("data hash groups found when none expected.");
            }

			if (versionInfo != null)
			{
				if (!versionInfo.Equals(so.VersionInfo))
				{
					Fail("versionInfo doesn't match");
				}
			}
			else if (so.VersionInfo != null)
			{
				Fail("version info found when none expected.");
			}
        }
		private void CheckConstruction(
			LdsSecurityObject	so,
			AlgorithmIdentifier	digestAlgorithmIdentifier,
			DataGroupHash[]		datagroupHash,
			LdsVersionInfo		versionInfo)
		{
			if (!so.Version.Equals(BigInteger.One))
			{
				Fail("version number not 1");
			}

			CheckStatement(so, digestAlgorithmIdentifier, datagroupHash, versionInfo);

			so = LdsSecurityObject.GetInstance(so);

			CheckStatement(so, digestAlgorithmIdentifier, datagroupHash, versionInfo);

			Asn1Sequence seq = (Asn1Sequence) Asn1Object.FromByteArray(
				so.ToAsn1Object().GetEncoded());

			so = LdsSecurityObject.GetInstance(seq);

			CheckStatement(so, digestAlgorithmIdentifier, datagroupHash, versionInfo);
		}
		private void CheckConstruction(
            LdsSecurityObject	so,
            AlgorithmIdentifier	digestAlgorithmIdentifier,
            DataGroupHash[]		datagroupHash)
        {
            CheckStatement(so, digestAlgorithmIdentifier, datagroupHash, null);

			so = LdsSecurityObject.GetInstance(so);

			CheckStatement(so, digestAlgorithmIdentifier, datagroupHash, null);

			Asn1Sequence seq = (Asn1Sequence) Asn1Object.FromByteArray(
				so.ToAsn1Object().GetEncoded());

			so = LdsSecurityObject.GetInstance(seq);

			CheckStatement(so, digestAlgorithmIdentifier, datagroupHash, null);
        }