public void CipherTest()
        {
            var keyHex      = "92faa793d717675e2be804584a8a98252083fe6bf16010546a92e2ef4bdd27fd";
            var ivHex       = "31164b2f661e41fed5df60bfcfa40baa";
            var inputHex    = "379ddb78c30e5e4bf19dd81ae705796f";
            var expectedHex = "671db60d464b09e9c3b03242dd29bdc5";

            var keyBytes               = CallbackUtils.GetBytesFromHex(keyHex);
            var ivBytes                = CallbackUtils.GetBytesFromHex(ivHex);
            var inputBytes             = CallbackUtils.GetBytesFromHex(inputHex); // decryptedBytes
            var expectedEncryptedBytes = CallbackUtils.GetBytesFromHex(expectedHex);

#if !NETCOREAPP1_1
            var encryptedBytes = CipherCallbacks.AesCrypt(keyBytes, ivBytes, inputBytes, CryptMode.Encrypt);
            encryptedBytes.Should().Equal(expectedEncryptedBytes);

            var decryptedBytes = CipherCallbacks.AesCrypt(keyBytes, ivBytes, encryptedBytes, CryptMode.Decrypt);
            decryptedBytes.Should().Equal(inputBytes);
#else
            var exception = Record.Exception(() => CipherCallbacks.AesCrypt(keyBytes, ivBytes, inputBytes, CryptMode.Encrypt));
            exception.Should().BeOfType <System.PlatformNotSupportedException>();
            exception = Record.Exception(() => CipherCallbacks.AesCrypt(keyBytes, ivBytes, inputBytes, CryptMode.Decrypt));
            exception.Should().BeOfType <System.PlatformNotSupportedException>();
#endif
        }
Esempio n. 2
0
        public void HmacShaTest(int bitness, string inputHex, string keyHex, string expectedHex)
        {
            var keyBytes      = CallbackUtils.GetBytesFromHex(keyHex);
            var inputBytes    = CallbackUtils.GetBytesFromHex(inputHex);
            var expectedBytes = CallbackUtils.GetBytesFromHex(expectedHex);

            var resultBytes = HmacShaCallbacks.CalculateHash(keyBytes, inputBytes, bitness);

            resultBytes.Should().Equal(expectedBytes);
        }
        public void HashTest()
        {
            var inputHex    = "74657374206f66206d6163";
            var expectedHex = "9ff3e52fa31c9e0fa0b08e19c40591553ea64b73709633271975bfab2db9d980";

            var inputBytes    = CallbackUtils.GetBytesFromHex(inputHex);
            var expectedBytes = CallbackUtils.GetBytesFromHex(expectedHex);

            var resultBytes = HashCallback.CalculateHash(inputBytes);

            resultBytes.Should().Equal(expectedBytes);
        }
Esempio n. 4
0
        public void HmacShaTest(int bitness, string inputHex, string keyHex, string expectedHex)
        {
            var keyBytes      = CallbackUtils.GetBytesFromHex(keyHex);
            var inputBytes    = CallbackUtils.GetBytesFromHex(inputHex);
            var expectedBytes = CallbackUtils.GetBytesFromHex(expectedHex);

#if !NETCOREAPP1_1
            var resultBytes = HmacShaCallbacks.CalculateHash(keyBytes, inputBytes, bitness);
            resultBytes.Should().Equal(expectedBytes);
#else
            var exception = Record.Exception(() => HmacShaCallbacks.CalculateHash(keyBytes, inputBytes, bitness));
            exception.Should().BeOfType <System.PlatformNotSupportedException>();
#endif
        }
Esempio n. 5
0
        public void HashTest()
        {
            var inputHex    = "74657374206f66206d6163";
            var expectedHex = "9ff3e52fa31c9e0fa0b08e19c40591553ea64b73709633271975bfab2db9d980";

            var inputBytes    = CallbackUtils.GetBytesFromHex(inputHex);
            var expectedBytes = CallbackUtils.GetBytesFromHex(expectedHex);

#if !NETCOREAPP1_1
            var resultBytes = HashCallback.CalculateHash(inputBytes);
            resultBytes.Should().Equal(expectedBytes);
#else
            var exception = Record.Exception(() => HashCallback.CalculateHash(inputBytes));
            exception.Should().BeOfType <System.PlatformNotSupportedException>();
#endif
        }
        public void CipherTest()
        {
            var keyHex      = "92faa793d717675e2be804584a8a98252083fe6bf16010546a92e2ef4bdd27fd";
            var ivHex       = "31164b2f661e41fed5df60bfcfa40baa";
            var inputHex    = "379ddb78c30e5e4bf19dd81ae705796f";
            var expectedHex = "671db60d464b09e9c3b03242dd29bdc5";

            var keyBytes               = CallbackUtils.GetBytesFromHex(keyHex);
            var ivBytes                = CallbackUtils.GetBytesFromHex(ivHex);
            var inputBytes             = CallbackUtils.GetBytesFromHex(inputHex); // decryptedBytes
            var expectedEncryptedBytes = CallbackUtils.GetBytesFromHex(expectedHex);
            var encryptedBytes         = CipherCallbacks.AesCrypt(keyBytes, ivBytes, inputBytes, CryptMode.Encrypt);

            encryptedBytes.Should().Equal(expectedEncryptedBytes);

            var decryptedBytes = CipherCallbacks.AesCrypt(keyBytes, ivBytes, encryptedBytes, CryptMode.Decrypt);

            decryptedBytes.Should().Equal(inputBytes);
        }