1.1.101
Chris Fuertes 3 years ago
parent fa4d91f85c
commit 177df84068
  1. 10
      chrome/content/columnOverlay.js
  2. BIN
      chrome/content/green-shield-white.png
  3. 36
      chrome/content/modules/pEp.js
  4. 36
      chrome/content/modules/pEpAdapter.js
  5. BIN
      chrome/content/no-color-shield-white.png
  6. 0
      chrome/content/options.js
  7. 55
      chrome/content/options.xul
  8. 32
      chrome/content/p4tb.js
  9. 17
      chrome/content/pEp.css
  10. 30
      chrome/content/pEpMimeEncrypt.js
  11. 22
      chrome/content/pepmessengercompose.js
  12. 224
      chrome/content/pepmsghdrview.js
  13. BIN
      chrome/content/red-shield-white.png
  14. BIN
      chrome/content/yellow-shield-white.png
  15. 1
      chrome/defaults/preferences/defaults.js
  16. 3
      chrome/defaults/preferences/pref.js
  17. 2
      chrome/install.rdf
  18. 3
      tests/features/decrypt_feature_spec.js
  19. 56
      tests/features/decrypt_mime_feature_spec.js
  20. 89
      tests/features/enc_dec_feature_spec.js
  21. 20
      tests/features/encrypt_feature_spec.js
  22. 2
      tests/features/get_mime_decode_message_feature.js
  23. 9
      tests/features/result_test_mime.eml
  24. 117
      tests/features/test_mime.eml
  25. 11
      tests/test.html

@ -75,6 +75,16 @@ let columnHandler = {
let ColumnOverlay = {
init: () => {
console.log("columnOverlay.js: init()");
let prefs = Services.prefs.getBranch("extensions.p4tb.");
//Open options for configuring if this is the first time
if (prefs.getBoolPref("first_run")) {
// let options = window.openDialog("chrome://p4t/content/options.xul",
// "options", "chrome,centerscreen");
// options.focus();
}
window.addEventListener("load", columnHandler.onLoadpEp, false);
},
destroy: () => {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 808 B

@ -23,8 +23,10 @@ const ENV_USER = "USER";
const DIR_INCOMING = 0;
const DIR_OUTGOING = 1;
const ENC_FORMAT_PEP = 4;
const ENC_FORMAT_NONE = 0;
const ENC_FORMAT_PGP_MIME = 3;
const ENC_FORMAT_PEP = 4;
const PEP_PREFIX = "pEp-";
class pEp {
@ -54,7 +56,7 @@ class pEp {
/**
* Function called on send mail
*/
async encryptMail(subject = "", body = "", htmlBody = "", from = "", to = [], cc = [], bcc = [], encodingFormat = ENC_FORMAT_PEP) {
async encryptMail(subject = "", body = "", htmlBody = "", from = "", to = [], cc = [], bcc = [], encodingFormat = ENC_FORMAT_PGP_MIME) {
this.log("pEp: encryptMail()", "subject:", subject, "body:", body, "from:", from, "to:", to, "cc: ", cc, "bcc: ", bcc);
if (typeof bcc !== "undefined" && bcc.length > 0) {
@ -71,14 +73,11 @@ class pEp {
if (cc) {
message.setCc(cc)
}
if (typeof bcc != "undefined" && bcc.length > 0) {
message.setBcc(bcc);
}
return await this.encryptMailWithMessage(message);
return await this.encryptMailWithMessage(message, encodingFormat);
}
async encryptMailWithMessage(message, encodingFormat = ENC_FORMAT_PEP) {
async encryptMailWithMessage(message, encodingFormat = ENC_FORMAT_PGP_MIME) {
message.dir = DIR_OUTGOING;
message.enc_format = encodingFormat;
let result = await this.adapter.encrypt_message(message);
@ -130,7 +129,7 @@ class pEp {
}
async getOngoingRating(from, to = [], cc, bcc) {
this.log("getOngoingRating: ", to, cc, bcc);
this.log("getOngoingRating: ", from, to, cc, bcc);
const filteredTo = to.filter( (address) => typeof address === "string" || (typeof address.address !== "undefined" && address.address !== ""));
if(filteredTo.length < 1)
@ -218,12 +217,17 @@ pEp.Identity = class {
this.fingerprint = fingerprint;
}
else {
this.user_id = address.user_id;
this.username = address.username;
this.address = address.address;
this.fingerprint = address.fingerprint;
console.log("==============");
console.log(address);
console.log(typeof address);
console.log("==============");
Object.assign(this, address);
}
}
toMail() {
return this.username + " <" + this.address +">";
}
};
pEp.Attachment = class {
@ -251,9 +255,13 @@ if (typeof btoa === "undefined") {
}
pEp.Message = class {
constructor(id, short, long, from, to = [], dir = DIR_OUTGOING, enc_format = ENC_FORMAT_PEP, attachmentsArray = [], optFieldsArray = [], formatted_long = undefined) {
constructor(id, short, long, from, to = [], dir = DIR_OUTGOING, enc_format = ENC_FORMAT_PGP_MIME, attachmentsArray = [], optFieldsArray = [], formatted_long = undefined) {
if (typeof to === "string") to = [to];
console.log("==============");
console.log("NEW MESSAGE");
console.log(id, short, long, from, to );
console.log("==============");
this.id = id;
this.shortmsg = short;
this.longmsg = long;

@ -20,6 +20,7 @@ const PEP_WRONG_SEC_TOKEN_CODE = -32600;
const JRPC_INTERNAL_ERROR = -32603;
const PEP_RESPONSE_OK = 0;
const PEP_ILLEGAL_VALUE = -4;
const PEP_UNENCRYPTED = 1024;
const PEP_RESPONSE_DECRYPTED = 1026;
const PEP_KEY_NOT_FOUND = 0x0201;
@ -100,8 +101,7 @@ class pEpAdapter {
).then((response) => {
console.log("pEpAdapter.js: decrypt() success: ", response);
if ((typeof(response) === "object") && response.hasOwnProperty("error")) {
if ((typeof (response) === "object") && response.hasOwnProperty("error")) {
switch (response.error.code) {
case PEP_WRONG_SEC_TOKEN_CODE:
this.server.reload();
@ -130,10 +130,9 @@ class pEpAdapter {
case(PEP_RESPONSE_OK):
case(PEP_RESPONSE_DECRYPTED):
if(response.result.outParams[1].rating === 2) {
if (response.result.outParams[1].rating === 2 || response.result.outParams[1].rating === 3) {
decryptedMessage = message;
}
else {
} else {
decryptedMessage = response.result.outParams[3];
}
decryptedMessage.rating = response.result.outParams[1].rating;
@ -154,16 +153,23 @@ class pEpAdapter {
}
return decryptedMessage;
}).catch((err) => {
console.log("==============");
console.log("ERROR", err);
console.log("==============");
});
}
async encrypt_message(message) {
console.log("=== ENCRYPTALO ===========");
console.log(message);
console.log("==============");
let params = [
message,
[],
["OP"],
message.enc_format,
0
message, // Outgoing encrypted message
[], // Extra keys
["OP"], // Output message
message.enc_format, // Encoding Format
0 // Flags
];
this.log("pEpAdapter.js: encrypt_message()", message);
return await this.server.callPepAdapter(
@ -175,7 +181,7 @@ class pEpAdapter {
this.log("RESPONSE: pEpAdapter.js: encrypt_message()", response);
let encryptedMessage = {};
if ((typeof(response) === "object") && response.hasOwnProperty("error")) {
if ((typeof (response) === "object") && response.hasOwnProperty("error")) {
switch (response.error.code) {
case PEP_WRONG_SEC_TOKEN_CODE:
throw new Error({code: "PEP-ERROR", message: "Invalid Security Token", response});
@ -208,6 +214,10 @@ class pEpAdapter {
this.log("callPepAdapter: 'encrypt' returned with UNENCRYPTED status: ", response);
break;
case(PEP_ILLEGAL_VALUE):
encryptedMessage = message;
this.log("callPepAdapter: 'encrypt' returned with illegal value", response.result.return, message);
default:
this.log("callPepAdapter: 'encrypt' returned with error: ", response);
throw new Error({code: "PEP-ERROR", message: response});
@ -256,11 +266,11 @@ class pEpAdapter {
// );
let cachedMail = this.ratings[identity.address];
if(cachedMail) {
if (cachedMail) {
return cachedMail;
}
let params = [ identity, ["OP"] ];
let params = [identity, ["OP"]];
return await this.server.callPepAdapter(
SERVER_TYPE_CALL_FUNC,
API_METHOD_IDENTITY_RATING,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 774 B

@ -0,0 +1,55 @@
<?xml version="1.0"?>
<!-- (C) Copyright 2017 Grier Forensics. All rights reserved.-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://greatdane/content/pEp.css" type="text/css" ?>
<prefwindow
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="pEp-prefs"
title="Pretty Easy Privacy options" >
<script type="application/x-javascript" src="chrome://pEp/content/options.js" />
<prefpane id="pEp-engine" label="Engine" image="chrome://messenger/skin/preferences/general.png">
<preferences>
<preference id="url" name="extensions.pEp.remote_url" type="string" instantApply="true" />
<preference id="engine" name="extensions.pEp.engine_type" type="string" instantApply="true" />
</preferences>
<groupbox>
<label value="Choose an option below and test your connection:" />
<caption label="pEp Engine" />
<radiogroup preference="engine" >
<grid>
<columns>
<column />
<column />
</columns>
<rows>
<row>
<radio id="grier" value="grier" label="Grier Forensics hosted instance" />
</row>
<row>
<radio id="local" value="local" label="Locally installed instance" />
</row>
<row>
<radio id="remote" value="remote" label="Other (example: http://example.com:25353/)" />
<textbox preference="url" id="remoteUrl" />
</row>
<row>
<button class="test-connection" label="Test Connection" oncommand="" />
<label class="test-connection" id="testConnResults" />
</row>
</rows>
</grid>
</radiogroup>
</groupbox>
<hbox>
<label style="text-decoration: underline; color: navy; cursor: pointer" value="Help!"
onclick="alert('click Help!');"/>
<label style="text-decoration: underline; color: navy; cursor: pointer" value="Install Great DANE Engine"
onclick="window.open('https://pep.security/', '', 'dialog=no,menubar,toolbar,location,personalbar,status,resizable')"/>
</hbox>
</prefpane>
</prefwindow>

@ -15,6 +15,8 @@ let pEpMimeEncrypt = Cu.import("chrome://p4t/content/pEpMimeEncrypt.js");
Cu.importGlobalProperties(["XMLHttpRequest"]);
const jsmime = ChromeUtils.import("resource:///modules/jsmime.jsm").jsmime;
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
//let logger = console.log;
let logger = () => {
@ -132,6 +134,36 @@ pEpController.messageToCompFields = (pEpMessage, compFields) => {
return compFields;
};
pEpController.mimeFromMessage = (message) => {
let mimeStr = "";
function pEpIdentityToRFC5322(identity) {
//return identity.username + " <" + identity.address +">";
return {email: identity.address || "", value: identity.username || ""}
}
mimeStr += jsmime.headeremitter.emitStructuredHeader("mime-version", "1.0", {});
mimeStr += jsmime.headeremitter.emitStructuredHeader("message-id", "<" + message.id + ">", {});
mimeStr += jsmime.headeremitter.emitStructuredHeader("from", pEpIdentityToRFC5322(message.from), {});
if(message.to) mimeStr += jsmime.headeremitter.emitStructuredHeader("to", message.to.map(pEpIdentityToRFC5322), {});
if(message.cc) mimeStr += jsmime.headeremitter.emitStructuredHeader("cc", message.cc.map(pEpIdentityToRFC5322), {});
if(message.bcc) mimeStr += jsmime.headeremitter.emitStructuredHeader("bcc", message.bcc.map(pEpIdentityToRFC5322), {});
mimeStr += jsmime.headeremitter.emitStructuredHeader("subject", message.shortmsg, {});
for ( let header of message.opt_fields) {
mimeStr += jsmime.headeremitter.emitStructuredHeader(header.key, header.value, {});
}
// body
// content-type: plain/text -> longmsg
// content-type: html/text -> longmsg_formatted
// attachments
return mimeStr;
};
let factories = [];
let init = () => {

@ -22,26 +22,31 @@
.footer-privacy-bar {
bottom: 15px;
position: fixed;
position: relative;
margin: auto;
top: 50%;
vertical-align: middle;
height: 25px;
color: white;
padding-left: 36px;
height: 25px;
line-height: 25px;
background-repeat: no-repeat;
background-size: 16px;
background-position: center left 10px;
}
.header-privacy-bar {
position: relative;
margin: auto;
top: 50%;
vertical-align: middle;
height: 25px;
color: white;
padding-left: 36px;
height: 25px;
line-height: 25px;
background-repeat: no-repeat;
background-size: 16px;
background-position: center left 10px;

@ -111,9 +111,15 @@ PgpMimeEncrypt.prototype = {
// nsIMsgComposeSecure interface
requiresCryptoEncapsulation: function (msgIdentity, msgCompFields) {
console.log("mimeEncrypt.js: requiresCryptoEncapsulation\n");
try {
return msgIdentity.getBoolAttribute("enablePEP");
console.log("mimeEncrypt.js: requiresCryptoEncapsulation(): enablePEP", msgIdentity.getBoolAttribute("enablePEP") );
this.originalSubject = msgCompFields.subject;
// return msgIdentity.getBoolAttribute("enablePEP");
return true;
}
catch (ex) {
console.error("mimeEncrypt.js", ex);
@ -258,7 +264,6 @@ PgpMimeEncrypt.prototype = {
console.log("mimeEncrypt.js: processPepEncryption:\n");
//let result = `-----BEGIN PGP MESSAGE-----\r\n\r\nhQEMA6lSeIwYS9F1AQf/ax6cAexblwi0vkVJftU9HZsjze7e2KLkl3LnG+Jkcdu0\r\nK7eBhuNLWpo63QxyAZh8r0yGh0U50Y4mM/QXcSUCDL53rqNrLNFFRbFyb0Q8dCuM\r\nQheD4T9HkYWm0yCCHeMXaCzCbH20u7uZK7rT2Iw8NYZV2EqoERDAHVT8LuIvf42/\r\n241rDX2I5sr19wfQ3t0C80zUjMogskonzLMPgKQ0v1S1rdv8n2azSXTRbmVLOpua\r\nBRAmNRd3uXctnO4mpOzJyzFrV0RrB5l0Rp4fidl9mpu4F8K2mRehNQykFaU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this.sendFlags & SEND_ENCRYPTED);
@ -294,19 +299,22 @@ PgpMimeEncrypt.prototype = {
s += jsmime.headeremitter.emitStructuredHeader("to", toAddr, {});
if (originalSubject !== null) {
console.log("======= EMITING ORIGINAL SUBJECT =======");
console.log(originalSubject);
console.log("==============");
s += jsmime.headeremitter.emitStructuredHeader("subject", originalSubject, {});
}
// PROCESS PEP ENCRYPTION
let string = s + this.pipeQueue;
console.log(" ============== PROCESSING PEP ENCRYPTION ", string);
this.pEpController.messageFromMIME(string).then((pEpMessage) => {
console.log("======= PEP MIME ENCRYPT MESSAGE FROM MIME =======");
console.log(string);
console.log(pEpMessage);
console.log("==============");
this.pEpController.encryptMailWithMessage(pEpMessage).then((result) => {
console.log(" (2) ==============");
console.log(result);
console.log("==============");
resultObj = result;
// unblock the waiting lock in finishCryptoEncapsulation
@ -357,6 +365,9 @@ PgpMimeEncrypt.prototype = {
// =============================
console.log("==============");
console.log(this.outStringStream);
console.log("==============");
this.outStringStream.setData(this.outQueue, this.outQueue.length);
let writeCount = this.outStream.writeFrom(this.outStringStream, this.outQueue.length);
@ -375,6 +386,10 @@ PgpMimeEncrypt.prototype = {
*/
stripMsgHeadersFromEncryption: function (resObj) {
console.log("===== stripMsgHeadersFromEncryption =========");
console.log(resObj);
console.log("==============");
let mimeMessage = "";
if (this.cryptoBoundary === null) {
this.cryptoBoundary = generateRandomString(33); // Random generated string
@ -397,6 +412,7 @@ PgpMimeEncrypt.prototype = {
' boundary="' + this.cryptoBoundary + '"\r\n' +
"\r\n" +
resObj.longmsg + "\r\n" +
"\r\n" +
"--" + this.cryptoBoundary + "\r\n" +
"Content-Type: application/pgp-encrypted\r\n" +
"Content-Description: PGP/MIME version identification\r\n" +

@ -15,19 +15,26 @@ let getCompFields = () => {
};
let getCurrentIdentity = () => {
/* global gMsgCompose: false */
/* global gCurrentIdentity: false */
console.log("CURRENT IDENTITY:", gCurrentIdentity);
return gCurrentIdentity;
};
let createNode = (nodeId, elementType, parentId, text, ...nodeClass) => {
let newNode = document.createElement(elementType);
newNode.setAttribute("flex", "1");
//newNode.setAttribute("flex", "1");
newNode.classList.add(...nodeClass);
newNode.id = nodeId;
let nodeText = document.createTextNode(text);
newNode.appendChild(nodeText);
let nodeLabel = document.createElement("label");
//nodeLabel.id = nodeId+"-label";
nodeLabel.value = text;
nodeLabel.innerHTML = text;
newNode.appendChild(nodeLabel);
let parentNode = document.getElementById(parentId);
parentNode.parentNode.appendChild(newNode);
@ -67,8 +74,6 @@ let _parseAddress = (address) => {
})
};
let pEpComposer = {
init: function () {
console.log("pEpComposer: init()");
@ -78,6 +83,7 @@ let pEpComposer = {
}, true);
window.addEventListener("compose-window-init", this.initListener.bind(this), true);
window.addEventListener("compose-from-changed", this.fromChangedListener.bind(this), true);
window.addEventListener('compose-send-message', this.sendMessageListener.bind(this), true);
},
@ -86,6 +92,7 @@ let pEpComposer = {
window.removeEventListener("compose-window-init", this.initListener, false);
window.removeEventListener("compose-from-changed", this.fromChangedListener, false);
window.removeEventListener("compose-send-message", this.sendMessageListener, false);
},
@ -140,6 +147,11 @@ let pEpComposer = {
console.log("pepmessengercompose.js: compose-from-changed()");
//TODO To be implemented
},
sendMessageListener: function (event) {
console.log("pepmessengercompose.js: compose-send-message()");
//TODO To be implemented
},
pEp_onRecipientsChanged: function () {
console.log("pepmessengercompose.js: pEp_onRecipientsChanged()");
this.addressPopupListener();

@ -2,6 +2,8 @@ const Cu = Components.utils;
Cu.import("chrome://p4t/content/p4tb.js");
const RATING_COLOR_NO_COLOR = "no-color";
const PGP_MESSAGE_HEADER = "-----BEGIN PGP MESSAGE-----";
const PGP_MESSAGE_FOOTER = "-----END PGP MESSAGE-----";
let getPanel = (name, targetWindow) => {
for (let i = 0; i < targetWindow.frames.length; i++) {
@ -46,6 +48,7 @@ function updatePrivacy(privacyStatus, msgHdr) {
oldNode.parentNode.removeChild(oldNode);
}
// Add privacy bar to message
let newNode = document.createElement("hbox");
newNode.classList.add("header-privacy-bar");
newNode.classList.add(privacyTextClass.class);
@ -56,11 +59,12 @@ function updatePrivacy(privacyStatus, msgHdr) {
let mainHeaderAreaNode = document.getElementById("msgHeaderView");
mainHeaderAreaNode.parentNode.appendChild(newNode);
// Set property for message list
msgHdr.setStringProperty("pEpPrivacy", privacyStatus)
}
function getINNERBody(body) {
let INNER_TAG = "pEp-Wrapped-Message-Info: INNER";
let INNER_TAG = "pEp-Wrapped-Message-Info: INNER\r\n";
if (body.indexOf(INNER_TAG) < 0) return body;
return body.slice(body.indexOf(INNER_TAG) + INNER_TAG.length);
}
@ -97,8 +101,7 @@ function reformatBody(body) {
preface += '<blockquote type="cite">';
}
preface += '<pre wrap="">\n';
}
else if (citeLevel < oldCiteLevel) {
} else if (citeLevel < oldCiteLevel) {
preface = '</pre>';
for (let j = 0; j < oldCiteLevel - citeLevel; j++)
preface += "</blockquote>";
@ -110,8 +113,7 @@ function reformatBody(body) {
preface += '<span class="moz-txt-citetags">' +
gTxtConverter.scanTXT(lines[i].substr(0, logLineStart.value), convFlags) +
'</span>';
}
else if (lines[i] == "-- ") {
} else if (lines[i] == "-- ") {
preface += '<div class="moz-txt-sig">';
isSignature = true;
}
@ -125,12 +127,14 @@ function reformatBody(body) {
function updateBody(newBody) {
console.log("updateBody: ", newBody);
let panel = window.GetMessagePaneFrame();
let bodyElement = panel.document.getElementsByTagName("body")[0];
let node = bodyElement.firstChild;
while (node) {
if (node.nodeName === "DIV" || node.nodeName === "PRE") {
if (node.textContent.indexOf("-----BEGIN PGP")) {
if (node.textContent.indexOf(PGP_MESSAGE_HEADER)) {
node.innerHTML = newBody;
return;
}
@ -142,6 +146,7 @@ function updateBody(newBody) {
/* global currentHeaderData: false, gViewAllHeaders: false, gExpandedHeaderList: false, goDoCommand: false, HandleSelectedAttachments: false */
function updateSubject(newSubject) {
console.log("updateSubject:", newSubject);
//FIXME VALIDATE THAT THE MESSAGE STILL THE SAME AND NOT REPLACE IT WITH A PREVIOUS MESSAGE SUBJECT
let subjectBox = document.getElementById("expandedsubjectBox");
subjectBox.headerValue = newSubject;
@ -176,22 +181,20 @@ let onLoadMsgPanelFrameListener = (event) => {
try {
let mimeMessage = readMailFromUri(currentUri);
let msgHdr = gFolderDisplay.selectedMessage.folder.GetMessageHeader( gFolderDisplay.selectedMessage.messageKey );
let msgHdr = gFolderDisplay.selectedMessage.folder.GetMessageHeader(gFolderDisplay.selectedMessage.messageKey);
let msgFolderUri = msgHdr.folder.URI;
// Clean previous privacy labels
updatePrivacy("no-color", msgHdr);
let isTrustedServer = pEpController.isTrustedServer(msgFolderUri);
console.log("IS TRUSTED SERVER?: ", isTrustedServer);
if (isTrustedServer) {
copyMessageToFolder(msgHdr, mimeMessage);
}
pEpController.messageFromMIME(mimeMessage).then(message => {
console.log("==============");
console.log("MESSAGE FROM MIME");
console.log(message);
// console.log(pEpController.mimeFromMessage(message));
console.log("==============");
if (message.longmsg === "") {
for (let attachment of message.attachments) {
if (attachment.mime_type === "application/octet-stream") {
@ -201,70 +204,124 @@ let onLoadMsgPanelFrameListener = (event) => {
}
}
if ( message.opt_fields && message.opt_fields.includes("X-EncStatus")) {
let color;
switch(message.opt_fields["X-EncStatus"]) {
case "have_no_key":
case "unreliable":
case "unencrypted":
color = "no-color";
break;
case "reliable":
color = "yellow";
break;
case "trusted":
case "trusted_and_anonymized":
case "fully_anonymous":
color = "green";
break;
case "mistrust":
case "b0rken":
case "under_attack":
color = "red";
break;
default:
color = "no-color";
}
pEpController.getPrivacyColorFromRating(decryptedmessage.rating).then(colorRating => {
updatePrivacy(colorRating, msgHdr);
}
);
return;
}
pEpController.decryptMailWithMessage(message).then(decryptedmessage => {
if(decryptedmessage === null) {
console.log("==============");
console.log("DECRYPTDECRYPTDECRYPTDECRYPT");
console.log(decryptedmessage);
console.log("==============");
if (decryptedmessage === null) {
console.log("pepmsghdrview.js: onLoadMsgPanelFrameListener(): decryptMailWithMessage(): Nothing to decrypt");
return;
}
updateSubject(decryptedmessage.shortmsg);
pEpController.getPrivacyColorFromRating(decryptedmessage.rating).then(colorRating => {
updatePrivacy(colorRating, msgHdr);
}
);
function updateStuff(body, subject, msgHdr, msgToCopy) {
updateBody(body);
updateSubject(subject);
if (decryptedmessage.longmsg_formatted) {
updateBody(decryptedmessage.longmsg_formatted);
updateSubject(decryptedmessage.shortmsg);
if( msgHdr ) {
copyMessageToFolder(msgHdr, msgToCopy);
}
}
else {
pEpController.messageFromMIME(decryptedmessage.longmsg).then(decoded_decrypted_message => {
const OUTER_TAG = "pEp-Wrapped-Message-Info: OUTER";
if (decoded_decrypted_message.longmsg.indexOf(OUTER_TAG) >= 0) {
if (decoded_decrypted_message.attachments && decoded_decrypted_message.attachments.length > 0) {
for (let attachment of decoded_decrypted_message.attachments) {
if (attachment.mime_type === "text/rfc822") {
pEpController.messageFromMIME(atob(attachment.value)).then((decoded_message) => {
console.log("INNER MIME DECODED MESAGE: ", decoded_message);
copyMessageToFolder( msgHdr, atob(attachment.value) );
if (decoded_message.longmsg_formatted) {
updateBody(decoded_message.longmsg_formatted);
} else {
updateBody(reformatBody(getINNERBody(decoded_message.longmsg )+ "\n"));
}
updateSubject(decoded_message.shortmsg || message.shortmsg);
});
break;
}
// body += addAttachment(attachment);
}
}
} else {
copyMessageToFolder(msgHdr, decryptedmessage.longmsg);
updateBody(reformatBody(getINNERBody(decoded_decrypted_message.longmsg) + "\n"));
updateSubject(decoded_decrypted_message.shortmsg);
}
});
function extractBody(mime) {
}
pEpController.getPrivacyColorFromRating(decryptedmessage.rating).then(colorRating => {
updatePrivacy(colorRating, msgHdr);
if (decryptedmessage.longmsg_formatted) {
console.log("MESSAGE DECRIPTED LONG FORMATED");
updateStuff(decryptedmessage.longmsg_formatted, decryptedmessage.shortmsg, msgHdr, decryptedmessage.longmsg);
return;
}
pEpController.messageFromMIME(decryptedmessage.longmsg).then(decoded_decrypted_message => {
const OUTER_TAG = "pEp-Wrapped-Message-Info: OUTER";
if (decoded_decrypted_message.longmsg.indexOf(OUTER_TAG) < 0) {
updateStuff(reformatBody(getINNERBody(decoded_decrypted_message.longmsg) + "\r\n\r\n"), decoded_decrypted_message.shortmsg, msgHdr, decryptedmessage.longmsg);
return;
}
);
if (!(decoded_decrypted_message.attachments && decoded_decrypted_message.attachments.length > 0)) {
console.error("Inner body found and but there are not attachments");
return;
}
for (let attachment of decoded_decrypted_message.attachments) {
if (attachment.mime_type !== "text/rfc822") continue;
pEpController.messageFromMIME(atob(attachment.value)).then((decoded_message) => {
console.log("DECODED DECRYPTED MESSAGE: ", decoded_decrypted_message);
console.log("INNER MIME DECODED MESAGE: ", decoded_message);
if (typeof decoded_message.opt_fields === "undefined") {
decoded_message.opt_fields.push(decryptedmessage.opt_fields);
}
else {
decoded_message.opt_fields = decryptedmessage.opt_fields;
}
let newBody;
if (decoded_message.longmsg_formatted) {
console.log("INNER DECODED LONG FORMATED");
newBody = decoded_message.longmsg_formatted;
} else {
console.log("INNER DECODED ELSE");
newBody = reformatBody(getINNERBody(decoded_message.longmsg) + "\r\n\r\n");
}
let mimeBody = decryptedmessage.longmsg.substr(decryptedmessage.longmsg.indexOf("Content-Type: message/rfc822\r\n\r\n") + "Content-Type: message/rfc822\r\n\r\n".length).replace("Content-Disposition: inline; filename=\"msg.txt\"\r\n", "");
updateStuff(newBody, decoded_message.shortmsg || message.shortmsg, msgHdr, mimeBody);
});
break;
}
});
}).catch(err => {
console.log("pepmsghdrview.js: onLoadMsgPanelFrameListener(): decryptMailWithMessage", err)
});
}).catch(err => {
console.log("pepmsghdrview.js: onLoadMsgPanelFrameListener(): getMimeDecodedMessage", err)
});
}
catch (e) {
} catch (e) {
console.debug("Errors while reading message from uri", e);
}
}
@ -284,12 +341,7 @@ let _parseAddress = (address) => {
let copyMessageToFolder = (msgHdr, content) => {
if ( ! pEpController.isTrustedServer(msgHdr.folder.URI)) return;
console.log("==============");
console.log("WRITE MAIL TO URI:", msgHdr);
console.log(content);
console.log("==============");
if (!pEpController.isTrustedServer(msgHdr.folder.URI)) return;
let msgFolder = msgHdr.folder;
let isDraftOrTemplate = false;
@ -297,12 +349,18 @@ let copyMessageToFolder = (msgHdr, content) => {
let msgKeywords = "";
let msgWindow = null;
let msgArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
msgArray.appendElement(msgHdr, false);
// Create temp file to upload to smpt server
let tempFile = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
tempFile.append("pEpMsg.eml");
tempFile.createUnique(0, 0o600);
// ensure that file gets deleted on exit, if something goes wrong ...
let extAppLauncher = Cc["@mozilla.org/mime;1"].getService(Ci.nsPIExternalAppLauncher);
extAppLauncher.deleteTemporaryFileOnExit(tempFile);
let outputStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
outputStream.init(tempFile, 2, 0x200, false); // open as "write only"
outputStream.write(content, content.length);
@ -314,24 +372,34 @@ let copyMessageToFolder = (msgHdr, content) => {
let msgCopyService = Cc["@mozilla.org/messenger/messagecopyservice;1"].getService(Ci.nsIMsgCopyService);
let copyListener = {
OnStopCopy: function(statusCode) {
QueryInterface: function (iid) {
if (iid.equals(Ci.nsIMsgCopyServiceListener) || iid.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_NOINTERFACE;
},
GetMessageId: function (messageId) {
},
SetMessageKey: function (key) {
},
OnStopCopy: function (statusCode) {
console.log("(6)");
console.debug("pepmsghdrview.js: copyListener: OnStopCopy()\n");
if (statusCode !== 0) {
console.debug("pepmsghdrview.js: Error copying message: " + statusCode + "\n");
try {
tempFile.remove(false);
} catch (ex) {
try {
file.remove(false);
} catch (ex) {
console.debug("pepmsghdrview.js: Could not delete temp file\n");
}
}
return;
console.log("(7) ERROR");
console.error("pepmsghdrview.js: Error copying message: " + statusCode + "\n");
}
console.debug("pepmsghdrview.js: Copy complete\n");
try {
let urlListener = null;
msgFolder.getNewMessages(msgWindow, urlListener);
let deleteStorage = false;
let isMove = false;
let listener = null;
let allowUndo = false;
msgFolder.deleteMessages(msgArray, msgWindow, deleteStorage, isMove, listener, allowUndo);
tempFile.remove(false);
} catch (ex) {
try {
@ -379,8 +447,7 @@ let readMailFromUri = (msgUri) => {
let content = "";
let str = "";
const PGP_MESSAGE_HEADER = "-----BEGIN PGP MESSAGE-----";
const PGP_MESSAGE_FOOTER = "-----END PGP MESSAGE-----";
const INPUTSTREAM_READING_SIZE = 512;
while (scriptInputStream.available()) {
@ -400,7 +467,6 @@ let getCurrentMessageURI = () => {
window.addEventListener("load", onLoadListener, false);
let pEpHdrView = {
init: () => {
console.log("pEpHdrView: init()");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 B

After

Width:  |  Height:  |  Size: 750 B

@ -0,0 +1 @@
pref("extensions.p4tb.first_run", true);

@ -7,5 +7,6 @@ const prefs = {
secondary_jsonTokenPath: "pEp-json-token-",
min_required_version: "0.14.0",
pepHomeDir: ".pEp/"
}
},
first_run: true
};

@ -14,6 +14,8 @@
<em:creator>Chris Fuertes</em:creator>
<em:homepageURL>https://pep.foundation/</em:homepageURL>
<em:optionsURL>chrome://p4t/content/options.xul</em:optionsURL>
<!-- Target Applications this extension can install into,
with minimum and maximum supported versions. -->
<em:targetApplication>

@ -652,8 +652,7 @@ uHUVx+/Oj456Dd0jYGERNKILhw==
--YFw2R7sBar3mMMH5OlJba8kDy1XRXjJSM--`;
result = pEpController.decryptFromMIME(mimeMessage).then((message) => {
console.log("============", message);
result = pEpController.decryptFromMIME(mimeMessage).then(function (message) {
return message
});

@ -0,0 +1,56 @@
/* eslint-disable no-console */
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let atob = require('atob');
let pEp = require('../../chrome/content/modules/pEp');
let pEpAdapter = require('../../chrome/content/modules/pEpAdapter');
let pEpServer = require('../../chrome/content/modules/pEpServer');
let XhrQueue = require('../../chrome/content/modules/xhrQueue');
let log = console.log;
let fs = require('fs');
let os = require('os');
let connectionInfoDetector = function () {
return JSON.parse(fs.readFileSync('/Users/chris/.pEp/json-token', 'utf8'));
};
let server = new pEpServer(log, connectionInfoDetector, new XhrQueue(log));
let adapter = new pEpAdapter(console.log, server);
let pEpController = new pEp([], log, adapter, fs, os);
let mimeMessage = fs.readFileSync('/Users/chris/WebstormProjects/p4t/tests/features/test_mime.eml', 'utf8');
describe('Encrypt and then decrypt that message', () => {
//TODO Launch a pEp Desktop Adapter instance before each test
describe('Perfect scenario', () => {
let result;
let subject = "Test Subject";
let body = "Test Body";
let htmlBody = "Test html body";
let from = "cfg@pep.security";
let to = "cfg@pep.security";
before(() => {
console.log("==============");
console.log(mimeMessage);
console.log("==============");
result = pEpController.messageFromMIME(mimeMessage)
.then((message) => {
message.longmsg = atob(message.attachments[1].value);
return pEpController.decryptMailWithMessage(message)
.then(message => {
return message.longmsg.substr(message.longmsg.indexOf("Content-Type: message/rfc822\r\n\r\n") + "Content-Type: message/rfc822\r\n\r\n".length).replace("Content-Disposition: inline; filename=\"msg.txt\"\r\n", "");
});
});
});
it('should return a Object', () => {
return result.should.become("Message-ID: <pEp.PSKIS2.0HZWAQGGSUKQW.7ADF2614-81DE-47B1-9710-2DF90E5FC13E@pep.security>\r\nFrom: Chris <cfg@pep.security>\r\nTo: Chris <cfg@pep.security>\r\nSubject: \r\nX-pEp-Version: 2.0\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=\"utf-8\"\r\nContent-Transfer-Encoding: quoted-printable\r\nContent-Disposition: inline; filename=\"msg.txt\"\r\n\r\npEp-Wrapped-Message-Info: INNER\r\n\r\nTesting mime body message\r\n\r\n\r\n\r\n--b13a3164429599631f169025973e32\r\nContent-Type: application/pgp-keys\r\nContent-Disposition: attachment; filename=\"pEpkey.asc\"\r\n\r\n-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n\r\nmQENBFt6xIIBCADCOVTvp1nMpdKJ6GYy5F4ajFMMMlXWkQlxoRTAy+amxHsEpT9n\r\nQb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N4ftb\r\n1EmuRsbzLRD6VNcCBKSwm+sJ8vNE11xiEOPZLxd468hum1hVfeknDijGX16IivUV\r\nVkoHkGkR00qXV2ijQChFH4/Zu6eyivCSq3ME/s2LQa4XsEdbIp9VFaFS+qkAEQEA\r\nAYkBPAQYAQgAJhYhBLJ3XXuRnJ4o7BubSSwOjeWV5KWUBQJbesSDAhsMBQkB4TOA\r\nAAoJECwOjeWV5KWUAWoIAKo1VuCKGhT8J0zI+mNpT8Xx4yy/Nl2athSGw5rktsmF\r\ncEEwnWy2sYvkqpbbBxC1VOqzKQ/+/VL7ArPODkrFDpbZZ2qt5xC7ugT8wQRDhNx5\r\nesPZrty6vrfwt95PBWuJ+cQPts94D6qCpl4gl+wcg/fVMULIaN8plKXeeuUy80Yd\r\nZJMCenurL5JTz/bRETaIAUYbmJ3JNoJgJzqxMP1z2GyOB/pXouzSavPimdLxNmtK\r\niL3FFJqX3San2mu0+kUzGiO0gN0nrAPSObbJkZlhZIxAPWS6DyDlKKOoVppswFqR\r\nblHVpYLS0gr9k2it10aw+o2kUaM52QfrAEc1hTtf6AU=\r\n=Zj4H\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n\r\n--b13a3164429599631f169025973e32--\r\n");
});
});
});

@ -0,0 +1,89 @@
/* eslint-disable no-console */
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let pEp = require('../../chrome/content/modules/pEp');
let pEpAdapter = require('../../chrome/content/modules/pEpAdapter');
let pEpServer = require('../../chrome/content/modules/pEpServer');
let XhrQueue = require('../../chrome/content/modules/xhrQueue');
let log = console.log;
let fs = require('fs');
let os = require('os');
let connectionInfoDetector = function () {
return JSON.parse(fs.readFileSync('/Users/chris/.pEp/json-token', 'utf8'));
};
let server = new pEpServer(log, connectionInfoDetector, new XhrQueue(log));
let adapter = new pEpAdapter(console.log, server);
let pEpController = new pEp([], log, adapter, fs, os);
describe('Encrypt and then decrypt that message', () => {
//TODO Launch a pEp Desktop Adapter instance before each test
describe('Perfect scenario', () => {
let result;
let subject = "Test Subject";
let body = "Test Body";
let htmlBody = "Test html body";
let from = "cfg@pep.security";
let to = "cfg@pep.security";
before(() => {
result = pEpController.encryptMail(subject, body, htmlBody, from, to)
.then( (message) => {
message.longmsg = "PFGPDSJPSDJFPAS";
return pEpController.decryptMailWithMessage(message);
});
});
it('should return a Object', () => {
return result.should.become({
"attachments": [
{
"mime_type": "application/pgp-encrypted",
"size": 10,
"value": "VmVyc2lvbjogMQ==",
},
{
"filename": "file://msg.asc",
"mime_type": "application/octet-stream",
"size": 3409,
"value": "LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgpoUUVNQTNuVGpQY2RwUGltQVFmL1JMb1NDUzlIb29ZOHA4akdnWTZLL0xIZkdqeWdHT3lzWkZybEE4YitFODgwCmFpdEt6SnFpekFrR1dHVzh4R0pwcUIxOHlPeDZyQnJHbDdOeWNaSWpIb1o1Nkc2RFREbjFLdGdNYXgyS1p5UmMKcGRWOENpeUc1UmJrRnNWbHFidlNiaU5DVVluTjhVeHJNaVhlTkl0TDcrRzlITDRSQUd3ZmphUXJGbTc1a1lSOApQT0tLMml1MjJxZk1tSlc2aWt0VkRWVm5Gemd2TzZsZDJzbzkxN1NmcFZBWWpkWnV5aEVXcFVYQ3BIRjJWZVFZCk1sUmNXSjF2VG5kSCtGYk0xaytpZVUya3phTk92SUxkU0JzY3Rka0RBMUJ0Nk1lYWZ2VXVTcCtxL01Nb1d5SzMKaVdrZ0l1QWlWNnloYnpyZ2ZScVZHU3Y2ZU9WMGlTMUJJTGVqRndMVVR0THJBYVBJTGFCMmtsM3NaNk1NUURjNgpEQ2xzYzk5ZlllVWNCM2dqWStlb2lJZUFKZG96SjFmNXpyUktIeExFa3ZOWEJnNzFTSnE0bUVzTmp6Tm9KYXprCnlxeXZuODJ6eldUU08rRnZ3ZjlnMFBES1VZMXNzQktTREduY2N3UFlQWDhuYTV0R2FJZTJVaTRyOEluOHMrSWcKQ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JHM25sWS8wRWw0eFFqR3ExcU5BSGU2d3g4MjhiN1lJTDlUZwovbm5BbkRBWlQ0V0N6b0ZaMmY1V2cwT0xITHd5QlJseXU3SUNCRHVqdFJod0tyOWYremgyN1BuSGRMQ0xDNWxrCnh6b1lRSmRabm13MXpNYlM3TkpFTnpDeU9SbGxVNlByT1V6TDdZdjZoT2JOUm9TdUhxTzE4NGdrSGdpM1FjMkMKalpxa3FnOEhHWmNMakowNlBFTkVHOXZ3MEhWRy9HZGNIZ2M1K0VqVkI3NXZYQXB2ZDFlZk9qMjNLUjRXc1V0bgp3MHV2WVQ5a2cyRE9ySjBSTVBwd3Y5T1Y5cE4wa3cvbFNrYkZqUHpZSzNuRTBUVCt5MndhNS9odzE4eG9DK25LCkdKOWpRQk15Q2psaGhzNWsvc0ZLN0l1N3pzcEF6V1RjbHMySjBId3pBUkJ0ZjhUZGZYL2tVT1V0OGtjYXlHdkwKQTZxVzhERmE1KzlLd0xtNi93Qy9VVmw5bG1pekpMeklucStkV0IycGNoejVFRjNHUTVlekNGRVpSZWE1TUc3eApJSk1DUDlzckNuUVkrWmlxTjJLOU9JV3BObmNFYjhBPQo9V1duegotLS0tLUVORCBQR1AgTUVTU0FHRS0tLS0tCg=="
}
],
"dir": 0,
"enc_format": 3,
"from": {
"address": from,
"comm_type": 255,
"fpr": "B2775D7B919C9E28EC1B9B492C0E8DE595E4A594",
"user_id": "pEp_own_userId",
"username": "anonymous"
},
"id": "pEp.PRYNEI.1LYRY6EOZYQ1C.CEB82F67-B86B-4947-A496-03441F46D492@pep.security",
"longmsg": body,
"formated_longmsg": htmlBody,
"opt_fields": [
{
"key": "X-pEp-Version",
"value": "2.0"
}
],
"rating": 3,
"shortmsg": subject,
"to": [
{
"address": to,
"comm_type": 255,
"fpr": "B2775D7B919C9E28EC1B9B492C0E8DE595E4A594",
"user_id": "pEp_own_userId",
"username": "anonymous"
}
]
});
});
});
});

@ -29,7 +29,7 @@ describe('Encrypt Feature', () => {
to = "to@test.com";
subject = "subject";
body = "Not Encrypted Message";
message = new pEp.Message("pEp-0", subject, body, from, to);
message = new pEp.Message("pEp-1", subject, body, from, to);
message.longmsg_formatted = "";
message.setCc([]);
result = pEpController.encryptMail(subject, body, "", from, to);
@ -129,7 +129,8 @@ describe('Encrypt Feature', () => {
// "to":[{"user_id":"","username":"anonymous","address":"Volker Birk <vb@pep-project.org>"}],
// "dir":1,"enc_format":4,"attachments":[],"opt_fields":[],"cc":[]},[],["OP"],4,0]
from = "cfg@pep.security";
to = {address: "Volker Birk <vb@pep-project.org>"};
// to = {address: "Volker Birk <vb@pep-project.org>"};
to = "vb@pep-project.org";
subject = "subject";
body = "Not Encrypted Message";
let htmlBody = "<html><head>\\n<meta http-equiv=\\\"content-type\\\" content=\\\"text/html; charset=UTF-8\\\"></head><body text=\\\"#000000\\\" bgcolor=\\\"#FFFFFF\\\">\\n <p>Ignore this message<br>\\n </p>\\n</body>\\n</html>";
@ -245,7 +246,7 @@ describe('Encrypt Feature', () => {
return result.should.eventually.have.property("to").then((receivers) => {
receivers.length.should.be.equal(2);
receivers[0].address.should.be.equal(to[0]);
receivers[0].comm_type.should.be.equal(56);
receivers[0].comm_type.should.be.equal(127);
receivers[0].fpr.should.be.equal("F8AA1E0412B59A6F1CD3E92795E5C12702A9BEC3");
receivers[0].user_id.should.be.equal("TOFU_hk@pep.security");
receivers[0].username.should.be.equal("anonymous");
@ -262,7 +263,7 @@ describe('Encrypt Feature', () => {
return result.should.eventually.have.property("cc").then((receivers) => {
receivers.length.should.be.equal(3);
receivers[0].address.should.be.equal(cc[0]);
receivers[0].comm_type.should.be.equal(56);
receivers[0].comm_type.should.be.equal(127);
receivers[0].fpr.should.be.equal("F8AA1E0412B59A6F1CD3E92795E5C12702A9BEC3");
receivers[0].user_id.should.be.equal("TOFU_hk@pep.security");
receivers[0].username.should.be.equal("anonymous");
@ -319,15 +320,18 @@ describe('Encrypt Feature', () => {
bcc = ["hk@pep.security"];
subject = "subject";
body = "Not Encrypted Message";
message = new pEp.Message("pEp-3", subject, body, from, to, 1, 0);
message = new pEp.Message("pEp-0", subject, body, from, to, 1, 0);
message.longmsg_formatted = "";
message.setCc(cc);
message.setBcc(bcc);
result = pEpController.encryptMail(subject, body, "", from, to, cc, bcc, 0);
result = pEpController.encryptMail(subject, body, "", from, to, cc, bcc);
});
it('should become the same message', () => {
return result.should.become(message);
let expectedMessage = message;
expectedMessage.enc_format = 0;
delete expectedMessage.bcc;
return result.should.become(expectedMessage);
});
});
@ -373,7 +377,7 @@ describe('Encrypt Feature', () => {
sender.comm_type.should.be.equal(255);
sender.fpr.should.be.equal("B2775D7B919C9E28EC1B9B492C0E8DE595E4A594");
sender.user_id.should.be.equal("pEp_own_userId");
sender.username.should.be.equal("Chris");
sender.username.should.be.equal("anonymous");
});
});

@ -59,7 +59,7 @@ describe('pEp Get MIME Decode Message Feature', () => {
"Content-Transfer-Encoding: quoted-printable\r\n" +
"Content-Language: en-US\r\n" +
"\r\n" +
"dafdasfda\r\n";
"dafdasfda\r\n";j
result = pEpController.messageFromMIME(mimeMessage);
});

@ -0,0 +1,9 @@
pEp-Wrapped-Message-Info: INNER
Testing mime body message
--b13a3164429599631f169025973e32
Content-Type: application/pgp-keys
Content-Disposition: attachment; filename"

@ -0,0 +1,117 @@
Received: from ex02.intranet.pep.security (192.168.4.40) by
ex02.intranet.pep.security (192.168.4.40) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.330.5
via Mailbox Transport; Tue, 4 Jun 2019 11:38:27 +0200
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted";
boundary="dSffkWumYy7JTe0WwRpqf0fy0XgyDkpfg"
DKIM-Signature: v=1; a=rsa-sha256; d=pep.security; s=1519399626.pep;
c=simple/simple; t=1559641107; h=from:subject:to:date:message-id;
bh=ZYTIiDxhL968tSEE/wL2os2N9luHuCAvFTsnwAEFoHk=;
b=fh36P9aIB7+/n4q0SeXKK2tMkMQf0QSQmfVHJHnNhbjYyAgS15FAm9jMdN1xbErOvI4PjetvhWc
Zu/pao0NaX27mtUNU2iDkC0TpHsIYt/TnJt3bXwYRaZGPsU8cPQWENy0l8NStEudB2Wq9vS/lWEk2
UC63keyh97OdabuI2f7VtqdXZ6E5ar071k4RyEU8x30tlxVV6f5N3fMkL/M/Az1ifMPZcAbvfOKTl
ZzyqbkrGB8+Jj9sha/D3IK3xKKHlACHH6lbpz4aDIN3m15nGnI0VxwqmzAm4JmvariYklmoAtGMC7
W29c4znZpm2w7I7EAmheHLB1E7relM9/UVcg==
Received: from ex.intranet.pep.security (192.168.3.40) by
ex02.intranet.pep.security (192.168.4.40) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.330.5;
Tue, 4 Jun 2019 11:38:27 +0200
DKIM-Signature: v=1; a=rsa-sha1; d=pep.security; s=1519399626.pep;
c=relaxed/relaxed; t=1559641107; h=from:subject:to:date:ad-hoc;
bh=Hw+srMMhrDFkcI+1OdhdTKukNE8=;
b=Ilqb/5o+6jsEHMK6FuviTQpoxcNFS//ggesFrnQlwQ3twAHUw5WMrTjr8+i7mUcZPT7lqFdu19l
eu1I3CeL/Lsd7UaNGwOUrRLVH5r9tEaXEHq/8IVMxdcM7G2n4diArAwXMq114xzQacgkpQvqtjEQM
pfMge+Nx1PBZFO2z/UBsODe+bfJnhLjPbJgnNA1O76sLpj5SKlU7grD8lqbiD2HB7NUx3g6Zq4Srx
+kjaLxPzueUflc16nLhOy+RgI6dshpQWAlnZb4P8IygIvGubqUezhM+gk5/F62MmSwnC+Uf7zyKrV</