1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
Index: kperm_64.inc
===================================================================
--- kperm_64.inc (revision 6895)
+++ kperm_64.inc (working copy)
@@ -33,10 +33,14 @@
{---------------------------------------------------------------------------}
+{$IFDEF FPC}
+ {$MACRO ON} {$DEFINE RotL:= RolQWord}
+{$ELSE}
function RotL(x: u64bit; c: integer): u64bit; {$ifdef HAS_INLINE} inline; {$endif}
begin
RotL := (x shl c) or (x shr (64-c));
end;
+{$ENDIF}
{---------------------------------------------------------------------------}
Index: sha1.pas
===================================================================
--- sha1.pas
+++ sha1.pas
@@ -106,7 +106,7 @@
{$i STD.INC}
-{$ifdef BIT64}
+{$ifndef CPUI386}
{$ifndef PurePascal}
{$define PurePascal}
{$endif}
Index: sha3.pas
===================================================================
--- sha3.pas (revision 6895)
+++ sha3.pas (working copy)
@@ -6,6 +6,15 @@
{$i STD.INC}
+{$ifdef FPC}
+ {$ifdef CPUI386}
+ {$define USE_MMXCODE}
+ {$endif}
+ {$ifdef CPU64}
+ {$define USE_64BITCODE}
+ {$endif}
+{$endif}
+
{.$define USE_64BITCODE} {Use 64-bit for Keccak permutation}
{.$define USE_MMXCODE } {Use MMX for Keccak permutation, contributed by Eric Grange}
{.$define USE_MMX_AKP } {Use MMX for Keccak permutation, contributed by Anna Kaliszewicz / payl}
Index: scrypt.pas
===================================================================
--- scrypt.pas (revision 7740)
+++ scrypt.pas (working copy)
@@ -90,7 +90,7 @@
implementation
uses
- sha256; {Register SHA256 for HMAC-SHA256}
+ SHA3_512; {Register SHA3_512 for HMAC_SHA3_512}
type
TLA16 = array[0..15] of longint;
@@ -361,14 +361,14 @@
{---------------------------------------------------------------------------}
-function pbkfd2_hmac_sha256(pPW: pointer; pLen: word; salt: pointer; sLen,C: longint; var DK; dkLen: longint): integer;
- {-Derive key DK from password pPW using salt and iteration count C using (hmac-)sha256}
+function pbkdf2_hmac_sha3_512(pPW: pointer; pLen: word; salt: pointer; sLen,C: longint; var DK; dkLen: longint): integer;
+ {-Derive key DK from password pPW using salt and iteration count C using hmac_sha3_512}
var
phash: PHashDesc;
begin
- {Note: pbkdf2 will return error indicator phash=nil if _SHA256 is not found!}
- phash := FindHash_by_ID(_SHA256);
- pbkfd2_hmac_sha256 := pbkdf2(phash,pPW,pLen,salt,sLen,C,DK,dkLen);
+ {Note: pbkdf2 will return error indicator phash=nil if _SHA3_512 is not found!}
+ phash := FindHash_by_ID(_SHA3_512);
+ pbkdf2_hmac_sha3_512 := pbkdf2(phash,pPW,pLen,salt,sLen,C,DK,dkLen);
end;
@@ -418,7 +418,7 @@
pV := malloc(sV);
pXY := malloc(sXY);
if (pB<>nil) and (pV<>nil) and (pXY<>nil) then begin
- err := pbkfd2_hmac_sha256(pPW, pLen, salt, sLen, 1, pB^, sB);
+ err := pbkdf2_hmac_sha3_512(pPW, pLen, salt, sLen, 1, pB^, sB);
if err=0 then begin
pw := pB;
for i:=0 to p-1 do begin
@@ -425,7 +425,7 @@
smix(pw, r, N, pV, pXY);
inc(Ptr2Inc(pw), r*128);
end;
- err := pbkfd2_hmac_sha256(pPW, pLen, pB, sB, 1, DK, dKlen);
+ err := pbkdf2_hmac_sha3_512(pPW, pLen, pB, sB, 1, DK, dKlen);
end;
scrypt_kdf := err;
end
|