Skip to content

Compatibility with Platforms other than Windows #5

@GabryJ84

Description

@GabryJ84

Latest Delphi versions added the possibility to compile also for other platforms, including Android, iOS/OSX and Linux64.

The code is not compatible because of the following issues:

  • It uses Windows, ComObj and ActiveX which are Windows exclusives.

I am not a Crypto expert but as far as I have been able to investigate, the incompatibilities are relative to some Memory Management, the Hash Generation and the Password robustness check and, in particular:

CryptAcquireContextW
CryptReleaseContext
CryptGenRandom
CryptAcquireContext
CryptCreateHash
CryptHashData
CryptGetHashParam
CryptDestroyHash

who use advapi32 which is not present in other platforms.

OleCheck/CoCreateGUID

which doesn't work outside Windows

ZeroMemory
HResultFromWin32

which doesn't work outside Windows too

AnsiString
PAnsiChar
FoldStringW
WideCharToMultiByte

which is not present in Linux64, Android and iOS

QueryPerformanceFrequency
QueryPerformanceCounter

which works only with Windows

I have investigated a bit and discovered that the 2 point is easily solvable since Delphi provides a CreateGuid function which is platform independent.

As for point 5, there should be TStopWatch (which, on Windows, queries QueryPerformanceCounter), but I don't know if it works also for QueryPerformanceFrequency.

As for point 4, the matter is tricky since strings are all UTF-16 encoded and the type AnsiString is not present.

As for point 3, Zeromemory seems to be replaceable with FillByte but don't know if you achieve the same results, while HResultFromWin32 maybe is useless and GetLastError is sufficient enough?

Point 1 could be solved using System.Hash functions, although I don't know when this was added (no more than 10 years ago) so there should be some conditionals telling the code to use System.Hash on non windows systems.

I believe that since this unit is gold for developers, since it allows to write cross platform apache modules and CGIs, it would be a good thing to add the compatibility to all of the platforms delphi supports.

Thankyou

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions