-
Notifications
You must be signed in to change notification settings - Fork 556
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 Blake2b intrinsics POC #398
base: master
Are you sure you want to change the base?
Conversation
Great numbers, but suggest the following changes:
At least add the license comment, the rest I can take care of if necessary. |
…on/bc-csharp into blake2_intrinsics
Added Blake2s_X86.Blake2sNon intrinsics
Intrinsics
Blake2xsNon intrinsics
Intrinsics
There was no overlap between Blake2b and Blake2s so I deleted SuggestionsAdd a length check to There are several repeat implementations of |
Note that intrinsics aren't available for NETSTANDARD2_1_OR_GREATER, so those directives should be removed (just NETCOREAPP3_0_OR_GREATER). I'd still like methods on the _X86 classes, e.g.: although ideally BitConverter.IsLittleEndian isn't a requirement and only affects Load/Store (this could fall out later when I factor out all the load/store methods and support bigendian). Also if all the rounds have the same structure (or a small set thereof), please factor out a method for 1 round (using ref parameters where each round applies to different parts of the state). I've added length checks that you suggested also (this mirror can take a few days to be updated though). |
public static bool IsSupported => Avx2.IsSupported && BitConverter.IsLittleEndian;
I've created a
Thanks, it was driving me nuts when debugging the benchmarks Should I update the xml documentation? It looks like the docs haven't been updated since being converted from java. Are you okay with using /// <inheritdoc />
public void Update(byte b)
{ |
I've converted the javadocs to xml form. I've used Nitpick: I've noticed that a couple of functions such as |
Is this ready for review/merge? |
I'll hold off for and convert this to a draft. Want to double check I haven't added a regression for .Net 3 |
Adapted @saucecontrol's Blake2Fast intrinsics code to work with the Konscious.Security.Cryptography library and thought it would work here.
The benchmark measured a 6x-13x speed up without additional memory usage. Blake2s or Blake2xs would probably experience similar benefits.
Non intrinsics
Intrinsics
Note that I'm new to intrinsics and CompilerServices.Unsafe, this shouldn't be considered complete or safe. Do you have a CI pipeline for testing intrinsic code?