public void SetupSshFormattingProviderTest()
        {
            keyProvider      = new Mock <ISshKeyProvider>();
            contentFormatter = new Mock <Ssh2ContentFormatter>();
            contentFormatter.Setup(c => c.FormatToSsh2HeaderLength(It.IsAny <string>()))
            .Returns <string>(s => $"formatted {s}");
            contentFormatter.Setup(c => c.FormatToSsh2KeyContentLength(It.IsAny <string>()))
            .Returns <string>(s => $"formattedkey {s}");

            provider = new SshFormattingProvider(keyProvider.Object, new EncodingWrapper(), contentFormatter.Object, null, new Base64Wrapper());
        }
            public void Setup()
            {
                var randomGenerator = new Mock <SecureRandomGenerator>();

                randomGenerator.Setup(r => r.NextBytes(4))
                .Returns(new byte[] { 1, 1, 1, 1 });

                ecKeyProvider  = new EcKeyProvider(new AsymmetricKeyPairGenerator(new SecureRandomGenerator()), new FieldToCurveNameMapper());
                sshKeyProvider = new SshKeyProvider(new EncodingWrapper(), new Base64Wrapper(), null, null, ecKeyProvider, randomGenerator.Object);

                keyPair  = ecKeyProvider.CreateKeyPair("curve25519");
                provider = new SshFormattingProvider(sshKeyProvider, new EncodingWrapper(), new Ssh2ContentFormatter(), new OpenSshContentFormatter(), new Base64Wrapper());

                string result = provider.GetAsOpenSshPrivateKey(keyPair, "key comment");

                resultLines = result.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            }
            public void SetupGetAsDer()
            {
                var secureRandom = new SecureRandomGenerator();
                var asymmetricKeyPairGenerator = new AsymmetricKeyPairGenerator(secureRandom);
                var rsaKeyProvider             = new RsaKeyProvider(asymmetricKeyPairGenerator);
                var dsaKeyProvider             = new DsaKeyProvider(asymmetricKeyPairGenerator);
                var ecKeyProvier = new EcKeyProvider(asymmetricKeyPairGenerator, new FieldToCurveNameMapper());
                var keyPair      = rsaKeyProvider.CreateKeyPair(1024);
                var key          = keyPair.PublicKey;

                var encoding       = new EncodingWrapper();
                var base64         = new Base64Wrapper();
                var sshKeyProvider = new SshKeyProvider(encoding, base64, rsaKeyProvider, dsaKeyProvider, ecKeyProvier, null);

                var formattingProvider = new SshFormattingProvider(sshKeyProvider, encoding, new Ssh2ContentFormatter(), null, base64);

                ssh2Key    = formattingProvider.GetAsSsh2PublicKey(key, "foo");
                keyContent = sshKeyProvider.GetRsaPublicKeyContent(key);
                openSshKey = formattingProvider.GetAsOpenSshPublicKey(key, "foo");
            }