public static string SetIdentityFromSecKey([ExcelArgument("Path to Secretarium key file")] string secFile, [ExcelArgument("Key password")] string password) { if (string.IsNullOrEmpty(secFile)) { return("Missing Secretarium key file"); } if (string.IsNullOrEmpty(password)) { return("Missing password"); } try { var cfg = JsonHelper.DeserializeJsonFromFileAs <ScpConfig.KeyConfig>(secFile); cfg.password = password; if (cfg.TryGetECDsaKey(out ECDsaCng key)) { Scp.Set(key); } else { return("Could not load your identity"); } } catch (Exception ex) { return("Could not load your identity " + ex.Message); } Logger.InfoFormat(@"New identity set:{0}", Scp.PublicKey); return(Scp.PublicKey); }
public void TestFullProtocolFromSecKeyGcm() { Assert.IsTrue(ScpConfigHelper.TryLoad("test.secKey.json", out ScpConfig config)); Assert.IsTrue(config.TryGetECDsaKey(out ECDsaCng key, "SecretariumTestClient256")); config.encryptionMode = ScpConfig.EncryptionMode.AESGCM; using (var scp = new SecureConnectionProtocol()) { scp.Init(config); scp.Set(key); var connected = scp.Connect(20000); Assert.IsTrue(connected); } }
public void TestFullProtocolFromSecKeyCtr() { Assert.IsTrue(ScpConfigHelper.TryLoad("test.secKey.json", out ScpConfig config)); Assert.IsTrue(config.secretariumKey.TryGetECDsaKeys("SecretariumTestClient256", out byte[] publicKeyRaw, out byte[] privateKeyRaw)); var key = ECDsaHelper.ImportPrivateKey(publicKeyRaw, privateKeyRaw); Assert.NotNull(key); using (var scp = new SecureConnectionProtocol()) { scp.Init(config); scp.Set(key); var connected = scp.Connect(20000); Assert.IsTrue(connected); } }