protected override void Deserialize(DeserializeContext context, byte version) { base.Deserialize(context, version); Request = context.ReadObject<SignatureRequest>(); SecureRequest = context.ReadObject<Secure<SignatureRequest>>(); SecureRequestInfo = context.ReadObject<Secure<SignatureRequestInfo>>(); }
public RequestContainer(SignatureRequest request, Secure<SignatureRequest> secureRequest, Secure<SignatureRequestInfo> secureRequestInfo) { Request = request; SecureRequest = secureRequest; SecureRequestInfo = secureRequestInfo; }
// ファイルに書き込み (ハッシュ付ける) public void WriteToFileWithHash(string filename) { byte[] data = this.ByteData; byte[] hash = Secure.HashSHA1(data); Buf b = new Buf(); b.Write(hash); b.Write(data); b.WriteToFile(filename); }
public ActionResult Login(UserLogin ul) { UserDetailsBEL objUserBEL = new UserDetailsBEL(); if (ModelState.IsValid) { if (ul.UserName.Contains('@')) { objUserBEL.Email_Id = ul.UserName; } else { objUserBEL.Phone_No1 = ul.UserName; } objUserBEL.Password = Secure.Encrypt(ul.Password); UserDetailsDAL objUserDAL = new UserDetailsDAL(); //UserDetailsBEL tr = UserLoginDetailsViewModel vm = new UserLoginDetailsViewModel(objUserDAL.FunAuthenticateUser(objUserBEL)); //UserLoginDetailsViewModel vm = new UserLoginDetailsViewModel(objUserDAL.CheckPhoneNoExists(objUserBEL.Phone_No1)); if (vm.ErrorMessage == string.Empty) { FormsAuthentication.SetAuthCookie(objUserBEL.User_ID, true); Session["userDetail"] = vm; Session["userPhoneNo/Email"] = !string.IsNullOrWhiteSpace(vm.Phone_No1)? vm.Phone_No1: vm.Email_Id; string tempdata; if (TempData["RequestedUrl"] != null) { tempdata = Convert.ToString(TempData["RequestedUrl"]); TempData["RequestedUrl"] = null; //need to modify later return(Redirect("http://localhost/" + tempdata)); // return RedirectToAction(tempdata, "parkingArea"); } else { return(RedirectToAction("Index", "UserDashbaord")); } } else { ModelState.AddModelError("", vm.ErrorMessage.ToString()); } } else { ModelState.AddModelError("", "Login data is incorrect!"); } return(View()); }
public override int GetHashCode() { return(StringComparer.OrdinalIgnoreCase.GetHashCode(_name) ^ StringComparer.OrdinalIgnoreCase.GetHashCode(_value) ^ (Expires.HasValue ? Expires.GetHashCode() : 0) ^ (MaxAge.HasValue ? MaxAge.GetHashCode() : 0) ^ (Domain != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(Domain) : 0) ^ (Path != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(Path) : 0) ^ Secure.GetHashCode() ^ HttpOnly.GetHashCode()); }
void UpdateSignInInfo(string user, string password) { // If the client has changed some settings in the meantime, make sure we keep the changes if (!Options.Load()) { return; } Options.Set("launcher-cc-username", user); Options.Set("launcher-cc-password", Secure.Encode(password, user)); Options.Save(); }
public override string ToString() { string toReturn = string.Empty; toReturn += "ServerAddress: " + ServerAddress + Environment.NewLine; toReturn += "Port: " + Port.ToString() + Environment.NewLine; toReturn += "Secure: " + Secure.ToString() + Environment.NewLine; toReturn += "Channels: " + Channels.ToString() + Environment.NewLine; toReturn += "UserName: "******"fullfilepath: " + fullfilepath + Environment.NewLine; return(toReturn); }
//public void AddNormal(int type) //{ // int n = NumSet(type); // if (GC.ResCount[n, 1] > Value[type - 1, 1]) // { // Value[type - 1, 1] += 1; // NumCheck(false, type); // } // UpdateInfo(); //} //public void ReduceNormal(int type) //{ // int n = NumSet(type); // if (Value[type - 1, 1] > 0) // { // Value[type - 1, 1] -= 1; // NumCheck(true, type); // } // UpdateInfo(); //} //public void AddGood(int type) //{ // int n = NumSet(type); // if (GC.ResCount[n, 2] > Value[type - 1, 2]) // { // Value[type - 1, 2] += 1; // NumCheck(false, type); // } // UpdateInfo(); //} //public void ReduceGood(int type) //{ // int n = NumSet(type); // if (Value[type - 1, 2] > 0) // { // Value[type - 1, 2] -= 1; // NumCheck(true, type); // } // UpdateInfo(); //} //public void AddPerfect(int type) //{ // int n = NumSet(type); // if (GC.ResCount[n, 3] > Value[type - 1, 3]) // { // Value[type - 1, 3] += 1; // NumCheck(false, type); // } // UpdateInfo(); //} //public void ReducePerfect(int type) //{ // int n = NumSet(type); // if (Value[type - 1, 3] > 0) // { // Value[type - 1, 3] -= 1; // NumCheck(true, type); // } // UpdateInfo(); //} void UpdateInfo() { for (int i = 0; i < Text_Counts.Length; i++) { Text_Counts[i].text = Value[i].ToString(); } ValueCalc(); Text_Value[0].text = Art.ToString(); Text_Value[1].text = Function.ToString(); Text_Value[2].text = Fluence.ToString(); Text_Value[3].text = Secure.ToString(); }
private Model_用户 SetData() { Model_用户 m = new Model_用户(); m.用户名 = TextBox_用户名.Text.Trim(); m.密码 = Secure.TranslatePassword(TextBox_用户密码.SecurePassword); m.真实姓名 = TextBox_真实姓名.Text.Trim(); m.权限值 = ComboBox_用户权限.SelectedIndex - 1; m.创建日期 = DateTime.Now; m.用户说明 = TextBox_用户说明.Text.Trim(); return(m); }
/// <summary> /// Get the main Vndb data /// </summary> private void LoadMainData() { try { if (VndbContentViewModel.VnId == 0) { return; } var cred = CredentialManager.GetCredentials(App.CredDb); if (cred == null || cred.UserName.Length < 1) { return; } using (var db = new LiteDatabase($"{App.GetDbStringWithoutPass}'{cred.Password}'")) { var vnInfoEntry = db.GetCollection <VnInfo>(DbVnInfo.VnInfo.ToString()).Query().Where(x => x.VnId == VndbContentViewModel.VnId).FirstOrDefault(); Title = vnInfoEntry.Title; MainTitle = vnInfoEntry.Title; Aliases = vnInfoEntry.Aliases; ReleasedDate = TimeDateChanger.GetHumanDate(DateTime.Parse(vnInfoEntry.Released, CultureInfo.InvariantCulture)); VnLength = vnInfoEntry.Length; Popularity = $"{vnInfoEntry.Popularity:F}"; Rating = $"{vnInfoEntry.Rating:F}"; LoadLanguages(ref vnInfoEntry); var coverPath = $@"{App.AssetDirPath}\sources\vndb\images\cover\{vnInfoEntry.VnId}.jpg"; var rawRating = NsfwHelper.RawRatingIsNsfw(vnInfoEntry.ImageRating); if (rawRating && File.Exists($"{coverPath}.aes")) { var imgBytes = File.ReadAllBytes($"{coverPath}.aes"); var imgStream = Secure.DecStreamToStream(new MemoryStream(imgBytes)); var imgNsfw = ImageHelper.CreateBitmapFromStream(imgStream); CoverImage = imgNsfw; if (NsfwHelper.UserIsNsfw(vnInfoEntry.ImageRating)) { const int blurWeight = 10; CoverImage = ImageHelper.BlurImage(imgNsfw, blurWeight); } } else { CoverImage = File.Exists(coverPath) ? ImageHelper.CreateBitmapFromPath(coverPath) : ImageHelper.CreateEmptyBitmapImage(); } DescriptionInLine = BBCodeHelper.Helper(vnInfoEntry.Description); } } catch (Exception e) { App.Logger.Warning(e, "Failed to load Main Vndb Data"); SentrySdk.CaptureException(e); } }
public static string GetUniqueId(Context currentContext) { string devcieId; var telephonyManager = (TelephonyManager)currentContext.GetSystemService(Context.TelephonyService); devcieId = telephonyManager.DeviceId; if (telephonyManager.DeviceId == null) { devcieId = Secure.GetString(currentContext.ContentResolver, Secure.AndroidId); } return(devcieId); }
public void SetDeviceId() { deviceId = Preferences.Get("deviceId", string.Empty); if (string.IsNullOrWhiteSpace(deviceId)) { // deviceId = Guid.NewGuid().ToString(); deviceId = Secure.GetString(mainActivity.ContentResolver, Secure.AndroidId); Preferences.Set("deviceId", deviceId); } Log.Debug(TAG, "DEVICE ID:" + deviceId); }
private String GetDeviceID() { String result = null; String deviceID = null; deviceID = Secure.GetString(Application.Context.ContentResolver, Secure.AndroidId); if (String.IsNullOrEmpty(deviceID)) { deviceID = Build.Serial; } result = deviceID + "_" + Build.Manufacturer + "_" + Build.Model; return(result); }
private bool ProfileContainsMethod(Secure Secure) { bool contains = false; foreach (IPermission permission in _profile.Permissions) { if (permission.FullMethodName.Equals(Secure.FullName)) { contains = true; break; } } return(contains); }
public string[] GetIdentifier() { var myList = new List <string>(); ContentResolver context = Android.App.Application.Context.ContentResolver; udCode = Secure.GetString(context, Secure.AndroidId); modelNow = Android.OS.Build.Model; myList.Add(modelNow); myList.Add(udCode); var myArray = myList.ToArray(); return(myArray); }
public ZipEncryptionStream(Stream baseStream, bool leaveStreamOpen, string password, byte byte11th) : base(baseStream, leaveStreamOpen, new StreamImplBaseOptions(false, true, false)) { this.Enc = new ZipEncryption(password); // 最初の 12 バイトのダミーデータ (PKZIP のドキュメントではヘッダと呼ばれている) を書き込む byte[] header = new byte[12]; Secure.Rand(12); header[11] = byte11th; this.Write(header); }
public override string ToString() { return(string.Join("\t", new string[7] { Host, Http.ToString().ToUpper(), Path, Secure.ToString().ToUpper(), Expires, Name, Value })); }
protected override void OnInit(EventArgs e) { if (AppServiceStartAction.state != DataBaseService.PingDbState.NoError) { SessionServices.StartSession(HttpContext.Current); return; } base.OnInit(e); Secure.VerifySessionForErrors(); Secure.VerifyAccessLevel(); CommonHelper.DisableBrowserCache(); }
void SaveToOptions(ClientStartData data, bool ccSkins) { if (!Options.Load()) { return; } Options.Set("launcher-dc-username", data.Username); Options.Set("launcher-dc-ip", data.Ip); Options.Set("launcher-dc-port", data.Port); Options.Set("launcher-dc-mppass", Secure.Encode(data.Mppass, data.Username)); Options.Set("launcher-dc-ccskins", ccSkins); Options.Save(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string abc = @"Software\pos\PosPrivate"; Secure scr = new Secure(); bool logic = scr.Algorithm("DA412-628DS-S1VD2-SITCH", abc); if (logic == true) { Application.Run(new Login()); } }
/// <inheritdoc /> public override int GetHashCode() { unchecked { var hashCode = (Method != null ? Method.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Headers != null ? Headers.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Cookies != null ? Cookies.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Body != null ? Body.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Path != null ? Path.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Secure.GetHashCode(); hashCode = (hashCode * 397) ^ KeepAlive.GetHashCode(); return(hashCode); } }
public override bool Connect(IPEndPoint endPoint) { if (State != ConnectionState.OFFLINE) { return(false); } Reset(); EndPoint = endPoint; State = ConnectionState.CONNECT; Token = Secure.RandomUInt32(); SendConnect(); return(true); }
public Client(Socket socket) { _crypt = new Secure(); _readLock = new object(); _writeLock = new object(); _socket = socket; _stream = new NetworkStream(_socket); _reader = new BinaryReader(_stream); _writer = new BinaryWriter(_stream); }
private void Window_Loaded(object sender, RoutedEventArgs e) { string RegistryPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VRodLooP"; Secure scr = new Secure(); bool logic = scr.Algorithm("vikash", RegistryPath); if (logic == true) { GridLogIn.IsEnabled = true; } else { Application.Current.Shutdown(); } }
public async Task <bool> ChangePassword(int id, string old_password, string new_password) { var user = await userRepository.GetAsync(u => u.ID == id && u.Password == Secure.Encryptpass(old_password)); if (user == null || user.DeletedAt != null) { return(false); } user.Password = Secure.Encryptpass(new_password); await userRepository.SaveAsync(); return(true); }
void LoadFromOptions() { if (!Options.Load()) { return; } string user = Options.Get("launcher-cc-username") ?? ""; string pass = Options.Get("launcher-cc-password") ?? ""; pass = Secure.Decode(pass, user); Set(0, user); Set(1, pass); }
private bool DoSignPdfFile(Secure pdf, ConversionProfile profile, X509Certificate2 certificate, TimeServerAccount timeServerAccount) { var signatureSettings = profile.PdfSettings.Signature; if (!certificate.HasPrivateKey) { _logger.Error("Canceled signing. The certificate '" + signatureSettings.CertificateFile + "' has no private key."); throw new ProcessingException( "Canceled signing. The certificate '" + signatureSettings.CertificateFile + "' has no private key.", ErrorCode.Signature_NoPrivateKey); } using (var signature = new Pdftools.PdfSecure.Signature()) { signature.Provider = ""; //"Microsoft Base Cryptographic Provider v1.0;123456"; signature.Name = certificate.GetNameInfo(X509NameType.SimpleName, false); signature.Store = "MY"; signature.StoreLocation = 1; // 0 = Local Machine; 1 = Current User signature.SignerFingerprintStr = certificate.Thumbprint; signature.ContactInfo = signatureSettings.SignContact; signature.Location = signatureSettings.SignLocation; signature.Reason = signatureSettings.SignReason; signature.PageNo = GetSignaturePageNumber(signatureSettings); signature.Rect = GetSignatureRect(signatureSettings); var timeServerUri = new UriBuilder(timeServerAccount.Url); if (timeServerAccount.IsSecured) { timeServerUri.UserName = Uri.EscapeDataString(timeServerAccount.UserName); timeServerUri.Password = Uri.EscapeDataString(timeServerAccount.Password); } signature.TimeStampURL = timeServerUri.ToString(); signature.FillColor = 16777215; //White signature.StrokeColor = 13158600; //Grey if (!signatureSettings.AllowMultiSigning && profile.OutputFormat != OutputFormat.PdfA1B) { return(pdf.AddDocMDPSignature(signature, 1)); } return(pdf.AddSignature(signature)); } }
// Flush to disk public static void Flush() { string txt = IO.CreateTempFileNameByExt(".txt"); byte[] ret = Secure.Rand(64); FileStream f = File.Create(txt); f.Write(ret, 0, ret.Length); f.Flush(); f.Close(); File.Delete(txt); }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Value != null ? Value.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Path != null ? Path.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Secure.GetHashCode(); hashCode = (hashCode * 397) ^ HttpOnly.GetHashCode(); hashCode = (hashCode * 397) ^ (Domain != null ? Domain.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Expires.GetHashCode(); hashCode = (hashCode * 397) ^ MaxAge.GetHashCode(); hashCode = (hashCode * 397) ^ (int)SameSite; return(hashCode); } }
public object Any(Secure request) { var serviceClient = new JsonServiceClient("http://localhost:5003/"); serviceClient.Post(new Authenticate { provider = IdentityServerAuthProvider.Name }); var response = serviceClient.Get(new Hello { Name = request.Name }); return(new SecureResponse { Result = response.Result }); }
/// <summary> /// Releases the unmanaged resources used by the <see cref="T:System.IO.Stream"/> and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { Flush(); Secure.Clear(_nonce); _nonce = null; Secure.Clear(_header); _header = null; //_cipher.Reset(); _cipher = null; _initFunc = null; _output = null; _outLen = 0; _init = false; _inLen = 0; base.Dispose(disposing); }
public ActionResult SignUp(SignupViewModel vm) { UserDetailsBEL objUserBEL = new UserDetailsBEL(); objUserBEL.Email_Id = vm.EmailId; objUserBEL.Password = Secure.Encrypt(vm.Password); objUserBEL.First_Name = vm.FirstName; objUserBEL.Last_Name = vm.LastName; objUserBEL.Phone_No1 = vm.Mobile; UserDetailsDAL objUserDAL = new UserDetailsDAL(); List <string> OTPList = new List <string>(); if (ModelState.IsValid) { UserLoginDetailsViewModel LDvm = new UserLoginDetailsViewModel(objUserDAL.AddUserDetails(objUserBEL)); if (string.IsNullOrEmpty(LDvm.ErrorMessage) && (LDvm.User_ID != "" || LDvm.User_ID != string.Empty)) { //FormsAuthentication.SetAuthCookie(objUserBEL.User_ID, true); Session["userDetail"] = LDvm; // return RedirectToAction("Index", "UserDashbaord"); OTPBEL OTPBel = new OTPBEL(); OTPList = OTPBel.GetAndSendOTP(Convert.ToInt64(objUserBEL.Phone_No1)); if (OTPList != null) { if (Convert.ToBoolean(OTPList[2])) { // Session[OTPList[2]+"_OTP"] = OTPList[0]; Session["OTP"] = OTPList[0]; } } return(RedirectToAction("VerifyOTP", "OTP")); // return RedirectToAction("Login", "TrueWheelsUser"); } else { ModelState.AddModelError("", LDvm.ErrorMessage.ToString()); } } else { // Response.Write(ModelState.SelectMany(x => x.Value.Errors.Select(z => z.Exception))); ModelState.AddModelError("", "Data is incorrect!"); } return(View()); }
public Boolean Get_Security(string path_to_password) { try { var read_key = File.ReadAllBytes(path_to_password); var read_key_sub_array = new byte[32]; Buffer.BlockCopy(read_key, 0, read_key_sub_array, 0, 32); security = new Secure(read_key_sub_array); return true; } catch (FileNotFoundException e) { return ThrowExceptions.ThrowExceptionError("You provided an invalid path to the password file.", e); } catch (Exception e) { return ThrowExceptions.ThrowExceptionError("Failed to fetch some or all of the securities.", e); } }
public override void Begin() { if (Status.Certificate == null) { SetEnable(true); this.printButton.Enabled = false; this.uploadButton.Enabled = false; this.done = false; } else if (Status.Certificate.Validate(Status.CertificateStorage) == CertificateValidationResult.Valid) { SetEnable(false); this.printButton.Enabled = false; this.uploadButton.Enabled = false; this.done = true; Status.SetMessage(Resources.CheckCertificateReady, MessageType.Info); } else { string signatureRequestDataFileName = Path.Combine(Status.DataPath, Status.Certificate.Id.ToString() + Files.SignatureRequestDataExtension); if (File.Exists(signatureRequestDataFileName)) { if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(Status.Certificate, GuiResources.UnlockActionSignRequest)) { this.signatureRequest = Serializable.Load<SignatureRequest>(signatureRequestDataFileName); this.signatureRequestInfo = new SignatureRequestInfo( this.signatureRequest.EmailAddress, this.signatureRequest.Encrypt()); this.secureSignatureRequest = new Secure<SignatureRequest>(this.signatureRequest, Status.CaCertificate, Status.Certificate); this.secureSignatureRequestInfo = new Secure<SignatureRequestInfo>(this.signatureRequestInfo, Status.ServerCertificate, Status.Certificate); if (Status.Certificate is VoterCertificate) { this.typeComboBox.SelectedIndex = 0; } else if (Status.Certificate is AuthorityCertificate) { this.typeComboBox.SelectedIndex = 1; } else if (Status.Certificate is AdminCertificate) { this.typeComboBox.SelectedIndex = 2; } this.firstNameTextBox.Text = this.signatureRequest.FirstName; this.familyNameTextBox.Text = this.signatureRequest.FamilyName; this.emailAddressTextBox.Text = this.signatureRequest.EmailAddress; if (Status.Certificate is VoterCertificate) { this.groupComboBox.Value = Status.Groups.Where(group => group.Id == ((VoterCertificate)Status.Certificate).GroupId).Single(); } SetEnable(false); this.printButton.Enabled = true; this.uploadButton.Enabled = true; this.done = false; } else { Status.CertificateFileName = null; Status.Certificate = null; SetEnable(true); this.printButton.Enabled = false; this.uploadButton.Enabled = false; this.done = false; Status.SetMessage(Resources.SimpleCreateCertificateSigningCanceled, MessageType.Info); } } else { File.Move(Status.CertificateFileName, Status.CertificateFileName + Files.BakExtension); Status.CertificateFileName = null; Status.Certificate = null; SetEnable(true); this.printButton.Enabled = false; this.uploadButton.Enabled = false; this.done = false; Status.SetMessage(Resources.SimpleCreateCertificateFileMissing, MessageType.Error); } } OnUpdateWizard(); }
public void SecureNonDecryptionTest() { Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty)); Secure<Option> encryptedOption = new Secure<Option>(option, this.admin.OnlyPublicPart, this.admin); Option other = encryptedOption.Value.Decrypt(this.eve); }
private void sendButton_Click(object sender, EventArgs e) { SetEnable(false); this.run = true; OnUpdateWizard(); SignatureRequest signatureRequest = new SignatureRequest( this.firstNameTextBox.Text, this.familyNameTextBox.Text, this.emailAddressTextBox.Text); SignatureRequestInfo signatureRequestInfo = new SignatureRequestInfo( this.emailAddressTextBox.Text, signatureRequest.Encrypt()); SignatureRequestDocument document = new SignatureRequestDocument( signatureRequest, Status.Certificate, Status.GetGroupName); SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = GuiResources.SaveDocumentDialogTitle; dialog.Filter = Files.PdfFileFilter; if (dialog.ShowDialog() == DialogResult.OK) { document.Create(dialog.FileName); Secure<SignatureRequest> secureSignatureRequest = new Secure<SignatureRequest>(signatureRequest, Status.CaCertificate, Status.Certificate); Secure<SignatureRequestInfo> secureSignatureRequestInfo = new Secure<SignatureRequestInfo>(signatureRequestInfo, Status.ServerCertificate, Status.Certificate); Status.VotingClient.SetSignatureRequest(secureSignatureRequest, secureSignatureRequestInfo, SetSignatureRequestComplete); while (this.run) { Status.UpdateProgress(); Thread.Sleep(10); } Status.UpdateProgress(); if (this.exception == null) { Status.SetMessage(Resources.CreateCertificateDone, MessageType.Success); } else { Status.SetMessage(this.exception.Message, MessageType.Error); } } else { SetEnable(true); this.run = false; } OnUpdateWizard(); }
public FetchSignatureRequestResponse(Guid requestId, Secure<SignatureRequest> signatureRequest) : base(requestId) { SecureSignatureRequest = signatureRequest; }
private void Upload() { if (Status.Controller.Status.ServerCertificate != null) { if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(Status.Certificate, GuiResources.UnlockActionSignRequest)) { try { Pirate.PiVote.Circle.Status.TextStatusDialog.ShowInfo(Status.Controller, FindForm()); var secureSignatureRequest = new Secure<SignatureRequest>(Status.SignatureRequest, Status.Controller.Status.CaCertificate, Status.Certificate); var secureSignatureRequestInfo = new Secure<SignatureRequestInfo>(Status.SignatureRequestInfo, Status.Controller.Status.ServerCertificate, Status.Certificate); Status.Controller.SetSignatureRequest(secureSignatureRequest, secureSignatureRequestInfo); } catch (Exception exception) { Error.ErrorDialog.ShowError(exception); } finally { Status.Certificate.Lock(); Pirate.PiVote.Circle.Status.TextStatusDialog.HideInfo(); } } } else { MessageForm.Show(Resources.CreateCertificateServerCertificateInvalidMessage, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } this.uploaded = true; }
private void createButton_Click(object sender, EventArgs e) { this.run = true; OnUpdateWizard(); SetEnable(false); var encryptResult = EncryptPrivateKeyDialog.ShowSetPassphrase(); if (encryptResult.First == DialogResult.OK) { string passphrase = encryptResult.Second; Status.Certificate = new VoterCertificate(Resources.Culture.ToLanguage(), passphrase, this.groupComboBox.Value.Id); Status.Certificate.CreateSelfSignature(); Status.CertificateFileName = Path.Combine(Status.DataPath, Status.Certificate.Id.ToString() + Files.CertificateExtension); Status.Certificate.Save(Status.CertificateFileName); Certificate parentCertificate = TryFindValidParentCertificate(); if (parentCertificate != null) { DateTime parentValidUntil = parentCertificate.ExpectedValidUntil(Status.CertificateStorage, DateTime.Now); DialogResult result = DialogResult.Yes; while (result == DialogResult.Yes) { result = MessageForm.Show( string.Format(Resources.AskToSignSignatureRequestWithParent, parentValidUntil), GuiResources.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, DialogResult.Yes); if (result == DialogResult.Yes && DecryptPrivateKeyDialog.TryDecryptIfNessecary(parentCertificate, string.Empty)) { this.signatureRequest = new SignatureRequest2(this.firstNameTextBox.Text, this.familyNameTextBox.Text, this.emailAddressTextBox.Text, parentCertificate); result = DialogResult.OK; } parentCertificate.Lock(); } } if (this.signatureRequest == null) { this.signatureRequest = new SignatureRequest(this.firstNameTextBox.Text, this.familyNameTextBox.Text, this.emailAddressTextBox.Text); } this.signatureRequestInfo = new SignatureRequestInfo( this.emailNotificationCheckBox.Checked ? this.emailAddressTextBox.Text : string.Empty, this.signatureRequest.Encrypt()); this.secureSignatureRequest = new Secure<SignatureRequest>(this.signatureRequest, Status.CaCertificate, Status.Certificate); this.secureSignatureRequestInfo = new Secure<SignatureRequestInfo>(this.signatureRequestInfo, Status.ServerCertificate, Status.Certificate); string signatureRequestDataFileName = Path.Combine(Status.DataPath, Status.Certificate.Id.ToString() + Files.SignatureRequestDataExtension); this.signatureRequest.Save(signatureRequestDataFileName); this.run = false; OnUpdateWizard(); if (this.signatureRequest is SignatureRequest2) { this.uploadButton.Enabled = true; } else { this.printButton.Enabled = true; } } else { this.run = false; OnUpdateWizard(); SetEnable(true); } }
/// <summary> /// Create a new vote cast opeation. /// </summary> /// <param name="signatureRequest">Signature Request signed and encrypted for the CA.</param> /// <param name="signatureRequestInfo">Signature Request Info signed and encrypted for the server.</param> /// <param name="callBack">Callback upon completion.</param> public SetSignatureRequestOperation(Secure<SignatureRequest> signatureRequest, Secure<SignatureRequestInfo> signatureRequestInfo, SetSignatureRequestCallBack callBack) { this.signatureRequest = signatureRequest; this.signatureRequestInfo = signatureRequestInfo; this.callBack = callBack; }
/// <summary> /// Set a signature request. /// </summary> /// <remarks> /// Add or replaces a signature request. /// </remarks> /// <param name="signatureRequest">Signed signature request.</param> public void SetSignatureRequest( IRpcConnection connection, Secure<SignatureRequest> signatureRequest, Secure<SignatureRequestInfo> signatureRequestInfo) { Guid id = signatureRequest.Certificate.Id; if (signatureRequest.Certificate.Id != signatureRequestInfo.Certificate.Id) { Logger.Log(LogLevel.Warning, "Connection {0}: Certificate id {1} (unverified) tried to set a signature request, but the certificate id on the request info was {2}.", connection.Id, signatureRequest.Certificate.Id.ToString(), signatureRequestInfo.Certificate.Id); throw new PiArgumentException(ExceptionCode.SignatureRequestInvalid, "Signature request invalid."); } if (!signatureRequest.VerifySimple()) { Logger.Log(LogLevel.Warning, "Connection {0}: Certificate id {1} (unverified) tried to set a signature request, but the signature on the request was invalid.", connection.Id, signatureRequest.Certificate.Id.ToString()); throw new PiArgumentException(ExceptionCode.SignatureRequestInvalid, "Signature request invalid."); } if (!signatureRequestInfo.VerifySimple()) { Logger.Log(LogLevel.Warning, "Connection {0}: Certificate id {1} (unverified) tried to set a signature request, but the signature on the request info was invalid.", connection.Id, signatureRequest.Certificate.Id.ToString()); throw new PiArgumentException(ExceptionCode.SignatureRequestInvalid, "Signature request invalid."); } SignatureRequestInfo requestInfo = signatureRequestInfo.Value.Decrypt(this.serverCertificate); if (!requestInfo.Valid) { Logger.Log(LogLevel.Warning, "Connection {0}: Certificate id {1} (unverified) tried to set a signature request, but the request data was invalid.", connection.Id, signatureRequest.Certificate.Id.ToString()); throw new PiArgumentException(ExceptionCode.InvalidSignatureRequest, "Signature request data not valid."); } MySqlCommand replaceCommand = new MySqlCommand("REPLACE INTO signaturerequest (Id, Value, Info) VALUES (@Id, @Value, @Info)", DbConnection); replaceCommand.Parameters.AddWithValue("@Id", id.ToByteArray()); replaceCommand.Parameters.AddWithValue("@Value", signatureRequest.ToBinary()); replaceCommand.Parameters.AddWithValue("@Info", signatureRequestInfo.ToBinary()); replaceCommand.ExecuteNonQuery(); Logger.Log(LogLevel.Info, "Connection {0}: Signature request for certificate id {1} stored.", connection.Id, signatureRequest.Certificate.Id.ToString()); MySqlCommand deleteCommand = new MySqlCommand("DELETE FROM signatureresponse WHERE Id = @Id", DbConnection); deleteCommand.Parameters.AddWithValue("@Id", id.ToByteArray()); deleteCommand.ExecuteNonQuery(); if (signatureRequest.Certificate is AuthorityCertificate) { CertificateStorage.Add(signatureRequest.Certificate); } if (!requestInfo.EmailAddress.IsNullOrEmpty()) { SendMail( requestInfo.EmailAddress, MailType.VoterRequestDeposited, requestInfo.EmailAddress, signatureRequest.Certificate.Id.ToString(), CertificateTypeText(signatureRequest.Certificate, Language.English), CertificateTypeText(signatureRequest.Certificate, Language.German), CertificateTypeText(signatureRequest.Certificate, Language.French)); } SendMail( this.serverConfig.MailAdminAddress, MailType.AdminNewRequest, requestInfo.EmailAddress.IsNullOrEmpty() ? "?@?.?" : requestInfo.EmailAddress, signatureRequest.Certificate.Id.ToString(), signatureRequest.Certificate.TypeText); }
/// <summary> /// Send a signature request to the server. /// </summary> /// <param name="signatureRequest">Signature Request signed and encrypted for the CA.</param> /// <param name="signatureRequestInfo">Signature Request Info signed and encrypted for the server.</param> /// <param name="callBack">Callback upon completion.</param> public void SetSignatureRequest(Secure<SignatureRequest> signatureRequest, Secure<SignatureRequestInfo> signatureRequestInfo, SetSignatureRequestCallBack callBack) { lock (this.operations) { this.operations.Enqueue(new SetSignatureRequestOperation(signatureRequest, signatureRequestInfo, callBack)); } }
public bool TrySetSignatureRequest(Secure<SignatureRequest> secureSignatureRequest, Secure<SignatureRequestInfo> secureSignatureRequestInfo) { Begin(); Status.VotingClient.SetSignatureRequest(secureSignatureRequest, secureSignatureRequestInfo, SetSignatureRequestComplete); if (WaitForCompletion()) { return true; } else { return false; } }
public void SetSignatureRequest(Secure<SignatureRequest> signatureRequest, Secure<SignatureRequestInfo> signatureRequestInfo) { Begin(); Status.VotingClient.SetSignatureRequest(signatureRequest, signatureRequestInfo, SetSignatureRequestCompleted); if (WaitForCompletion()) { MessageForm.Show(Resources.ControllerSetSignatureRequestOk, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { throw this.exception; } }
public void SecureDecryptionTest() { Option option = new Option(new MultiLanguageString("Test"), new MultiLanguageString(string.Empty), new MultiLanguageString(string.Empty)); Secure<Option> encryptedOption = new Secure<Option>(option, this.admin.OnlyPublicPart, this.admin); Assert.IsTrue(encryptedOption.Verify(this.storage)); Option other = encryptedOption.Value.Decrypt(this.admin); Assert.IsTrue(other.ToBinary().Equal(option.ToBinary())); }
private void createAdminCertificateToolStripMenuItem_Click(object sender, EventArgs e) { CreateAdminDialog dialog = new CreateAdminDialog(); if (dialog.ShowDialog() == DialogResult.OK) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Save Admin Certificate"; saveDialog.CheckPathExists = true; saveDialog.Filter = Files.CertificateFileFilter; if (saveDialog.ShowDialog() == DialogResult.OK) { string fullName = string.Format("{0} {1}, {2}", dialog.FirstName, dialog.FamilyName, dialog.Function); AdminCertificate certificate = new AdminCertificate(Language.English, dialog.Passphrase, fullName); certificate.CreateSelfSignature(); SignatureRequest request = new SignatureRequest(dialog.FirstName, dialog.FamilyName, dialog.EmailAddress); Secure<SignatureRequest> signedRequest = new Secure<SignatureRequest>(request, CaCertificate, certificate); CertificateAuthorityEntry entry = new CertificateAuthorityEntry(signedRequest); entry.Sign(CaCertificate, DateTime.Now, dialog.ValidUntil); certificate.AddSignature(entry.Response.Value.Signature); string entryFileName = DataPath(entry.Certificate.Id.ToString() + ".pi-ca-entry"); entry.Save(DataPath(entryFileName)); ListEntry listEntry = new ListEntry(entryFileName, entry, CaCertificate); Entries.Add(listEntry); this.entryListView.Items.Add(listEntry.CreateItem(CaCertificate)); certificate.Save(saveDialog.FileName); } } }
private void okButton_Click(object sender, EventArgs e) { this.passphraseTextBox.Enabled = false; this.repeatTextBox.Enabled = false; this.okButton.Enabled = false; var signatureRequest = this.controller.UserData; var certificate = new VoterCertificate(Language.German, this.passphraseTextBox.Text, 0); certificate.CreateSelfSignature(); var secureRequest = new Secure<SignatureRequest>(signatureRequest, this.caCertificate, certificate); var requestInfo = new SignatureRequestInfo(string.Empty, signatureRequest.Encrypt()); var secureRequestInfo = new Secure<SignatureRequestInfo>(requestInfo, this.controller.ServerCertificate, certificate); var requestContainer = new RequestContainer(signatureRequest, secureRequest, secureRequestInfo); this.requestStatusTextBox.Text = "Übermitteln..."; this.controller.RequestContainer = requestContainer; }
private void createServerCertifiToolStripMenuItem_Click(object sender, EventArgs e) { CreateServerDialog dialog = new CreateServerDialog(); if (dialog.ShowDialog() == DialogResult.OK) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Save Server Certificate"; saveDialog.CheckPathExists = true; saveDialog.Filter = Files.CertificateFileFilter; if (saveDialog.ShowDialog() == DialogResult.OK) { ServerCertificate certificate = new ServerCertificate(dialog.FullName); certificate.CreateSelfSignature(); SignatureRequest request = new SignatureRequest(dialog.FullName, string.Empty, string.Empty); Secure<SignatureRequest> signedRequest = new Secure<SignatureRequest>(request, CaCertificate, certificate); CertificateAuthorityEntry entry = new CertificateAuthorityEntry(signedRequest); entry.Sign(CaCertificate, DateTime.Now, dialog.ValidUntil); certificate.AddSignature(entry.Response.Value.Signature); string entryFileName = DataPath(entry.Certificate.Id.ToString() + ".pi-ca-entry"); entry.Save(DataPath(entryFileName)); ListEntry listEntry = new ListEntry(entryFileName, entry, CaCertificate); Entries.Add(listEntry); this.entryListView.Items.Add(listEntry.CreateItem(CaCertificate)); certificate.Save(saveDialog.FileName); } } }
/// <summary> /// Creates a new certificate entry. /// </summary> /// <param name="request">Request to create from.</param> public CertificateAuthorityEntry(Secure<SignatureRequest> request) { Request = request; Response = null; Revoked = false; }