diff options
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/Tox/Onion/Transport.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs index 539e7cee..5c4544ca 100644 --- a/src/Network/Tox/Onion/Transport.hs +++ b/src/Network/Tox/Onion/Transport.hs | |||
@@ -685,19 +685,19 @@ decrypt :: TransportCrypto -> OnionMessage Encrypted -> OnionDestination r -> IO | |||
685 | decrypt crypto msg addr = do | 685 | decrypt crypto msg addr = do |
686 | (skey,pkey) <- selectKey crypto msg addr | 686 | (skey,pkey) <- selectKey crypto msg addr |
687 | let decipher1 :: Serialize a => | 687 | let decipher1 :: Serialize a => |
688 | TransportCrypto -> SecretKey -> PublicKey -> Nonce24 | 688 | TransportCrypto -> SecretKey -> Nonce24 |
689 | -> Either (PublicKey,Encrypted a) (Asymm (Encrypted a)) | 689 | -> Either (PublicKey,Encrypted a) (Asymm (Encrypted a)) |
690 | -> (IO ∘ Either String ∘ Identity) a | 690 | -> (IO ∘ Either String ∘ Identity) a |
691 | decipher1 crypto k pk n d = Composed $ do | 691 | decipher1 crypto k n arg = Composed $ do |
692 | secret <- lookupSharedSecret crypto k pk n | 692 | let (sender,e) = either id (senderKey &&& asymmData) arg |
693 | let ciphered = either snd asymmData d | 693 | secret <- lookupSharedSecret crypto k sender n |
694 | return $ Composed $ do | 694 | return $ Composed $ do |
695 | plain <- ToxCrypto.decrypt secret ciphered | 695 | plain <- ToxCrypto.decrypt secret e |
696 | Identity <$> decodePlain plain | 696 | Identity <$> decodePlain plain |
697 | decipher :: Serialize a | 697 | decipher :: Serialize a |
698 | => Nonce24 -> Either (Encrypted a) (Asymm (Encrypted a)) | 698 | => Nonce24 -> Either (Encrypted a) (Asymm (Encrypted a)) |
699 | -> (IO ∘ Either String ∘ Identity) a | 699 | -> (IO ∘ Either String ∘ Identity) a |
700 | decipher = (\n -> decipher1 crypto skey pkey n . left (senderkey addr)) | 700 | decipher = (\n -> decipher1 crypto skey n . left (senderkey addr)) |
701 | foo <- sequenceMessage $ transcode decipher msg | 701 | foo <- sequenceMessage $ transcode decipher msg |
702 | return $ do | 702 | return $ do |
703 | msg <- sequenceMessage foo | 703 | msg <- sequenceMessage foo |
@@ -726,7 +726,6 @@ decryptMessage crypto (sk,pk) n arg = do | |||
726 | secret <- lookupSharedSecret crypto sk sender n | 726 | secret <- lookupSharedSecret crypto sk sender n |
727 | return $ plain $ ToxCrypto.decrypt secret e | 727 | return $ plain $ ToxCrypto.decrypt secret e |
728 | 728 | ||
729 | |||
730 | sequenceMessage :: Applicative m => OnionMessage (m ∘ f) -> m (OnionMessage f) | 729 | sequenceMessage :: Applicative m => OnionMessage (m ∘ f) -> m (OnionMessage f) |
731 | sequenceMessage (OnionAnnounce a) = fmap OnionAnnounce $ sequenceA $ fmap uncomposed a | 730 | sequenceMessage (OnionAnnounce a) = fmap OnionAnnounce $ sequenceA $ fmap uncomposed a |
732 | sequenceMessage (OnionAnnounceResponse n8 n24 dta) = OnionAnnounceResponse n8 n24 <$> uncomposed dta | 731 | sequenceMessage (OnionAnnounceResponse n8 n24 dta) = OnionAnnounceResponse n8 n24 <$> uncomposed dta |