[fpc-devel] x86_64 SHA1 implementation (J. Gareth Moreton)

2023-09-16 Thread Arnaud Bouchez via fpc-devel
There is a working SHA-1 and SHA-256 implementation using x86_64 asm and also SHA-NI in mORMot 2. Numbers are very high, e.g. 2GB/s on my Core i5 13500. Since there is no SHA opcode in FPC asm yet (neither in Delphi), I am using hardcoded "db" arrays for SHA-NI instructions. See https://

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread J. Gareth Moreton via fpc-devel
True, that's fair.  Just having this feature for the sake of compiling the "hash" package more efficiently is... well... favouritism?!  Or just a feature that has a single purpose. Kit On 16/09/2023 17:45, Florian Klämpfl via fpc-devel wrote: Am 16.09.2023 um 17:45 schrieb J. Gareth Moreton

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread Florian Klämpfl via fpc-devel
> Am 16.09.2023 um 17:45 schrieb J. Gareth Moreton via fpc-devel > : > > I missed this post - thanks Florian! > > Indeed, SHA-1 is deprecated at least as far as being a cryptographic > algorithm is concerned, but it still has some uses in data verification in a > similar vein to MD5. I know

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread Wayne Sherman via fpc-devel
> assembly version of SHA-1 for x86_64 Another example which I thought is beautiful in form and simplicity (I don't know how it compares for performance): https://github.com/nayuki/Nayuki-web-published-code/blob/master/fast-sha1-hash-implementation-in-x86-assembly/sha1-fast-x8664.S ___

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread J. Gareth Moreton via fpc-devel
I missed this post - thanks Florian! Indeed, SHA-1 is deprecated at least as far as being a cryptographic algorithm is concerned, but it still has some uses in data verification in a similar vein to MD5.  I know git uses it internally so server branches can't be corrupted. I have probably sp

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread Wayne Sherman via fpc-devel
> OpenSSL x86 64-bit assembly code > https://github.com/openssl/openssl/blob/master/crypto/sha/asm/sha1-x86_64.pl To generate plain assembly from the OpenSSL perl asm script requires downloading these files to the same folder: https://github.com/openssl/openssl/tree/master/crypto/perlasm _

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread J. Gareth Moreton via fpc-devel
Thanks for the resources - these will prove very useful!  Intel and AMD processors also have specialised SHA instructions later on.  I know the AMD Zen supports them - not sure the earliest Intel models though. Currently I'm sticking with pure SSE2 since this is the latest instruction set that

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread Wayne Sherman via fpc-devel
J. Gareth Moreton via fpc-devel wrote: > So this past week I've been building on Rika's work by adding an > assembly version of SHA-1 for x86_64 to complement Rika's i386 version. > So far I've successfully made a version that runs twice as fast as the > Pascal code. I hoped to go even faster by

Re: [fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread Florian Klämpfl via fpc-devel
Am 16.09.23 um 15:13 schrieb J. Gareth Moreton via fpc-devel: Hi everyone, So this past week I've been building on Rika's work by adding an assembly version of SHA-1 for x86_64 to complement Rika's i386 version. So far I've successfully made a version that runs twice as fast as the Pascal cod

[fpc-devel] x86_64 SHA1 implementation

2023-09-16 Thread J. Gareth Moreton via fpc-devel
Hi everyone, So this past week I've been building on Rika's work by adding an assembly version of SHA-1 for x86_64 to complement Rika's i386 version.  So far I've successfully made a version that runs twice as fast as the Pascal code.  I hoped to go even faster by making use of the SSE2 instr