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