Skip to content

Commit 90d1f44

Browse files
LordOfXenCopilot
andauthored
Config profiles support (#1)
* Update ReflectionHelper.cs with refurbished instance creaters Signed-off-by: Xen <lordofxen@deskasoft.com> * Add config profile attributes Signed-off-by: Xen <lordofxen@deskasoft.com> * Add config profile class and interface Signed-off-by: Xen <lordofxen@deskasoft.com> * Refactor HashFactory to include config profiles and way better lambdas Signed-off-by: Xen <lordofxen@deskasoft.com> * Update _implementations access in Hash Factory Extensions Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename ConfigProfilesAttribute to HashConfigProfilesAttribute Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename ConfigProfilesAttribute to HashConfigProfilesAttribute Signed-off-by: Xen <lordofxen@deskasoft.com> * Delete HashifyNet/Core/Attributes/HashConfigProfilesAttribute.cs Signed-off-by: Xen <lordofxen@deskasoft.com> * Add files via upload Signed-off-by: Xen <lordofxen@deskasoft.com> * Switch config profile attribute implementation to a CLS-Compliant code Signed-off-by: Xen <lordofxen@deskasoft.com> * Update attribute references Signed-off-by: Xen <lordofxen@deskasoft.com> * Delete HashifyNet/Core/Attributes/HashConfigProfileAttribute.cs Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename HashConfigProfileAttribute to DefineHashConfigProfile Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename HashConfigProfile to DefineHashConfigProfile Signed-off-by: Xen <lordofxen@deskasoft.com> * Remove redundant usings Signed-off-by: Xen <lordofxen@deskasoft.com> * Add config profile definition attribute Signed-off-by: Xen <lordofxen@deskasoft.com> * Add config declaration attribute Signed-off-by: Xen <lordofxen@deskasoft.com> * Update BuzHashConfig with correct usings and comments Signed-off-by: Xen <lordofxen@deskasoft.com> * Update using directives Signed-off-by: Xen <lordofxen@deskasoft.com> * Add config profile definition attribute Signed-off-by: Xen <lordofxen@deskasoft.com> * Add config profile declaration attribute Signed-off-by: Xen <lordofxen@deskasoft.com> * Enhance DefineHashConfigProfileAttribute with length checks Added validation for name and description length in DefineHashConfigProfileAttribute. Signed-off-by: Xen <lordofxen@deskasoft.com> * Reduce max name length in DefineHashConfigProfileAttribute Updated maximum name length from 255 to 64 characters. Signed-off-by: Xen <lordofxen@deskasoft.com> * Enhance validation for DefineHashConfigProfileAttribute Updated validation rules for Name and Description properties to include minimum length requirements. Signed-off-by: Xen <lordofxen@deskasoft.com> * Refactor Argon2idConfig with new attributes Signed-off-by: Xen <lordofxen@deskasoft.com> * Add Argon2id Config Profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Delete HashifyNet/Algorithms/Argon2id/ConfigProfiles directory Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename Argon2idConfig defaults to include "Profile" in name Signed-off-by: Xen <lordofxen@deskasoft.com> * Repush previous commit Signed-off-by: Xen <lordofxen@deskasoft.com> * Update Argon2id default configs to include Profile in their names Signed-off-by: Xen <lordofxen@deskasoft.com> * Delete HashifyNet/Algorithms/BuzHash/DefaultBuzHashConfig.cs Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename DefaultBuzHashConfig Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename DefaultBuzHashConfig Signed-off-by: Xen <lordofxen@deskasoft.com> * Delete HashifyNet/Algorithms/Pearson/WikipediaPearsonConfig.cs Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename WikipediaPearsonConfig Signed-off-by: Xen <lordofxen@deskasoft.com> * Rename WikipediaPearsonConfig Signed-off-by: Xen <lordofxen@deskasoft.com> * Seal the wikipedia profile of pearson config Signed-off-by: Xen <lordofxen@deskasoft.com> * Refactor BuzHashConfigProfileDefault class Signed-off-by: Xen <lordofxen@deskasoft.com> * Refactor FNVConfig by adding hash profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Add FNV Config Profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Cover implementation in scopes for clarity Signed-off-by: Xen <lordofxen@deskasoft.com> * Pad fields Signed-off-by: Xen <lordofxen@deskasoft.com> * Move out CRC standards and use profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Add CRC Config Profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Update Pearson Tests to switch to Config Profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Refactor WikipediaPearsonConfig_Tests for new class Signed-off-by: Xen <lordofxen@deskasoft.com> * Update FactoryTests to use new config profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Update universal tests to use config profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Update BuzHash tests to use config profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Update DefaultBuzHashConfig tests to use config profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Refactor FNV1Base_Tests Signed-off-by: Xen <lordofxen@deskasoft.com> * Add Config Profile Helper for FNV Tests Signed-off-by: Xen <lordofxen@deskasoft.com> * Use ConfigProfileHelper for FNV tests Signed-off-by: Xen <lordofxen@deskasoft.com> * Use ConfigProfileHelper for FNV Tests Signed-off-by: Xen <lordofxen@deskasoft.com> * Use ConfigProfileHelper for FNV Tests Signed-off-by: Xen <lordofxen@deskasoft.com> * Update CRC tests to use config profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Update CRC tests to use config profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Update Argon2id tests to use config profiles Signed-off-by: Xen <lordofxen@deskasoft.com> * Enhance error messages in DefineHashConfigProfileAttribute Updated error messages to include current values for better debugging. Signed-off-by: Xen <lordofxen@deskasoft.com> * Modify minimum name length in DefineHashConfigProfileAttribute Updated minimum name length from 4 to 3 characters. Signed-off-by: Xen <lordofxen@deskasoft.com> * Add GetConfigProfiles extension Signed-off-by: Xen <lordofxen@deskasoft.com> * Enhance FactoryTests with config profile validations Added tests for retrieving and validating hash algorithm configurations and profiles. Signed-off-by: Xen <lordofxen@deskasoft.com> * Update HashifyNet/Algorithms/FNV/ConfigProfiles/FNVConfigProfile64Bits.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Xen <lordofxen@deskasoft.com> * Change configType to configProfileType Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Xen <lordofxen@deskasoft.com> * Remove trailing whitespace Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Xen <lordofxen@deskasoft.com> * Remove extra space Signed-off-by: Xen <lordofxen@deskasoft.com> * Reorder fields Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Xen <lordofxen@deskasoft.com> * Add ProfileType property to IHashConfigProfile Updated IHashConfigProfile interface to include ProfileType property. Signed-off-by: Xen <lordofxen@deskasoft.com> * Add ProfileType to HashConfigProfile class Added ProfileType property and updated constructor to include it. Enhanced validation for profileType parameter. Signed-off-by: Xen <lordofxen@deskasoft.com> * Pass configProfileType to HashConfigProfile class Signed-off-by: Xen <lordofxen@deskasoft.com> * Add Factory_GetConfigProfiles_Create_Works test Signed-off-by: Xen <lordofxen@deskasoft.com> --------- Signed-off-by: Xen <lordofxen@deskasoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent cfa0e25 commit 90d1f44

File tree

108 files changed

+5174
-1683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+5174
-1683
lines changed

HashifyNet.UnitTests/Algorithms/Argon2id/Argon2id_Implementation_Tests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void Argon2id_Implementation_HashSizeInBits_IsFromConfig()
140140
[Fact]
141141
public void Argon2id_Implementation_Verify_Works()
142142
{
143-
Argon2id_Implementation impl = new Argon2id_Implementation(Argon2idConfig.OWASP_Standard);
143+
Argon2id_Implementation impl = new Argon2id_Implementation(new Argon2idConfigProfileOWASP());
144144
IHashValue hash1 = impl.ComputeHash(TestConstants.FooBar);
145145

146146
Assert.NotNull(hash1);
@@ -153,7 +153,7 @@ public void Argon2id_Implementation_Verify_Works()
153153
[Fact]
154154
public void Argon2id_Implementation_Verify_Irrelevant_Fails()
155155
{
156-
Argon2id_Implementation impl = new Argon2id_Implementation(Argon2idConfig.OWASP_Standard);
156+
Argon2id_Implementation impl = new Argon2id_Implementation(new Argon2idConfigProfileOWASP());
157157
IHashValue hash1 = impl.ComputeHash(TestConstants.FooBar);
158158

159159
Assert.NotNull(hash1);
@@ -185,7 +185,7 @@ protected override IHashValue ComputeHash(IArgon2id hf, byte[] data)
185185

186186
protected override IArgon2id CreateHashFunction(int hashSize) =>
187187
new Argon2id_Implementation(
188-
Argon2idConfig.OWASP_Standard);
188+
new Argon2idConfigProfileOWASP());
189189
}
190190
}
191191
}

HashifyNet.UnitTests/Algorithms/BuzHash/BuzHash_Implementation_Tests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void BuzHash_Implementation_Constructor_Config_IsCloned()
8282
var buzHashConfigMock = new Mock<IBuzHashConfig>();
8383
{
8484
buzHashConfigMock.Setup(bhc => bhc.Clone())
85-
.Returns(new DefaultBuzHashConfig());
85+
.Returns(new BuzHashConfigProfileDefault());
8686
}
8787

8888
GC.KeepAlive(
@@ -402,7 +402,7 @@ public class IStreamableHashFunction_Tests
402402

403403
protected override IBuzHash CreateHashFunction(int hashSize) =>
404404
new BuzHash_Implementation(
405-
new DefaultBuzHashConfig()
405+
new BuzHashConfigProfileDefault()
406406
{
407407
HashSizeInBits = hashSize
408408
});
@@ -420,7 +420,7 @@ public class IStreamableHashFunction_Tests_DefaultConstructor
420420

421421
protected override IBuzHash CreateHashFunction(int hashSize) =>
422422
new BuzHash_Implementation(
423-
new DefaultBuzHashConfig());
423+
new BuzHashConfigProfileDefault());
424424
}
425425

426426
public class IStreamableHashFunction_Tests_RightShift
@@ -444,7 +444,7 @@ public class IStreamableHashFunction_Tests_RightShift
444444

445445
protected override IBuzHash CreateHashFunction(int hashSize) =>
446446
new BuzHash_Implementation(
447-
new DefaultBuzHashConfig()
447+
new BuzHashConfigProfileDefault()
448448
{
449449
HashSizeInBits = hashSize,
450450
ShiftDirection = CircularShiftDirection.Right
@@ -463,7 +463,7 @@ public class IStreamableHashFunction_Tests_RightShift_DefaultConstructor
463463

464464
protected override IBuzHash CreateHashFunction(int hashSize) =>
465465
new BuzHash_Implementation(
466-
new DefaultBuzHashConfig()
466+
new BuzHashConfigProfileDefault()
467467
{
468468
ShiftDirection = CircularShiftDirection.Right
469469
});

HashifyNet.UnitTests/Algorithms/BuzHash/DefaultBuzHashConfig_Tests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class DefaultBuzHashConfig_Tests
3636
[Fact]
3737
public void DefaultBuzHashConfig_Defaults_HaventChanged()
3838
{
39-
var defaultBuzHashConfig = new DefaultBuzHashConfig();
39+
var defaultBuzHashConfig = new BuzHashConfigProfileDefault();
4040

4141
Assert.Equal(_expectedRtab.Select(u => unchecked((long)u)).ToArray(), defaultBuzHashConfig.Rtab);
4242
Assert.Equal(64, defaultBuzHashConfig.HashSizeInBits);
@@ -47,7 +47,7 @@ public void DefaultBuzHashConfig_Defaults_HaventChanged()
4747
[Fact]
4848
public void DefaultBuzHashConfig_Clone_Works()
4949
{
50-
var defaultBuzHashConfig = new DefaultBuzHashConfig()
50+
var defaultBuzHashConfig = new BuzHashConfigProfileDefault()
5151
{
5252
HashSizeInBits = 32,
5353
Seed = 1337L,
@@ -56,7 +56,7 @@ public void DefaultBuzHashConfig_Clone_Works()
5656

5757
var defaultBuzHashConfigClone = defaultBuzHashConfig.Clone();
5858

59-
Assert.IsType<DefaultBuzHashConfig>(defaultBuzHashConfig);
59+
Assert.IsType<BuzHashConfigProfileDefault>(defaultBuzHashConfig);
6060

6161
Assert.Equal(defaultBuzHashConfig.Rtab, defaultBuzHashConfigClone.Rtab);
6262
Assert.Equal(defaultBuzHashConfig.HashSizeInBits, defaultBuzHashConfigClone.HashSizeInBits);

0 commit comments

Comments
 (0)