public void UnicodeUtf8PageTest() { var clear = @"Hi Meddington, i think i have found the issue. I write this mail as - only text - message. If another receive this email, my signature email and webaddress are i nterpreted as links and will be changed by outlook to html elements. Mit freundlichen Grüßen, Sebastian Lutz Baebeca Solutions - Lutz E-Mail: [email protected] Tel. Büro: 02261 - 9202935 Tel. Mobil: 0171 - 6431821 Web: https://www.baebeca.de PGP Key: 0x5AD0240C "; var context = new CryptoContext(GetPasswordCallback, Pubring, Secring, "rsa", "sha-1"); var crypto = new PgpCrypto(context); var clearSig = crypto.SignClear(clear, "*****@*****.**", Encoding.UTF8, new Dictionary<string, string>()); var ret = crypto.VerifyClear(Encoding.UTF8.GetBytes(clearSig)); Assert.IsTrue(ret); }
// Not working yet //[Test] public void ClearTextSignTest() { var context = new CryptoContext( GetPasswordCallback, @"C:\projects\OutlookPrivacyPlugin\Deja.Crypto.Test\pubring.gpg", @"C:\projects\OutlookPrivacyPlugin\Deja.Crypto.Test\secring.gpg", "rsa", "sha-1"); var crypto = new PgpCrypto(context); var dataDir = @"C:\projects\OutlookPrivacyPlugin\Deja.Crypto.Test\data"; var signKey = "*****@*****.**"; var sign = string.Empty; foreach (var file in Directory.EnumerateFiles(dataDir, "*.bin")) { Console.WriteLine("ClearTextSignTest: " + file); context.Digest = "sha-1"; sign = crypto.SignClear(File.ReadAllText(file), signKey, Encoding.UTF8, new Dictionary<string, string>()); File.WriteAllText(@"c:\temp\test.bin", sign); Assert.AreEqual(File.ReadAllText(file + ".rsa.sha1.clearsign"), sign); context.Digest = "SHA-256"; sign = crypto.SignClear(File.ReadAllText(file), signKey, Encoding.UTF8, new Dictionary<string, string>()); Assert.AreEqual(File.ReadAllText(file + ".rsa.sha256.clearsign"), sign); context.Digest = "SHA-1"; sign = crypto.Sign(File.ReadAllBytes(file), signKey, new Dictionary<string, string>()); File.WriteAllText(@"c:\temp\test.bin", sign); Assert.AreEqual(File.ReadAllText(file + ".rsa.sha1.sign"), sign); } }
private string SignEmail(string data, string key, bool wrapLines = true) { try { var context = new CryptoContext(PasswordCallback, _settings.Cipher, _settings.Digest); var crypto = new PgpCrypto(context); var headers = new Dictionary<string, string>(); headers["Version"] = Localized.DialogTitle; return crypto.SignClear(data, key, this._encoding, headers, wrapLines); } catch (CryptoException ex) { WriteErrorData("SignEmail", ex); MessageBox.Show( ex.Message, Localized.ErrorDialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } }
private string SignEmail(string data, string key) { try { if (!PromptForPasswordAndKey()) return null; var context = new CryptoContext(Passphrase); var crypto = new PgpCrypto(context); var headers = new Dictionary<string, string>(); headers["Version"] = "Outlook Privacy Plugin"; return crypto.SignClear(data, key, this._encoding, headers); } catch (CryptoException ex) { this.Passphrase = null; WriteErrorData("SignEmail", ex); MessageBox.Show( ex.Message, "Outlook Privacy Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } }
private string SignEmail(string data, string key) { try { var context = new CryptoContext(PasswordCallback, _settings.Cipher, _settings.Digest); var crypto = new PgpCrypto(context); var headers = new Dictionary<string, string>(); headers["Version"] = "Outlook Privacy Plugin"; return crypto.SignClear(data, key, this._encoding, headers); } catch (CryptoException ex) { WriteErrorData("SignEmail", ex); MessageBox.Show( ex.Message, "Outlook Privacy Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } }