private void UpdateIndentityToSecurityLevel(int targetLevel) { if (TsCrypt.GetSecurityLevel(identity) < targetLevel) { Log.Info("Calculating up to required security level: {0}", targetLevel); TsCrypt.ImproveSecurity(identity, targetLevel); config.Connect.Identity.Offset.Value = identity.ValidKeyOffset; } }
public static bool IsValid(string uid) { if (uid == "anonymous" || uid == "serveradmin") { return(true); } var result = TsCrypt.Base64Decode(uid); return(result.Ok && result.Value.Length == 20); }
public static bool IsValid(string uid) { if (uid == Anonymous.Value || uid == ServerAdmin.Value) { return(true); } var result = TsCrypt.Base64Decode(uid); return(result != null && result.Length == 20); }
public E <string> Connect() { // get or compute identity var identityConf = config.Connect.Identity; if (string.IsNullOrEmpty(identityConf.PrivateKey)) { identity = TsCrypt.GenerateNewIdentity(); identityConf.PrivateKey.Value = identity.PrivateKeyString; identityConf.Offset.Value = identity.ValidKeyOffset; } else { var identityResult = TsCrypt.LoadIdentityDynamic(identityConf.PrivateKey.Value, identityConf.Offset.Value); if (!identityResult.Ok) { Log.Error("The identity from the config file is corrupted. Remove it to generate a new one next start; or try to repair it."); return("Corrupted identity"); } identity = identityResult.Value; identityConf.PrivateKey.Value = identity.PrivateKeyString; identityConf.Offset.Value = identity.ValidKeyOffset; } // check required security level if (identityConf.Level.Value >= 0 && identityConf.Level.Value <= 160) { UpdateIndentityToSecurityLevel(identityConf.Level.Value); } else if (identityConf.Level.Value != -1) { Log.Warn("Invalid config value for 'Level', enter a number between '0' and '160' or '-1' to adapt automatically."); } config.SaveWhenExists(); reconnectCounter = 0; lastReconnect = null; reconnectChannel = null; ts3FullClient.QuitMessage = Tools.PickRandom(QuitMessages); ClearAllCaches(); _ = ConnectClient(); return(R.Ok); }
public static Password FromPlain(string pass) => new Password(TsCrypt.HashPassword(pass));
public bool CheckValid() => TsCrypt.EdCheck(this);
public void VersionSelfCheck() { TsCrypt.VersionSelfCheck(); }