コード例 #1
0
ファイル: AccountSigner.cs プロジェクト: zoka-ml/win-acme
        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}]");
        }
コード例 #2
0
        public void SerDesRSA()
        {
            var rng = RandomNumberGenerator.Create();

            for (var i = 0; i < 1000; i++)
            {
                var original = new RSJwsTool(); // 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 RSJwsTool();
                copy.Init();
                copy.Import(exported);
                var verified = copy.Verify(rawX, sigX);

                Assert.AreEqual(true, verified);
            }
        }