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

Supporting RSAPSS defined in TLS 1.3 #207

Merged
merged 17 commits into from
Apr 20, 2017

Conversation

kazu-yamamoto
Copy link
Collaborator

This implements #206.

Since TLS 1.3 flattens the structure of (Hash, Signature) and Hash 0x08 is a magic word for TLS 1.3, implementation is not straightforward and a little bit tricky.

@ocheron
Copy link
Contributor

ocheron commented Apr 12, 2017

Yes this is tricky. I see we don't have much choice regarding HashAlgorithm and SignatureAlgorithm considering the assignments and backward compatibility.

However internally I think we should stop using the tuple components individually as much as we can.
Especially move away from using type SignatureAlgorithm as an indication of key-exchange signature algorithm. sigAlgExpected only need the values RSA / DSS / ECDSA. Introducing a new data type would help readability in the handshake code.

@kazu-yamamoto
Copy link
Collaborator Author

Rebased and pushed -f to make discussion easier.

@kazu-yamamoto
Copy link
Collaborator Author

I will rebase my TLS 1.3 branch onto this first and will try to understand whether or not the new data type help readability.

@ocheron
Copy link
Contributor

ocheron commented Apr 12, 2017

I experimented ideas related to typing in branch ocheron:kxsigalg (without RSA PSS, but that should be easily extensible).

The benefits I see are:

  1. does not need (Hash, Bool) parameters in crypto code when not necessary. EdDSA will not need Hash. This API is approximately what we have in x509-validation.
  2. swapping signatureEqual arguments is not possible anymore (renamed signatureCompatible)
  3. type HashAndSignatureAlgorithm is now opaque in "Client" and "Server" code. Only two functions in module "Signature" need to look inside.

My understanding is that such a change would not interfere with TLS 1.3. Could you look into this?
Constructors for Ed25519 and Ed448 can be added if client/server have certificates and private keys.

@ocheron
Copy link
Contributor

ocheron commented Apr 12, 2017

Also a remark about your PSS code: are you sure RSA blinding is not desirable?
(ie. function PSS.signSafer vs PSS.sign Nothing)

@kazu-yamamoto
Copy link
Collaborator Author

Since I need to finish another job in this week, I will get back to this issue in the next week.
Sorry for you inconvenience.

@ocheron
Copy link
Contributor

ocheron commented Apr 13, 2017

OK, take the time you need.

@kazu-yamamoto
Copy link
Collaborator Author

I have ported my code onto your kxsigalg branch. Yes, your idea is really great. My code got much simpler.

I'm now trying to check if modifications are necessary forCredentials.hs.

@kazu-yamamoto
Copy link
Collaborator Author

I think I have done.
@ocheron May I ask you to review this PR again?

@ocheron
Copy link
Contributor

ocheron commented Apr 19, 2017

I'm glad you like it, and it's good we can use it for credentials too.

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.

Mostly minor items, except default supportedHashSignatures where there is a real choice to be made.


-- Check that a candidate cipher with a signature requiring
-- a hash will have at least one hash available. This avoids
-- a failure later in 'decideHash'.
hasSigningRequirements =
case cipherKeyExchange cipher of
CipherKeyExchange_DHE_RSA -> SignatureRSA `elem` possibleSigAlgs
CipherKeyExchange_DHE_RSA -> isJust $ find (RSA `signatureCompatible`) possibleHashSigAlgs
Copy link
Contributor

Choose a reason for hiding this comment

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

  • signatureCompatible can be used for DSS and ECDSA too.
  • elemBy is Data.List.any

-- and cipher key exchange.
data DigitalSignatureAlg = RSA | DSS | ECDSA | Ed25519 | Ed448
deriving (Show, Eq)

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 like DigitalSignatureAlg being defined in module "Struct" as it's internal and not protocol-related. Module "Types" would be better perhaps.

And if possible signatureCompatible should remain in "Handshake.Signature" where signatureParams is also defined (because those two must stay in sync).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does Crypto.Types make sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah. In my old implementation, signatureCompatible is necessary for the Credential module which causes cyclic import. But this is not the case anymore. I will try.

@@ -197,7 +197,8 @@ defaultSupported = Supported
{ supportedVersions = [TLS12,TLS11,TLS10]
, supportedCiphers = []
, supportedCompressions = [nullCompression]
, supportedHashSignatures = [ (Struct.HashSHA512, SignatureRSA)
, supportedHashSignatures = [ (Struct.HashTLS13, SignatureRSApssSHA256)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ordering is questionable, I think SHA-512 and SHA-384 should still have priority over SignatureRSApssSHA256.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh. This is a mistake. I don't want to modify this module.
I modified this file for local testing. I will revert this.

@kazu-yamamoto
Copy link
Collaborator Author

I did push -f. If you like Crypto.Types, this PR is ready to be merged.

@ocheron
Copy link
Contributor

ocheron commented Apr 20, 2017

Yes Crypto.Types will be fine, so good to merge.

kazu-yamamoto added a commit to kazu-yamamoto/hs-tls that referenced this pull request Apr 20, 2017
@kazu-yamamoto kazu-yamamoto merged commit 8aa9a89 into haskell-tls:master Apr 20, 2017
@kazu-yamamoto
Copy link
Collaborator Author

Thanks. Merged.

@kazu-yamamoto kazu-yamamoto deleted the rsapss branch April 20, 2017 07:18
@kazu-yamamoto kazu-yamamoto mentioned this pull request May 26, 2017
15 tasks
@ocheron
Copy link
Contributor

ocheron commented May 30, 2017

Reading draft-ietf-tls-rfc4492bis, I realize we could rename HashTLS13 to HashIntrinsic (cf. § 5.1.3. The signature_algorithms Extension and EdDSA). Otherwise it will be confusing to apply that to TLS 1.0, 1.1 and 1.2 too.

Also I wonder if we chose the best definition to DigitalSignatureAlg if EdDSA applies to ECDHE_ECDSA ciphers.

@kazu-yamamoto
Copy link
Collaborator Author

Reading draft-ietf-tls-rfc4492bis, I realize we could rename HashTLS13 to HashIntrinsic (cf. § 5.1.3. The signature_algorithms Extension and EdDSA). Otherwise it will be confusing to apply that to TLS 1.0, 1.1 and 1.2 too.

Oh, yes! Please rename it.

Also I wonder if we chose the best definition to DigitalSignatureAlg if EdDSA applies to ECDHE_ECDSA ciphers.

I have no idea on this.

@ocheron
Copy link
Contributor

ocheron commented Jun 1, 2017

OK thanks. I can explore this as I have some code for EdDSA certificates.

@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.

None yet

2 participants