pion / srtp

A Go implementation of SRTP
MIT License
119 stars 49 forks source link

Use speedy XOR from pion/transport #211

Closed jech closed 2 years ago

jech commented 2 years ago

Now that we have a speedy version of xorBytes in pion/transport, we might as well use it. Benchmarks indicate an improvement of 10% to 20% in CTR encryption speed for large blocks, depending on the architecture.

The semantics of xor.XorBytes is a little bit different from the previous version — it panics if the destination is too short, while the previous version used to truncate the output. As far as I can tell, we never call it with a too small destination, we always use GrowBuffer beforehand. I've removed XorTestBufferSize, which was testing this behaviour; if any further tests are necessary, they should go into the xor package.

codecov[bot] commented 2 years ago

Codecov Report

Merging #211 (7a85ea5) into master (88859d2) will decrease coverage by 0.23%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #211      +/-   ##
==========================================
- Coverage   76.54%   76.31%   -0.24%     
==========================================
  Files          17       17              
  Lines        1232     1220      -12     
==========================================
- Hits          943      931      -12     
  Misses        198      198              
  Partials       91       91              
Flag Coverage Δ
go 76.31% <100.00%> (-0.24%) :arrow_down:
wasm 75.81% <100.00%> (-0.24%) :arrow_down:

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

Impacted Files Coverage Δ
crypto.go 91.30% <100.00%> (-2.99%) :arrow_down:

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 88859d2...7a85ea5. Read the comment docs.

jech commented 2 years ago

I've now pushed the v0.13.1 tag to pion/transport. Can you try fixing up go.mod accordingly and we'll see if that works?

Done.