Exemplo n.º 1
0
        public IJwsTool JwsTool()
        {
            if (KeyType.StartsWith("ES"))
            {
                var tool = new ESJwsTool
                {
                    HashSize = int.Parse(KeyType.Substring(2))
                };
                tool.Init();
                tool.Import(KeyExport);
                return(tool);
            }

            if (KeyType.StartsWith("RS"))
            {
                var tool = new RSJwsTool
                {
                    KeySize = int.Parse(KeyType.Substring(2))
                };
                tool.Init();
                tool.Import(KeyExport);
                return(tool);
            }

            throw new Exception($"Unknown or unsupported KeyType [{KeyType}]");
        }
Exemplo n.º 2
0
        public void SerDesEC()
        {
            var rng = RandomNumberGenerator.Create();

            for (var i = 0; i < 1000; i++)
            {
                var original = new ESJwsTool(); // Default for ISigner
                original.Init();
                var rawX = new byte[8034];
                rng.GetBytes(rawX);
                var sigX = original.Sign(rawX);

                var exported = original.Export();
                var copy     = new ESJwsTool();
                copy.Init();
                copy.Import(exported);
                var verified = copy.Verify(rawX, sigX);

                Assert.AreEqual(true, verified);
            }
        }