public async Task <IActionResult> Create(Dh dh) { ValidateDh(dh); if (ModelState.IsValid) { dh.comA = PowWithMod(Convert.ToUInt64(dh.baseG), Convert.ToUInt64(dh.secretA), Convert.ToUInt64(dh.moduP)); dh.comB = PowWithMod(Convert.ToUInt64(dh.baseG), Convert.ToUInt64(dh.secretB), Convert.ToUInt64(dh.moduP)); dh.secretIntA = PowWithMod(Convert.ToUInt64(dh.comB), Convert.ToUInt64(dh.secretA), Convert.ToUInt64(dh.moduP)); dh.secretIntB = PowWithMod(Convert.ToUInt64(dh.comA), Convert.ToUInt64(dh.secretB), Convert.ToUInt64(dh.moduP)); _context.Add(dh); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(dh)); }
public async Task <IActionResult> Edit(int id, Dh dh) { if (id != dh.Id) { return(NotFound()); } if (!IdExists(id)) { return(RedirectToAction("Index")); } ValidateDh(dh); dh.UserId = GetUserId(); if (ModelState.IsValid) { dh.comA = PowWithMod(Convert.ToUInt64(dh.baseG), Convert.ToUInt64(dh.secretA), Convert.ToUInt64(dh.moduP)); dh.comB = PowWithMod(Convert.ToUInt64(dh.baseG), Convert.ToUInt64(dh.secretB), Convert.ToUInt64(dh.moduP)); dh.secretIntA = PowWithMod(Convert.ToUInt64(dh.comB), Convert.ToUInt64(dh.secretA), Convert.ToUInt64(dh.moduP)); dh.secretIntB = PowWithMod(Convert.ToUInt64(dh.comA), Convert.ToUInt64(dh.secretB), Convert.ToUInt64(dh.moduP)); try { _context.Update(dh); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DhExists(dh.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dh)); }
public void ValidateDh(Dh dh) { if (dh.moduP == 0) { ModelState.AddModelError(nameof(dh.moduP), "Value can not be null"); } if (dh.baseG == 0) { ModelState.AddModelError(nameof(dh.baseG), "Value can not be null"); } if (!CheckingPrime(Convert.ToUInt64(dh.moduP))) { ModelState.AddModelError(nameof(dh.moduP), "Value have to be prime"); } if (!IsPrimitiveRoot(Convert.ToUInt64(dh.baseG), Convert.ToUInt64(dh.moduP))) { ModelState.AddModelError(nameof(dh.moduP), "Invalid Input"); } }
private void UpdateAttributes() { Dh.UpdateItemAttributes( Id, enhanceComboBox.SelectedIndex.ToString(), qualityComboBox.SelectedIndex + 1, PrefixClass, SuffixClass, "", itemClassBox.Text, //TODO craftedby, itempartnr RgbToInt(color1), RgbToInt(color2), RgbToInt(color3), 0, 0, combiClassesBox.Text, part1Box.Text, part2Box.Text, part3Box.Text, part4Box.Text, part5Box.Text, ToInt32(combiSkillBox.Text) ); }
/// <summary> /// Overrides the DH function. It should only be used /// from Noise.Tests to fix the ephemeral private key. /// </summary> internal void SetDh(Dh dh) { this.dh = dh; }