Пример #1
0
        public override bool Equals(
            object o)
        {
            if (o == null || !(o is DEROctetString))
            {
                return(false);
            }

            DEROctetString other = (DEROctetString)o;

            byte[] b1 = other.getOctets();
            byte[] b2 = this.getOctets();

            if (b1.Length != b2.Length)
            {
                return(false);
            }

            for (int i = 0; i != b1.Length; i++)
            {
                if (b1[i] != b2[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        /**
         * convert a vector of octet strings into a single byte string
         */
        static private byte[] toBytes(
            ArrayList octs)
        {
            MemoryStream bOut = new MemoryStream();

            for (int i = 0; i != octs.Count; i++)
            {
                DEROctetString o = (DEROctetString)octs[i];

                try
                {
                    byte[] octets = o.getOctets();
                    bOut.Write(octets, 0, octets.Length);
                }
                catch (IOException e)
                {
                    throw new Exception("exception converting octets " + e.ToString());
                }
            }

            return(bOut.ToArray());
        }