From 0c90cde8f3a3b2e94cf7c6e00b80783dfed33244 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 5 Aug 2020 13:47:15 +0100 Subject: [PATCH] Local decrypt dummy function --- devices.py | 29 +++++++++++++++++++++++++++++ webinterface.py | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/devices.py b/devices.py index 607b6ee3..9fd97b45 100644 --- a/devices.py +++ b/devices.py @@ -37,3 +37,32 @@ def devicesCollection(baseDir: str, nickname: str, domain: str, 'items': deviceList } return devicesDict + + +def decryptMessageFromDevice(messageJson: {}) -> str: + """Locally decrypts a message on the device. + This should probably be a link to a local script + or native app, such that what the user sees isn't + something which the server could get access to. + """ + # TODO + # { + # "type": "EncryptedMessage", + # "messageType": 0, + # "cipherText": "...", + # "digest": { + # "type": "Digest", + # "digestAlgorithm": "http://www.w3.org/2000/09/xmldsig#hmac-sha256", + # "digestValue": "5f6ad31acd64995483d75c7..." + # }, + # "messageFranking": "...", + # "attributedTo": { + # "type": "Device", + # "deviceId": "11119" + # }, + # "to": { + # "type": "Device", + # "deviceId": "11876" + # } + # } + return '' diff --git a/webinterface.py b/webinterface.py index aade59c8..45df3d27 100644 --- a/webinterface.py +++ b/webinterface.py @@ -78,6 +78,7 @@ from git import isGitPatch from theme import getThemesList from petnames import getPetName from followingCalendar import receivingCalendarEvents +from devices import decryptMessageFromDevice def getAltPath(actor: str, domainFull: str, callingDomain: str) -> str: @@ -4248,8 +4249,13 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int, if not postJsonObject['object'].get('summary'): postJsonObject['object']['summary'] = '' + if postJsonObject['object'].get('cipherText'): + postJsonObject['object']['content'] = \ + decryptMessageFromDevice(postJsonObject['object']) + if not postJsonObject['object'].get('content'): return '' + isPatch = isGitPatch(baseDir, nickname, domain, postJsonObject['object']['type'], postJsonObject['object']['summary'],