예제 #1
0
        public void ComputeHash_WithKey_ExceptionTest()
        {
            HmacSha512 hmac = new HmacSha512();

            Exception ex = Assert.Throws <ArgumentNullException>(() => hmac.ComputeHash(null, new byte[1]));

            Assert.Contains("Data can not be null", ex.Message);

            ex = Assert.Throws <ArgumentNullException>(() => hmac.ComputeHash(new byte[1], null));
            Assert.Contains("Key can not be null", ex.Message);

            hmac.Dispose();
            ex = Assert.Throws <ObjectDisposedException>(() => hmac.ComputeHash(new byte[1], new byte[1]));
        }
예제 #2
0
        public void ComputeHash_ExceptionTest()
        {
            HmacSha512 hmac = new HmacSha512();

            Exception ex = Assert.Throws <ArgumentNullException>(() => hmac.ComputeHash(null));

            Assert.Contains("Data can not be null", ex.Message);

            ex = Assert.Throws <ArgumentNullException>(() => hmac.ComputeHash(new byte[1]));
            Assert.Contains("Key must be set before calling this function", ex.Message);

            hmac.Key = new byte[1];
            ex       = Assert.Throws <ArgumentNullException>(() => hmac.ComputeHash(null));
            Assert.Contains("Data can not be null", ex.Message);

            hmac.Dispose();
            ex = Assert.Throws <ObjectDisposedException>(() => hmac.ComputeHash(new byte[1]));
        }
예제 #3
0
        /// <summary>
        /// Releases the resources used by the <see cref="BIP0032"/> class.
        /// </summary>
        /// <param name="disposing">
        /// True to release both managed and unmanaged resources; false to release only unmanaged resources.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (!isDisposed)
            {
                if (disposing)
                {
                    if (!(hmac is null))
                    {
                        hmac.Dispose();
                    }
                    hmac = null;

                    if (!(PrvKey is null))
                    {
                        PrvKey.Dispose();
                    }
                    PrvKey = null;

                    PubKey = null;

                    if (ChainCode != null)
                    {
                        Array.Clear(ChainCode, 0, ChainCode.Length);
                    }
                    ChainCode = null;

                    if (ParentFingerPrint != null)
                    {
                        Array.Clear(ParentFingerPrint, 0, ParentFingerPrint.Length);
                    }
                    ParentFingerPrint = null;

                    if (ChildNumber != null)
                    {
                        Array.Clear(ChildNumber, 0, ChildNumber.Length);
                    }
                    ChildNumber = null;

                    b58Encoder = null;
                }

                isDisposed = true;
            }
        }