daviddesmet / paseto-dotnet

🔑 Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET
MIT License
96 stars 8 forks source link

Add password wrap for V1-V3. #89

Closed TimothyMakkison closed 1 year ago

TimothyMakkison commented 1 year ago

Added support for V1-V3 password wrap for both local and secret. Bit of a pain because the test vectors/php implemetation was incorrect 😅

V2-V4 will require Argon2id, so I'll probably use the repository Konscious.Security.Cryptography implementation.

Looking at the source code ptk = XChaCha20(msg=edk, key=Ek, nonce=n) is implemented as sodium_crypto_stream_xchacha20_xor. Does NaClCore support this? I've found the php implementation but can't find the logic section, the rust equivalent looks a bit more promising.

Note that I rebased Lid, Pid and Sid onto this branch. Hopefully it won't cause problems.

codecov-commenter commented 1 year ago

Codecov Report

Merging #89 (7500d27) into master (243b6a2) will increase coverage by 0.03%. The diff coverage is 78.87%.

@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
+ Coverage   82.62%   82.65%   +0.03%     
==========================================
  Files         104      107       +3     
  Lines        5295     5495     +200     
  Branches      327      353      +26     
==========================================
+ Hits         4375     4542     +167     
- Misses        798      817      +19     
- Partials      122      136      +14     
Impacted Files Coverage Δ
src/Paseto/Paserk.cs 36.50% <52.27%> (+10.19%) :arrow_up:
src/Paseto/Utils/EncodingHelper.cs 78.04% <60.00%> (-5.83%) :arrow_down:
src/Paseto/PaserkHelpers.cs 80.58% <80.58%> (ø)
...seto/Cryptography/Internal/ByteIntegerConverter.cs 25.85% <100.00%> (+1.54%) :arrow_up:
src/Paseto/Cryptography/Pbkdf2.cs 100.00% <100.00%> (ø)
src/Paseto/PaserkOperations/Pbkw.cs 100.00% <100.00%> (ø)
...c/Paseto/Exceptions/PaserkNotSupportedException.cs 25.00% <0.00%> (+25.00%) :arrow_up:

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

TimothyMakkison commented 1 year ago

Closing in favor of #91