Example #1
0
        public static TheoryData <HashTestVector> ReadHashTestVectors(params string[] filenames)
        {
            IEnumerable <string> resourcePaths = filenames.Select(x => $"LibHac.Tests.CryptoTests.TestVectors.{x}");
            var testVectors = new TheoryData <HashTestVector>();

            foreach (string path in resourcePaths)
            {
                using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path))
                {
                    var reader = new RspReader(stream);

                    foreach (HashTestVector tv in reader.GetHashTestVectors())
                    {
                        testVectors.Add(tv);
                    }
                }
            }

            return(testVectors);
        }
Example #2
0
        public static EncryptionTestVector[] ReadEncryptionTestVectorsArray(bool getEncryptTests, params string[] filenames)
        {
            IEnumerable <string> resourcePaths = filenames.Select(x => $"LibHac.Tests.CryptoTests.TestVectors.{x}");
            var testVectors = new List <EncryptionTestVector>();

            foreach (string path in resourcePaths)
            {
                using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path))
                {
                    var reader = new RspReader(stream);

                    foreach (EncryptionTestVector tv in reader.GetEncryptionTestVectors().Where(x => x.Encrypt == getEncryptTests))
                    {
                        testVectors.Add(tv);
                    }
                }
            }

            return(testVectors.ToArray());
        }