Add HKDF funcs for Key Scheduling - DTLS v1.3#737
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #737 +/- ##
==========================================
- Coverage 82.57% 82.54% -0.04%
==========================================
Files 116 117 +1
Lines 6650 6684 +34
==========================================
+ Hits 5491 5517 +26
- Misses 760 764 +4
- Partials 399 403 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
86be4d1 to
05b7a50
Compare
|
Thanks for starting on this! I think this PR should be scoped to implement the HKDF functions: |
No problem! I agree, this seems to be a rather large thing and due to the current block that you mentioned #736 (comment), I think it would make sense to tackle #736 in multiple parts. Just to clarify, I should still include |
|
@philipch07, yes we should also export a HkdfExtract function, good catch. |
|
I have made some changes to the draft to make better use of the standard crypto library and should be more in-line with the TLS 1.3 implementation. I also think we should add some tests that verify the byte output of Expand/Derive functions. Note: the crypto/hkdf library requires go version 1.24, which is a higher minimum version than we currently have. I think the usage of this library justifies the bump in minimum version, but I am unsure of how much this would break for our users. Looking for input on this! |
Sadly we can't upgrade to 1.24, unless we're shipping dtls 1.3 now. many users are still on 1.22, 1.23, And upgrading dtls to 1.24 will force to upgrade pion/webrtc too and many other libraries. Maybe we can keep this in a branch until we upgrade? we should upgrade to 1.24 before dtls 1.3 is ready anyway. |
|
@joeturki, I agree that we should wait to merge this until we are closer to a WIP for DTLS 1.3. Unfortunately, this blocks much of the implementation, so we should provide a similar mock API meanwhile. |
|
Maybe a dumb idea but as a band aid solution to the problem… can we copy and paste the crypto/hkdf into this repo? So we dont have to manage multiple branches :) then when we bump to 1.24 we get rid of the copy. |
|
I think it's safe to upgrade to 1.24 once 1.26 is released in a few days :) |
2ba5321 to
6e8e6a4
Compare
654e6e2 to
743d047
Compare
|
We finally bumped the go version, so this PR is unblocked! I have rebased and made some touch ups. |
adrianosela
left a comment
There was a problem hiding this comment.
LGTM! Feel free to ignore the nits.
I think we should add some tests for HkdfExpandLabel and DeriveSecret with known-good expected outputs. Maybe we can get some from https://github.com/openssl/openssl/blob/master/test/recipes/30-test_evp_data/evpkdf_tls13_kdf.txt (though these are for tls not dtls, we'll need to adapt them. I think we should be able to just change the prefixes from tls13 to dtls13)
^^ but this can be done in a separate PR/later. Ship it.
|
Here's one taken from openssl's tls13 tests. All the hex strings are the same except for The expected value I generated with a standalone Or if we wanted we could refactor the code into a function Feel free to ignore all this too... this PR is good to go as is IMO. |
|
@adrianosela, thanks for the review! I have added some of the nits;) Regarding the tests, I chose to not add them:
|
|
@theodorsm thank you for cleaning up this PR (and the key share extension), and apologies for not getting around to them. The work that both you and @adrianosela have been doing in DTLS has been amazing!! :)) |
Description
This adds the HKDF related functions for the key scheduling feature in accordance with DTLS v1.3 section 5.9. Note that it links to TLS 1.3 section 7.1.
This aims to add:
Note that the architecture is still a WIP (see #738) so the current file structures are subject to change.
Reference issue
Closes #740