-
-
Notifications
You must be signed in to change notification settings - Fork 8
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 password wrap for all versions #91
base: master
Are you sure you want to change the base?
Conversation
…ept PaserkItemTest parameter
…/paseto-dotnet into paserk_additions
Codecov Report
@@ Coverage Diff @@
## master #91 +/- ##
==========================================
+ Coverage 82.45% 82.87% +0.41%
==========================================
Files 105 119 +14
Lines 5387 5937 +550
Branches 344 413 +69
==========================================
+ Hits 4442 4920 +478
- Misses 815 853 +38
- Partials 130 164 +34
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Yay! You are on fire with the contributions! I really appreciate it! |
Conflicts should be resolved 🤞 and I've added some documentation to explain the different encoding operations. I'm a bit concerned with the Argon2id encode/decode, running all tests used to take me 40 secs but now its upwards of 4 mins. This might just be my computer though. |
Thanks for the update and for adding the documentation. I'm gonna take a look at the PR locally since it is failing in the macOS tests.
Yeah, looking at the numbers from the CI, it's taking longer than it used to. So, don't think is related to your computer. I'm not familiar with Argon2id so not sure if it is something expected. |
Looks like the problem might be caused by the difference in Argon2id implementations. PBKW takes the arguments So by setting the I've also made mislabeled the parameter |
Don't know if my earlier comment is right but looking at // Decode paserk to verify decoding works
var decoded = Paserk.Decode(test.Paserk, test.Password);
decoded.Key.Span.ToArray().Should().BeEquivalentTo(pasetoKey.Key.ToArray()); I'm not 100% sure how the test is passing because the test passes the field "memlimit": 67108864 (which I assumed is in KiB) into Argon2IdDecrypt as Tl Dr: I need to fix my KiB conversions, I still don't know why it's so slow. |
|
Sorry for looking at the PR until now, I was a bit overwhelmed by work.
I haven't looked into Argon yet, so I will trust your judgement on that.
I see the numbers changed, thanks for addressing those. =) Are you OK with all the changes done in the PR in order to merge it or do you want to keep working on it? |
No worries, I'm in no rush, this pr could probably do with more time as it is.
I'll update this commit later, it's a bit of a mess, I'd like to refactor a couple of things especially now that I've got PIE working. Might just flip a coin to resolve the byte units problem. I've been playing around with Avx2/Simd and think Argon2/Blake could be faster if we used some optimisations from saucecontrols Blake2Fast. Going to hack a proof of concept and see if Konscious.Secrurity would be interested. |
That sounds great, I've been postponing the Hardware Intrinsics topic for a while but it is still on my radar for NaCl.Core, there was a PR over there but it didn't make it into main due to some tests that broke. Maybe if you got some spare time and you are willing to, you could take also a look at it? |
|
Thanks for showing me this pr, it has some really clever usage of unpacking and parallelizing multiple shuffles, a bit beyond me tbh, I'm still very new to Avx It looks like @macaba bypassed I can think of two options I want to experiment with:
Looks like Salsa support has been added since the original pr, iirc Salsa and ChaCha use the same shuffling method but have different starting states layouts. I reckon Finally you mentioned |
I just left a minor comment regarding the documentation side, would be nice to add it to the README so people may know how to use those new password wrapper ones. What would you think?
I much prefer the cleaner one unless you come with something else.
XSalsa20 was added too, I haven't promoted those as stable yet since I feel we need more tests over there. My main plan as I mentioned in the other PR was to include XSalsa20Poly1305.
Aetting Wonder if we can have a cleaner way to execute with intrinsics on and off without running the tests twice with the variable set and unset. |
I merged your other PR and as a consequence, this PR would need to be updated, can you kindly update the PR so I can merge your changes? Once merged I think we can ship it as a new Nuget version, unless you want to add something else? |
Sorry this is yet another PR I've abandoned 😅. I'll make this PR compatible.
ID is not correctly supported. I misread the Paserk section on
When I added password wrapping I also added PIE which wraps local and secret keys using a symmetric key. I'll see if I can add that. Api ChangeI'd been meaning to suggest changing the Instead I suggest we use an interface to implement each operation with
interface IPaserk
{
string Encode(PasetoKey key);
PasetoKey Decode(string paserk);
// Declares supported verions/types, `Paserk.Encode` and `Paserk.Decode` could enforce this.
// Helps the user know if the operation is supported.
// PasetoKey[] SupportsKeyTypes { get; }
// ProtocolVersion[] SupportedVersions { get; }
// Could require a ToId implementation.
// string ToId(string paserk)
} public static class PaserkType
{
public static readonly IPaserk Public => new Public();
public static readonly IPaserk Local => new Local();
// Some operations require additional arguments.
// Static function (or constructor) that takes the arguments and returns the constructed type.
public static IPaserk LocalPw(string password) => new LocalPw(password);
public static IPaserk Seal(AsymmetricPrivateKey key) => new Seal(key);
} var paserk = PaserkType.Public.Encode(myKey);
var newKey = PaserkType.LocalPw("myPassword").Decode(myPaserk); |
No worries, you can work on it when you have free time. I've been busy also and haven't got that much free time.
Sure, please let me know when you feel ready to merge. I think I've seen you can mark PRs as a draft.
That sounds great! Thank you!
Yeah, when I first created that little helper I didn't measure how the API would evolve. And once again, thanks a lot for your contributions =) |
V2-V4 requires Argon2id, I've added the relevant files and tests from Konscious.Security.Cryptography and updated the README to reflect this.
V1-V3 and V2-V4 each require additional parameters, with V1-V3 taking a
password
&iterations
and V2-V4 takingpassword
,memoryCost
,iterations
°reeOfParallelism
. The current solution is to add method overloads toEncode
. I'm not sure if this is considered good practice/idiomatic and could be confusing for users.