mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 05:07:46 +02:00
feat(e2ee): secret fingerprint
This commit is contained in:
@ -26,8 +26,20 @@ interface E2eeInterface {
|
||||
*/
|
||||
boolean acceptPairingResponse(String friendId, in byte[] encapsulatedSecret);
|
||||
|
||||
/**
|
||||
* Check if a friend key exists
|
||||
* @param friendId
|
||||
* @return true if the friend key exists
|
||||
*/
|
||||
boolean friendKeyExists(String friendId);
|
||||
|
||||
/**
|
||||
* Get the fingerprint of a secret key
|
||||
* @param friendId
|
||||
* @return the fingerprint of the secret key
|
||||
*/
|
||||
@nullable String getSecretFingerprint(String friendId);
|
||||
|
||||
@nullable EncryptionResult encryptMessage(String friendId, in byte[] message);
|
||||
|
||||
@nullable byte[] decryptMessage(String friendId, in byte[] message, in byte[] iv);
|
||||
|
@ -153,21 +153,35 @@ class EndToEndEncryption : MessagingRuleFeature(
|
||||
|
||||
private fun openManagementPopup() {
|
||||
val conversationId = context.feature(Messaging::class).openedConversationUUID?.toString() ?: return
|
||||
val friendId = context.database.getDMOtherParticipant(conversationId)
|
||||
|
||||
if (context.database.getDMOtherParticipant(conversationId) == null) {
|
||||
if (friendId == null) {
|
||||
context.shortToast("This menu is only available in direct messages.")
|
||||
return
|
||||
}
|
||||
|
||||
val actions = listOf(
|
||||
"Initiate a new shared secret"
|
||||
"Initiate a new shared secret",
|
||||
"Show shared key fingerprint"
|
||||
)
|
||||
|
||||
ViewAppearanceHelper.newAlertDialogBuilder(context.mainActivity!!).apply {
|
||||
setTitle("End-to-end encryption")
|
||||
setItems(actions.toTypedArray()) { _, which ->
|
||||
when (which) {
|
||||
0 -> askForKeys(conversationId)
|
||||
0 -> {
|
||||
warnKeyOverwrite(friendId) {
|
||||
askForKeys(conversationId)
|
||||
}
|
||||
}
|
||||
1 -> {
|
||||
val fingerprint = e2eeInterface.getSecretFingerprint(friendId)
|
||||
ViewAppearanceHelper.newAlertDialogBuilder(context).apply {
|
||||
setTitle("End-to-end encryption")
|
||||
setMessage("Your fingerprint is:\n\n$fingerprint\n\nMake sure to check if it matches your friend's fingerprint!")
|
||||
setPositiveButton("OK") { _, _ -> }
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
setPositiveButton("OK") { _, _ -> }
|
||||
|
Reference in New Issue
Block a user