private async void BtnCrackKey(object sender, RoutedEventArgs e) {
ProgressBar.IsIndeterminate = true;
CheckInput checkInput = SetValues;
checkInput += CheckInputSyntax;
checkInput += CheckInputPrime;
foreach (CheckInput item in checkInput.GetInvocationList()) {
if (item.Invoke()) {
continue;
}
else {
return;
}
}
int i = 0;
Versuche = 0;
//exponent = 1;
stopwatch.Start();
//EXPONENT RESETEN und auf 1 setzen
gmp_lib.mpz_init(exponent);
gmp_lib.mpz_add_ui(exponent, exponent, 1);
ProgressBar.IsIndeterminate = true;
await Task.Run(() =>
{
while (gmp_lib.mpz_cmp(group, exponent) >= 0)
{
Versuche++;
//exponent++;
gmp_lib.mpz_add_ui(exponent, exponent, 1);
gmp_lib.mpz_powm(result, basis, exponent, group);
if (gmp_lib.mpz_cmp(result, ExchangeKeyAlice) == 0)
{
//exponent wird größer als uint
gmp_lib.mpz_init_set(secretKeyAlice, exponent);
i++;
}
if (gmp_lib.mpz_cmp(result, ExchangeKeyBob) == 0)
{
gmp_lib.mpz_init_set(secretKeyBob, exponent);
i++;
}
if (i >= 2)
{
break;
}
}
});
gmp_lib.mpz_powm(sharedSecretKeyAlice, ExchangeKeyBob, secretKeyAlice, group);
gmp_lib.mpz_powm(sharedSecretKeyBob, ExchangeKeyAlice, secretKeyBob, group);
stopwatch.Stop();
ZeitAusgabe.Text = stopwatch.ElapsedMilliseconds.ToString() + " ms";
ProgressBar.IsIndeterminate = false;
stopwatch.Reset();
ausgabeTopR.Text = secretKeyAlice.ToString();
ausgabeTop1R.Text = secretKeyBob.ToString();
ausgabeBottomR.Text = sharedSecretKeyAlice.ToString();
ausgabeBottomR1.Text = Versuche.ToString();
ProgressBar.IsIndeterminate = false;
}