Exemple #1
0
        static void TestSha1()
        {
            String name = "Sha1";

            if (Sha1.IsSupported)
            {
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.HashChoose(x, 20, y), sha1cRes);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.HashParity(x, 20, y), sha1pRes);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.HashMajority(x, 20, y), sha1mRes);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.SchedulePart1(x, y, z), sha1su1Res);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.SchedulePart2(x, y), sha1su2Res);
                if (Sha1.FixedRotate(100) != 25)
                {
                    throw new Exception("Sha1 FixedRotate failed.\n");
                }
            }
            else
            {
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.HashChoose(x, 20, y));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.HashParity(x, 20, y));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.HashMajority(x, 20, y));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.SchedulePart1(x, y, z));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.SchedulePart2(x, y));
            }
        }
Exemple #2
0
            public void RunStructFldScenario(SecureHashUnaryOpTest__FixedRotate_Vector64_UInt32 testClass)
            {
                var result = Sha1.FixedRotate(_fld1);

                Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
            }
Exemple #3
0
        static void TestSha1()
        {
#if ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE
            String name = "Sha1";
            if (Sha1.IsSupported)
            {
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.HashChoose(x, 20, y), sha1cRes);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.HashParity(x, 20, y), sha1pRes);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.HashMajority(x, 20, y), sha1mRes);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.SchedulePart1(x, y, z), sha1su1Res);
                testCryptoOp <uint, Vector128 <uint>, uint, Vector128 <uint> >(name, (x, y, z) => Sha1.SchedulePart2(x, y), sha1su2Res);
                if (Sha1.FixedRotate(100) != 25)
                {
                    throw new Exception("Sha1 FixedRotate failed.\n");
                }
            }
            else
            {
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.HashChoose(x, 20, y));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.HashParity(x, 20, y));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.HashMajority(x, 20, y));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.SchedulePart1(x, y, z));
                testThrowsPlatformNotSupported <Vector128 <uint>, Vector128 <uint>  >(name, (x, y, z) => Sha1.SchedulePart2(x, y));
            }
#endif //ARM64_SIMD_API_PENDING_APPROVAL_AND_OR_COREFX_MERGE
        }
Exemple #4
0
        public void RunClassFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario));

            var result = Sha1.FixedRotate(_fld1);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_fld1, _dataTable.outArrayPtr);
        }
Exemple #5
0
        public void RunStructLclFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario));

            var test   = TestStruct.Create();
            var result = Sha1.FixedRotate(test._fld1);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, _dataTable.outArrayPtr);
        }
Exemple #6
0
        public void RunClassLclFldScenario()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario));

            var test   = new SecureHashUnaryOpTest__FixedRotate_Vector64_UInt32();
            var result = Sha1.FixedRotate(test._fld1);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, _dataTable.outArrayPtr);
        }
Exemple #7
0
        public void RunLclVarScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load));

            var op1    = AdvSimd.LoadVector64((UInt32 *)(_dataTable.inArray1Ptr));
            var result = Sha1.FixedRotate(op1);

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(op1, _dataTable.outArrayPtr);
        }
Exemple #8
0
        public void RunBasicScenario_UnsafeRead()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead));

            var result = Sha1.FixedRotate(
                Unsafe.Read <Vector64 <UInt32> >(_dataTable.inArray1Ptr)
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(_dataTable.inArray1Ptr, _dataTable.outArrayPtr);
        }
Exemple #9
0
        public void RunStructLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario_Load));

            var test   = TestStruct.Create();
            var result = Sha1.FixedRotate(
                AdvSimd.LoadVector64((UInt32 *)(&test._fld1))
                );

            Unsafe.Write(_dataTable.outArrayPtr, result);
            ValidateResult(test._fld1, _dataTable.outArrayPtr);
        }
Exemple #10
0
            public void RunStructFldScenario_Load(SecureHashUnaryOpTest__FixedRotate_Vector64_UInt32 testClass)
            {
                fixed(Vector64 <UInt32> *pFld1 = &_fld1)
                {
                    var result = Sha1.FixedRotate(
                        AdvSimd.LoadVector64((UInt32 *)(pFld1))
                        );

                    Unsafe.Write(testClass._dataTable.outArrayPtr, result);
                    testClass.ValidateResult(_fld1, testClass._dataTable.outArrayPtr);
                }
            }
Exemple #11
0
        public void RunClassFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario_Load));

            fixed(Vector64 <UInt32> *pFld1 = &_fld1)
            {
                var result = Sha1.FixedRotate(
                    AdvSimd.LoadVector64((UInt32 *)(pFld1))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(_fld1, _dataTable.outArrayPtr);
            }
        }
Exemple #12
0
        public void RunClassLclFldScenario_Load()
        {
            TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario_Load));

            var test = new SecureHashUnaryOpTest__FixedRotate_Vector64_UInt32();

            fixed(Vector64 <UInt32> *pFld1 = &test._fld1)
            {
                var result = Sha1.FixedRotate(
                    AdvSimd.LoadVector64((UInt32 *)(pFld1))
                    );

                Unsafe.Write(_dataTable.outArrayPtr, result);
                ValidateResult(test._fld1, _dataTable.outArrayPtr);
            }
        }