daviddesmet / paseto-dotnet

πŸ”‘ Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET
MIT License
102 stars 7 forks source link

Removed allocations #81

Closed TimothyMakkison closed 2 years ago

TimothyMakkison commented 2 years ago

Hey was checking out Paseto when I found your library.

I've gone through the allocation TODOs and replaced byte[] allocations with Span<byte>, I've attempted to avoid changing logic or code flow, relying on adding or modifying existing methods.

When Spans weren't compatible with NaCl.Core I added two extension methods ByteIntegerConverterExtensions and CryptoBytesExtensions with adapted code.

daviddesmet commented 2 years ago

Terrific job @TimothyMakkison πŸ‘ Let me take a deeper look at your PR while the CI tests runs.

codecov-commenter commented 2 years ago

Codecov Report

Merging #81 (3c14107) into master (8118fa0) will increase coverage by 0.07%. The diff coverage is 40.00%.

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
+ Coverage   82.31%   82.39%   +0.07%     
==========================================
  Files         101      104       +3     
  Lines        5260     5293      +33     
  Branches      329      329              
==========================================
+ Hits         4330     4361      +31     
- Misses        804      807       +3     
+ Partials      126      125       -1     
Impacted Files Coverage Ξ”
...o/Cryptography/Internal/Ed25519Ref10/fe_tobytes.cs 100.00% <ΓΈ> (ΓΈ)
...o/Cryptography/Internal/Ed25519Ref10/ge_tobytes.cs 100.00% <ΓΈ> (ΓΈ)
...eto/Cryptography/Internal/Ed25519Ref10/sc_clamp.cs 50.00% <0.00%> (-50.00%) :arrow_down:
...o/Cryptography/Internal/Ed25519Ref10/sc_mul_add.cs 100.00% <ΓΈ> (ΓΈ)
...to/Cryptography/Internal/Ed25519Ref10/sc_reduce.cs 100.00% <ΓΈ> (ΓΈ)
...o/Cryptography/Internal/Ed25519Ref10/scalarmult.cs 0.00% <0.00%> (ΓΈ)
src/Paseto/Cryptography/Internal/Poly1305Donna.cs 0.00% <0.00%> (ΓΈ)
...seto/Cryptography/Internal/ByteIntegerConverter.cs 24.30% <23.77%> (ΓΈ)
...aphy/Internal/Ed25519Ref10/ge_double_scalarmult.cs 100.00% <100.00%> (ΓΈ)
...graphy/Internal/Ed25519Ref10/ge_scalarmult_base.cs 100.00% <100.00%> (ΓΈ)
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

TimothyMakkison commented 2 years ago

Thanks for the response! I'm happy I didn't break anything :grinning:

daviddesmet commented 2 years ago

I always wait for the tests to pass just to be safe. A new version will be available soon at NuGet.org with your changes.

TimothyMakkison commented 2 years ago

Just noticed a couple of redundant methods and inaccessible null checks, in Sha512.Update and sc_clamp. I'll remove them when i get the time.