Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2016-03

Implementing SHA256 Unit.

11 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Garry Wood
to H. Gabriel Máculus: I'm trying to write a sha256 implementation in pure pascal like sha1 and md5 units. With…
I'm trying to write a sha256 implementation in pure pascal like sha1 and md5 units. With negative results. Someone can helpme with this?

I recently ported the implementation from LibTimCrypt / wpa_supplicant (which are both from public domain implementations), you can find the unit here:

https://github.com/ultibohub/Core/blob/master/source/rtl/ultibo/core/crypto.pas

This is for our Ultibo embedded project but the code is pure pascal and should compile for any platform if you adjust the uses clause.

This has been validated against a number of test vectors available from different sources and seems correct although I can’t test on big endian unit also includes ports of AES, DES, DES3 and RC4 ciphers as well as MD5 and SHA1.

Cheers,

Garry.

Reply by email

Michael Van Canneyt
to Garry Wood
Garry Wood wrote 11 lines
> I'm trying to write a sha256 implementation in pure pascal like sha1 and md5 units. > With negative results. > Someone can helpme with this? I recently ported the implementation from LibTimCrypt / wpa_supplicant (which are both from public domain implementations), you can find the unit here: https://github.com/ultibohub/Core/blob/master/source/rtl/ultibo/core/crypto.pas This is for our Ultibo embedded project but the code is pure pascal and should compile for any platform if you adjust the uses clause. This has been validated against a number of test vectors available from different sources and seems correct although I can’t test on big endian unit also includes ports of AES, DES, DES3 and RC4 ciphers as well as MD5 and SHA1.

Would it be OK to extract some of the routines and include them in Free Pascal using the usual license ? We have several of these routines, but not all, it would be nice to have a more complete set available by default.

Michael.

Reply by email

Garry Wood
Michael Van Canneyt wrote 22 lines
On Sun, 20 Mar 2016, Garry Wood wrote: >> I'm trying to write a sha256 implementation in pure pascal like sha1 and md5 units. >> With negative results. >> Someone can helpme with this? > > I recently ported the implementation from LibTimCrypt / wpa_supplicant (which are both from public domain implementations), you can find the unit here: > > https://github.com/ultibohub/Core/blob/master/source/rtl/ultibo/core/crypto.pas > > This is for our Ultibo embedded project but the code is pure pascal and should compile for any platform if you adjust the uses clause. > > This has been validated against a number of test vectors available from different sources and seems correct although I can’t test on big endian unit also includes ports of AES, DES, DES3 and RC4 ciphers as well as MD5 and SHA1. Would it be OK to extract some of the routines and include them in Free Pascal using the usual license ? We have several of these routines, but not all, it would be nice to have a more complete set available by default. Michael.

Yes, no problem. The original sources are credited to public domain implementation and the Ultibo license is identical to the FPC RTL.

Cheers,

Garry.

Reply by email

Jy V
to Garry Wood: I recently ported the implementation from LibTimCrypt / wpa_supplicant (which are both…
Garry Wood wrote 7 lines
I recently ported the implementation from LibTimCrypt / wpa_supplicant (which are both from public domain implementations), you can find the unit here: https://github.com/ultibohub/Core/blob/master/source/rtl/ultibo/core/crypto.pas

Are you planning to support TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 embedded in Ultibo which looks to be the most common cipher requested by browser, would this allow to embed TLSv1.2 in order to implement https server in Ultibo?

Reply by email

Jy V
to Jy V
Garry Wood wrote 9 lines
> I recently ported the implementation from LibTimCrypt / wpa_supplicant > (which are both from public domain implementations), you can find the unit > here: > > > https://github.com/ultibohub/Core/blob/master/source/rtl/ultibo/core/crypto.pas >

I also see in your unit that you are supporting RC4 cipher, but as stated in
https://www.chromium.org/Home/chromium-security/education/tls#TOC-RC4 it looks like Chrome deprecated this cipher, probably other web browsers will follow,
any opinion ?

Reply by email

Garry Wood
Jy V wrote 12 lines
On Sun, Mar 20, 2016 at 2:11 AM, Garry Wood wrote: > >  I recently ported the implementation from LibTimCrypt / wpa_supplicant (which are both from public domain implementations), you can find the unit here: > > https://github.com/ultibohub/Core/blob/master/source/rtl/ultibo/core/crypto.pas Are you planning to support TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 embedded in Ultibo which looks to be the most common cipher requested by browser, would this allow to embed TLSv1.2 in order to implement https server in Ultibo?

Yes, the intent is to support https with TLS 1.0/1.1/1.2 so AES_128_GCM_SHA256 will be included in the cipher suite.

Garry.

Reply by email

Garry Wood
Jy V wrote 14 lines
> On Sun, Mar 20, 2016 at 2:11 AM, Garry Wood wrote: >> >>  I recently ported the implementation from LibTimCrypt / wpa_supplicant (which are both from public domain implementations), you can find the unit here: >> >> https://github.com/ultibohub/Core/blob/master/source/rtl/ultibo/core/crypto.pas I also see in your unit that you are supporting RC4 cipher, but as stated in https://www.chromium.org/Home/chromium-security/education/tls#TOC-RC4 it looks like Chrome deprecated this cipher, probably other web browsers will follow, any opinion ?

RC4 is included to support WEP and WPA (for 802.11). Even though both of those are also officially deprecated they are still widely used.

Garry.

Reply by email

Michael Van Canneyt
to Jy V
Jy V wrote 9 lines
On Sun, Mar 20, 2016 at 1:10 PM, Garry Wood wrote: > Yes, the intent is to support https with TLS 1.0/1.1/1.2 so > AES_128_GCM_SHA256 will be included in the cipher suite. > Pure FreePascal code only ? no dependency with OpenSSL (or third party libraries) ? -> this would be absolute great news !

Work is in progress to get the ciphers in the FPC SVN.

Michael.

Reply by email