Hello.
I'm using Lazarus 0.9.29 + FPC 2.4.1.
I'm trying to compile a project for Windows Mobile and everything works fine, except when it comes to use the InitStr method of DCPCrypt cypher.
When I click a button that executes
DCP_blowfish1.InitStr('test',TDCP_sha1);
The program shows a message error stating "Unable to allocate memory for hash digest".
I looked into dcpcrypt2.pas source code and found the InitStr code to be:
procedure TDCP_cipher.InitStr(const Key: string; HashType: TDCP_hashclass);
var
Hash: TDCP_hash;
Digest: pointer;
begin
if fInitialized then
Burn;
try
GetMem(Digest,HashType.GetHashSize div 8);
Hash:= HashType.Create(Self);
Hash.Init;
Hash.UpdateStr(Key);
Hash.Final(Digest^);
Hash.Free;
if MaxKeySize< HashType.GetHashSize then
begin
Init(Digest^,MaxKeySize,nil);
end
else
begin
Init(Digest^,HashType.GetHashSize,nil);
end;
FillChar(Digest^,HashType.GetHashSize div 8,$FF);
FreeMem(Digest);
except
raise EDCP_cipher.Create('Unable to allocate sufficient memory for hash digest');
end;
end;
If I replace the "except" part with
...
finally
end;
I can finally see what exception is being fired: it is the "Bus error or misaligned data access".
I read the wili about this error message but I can't understand what should I do.
Any help, please?