mirror of
https://github.com/logos-messaging/logos-chat.git
synced 2026-08-04 09:03:13 +00:00
fix: outgoing messages should not be decrypted
This commit is contained in:
parent
c6e03686fe
commit
523dca43e1
@ -94,6 +94,10 @@ proc decrypt*(convo: PrivateV1, enc: EncryptedPayload): Result[seq[byte], ChatEr
|
|||||||
)
|
)
|
||||||
copyMem(addr header.dhPublic[0], unsafeAddr dr.dh[0], dr.dh.len) # TODO: Avoid this copy
|
copyMem(addr header.dhPublic[0], unsafeAddr dr.dh[0], dr.dh.len) # TODO: Avoid this copy
|
||||||
|
|
||||||
|
if convo.doubleratchet.dhSelf.public == header.dhPublic:
|
||||||
|
info "outgoing message, no need to decrypt"
|
||||||
|
return err(ChatError(code: errDecryptOutgoing, context: "Attempted to decrypt outgoing message"))
|
||||||
|
|
||||||
convo.doubleratchet.decrypt(header, dr.ciphertext, @[]).mapErr(proc(e: NaxolotlError): ChatError = ChatError(code: errWrapped, context: repr(e) ))
|
convo.doubleratchet.decrypt(header, dr.ciphertext, @[]).mapErr(proc(e: NaxolotlError): ChatError = ChatError(code: errWrapped, context: repr(e) ))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ type
|
|||||||
ErrorCode* = enum
|
ErrorCode* = enum
|
||||||
errTypeError
|
errTypeError
|
||||||
errWrapped
|
errWrapped
|
||||||
|
errDecryptOutgoing
|
||||||
|
|
||||||
|
|
||||||
proc `$`*(x: ChatError): string =
|
proc `$`*(x: ChatError): string =
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const maxSkip = 10
|
|||||||
|
|
||||||
|
|
||||||
type Doubleratchet* = object
|
type Doubleratchet* = object
|
||||||
dhSelf: PrivateKey
|
dhSelf*: PrivateKey
|
||||||
dhRemote: PublicKey
|
dhRemote: PublicKey
|
||||||
|
|
||||||
rootKey: RootKey
|
rootKey: RootKey
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user