private void DCGenerateCertificateButton_Click(object sender, RoutedEventArgs e) { //Create a RSAWrapper object using the dropdown box selection. RSAWrapper envelopeRsaAlgorithm = new RSAWrapper(DCEnvelopeRsaDropdown.SelectedItem.ToString()); //Create a CipherMode object using the dropdown box selection. CipherMode cipherMode = HelperExtensions.StringToCipherMode(DCEnvelopeCipherDropdown.SelectedItem.ToString()); //Create a SymmetricAlgorithmWrapper object using the dropdown box selection and the CipherMode object. SymmetricAlgorithmWrapper symmetricAlgorithmType = HelperExtensions.StringToSymAlg(DCEnvelopeSymDropdown.SelectedItem.ToString(), cipherMode, DCEnvelopeCipherDropdown.SelectedItem.ToString()); //Create a DigitalEnvelope object using the dropdown box selection, the SymmetricAlgorithmWrapper object and the RSAWrapper object. DigitalEnvelope digitalEnvelope = new DigitalEnvelope(symmetricAlgorithmType, envelopeRsaAlgorithm, DCInputTextBox.Text); //Decrypt the envelope. DigitalEnvelopeEncrypted result = digitalEnvelope.CreateEnvelope(); //Create a HashAlgorithmName object using the dropdown box selection. HashAlgorithmName hashAlgorithmName = HelperExtensions.StringToHashAlgorithm(DCSignatureHashDropdown.SelectedItem.ToString()); //Create a RSAWrapper object using the dropdown box selection and the HashAlgorithmName object. RSAWrapper rsaAlgorithm = new RSAWrapper(DCSignatureRsaDropdown.SelectedItem.ToString(), hashAlgorithmName); //Create a DigitalSignature object using the RSAWrapper object and the encrypted envelope data. DigitalSignature digitalSignature = new DigitalSignature(rsaAlgorithm, result.EncryptedDataKeyPair()); //Create a signature for the encrypted envelope data. digitalSignature.CreateSignature(); DCInputTextBlock.Text = "Certificate generated successfully!"; }
private string GetRegisterResponse(Register registerMessage, byte[] AESKey) { var response = AESWrapper.BytesToString(AESKey); var encryptedResponse = RSAWrapper.Encryption(response, registerMessage.Modulus, registerMessage.Exponent); return(encryptedResponse); }
//Generate a signature. private void DSGenerateButton_Click(object sender, RoutedEventArgs e) { //Create a HashAlgorithmName object using the dropdown box selection. HashAlgorithmName hashAlgorithmName = HelperExtensions.StringToHashAlgorithm(DEHashDropdown.SelectedItem.ToString()); //Create a RSAWrapper object using the dropdown box selection and the HashAlgorithmName object. RSAWrapper rsaAlgorithm = new RSAWrapper(DSRsaDropdown.SelectedItem.ToString(), hashAlgorithmName); //Create a DigitalSignature object using the dropdown box selection and the RSAWrapper object. DigitalSignature digitalSignature = new DigitalSignature(rsaAlgorithm, DSInputTextBox.Text); digitalSignature.CreateSignature(); DSInputTextBlock.Text = "Signature generated successfully!"; }
//Generate a digital envelope. private void DEGenerateButton_Click(object sender, RoutedEventArgs e) { //Create a CipherMode object using the dropdown box selection. CipherMode cipherMode = HelperExtensions.StringToCipherMode(DESymTypeDropdown.SelectedItem.ToString()); //Create a SymmetricAlgorithmWrapper object using the dropdown box selections and the CipherMode object. SymmetricAlgorithmWrapper symmetricAlgorithmType = HelperExtensions.StringToSymAlg(DESymDropdown.SelectedItem.ToString(), cipherMode, DESymTypeDropdown.SelectedItem.ToString()); //Create a RSAWrapper object using the dropdown box selection. RSAWrapper rsaAlgorithm = new RSAWrapper(DERsaDropdown.SelectedItem.ToString()); DigitalEnvelope digitalEnvelope = new DigitalEnvelope(symmetricAlgorithmType, rsaAlgorithm, DEInputTextBox.Text); digitalEnvelope.CreateEnvelope(); DEInputTextBlock.Text = "Envelope generated successfully!"; }
public static string Decrypt(this string cipherText) { return(RSAWrapper.Decrypt(cipherText, _certificate)); }
public static string Encrypt(this string plainText) { return(RSAWrapper.Encrypt(plainText, _certificate)); }