Exemplo n.º 1
0
        public void WriteTest5()
        {
            DerData target = new DerData(); // TODO: Initialize to an appropriate value
            DerData data   = null;          // TODO: Initialize to an appropriate value

            target.Write(data);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Exemplo n.º 2
0
        public void WriteTest4()
        {
            DerData          target     = new DerData();          // TODO: Initialize to an appropriate value
            ObjectIdentifier identifier = new ObjectIdentifier(); // TODO: Initialize to an appropriate value

            target.Write(identifier);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Exemplo n.º 3
0
        public void IsEndOfDataTest()
        {
            DerData target = new DerData(); // TODO: Initialize to an appropriate value
            bool    actual;

            actual = target.IsEndOfData;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemplo n.º 4
0
        public void ReadIntegerTest()
        {
            DerData target   = new DerData(); // TODO: Initialize to an appropriate value
            int     expected = 0;             // TODO: Initialize to an appropriate value
            int     actual;

            actual = target.ReadInteger();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemplo n.º 5
0
        public void EncodeTest()
        {
            DerData target = new DerData(); // TODO: Initialize to an appropriate value

            byte[] expected = null;         // TODO: Initialize to an appropriate value
            byte[] actual;
            actual = target.Encode();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        /// <summary>
        /// Encodes hash using DER.
        /// </summary>
        /// <param name="hashData">The hash data.</param>
        /// <returns>DER Encoded byte array</returns>
        protected byte[] DerEncode(byte[] hashData)
        {
            var alg = new DerData();

            alg.Write(_oid);
            alg.WriteNull();

            var data = new DerData();

            data.Write(alg);
            data.Write(hashData);
            return(data.Encode());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EcdsaKey"/> class.
        /// </summary>
        /// <param name="data">DER encoded private key data.</param>
        public EcdsaKey(byte[] data)
        {
            var der     = new DerData(data);
            var version = der.ReadBigInteger(); // skip version

            // PrivateKey
            var privatekey = der.ReadOctetString().TrimLeadingZeros();

            // Construct
            var s0 = der.ReadByte();

            if ((s0 & 0xe0) != 0xa0)
            {
                throw new SshException(string.Format("UnexpectedDER: wanted constructed tag (0xa0-0xbf), got: {0:X}", s0));
            }
            var tag = s0 & 0x1f;

            if (tag != 0)
            {
                throw new SshException(string.Format("expected tag 0 in DER privkey, got: {0}", tag));
            }
            var construct = der.ReadBytes(der.ReadLength()); // object length

            // curve OID
            var curve_der = new DerData(construct, true);
            var curve     = curve_der.ReadObject();

            // Construct
            s0 = der.ReadByte();
            if ((s0 & 0xe0) != 0xa0)
            {
                throw new SshException(string.Format("UnexpectedDER: wanted constructed tag (0xa0-0xbf), got: {0:X}", s0));
            }
            tag = s0 & 0x1f;
            if (tag != 1)
            {
                throw new SshException(string.Format("expected tag 1 in DER privkey, got: {0}", tag));
            }
            construct = der.ReadBytes(der.ReadLength()); // object length

            // PublicKey
            var pubkey_der = new DerData(construct, true);
            var pubkey     = pubkey_der.ReadBitString().TrimLeadingZeros();

            Import(OidByteArrayToString(curve), pubkey, privatekey);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Key"/> class.
        /// </summary>
        /// <param name="data">DER encoded private key data.</param>
        public Key(byte[] data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            var der     = new DerData(data);
            var version = der.ReadBigInteger();

            var keys = new List <BigInteger>();

            while (!der.IsEndOfData)
            {
                keys.Add(der.ReadBigInteger());
            }

            this._privateKey = keys.ToArray();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Key"/> class.
        /// </summary>
        /// <param name="data">DER encoded private key data.</param>
        protected Key(byte[] data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            var der = new DerData(data);

            der.ReadBigInteger(); // skip version

            var keys = new List <BigInteger>();

            while (!der.IsEndOfData)
            {
                keys.Add(der.ReadBigInteger());
            }

            _privateKey = keys.ToArray();
        }
Exemplo n.º 10
0
        public void DerDataConstructorTest()
        {
            DerData target = new DerData();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }