public void SetupSshKeyProviderTest() { encoding = new EncodingWrapper(); keyPairGenerator = new AsymmetricKeyPairGenerator(new SecureRandomGenerator()); ecKeyProvider = new EcKeyProvider(keyPairGenerator, new FieldToCurveNameMapper()); provider = new SshKeyProvider(encoding, new Base64Wrapper(), Mock.Of <IRsaKeyProvider>(), Mock.Of <IDsaKeyProvider>(), ecKeyProvider, new SecureRandomGenerator()); base64 = new Base64Wrapper(); }
public void SetupGetKeyFromSsh() { var asymmetricKeyPairGenerator = new AsymmetricKeyPairGenerator(new SecureRandomGenerator()); rsaKeyProvider = new RsaKeyProvider(asymmetricKeyPairGenerator); dsaKeyProvider = new DsaKeyProvider(asymmetricKeyPairGenerator); provider = new SshKeyProvider(new EncodingWrapper(), new Base64Wrapper(), rsaKeyProvider, dsaKeyProvider, ecKeyProvider, null); }
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"); }