Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions for TLS 1.3 #278

Merged
merged 6 commits into from
Aug 6, 2018
Merged

Conversation

kazu-yamamoto
Copy link
Collaborator

RFC 8446 for TLS 1.3 is coming. My implementation of TLS 1.3 shows good inter-operability with other implementations (#167). So, I would like to start merge it into master step by step.

renaming getVersion to getVersion' to avoid conflict.
<message>    <old> <new>
ServerHello  True  MsgTServerHello
ClientHello  False MsgTClientHello

False in Client.hs was a mistake, I believe.
Copy link
Contributor

@ocheron ocheron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really look forward to this despite limited time I can allocate.
It's probably possible to improve style slightly in this PR or next ones, for example I don't think you used the same indentation than existing code for data-type declarations.
But this is minor compared to huge achievement of bringing TLS13.

@@ -296,3 +356,162 @@ instance Extension SignatureAlgorithms where
runGetMaybe $ do
len <- getWord16
SignatureAlgorithms <$> getList (fromIntegral len) (getSignatureHashAlgorithm >>= \sh -> return (2, sh))

type SignatureAlgorithmsCert = SignatureAlgorithms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how that one works. extensionID will be same, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault. They have different IDs. I will fix it.

return $ verOfNum (major, minor)

putVersion' :: Version -> Put
putVersion' ver = putWord8 major >> putWord8 minor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other ideas for naming: putBinaryVersion, putWireVersion, putSerializedVersion, putVersionBytes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took putBinaryVersion. Thank you for your nice suggestion!

-- | Extension class to transform bytes to and from a high level Extension type.
class Extension a where
extensionID :: a -> ExtensionID
extensionDecode :: Bool -> ByteString -> Maybe a
extensionDecode :: MessageType -> ByteString -> Maybe a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for moving away from Bool

instance Extension KeyShare where
extensionID _ = extensionID_KeyShare
extensionEncode (KeyShareClientHello kses) = runPut $ do
let !len = sum $ map (\(KeyShareEntry _ key) -> B.length key + 4) kses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would probably look nicer with list comprehension.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@kazu-yamamoto
Copy link
Collaborator Author

Thank you for your review.

It's probably possible to improve style slightly in this PR or next ones, for example I don't think you used the same indentation than existing code for data-type declarations.

Honestly I think we should use a formatter rather than hand-styling.

kazu-yamamoto added a commit to kazu-yamamoto/hs-tls that referenced this pull request Aug 6, 2018
@kazu-yamamoto kazu-yamamoto merged commit 33ba430 into haskell-tls:master Aug 6, 2018
@kazu-yamamoto kazu-yamamoto deleted the extension13 branch August 6, 2018 04:30
@kazu-yamamoto
Copy link
Collaborator Author

Merged. Thank you for reviewing!

@kazu-yamamoto kazu-yamamoto mentioned this pull request Sep 13, 2018
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants