public void TestCorrectResultIsComputed()
        {
            ActualString = Converters.ConvertBytesToHexString
                               (KdfInstance.GetBytes(ByteCount));

            AssertAreEqual(ExpectedString, ActualString);
        }
        public void TestKdfCloningWorks()
        {
            var kdfInstanceClone = KdfInstance.Clone();

            var result      = KdfInstance.GetBytes(ByteCount);
            var resultClone = kdfInstanceClone.GetBytes(ByteCount);

            AssertAreEqual(result, resultClone, $"Error in '{KdfInstance.Name}' cloning");
        }
        protected void DoTestVector(string password, string salt, int cost, int blockSize,
                                    int parallelism, int outputSize)
        {
            Password = Converters.ConvertStringToBytes(password, Encoding.ASCII);
            Salt     = Converters.ConvertStringToBytes(salt, Encoding.ASCII);

            KdfInstance = HashFactory.KDF.PBKDFScrypt.CreatePBKDFScrypt(Password,
                                                                        Salt, cost, blockSize, parallelism);

            ActualString = Converters.ConvertBytesToHexString(KdfInstance.GetBytes(outputSize));

            AssertAreEqual(ExpectedString, ActualString);
        }
示例#4
0
        public void TestCheckTestVectors()
        {
            foreach (var vector in Blake3TestVectors.Blake3Vectors)
            {
                var chunkedInput = new byte[Convert.ToInt32(vector[0])];
                Array.Copy(fullInput, chunkedInput, chunkedInput.Length);

                KdfInstance = HashFactory.KDF.PBKDFBlake3.CreatePBKDFBlake3(chunkedInput, ctx);

                var output = KdfInstance.GetBytes(vector[3].Length >> 1);

                AssertAreEqual(output, Converters.ConvertHexStringToBytes(vector[3]),
                               "test vector mismatch");
            }
        }
 private byte[] SyncComputation() => KdfInstance.GetBytes(ByteCount);
 public void TestInvalidByteCountThrowsCorrectException() =>
 Assert.Throws <ArgumentException>(() => KdfInstance.GetBytes(Zero));