Show pgp public key

main
Bob Mottram 2021-05-05 10:53:00 +01:00
parent fee2d0b47e
commit 8415c7d3f2
3 changed files with 12 additions and 2 deletions

View File

@ -478,6 +478,7 @@ following [page number] Show accounts that you are following
followers [page number] Show accounts that are following you followers [page number] Show accounts that are following you
approve [handle] Approve a follow request approve [handle] Approve a follow request
deny [handle] Deny a follow request deny [handle] Deny a follow request
pgp Show your PGP public key
``` ```
If you have a GPG key configured on your local system and are sending a direct message to someone who has a PGP key (the exported key, not just the key ID) set as a tag on their profile then it will try to encrypt the message automatically. So under some conditions end-to-end encryption is possible, such that the instance server only sees ciphertext. Conversely, for arriving direct messages if they are PGP encrypted then the desktop client will try to obtain the relevant public key and decrypt. If you have a GPG key configured on your local system and are sending a direct message to someone who has a PGP key (the exported key, not just the key ID) set as a tag on their profile then it will try to encrypt the message automatically. So under some conditions end-to-end encryption is possible, such that the instance server only sees ciphertext. Conversely, for arriving direct messages if they are PGP encrypted then the desktop client will try to obtain the relevant public key and decrypt.

View File

@ -45,6 +45,7 @@ from posts import c2sBoxJson
from posts import downloadAnnounce from posts import downloadAnnounce
from announce import sendAnnounceViaServer from announce import sendAnnounceViaServer
from announce import sendUndoAnnounceViaServer from announce import sendUndoAnnounceViaServer
from pgp import pgpLocalPublicKey
from pgp import pgpDecrypt from pgp import pgpDecrypt
from pgp import hasLocalPGPkey from pgp import hasLocalPGPkey
from pgp import pgpEncryptToActor from pgp import pgpEncryptToActor
@ -124,6 +125,8 @@ def _desktopHelp() -> None:
'Approve a follow request') 'Approve a follow request')
print(indent + 'deny [handle] ' + print(indent + 'deny [handle] ' +
'Deny a follow request') 'Deny a follow request')
print(indent + 'pgp ' +
'Show your PGP public key')
print('') print('')
@ -2324,6 +2327,12 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
_sayCommand(sayStr, sayStr, originalScreenReader, _sayCommand(sayStr, sayStr, originalScreenReader,
systemLanguage, espeak) systemLanguage, espeak)
print('') print('')
elif commandStr.startswith('pgp') or commandStr.startswith('gpg'):
if not hasLocalPGPkey():
print('No PGP public key was found')
else:
print(pgpLocalPublicKey())
print('')
elif commandStr.startswith('h'): elif commandStr.startswith('h'):
_desktopHelp() _desktopHelp()
sayStr = 'Press Enter to continue...' sayStr = 'Press Enter to continue...'

4
pgp.py
View File

@ -423,7 +423,7 @@ def _pgpLocalPublicKeyId() -> str:
return result.decode('utf-8').replace('"', '').strip() return result.decode('utf-8').replace('"', '').strip()
def _pgpLocalPublicKey() -> str: def pgpLocalPublicKey() -> str:
"""Gets the local pgp public key """Gets the local pgp public key
""" """
keyId = _pgpLocalPublicKeyId() keyId = _pgpLocalPublicKeyId()
@ -457,7 +457,7 @@ def pgpPublicKeyUpload(baseDir: str, session,
if not test: if not test:
if debug: if debug:
print('Getting PGP public key') print('Getting PGP public key')
PGPpubKey = _pgpLocalPublicKey() PGPpubKey = pgpLocalPublicKey()
if not PGPpubKey: if not PGPpubKey:
return None return None
PGPpubKeyId = _pgpLocalPublicKeyId() PGPpubKeyId = _pgpLocalPublicKeyId()