Exemplo n.º 1
0
    protected override bool Asn1Equals(Asn1Object asn1Object)
    {
        DerVisibleString derVisibleString = asn1Object as DerVisibleString;

        if (derVisibleString == null)
        {
            return(false);
        }
        return(str.Equals(derVisibleString.str));
    }
Exemplo n.º 2
0
        private void TestTaggedObject()
        {
            // boolean explicit, int tagNo, ASN1Encodable obj
            bool isExplicit = false;

            // Type1 ::= VisibleString
            DerVisibleString type1 = new DerVisibleString("Jones");

            if (!Arrays.AreEqual(Hex.Decode("1A054A6F6E6573"), type1.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type2 ::= [APPLICATION 3] IMPLICIT Type1
            isExplicit = false;
            DerApplicationSpecific type2 = new DerApplicationSpecific(isExplicit, 3, type1);

            // type2.isConstructed()
            if (!Arrays.AreEqual(Hex.Decode("43054A6F6E6573"), type2.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type3 ::= [2] Type2
            isExplicit = true;
            DerTaggedObject type3 = new DerTaggedObject(isExplicit, 2, type2);

            if (!Arrays.AreEqual(Hex.Decode("A20743054A6F6E6573"), type3.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type4 ::= [APPLICATION 7] IMPLICIT Type3
            isExplicit = false;
            DerApplicationSpecific type4 = new DerApplicationSpecific(isExplicit, 7, type3);

            if (!Arrays.AreEqual(Hex.Decode("670743054A6F6E6573"), type4.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type5 ::= [2] IMPLICIT Type2
            isExplicit = false;
            DerTaggedObject type5 = new DerTaggedObject(isExplicit, 2, type2);

            // type5.isConstructed()
            if (!Arrays.AreEqual(Hex.Decode("82054A6F6E6573"), type5.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }
        }
        private void TestTaggedObject()
        {
            // boolean explicit, int tagNo, ASN1Encodable obj
            bool isExplicit = false;

            // Type1 ::= VisibleString
            DerVisibleString type1 = new DerVisibleString("Jones");
            if (!Arrays.AreEqual(Hex.Decode("1A054A6F6E6573"), type1.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type2 ::= [APPLICATION 3] IMPLICIT Type1
            isExplicit = false;
            DerApplicationSpecific type2 = new DerApplicationSpecific(isExplicit, 3, type1);
            // type2.isConstructed()
            if (!Arrays.AreEqual(Hex.Decode("43054A6F6E6573"), type2.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type3 ::= [2] Type2
            isExplicit = true;
            DerTaggedObject type3 = new DerTaggedObject(isExplicit, 2, type2);
            if (!Arrays.AreEqual(Hex.Decode("A20743054A6F6E6573"), type3.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type4 ::= [APPLICATION 7] IMPLICIT Type3
            isExplicit = false;
            DerApplicationSpecific type4 = new DerApplicationSpecific(isExplicit, 7, type3);
            if (!Arrays.AreEqual(Hex.Decode("670743054A6F6E6573"), type4.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }

            // Type5 ::= [2] IMPLICIT Type2
            isExplicit = false;
            DerTaggedObject type5 = new DerTaggedObject(isExplicit, 2, type2);
            // type5.isConstructed()
            if (!Arrays.AreEqual(Hex.Decode("82054A6F6E6573"), type5.GetEncoded()))
            {
                Fail("ERROR: expected value doesn't match!");
            }
        }