|
@@ -11,7 +11,7 @@ uses
|
|
|
|
|
|
resourcestring
|
|
resourcestring
|
|
SInvalidHashSize =
|
|
SInvalidHashSize =
|
|
- 'BLAKE2B HashSize must be restricted to one of the following [20, 32, 48, 64], "%d"';
|
|
|
|
|
|
+ 'BLAKE2B HashSize must be restricted to one of the following [1 .. 64], "%d"';
|
|
SInvalidKeyLength = '"Key" Length Must Not Be Greater Than 64, "%d"';
|
|
SInvalidKeyLength = '"Key" Length Must Not Be Greater Than 64, "%d"';
|
|
SInvalidPersonalisationLength =
|
|
SInvalidPersonalisationLength =
|
|
'"Personalisation" Length Must Be Equal To 16, "%d"';
|
|
'"Personalisation" Length Must Be Equal To 16, "%d"';
|
|
@@ -48,6 +48,8 @@ type
|
|
|
|
|
|
public
|
|
public
|
|
constructor Create(AHashSize: THashSize = THashSize.hsHashSize512);
|
|
constructor Create(AHashSize: THashSize = THashSize.hsHashSize512);
|
|
|
|
+ overload;
|
|
|
|
+ constructor Create(AHashSize: Int32); overload;
|
|
property Personalisation: THashLibByteArray read GetPersonalisation
|
|
property Personalisation: THashLibByteArray read GetPersonalisation
|
|
write SetPersonalisation;
|
|
write SetPersonalisation;
|
|
property Salt: THashLibByteArray read GetSalt write SetSalt;
|
|
property Salt: THashLibByteArray read GetSalt write SetSalt;
|
|
@@ -62,10 +64,10 @@ implementation
|
|
|
|
|
|
procedure TBlake2BConfig.ValidateHashSize(AHashSize: Int32);
|
|
procedure TBlake2BConfig.ValidateHashSize(AHashSize: Int32);
|
|
begin
|
|
begin
|
|
- if not((AHashSize) in [20, 32, 48, 64]) then
|
|
|
|
|
|
+ if not((AHashSize) in [1 .. 64]) or (((AHashSize * 8) and 7) <> 0) then
|
|
begin
|
|
begin
|
|
raise EArgumentHashLibException.CreateResFmt(@SInvalidHashSize,
|
|
raise EArgumentHashLibException.CreateResFmt(@SInvalidHashSize,
|
|
- [Int32(AHashSize)]);
|
|
|
|
|
|
+ [AHashSize]);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -169,4 +171,11 @@ begin
|
|
FHashSize := LHashSize;
|
|
FHashSize := LHashSize;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+constructor TBlake2BConfig.Create(AHashSize: Int32);
|
|
|
|
+begin
|
|
|
|
+ Inherited Create();
|
|
|
|
+ ValidateHashSize(AHashSize);
|
|
|
|
+ FHashSize := AHashSize;
|
|
|
|
+end;
|
|
|
|
+
|
|
end.
|
|
end.
|