| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Tox.Transport.SecureSession
Synopsis
- data CookieRequest = CookieRequest {}
- data CookieRequestInner = CookieRequestInner {}
- data CookieResponse = CookieResponse {}
- data CookieResponseInner = CookieResponseInner {}
- data Cookie = Cookie {}
- data CookieInner = CookieInner {}
- data Handshake = Handshake {}
- data HandshakeInner = HandshakeInner {}
- data CryptoDataPacket = CryptoDataPacket {}
- data HandshakeStatus
- data SecureSessionState = SecureSessionState {
- ssOurRealKeyPair :: KeyPair
- ssPeerRealPk :: PublicKey
- ssOurDhtKeyPair :: KeyPair
- ssPeerDhtPk :: PublicKey
- ssPeerNodeInfo :: NodeInfo
- ssStatus :: Maybe HandshakeStatus
- ssOurSessionKeyPair :: KeyPair
- ssPeerSessionPk :: Maybe PublicKey
- ssSharedKey :: Maybe CombinedKey
- ssOurBaseNonce :: Nonce
- ssPeerBaseNonce :: Maybe Nonce
- ssSentPackets :: Word64
- ssRecvPackets :: Word64
- ssLastAttempt :: Maybe Timestamp
- ssRetryCount :: Int
- createCookie :: MonadRandomBytes m => CombinedKey -> Word64 -> PublicKey -> PublicKey -> m Cookie
- decryptCookie :: CombinedKey -> Cookie -> Maybe CookieInner
- dataNumThreshold :: Word16
- calculateNonce :: Nonce -> Word16 -> Nonce
- updateBaseNonce :: Nonce -> Word16 -> Nonce
- getDhtSharedKey :: Keyed m => SecureSessionState -> m CombinedKey
- getRealSharedKey :: Keyed m => SecureSessionState -> m CombinedKey
- getSessionSharedKey :: Keyed m => SecureSessionState -> m CombinedKey
- initSession :: MonadRandomBytes m => KeyPair -> PublicKey -> KeyPair -> PublicKey -> NodeInfo -> m SecureSessionState
- sendCookieRequest :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => m ()
- handlePacket :: (Timed m, MonadRandomBytes m, Keyed m, Networked m, MonadState SecureSessionState m) => CombinedKey -> NodeInfo -> Packet ByteString -> m ()
- handleCookieRequest :: (Timed m, MonadRandomBytes m, Keyed m, Networked m) => CombinedKey -> KeyPair -> NodeInfo -> ByteString -> m ()
- handleCookieResponse :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => NodeInfo -> ByteString -> m ()
- sendHandshake :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => Cookie -> m ()
- handleHandshake :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => CombinedKey -> NodeInfo -> ByteString -> m ()
- sendCryptoData :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => PlainText -> m ()
- handleCryptoData :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => NodeInfo -> ByteString -> m ()
Documentation
data CookieRequest Source #
Cookie Request Packet (0x18 / 24).
Constructors
| CookieRequest | |
Fields
| |
Instances
data CookieRequestInner Source #
Inner message of a Cookie Request.
Constructors
| CookieRequestInner | |
Fields
| |
Instances
data CookieResponse Source #
Cookie Response Packet (0x19 / 25).
Constructors
| CookieResponse | |
Fields
| |
Instances
data CookieResponseInner Source #
Inner message of a Cookie Response.
Constructors
| CookieResponseInner | |
Instances
Cookie structure (112 bytes).
Constructors
| Cookie | |
Fields
| |
Instances
| Eq Cookie Source # | |
| Show Cookie Source # | |
| Generic Cookie Source # | |
| Binary Cookie Source # | |
| type Rep Cookie Source # | |
Defined in Tox.Transport.SecureSession type Rep Cookie = D1 ('MetaData "Cookie" "Tox.Transport.SecureSession" "toxcore-0.2.12-inplace" 'False) (C1 ('MetaCons "Cookie" 'PrefixI 'True) (S1 ('MetaSel ('Just "cookieNonce") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Nonce) :*: S1 ('MetaSel ('Just "cookieEncryptedPayload") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CipherText))) | |
data CookieInner Source #
Inner payload of a Cookie.
Constructors
| CookieInner | |
Fields | |
Instances
Handshake Packet (0x1a / 26).
Constructors
| Handshake | |
Fields
| |
Instances
| Eq Handshake Source # | |
| Show Handshake Source # | |
| Generic Handshake Source # | |
| Binary Handshake Source # | |
| type Rep Handshake Source # | |
Defined in Tox.Transport.SecureSession type Rep Handshake = D1 ('MetaData "Handshake" "Tox.Transport.SecureSession" "toxcore-0.2.12-inplace" 'False) (C1 ('MetaCons "Handshake" 'PrefixI 'True) (S1 ('MetaSel ('Just "hCookie") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Cookie) :*: (S1 ('MetaSel ('Just "hNonce") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Nonce) :*: S1 ('MetaSel ('Just "hEncryptedMessage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CipherText)))) | |
data HandshakeInner Source #
Inner message of a Handshake.
Constructors
| HandshakeInner | |
Fields
| |
Instances
data CryptoDataPacket Source #
Encrypted Packet (0x1b / 27).
Constructors
| CryptoDataPacket | |
Fields
| |
Instances
data HandshakeStatus Source #
Constructors
| SessionCookieSent Word64 | Echo ID |
| SessionHandshakeSent Cookie | |
| SessionHandshakeAccepted Cookie | Received handshake from peer |
| SessionConfirmed | Received data packet, session established |
Instances
data SecureSessionState Source #
Constructors
Instances
createCookie :: MonadRandomBytes m => CombinedKey -> Word64 -> PublicKey -> PublicKey -> m Cookie Source #
Create a Cookie for a peer.
decryptCookie :: CombinedKey -> Cookie -> Maybe CookieInner Source #
Decrypt and validate a Cookie.
dataNumThreshold :: Word16 Source #
Threshold for base nonce rotation (1/3 of 65536).
updateBaseNonce :: Nonce -> Word16 -> Nonce Source #
Update the base nonce after successful decryption if necessary.
getDhtSharedKey :: Keyed m => SecureSessionState -> m CombinedKey Source #
getRealSharedKey :: Keyed m => SecureSessionState -> m CombinedKey Source #
getSessionSharedKey :: Keyed m => SecureSessionState -> m CombinedKey Source #
initSession :: MonadRandomBytes m => KeyPair -> PublicKey -> KeyPair -> PublicKey -> NodeInfo -> m SecureSessionState Source #
Initial state for a new session. | Initial state for a new session.
sendCookieRequest :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => m () Source #
handlePacket :: (Timed m, MonadRandomBytes m, Keyed m, Networked m, MonadState SecureSessionState m) => CombinedKey -> NodeInfo -> Packet ByteString -> m () Source #
Handle an incoming packet for this session.
handleCookieRequest :: (Timed m, MonadRandomBytes m, Keyed m, Networked m) => CombinedKey -> KeyPair -> NodeInfo -> ByteString -> m () Source #
Handle a CookieRequest (Server side).
handleCookieResponse :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => NodeInfo -> ByteString -> m () Source #
sendHandshake :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => Cookie -> m () Source #
handleHandshake :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => CombinedKey -> NodeInfo -> ByteString -> m () Source #
sendCryptoData :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => PlainText -> m () Source #
handleCryptoData :: (MonadState SecureSessionState m, Timed m, MonadRandomBytes m, Keyed m, Networked m) => NodeInfo -> ByteString -> m () Source #