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

Add support for KeyLogWriter #344

Closed
wants to merge 2 commits into from
Closed

Add support for KeyLogWriter #344

wants to merge 2 commits into from

Conversation

kegsay
Copy link
Contributor

@kegsay kegsay commented Feb 4, 2021

Fixes #343 - style is done in the same way as tls.Config.

Manually tested both as a client and as a server, then reading the resulting logs in Wireshark and confirming that data can be decrypted.

Fixes pion#343 - style is done in the same way as `tls.Config`.
@codecov
Copy link

codecov bot commented Feb 4, 2021

Codecov Report

Merging #344 (8d125fe) into master (eee772b) will decrease coverage by 0.04%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #344      +/-   ##
==========================================
- Coverage   75.84%   75.80%   -0.05%     
==========================================
  Files          86       86              
  Lines        3660     3670      +10     
==========================================
+ Hits         2776     2782       +6     
- Misses        600      603       +3     
- Partials      284      285       +1     
Flag Coverage Δ
go 75.82% <80.00%> (-0.05%) ⬇️
wasm 65.90% <80.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
config.go 100.00% <ø> (ø)
handshaker.go 74.30% <71.42%> (-0.15%) ⬇️
conn.go 82.60% <100.00%> (+0.03%) ⬆️
flight4handler.go 83.76% <100.00%> (+0.06%) ⬆️
flight5handler.go 81.73% <100.00%> (+0.08%) ⬆️
internal/net/dpipe/dpipe.go 93.24% <0.00%> (-2.71%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eee772b...2c19c14. Read the comment docs.

@Sean-Der
Copy link
Member

Sean-Der commented Feb 4, 2021

This looks fantastic! Would be happy to take right away. Would you mind adding a test? Then should be good to go :)

I can fix all the other little things (linters and so on)

@daenney
Copy link
Member

daenney commented Feb 4, 2021

I'd like to see some actual tests for this. Since the KeyLogWriter is an io.Writer, you can put in a bytes.Buffer during test and check what ends up in there.

@kegsay
Copy link
Contributor Author

kegsay commented Feb 4, 2021

It's hard to see at what level you wish to add tests for:

  • Verify something is written to the io.Writer which looks roughly right according to https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format - effectively a unit test for writeKeyLog.
  • Verify that something is written at the right stage of the handshake process. - tests at the handshakeFSM level.
  • Verify that the data written to io.Writer can actually decrypt traffic. - E2E test.

The latter being the most useful but also the most effort to write tests for.

@Sean-Der
Copy link
Member

Sean-Der commented Feb 4, 2021

I am happy with 1/2!

I think we can just remove randomness and then just assert a certain value is generated everytime. Just enough to make sure someone doesn't regress your work in the future :)

@kegsay
Copy link
Contributor Author

kegsay commented Feb 19, 2021

Test was added a few weeks ago.

@daenney
Copy link
Member

daenney commented Feb 19, 2021

The tests are fine, but as you can see from the PR status, our commit linter disagrees: https://github.com/pion/dtls/pull/344/checks?check_run_id=1838025192#step:3:15. It's a small thing, but we like to keep this consistent on this repo and everything else in the Pion org. Might be easiest to fold the test commit into the original one, that should make everything happy.

@Sean-Der
Copy link
Member

Sean-Der commented Feb 24, 2021

Thank you so much for contributing this @kegsay! I squashed your commits into 4879d34 also released v2.0.8

@Sean-Der Sean-Der closed this Feb 24, 2021
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.

Add support for KeyLogWriter
3 participants