Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-04-10 Thread Victor Campillo
On 25/03/13 23:56, silvioprog wrote: Done. http://bugs.freepascal.org/view.php?id=24136 The patch includes source, examples and test cases (7 for MD5 and 7 for SHA1). -- Silvio Clécio My public projects - github.com/silvioprog Hi Thank very much Silvio for s

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-04-01 Thread silvioprog
2013/4/2 Noah Silva > Hi, > > Actually I think on OS X and Linux it makes sense to depend on OpenSSL, > but not for the reasons you mentioned so much as one more: Security. If > you are using doing encryption, then it's better to use a library that is > updated more often for bug fixes, and to h

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-04-01 Thread Noah Silva
Hi, Actually I think on OS X and Linux it makes sense to depend on OpenSSL, but not for the reasons you mentioned so much as one more: Security. If you are using doing encryption, then it's better to use a library that is updated more often for bug fixes, and to have the updates be applied to you

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-26 Thread Sven Barth
Am 26.03.2013 14:26 schrieb "Ludo Brands" : > > On 03/26/2013 10:40 AM, Sven Barth wrote: > > Am 26.03.2013 06:53, schrieb Anthony Walter: > > >> I wasn't asking you to stop your work, rather I was attempting to > >> share insights and my opinions with the group. My point in the > >> previous messa

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-26 Thread silvioprog
2013/3/26 Sven Barth > Am 26.03.2013 06:53, schrieb Anthony Walter: > > On Tue, Mar 26, 2013 at 1:20 AM, silvioprog wrote: > >> I don't know if you noticed, but I sent the ALL test cases required by >> the RFC 2202 (http://tools.ietf.org/html/rfc2202), i.e., it's enough to >> check whether th

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-26 Thread Marcos Douglas
On Tue, Mar 26, 2013 at 10:05 AM, Anthony Walter wrote: > On Tue, Mar 26, 2013 at 5:57 AM, Marcos Douglas wrote: >> >> Hi, >> Is possible to make that only using Windows for any lib? >> >> Best regards, >> Marcos Douglas > > > Marcos, > > Are you asking, "Is it possible to build any static lib fo

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-26 Thread Ludo Brands
On 03/26/2013 10:40 AM, Sven Barth wrote: > Am 26.03.2013 06:53, schrieb Anthony Walter: >> I wasn't asking you to stop your work, rather I was attempting to >> share insights and my opinions with the group. My point in the >> previous message was that many times it make sense to reuse something >

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-26 Thread Anthony Walter
On Tue, Mar 26, 2013 at 5:57 AM, Marcos Douglas wrote: > Hi, > Is possible to make that only using Windows for any lib? > > Best regards, > Marcos Douglas Marcos, Are you asking, "Is it possible to build any static lib for Windows and link it to a free pascal project"? No, not all the time. L

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-26 Thread Marcos Douglas
On Tue, Mar 26, 2013 at 12:43 AM, Anthony Walter wrote: > > On Mon, Mar 25, 2013 at 11:24 PM, silvioprog wrote: >> >> Nice. >> >> But there situations that the user does not have the OpenSSL lib. >> >> The routines I sent does not depend on external libs. >> >> -- >> Silvio Clécio >> My public pr

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-26 Thread Sven Barth
Am 26.03.2013 06:53, schrieb Anthony Walter: On Tue, Mar 26, 2013 at 1:20 AM, silvioprog > wrote: I don't know if you noticed, but I sent the ALL test cases required by the RFC 2202 (http://tools.ietf.org/html/rfc2202), i.e., it's enough to check whether

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread silvioprog
2013/3/26 Anthony Walter > On Tue, Mar 26, 2013 at 1:20 AM, silvioprog wrote: > >> I don't know if you noticed, but I sent the ALL test cases required by >> the RFC 2202 (http://tools.ietf.org/html/rfc2202), i.e., it's enough to >> check whether the algorithm it's well implemented or not. >> >>

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread Anthony Walter
On Tue, Mar 26, 2013 at 1:20 AM, silvioprog wrote: > I don't know if you noticed, but I sent the ALL test cases required by the > RFC 2202 (http://tools.ietf.org/html/rfc2202), i.e., it's enough to check > whether the algorithm it's well implemented or not. > > I'll await the answer of the staff

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread silvioprog
2013/3/26 Anthony Walter > On Tue, Mar 26, 2013 at 12:23 AM, silvioprog wrote: > >> Don't know why so much work if you can use it directly from the FCL. >> > > Because... > > OpenSSL is quite robust, well documented. tested, and proven > OpenSSL provides a full compilement of cryptography and ha

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread Anthony Walter
On Tue, Mar 26, 2013 at 12:23 AM, silvioprog wrote: > Don't know why so much work if you can use it directly from the FCL. > Because... OpenSSL is quite robust, well documented. tested, and proven OpenSSL provides a full compilement of cryptography and hashing functions On Linux/OSX you can lin

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread silvioprog
2013/3/26 Anthony Walter > On Mon, Mar 25, 2013 at 11:24 PM, silvioprog wrote: > >> Nice. >> >> But there situations that the user does not have the OpenSSL lib. >> >> The routines I sent does not depend on external libs. >> >> -- >> Silvio Clécio >> My public projects - github.com/silvioprog >>

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread Anthony Walter
On Mon, Mar 25, 2013 at 11:24 PM, silvioprog wrote: > Nice. > > But there situations that the user does not have the OpenSSL lib. > > The routines I sent does not depend on external libs. > > -- > Silvio Clécio > My public projects - github.com/silvioprog > It's possible to build static lib file

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread silvioprog
2013/3/26 Anthony Walter > I use OpenSSL for this stuff, which can be compiled directly into your > project. > > {$ifdef windows} > // optionally link library into the project > {$define static} > {$endif} > > {$ifdef static} > {$define libssl := external} > {$define libeay := external} > {$

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread Anthony Walter
I use OpenSSL for this stuff, which can be compiled directly into your project. {$ifdef windows} // optionally link library into the project {$define static} {$endif} {$ifdef static} {$define libssl := external} {$define libeay := external} {$else} {$ifdef unix} {$define libssl := externa

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread silvioprog
2013/3/24 Sven Barth > On 24.03.2013 16:59, silvioprog wrote: > >> My function is more fast that cHash >> (http://fundementals.**sourceforge.net/dl.html). >> The comparison result is: >> >> HMAC: 00:00:01:689 cHash: 00:00:02:038 >> >> My final unit is:

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread silvioprog
2013/3/25 Lukas Gebauer > > Using Synapse: > > uses > > synacode; > > begin > > Write(HMAC_SHA1('The quick brown fox jumped over the lazy dog.', > > 'secret'); end. Result: ]M?p { ? #?>O"?c I > > ...because you must convert binary string into hexadecimal string, if > you wish. Use: > > write(

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-25 Thread Lukas Gebauer
> Using Synapse: > uses > synacode; > begin > Write(HMAC_SHA1('The quick brown fox jumped over the lazy dog.', > 'secret'); end. Result: ]M?p { ? #?>O"?c I ...because you must convert binary string into hexadecimal string, if you wish. Use: write(StrToHex(HMAC_SHA1('The quick brown fox jumpe

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
Oops ... 2013/3/25 silvioprog [...] > (seven for MD5 and nine for SHA1), ... > ... seven for both. -- Silvio Clécio My public projects - github.com/silvioprog ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/ma

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
Please discart the *hmac-sha1only.zip*. I improved the routines for SHA1 ( http://pastebin.com/PKdL2xx7). I'll finish all codes (MD5/SHA1) tomorrow. Now I'm implementing the test cases (seven for MD5 and nine for SHA1), and this will take a little time. Wait ... -- Silvio Clécio My public proje

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread Sven Barth
On 24.03.2013 21:06, silvioprog wrote: 2013/3/24 Sven Barth mailto:pascaldra...@googlemail.com>> On 24.03.2013 19:35, silvioprog wrote: 2013/3/24 Sven Barth mailto:pascaldra...@googlemail.com>

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
2013/3/24 Sven Barth > On 24.03.2013 19:35, silvioprog wrote: > >> 2013/3/24 Sven Barth > > >> >> >> On 24.03.2013 16:59, silvioprog wrote: >> >> My function is more fast that cHash >> >> (http://fundementals.__sourcef**orge.net/dl.html<

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread Sven Barth
On 24.03.2013 19:35, silvioprog wrote: 2013/3/24 Sven Barth mailto:pascaldra...@googlemail.com>> On 24.03.2013 16:59, silvioprog wrote: My function is more fast that cHash (http://fundementals.__sourceforge.net/dl.html ).

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
2013/3/24 Sven Barth > On 24.03.2013 16:59, silvioprog wrote: > >> My function is more fast that cHash >> (http://fundementals.**sourceforge.net/dl.html). >> The comparison result is: >> >> HMAC: 00:00:01:689 cHash: 00:00:02:038 >> >> My final unit is:

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread Sven Barth
On 24.03.2013 17:48, Sven Barth wrote: On 24.03.2013 16:59, silvioprog wrote: My function is more fast that cHash (http://fundementals.sourceforge.net/dl.html). The comparison result is: HMAC: 00:00:01:689 cHash: 00:00:02:038 My final unit is: http://pastebin.com/4484g9i8 Could you maybe ru

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread Sven Barth
On 24.03.2013 16:59, silvioprog wrote: My function is more fast that cHash (http://fundementals.sourceforge.net/dl.html). The comparison result is: HMAC: 00:00:01:689 cHash: 00:00:02:038 My final unit is: http://pastebin.com/4484g9i8 Could you maybe run your unit through some test vectors if

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
I changed it to: http://pastebin.com/mxeWtncP And now: cHash: 00:00:02:188 HMAC: 00:00:00:966 2013/3/24 silvioprog > My function is more fast that cHash ( > http://fundementals.sourceforge.net/dl.html). The comparison result is: > > HMAC: 00:00:01:689 cHash: 00:00:02:038 > > My final unit is

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
My function is more fast that cHash ( http://fundementals.sourceforge.net/dl.html). The comparison result is: HMAC: 00:00:01:689 cHash: 00:00:02:038 My final unit is: http://pastebin.com/4484g9i8 The code used in comparison: uses HMAC, cHash; procedure TForm1.Button1Click(Sender: TObject);

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
A small improvement: uses SHA1; function SHA1Raw(const ABuffer; const ABufferLength: PtrUInt): string; var I: Byte; VBytes : TBytes; VDigest: TSHA1Digest; VContext: TSHA1Context; begin Result := ''; SHA1Init(VContext); SHA1Update(VContext, ABuffer, ABufferLength); SHA1Final(VCon

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread silvioprog
2013/3/24 David Butler > congrats on re-inventing the wheel. all those string > allocations/de-allocations could make it slow. > OK, thank you, and what do you suggest to improve this code? Depend on a huge library of third parties and not simply use native code in FCL? -- Silvio Clécio My pub

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-24 Thread David Butler
congrats on re-inventing the wheel. all those string allocations/de-allocations could make it slow. On Sun, Mar 24, 2013 at 6:12 AM, silvioprog wrote: > Eureka! > > After spending all day working on it, I finally did it! The pseudo steps > are here: > http://en.wikipedia.org/wiki/Hash-based_mess

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Oops... 2013/3/24 silvioprog > [...] > Result: 0b7252985d63555b31db4755f37efe218c509711 (same result in PHP, JS > and Phyton! ;) ) > ... Result *in my PC*: 0b7252985d63555b31db4755f37efe218c509711 -- Silvio Clécio My public projects - github.com/silvioprog

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Eureka! After spending all day working on it, I finally did it! The pseudo steps are here: http://en.wikipedia.org/wiki/Hash-based_message_authentication_code And, this is the final code (please improves it please): uses SHA1; function SHA1Raw(const ABuffer; const ABufferLength: PtrUInt): str

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tomas Hajny
On Sat, March 23, 2013 16:21, silvioprog wrote: > 2013/3/23 Tomas Hajny >> On Sat, March 23, 2013 06:28, silvioprog wrote: >> >> Hi, >> >> > How to get HMAC_SHA1 using native functions of FPC? >> > >> > HMAC_SHA1: >> > >> http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 David Butler > What do you mean by "native"? > > It is pure pascal code that compiles under Delphi and FreePascal. > > Using it is as easy as: > > SHA1DigestToHexA(CalcHMAC_SHA1('secret', 'message') > To not implement a big code like this: unit Unit1; {$mode objfpc}{$H+} interface

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread David Butler
What do you mean by "native"? It is pure pascal code that compiles under Delphi and FreePascal. Using it is as easy as: SHA1DigestToHexA(CalcHMAC_SHA1('secret', 'message') On Sat, Mar 23, 2013 at 5:18 PM, silvioprog wrote: > 2013/3/23 David Butler > >> Hi >> >> You can find a hash library th

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Other PHP function: $block_size) { $k = pack("H*", sha1($key)); } else { $k = str_pad($key, $block_Size, "\x00", STR_PAD_RIGHT); } $ki = ''; for($i = 0; $i < $block_size; $i++) { $ki .= chr(ord(substr($k, $i, 1)) ^ 0x36); } $ko = ''; for($i = 0; $i < $block_size; $i++) { $ko .= chr(ord(substr

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Hello, I could be wrong, but I think that Synapse function have a bug. See: Using PHP: Result: b8e7ae12510bdfb1812e463a7f086122cf37e4f7 Using the http://www.freeformatter.com site Result: 5d4db2701c7b07de0e23db3e4f22e88bc1a31a49 Using Synapse: uses synacode; begin Write(HMAC_SHA1('The quic

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 Tony Whyman > Silvio, > > Just one extra point - the snippet I sent is example code. It is not > intended to be RFC compliant. > > Regards > > Tony Whyman > MWA > Thank you friend for the answer! So, seems the Synapse library has the function I'm looking for. I'll compare it with PHP

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tony Whyman
Silvio, Just one extra point - the snippet I sent is example code. It is not intended to be RFC compliant. Regards Tony Whyman MWA On 23/03/13 15:24, silvioprog wrote: > 2013/3/23 Tony Whyman > > > Silvio, > > I had the same requirement for an HMA

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 Tony Whyman > Silvio, > > I had the same requirement for an HMAC and used the DCP library: > > http://wiki.freepascal.org/DCPcrypt > > I then used the following code snippet to generate the HMAC > > Regards > > Tony Whyman > MWA > > unit hmac; > > {$mode objfpc}{$H+} > > interface > >

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 Tomas Hajny > On Sat, March 23, 2013 06:28, silvioprog wrote: > > Hi, > > > How to get HMAC_SHA1 using native functions of FPC? > > > > HMAC_SHA1: > > > http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples_of_HMAC_.28MD5.2C_SHA1.2C_SHA256.29 > > Doesn't package h

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 David Butler > Hi > > You can find a hash library that supports HMAC-SHA1 here: > > http://fundementals.sourceforge.net/dl.html > But it's not native in Free Pascal. x( -- Silvio Clécio My public projects - github.com/silvioprog ___ fpc-pasc

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tony Whyman
Silvio, I had the same requirement for an HMAC and used the DCP library: http://wiki.freepascal.org/DCPcrypt I then used the following code snippet to generate the HMAC Regards Tony Whyman MWA unit hmac; {$mode objfpc}{$H+} interface uses Classes, SysUtils; procedure MakeHMAC(text: stri

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tomas Hajny
On Sat, March 23, 2013 06:28, silvioprog wrote: Hi, > How to get HMAC_SHA1 using native functions of FPC? > > HMAC_SHA1: > http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples_of_HMAC_.28MD5.2C_SHA1.2C_SHA256.29 Doesn't package hash (included with FPC by default for all

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread David Butler
Hi You can find a hash library that supports HMAC-SHA1 here: http://fundementals.sourceforge.net/dl.html On Sat, Mar 23, 2013 at 7:28 AM, silvioprog wrote: > Hello, > > How to get HMAC_SHA1 using native functions of FPC? > > HMAC_SHA1: > http://en.wikipedia.org/wiki/Hash-based_message_authent

[fpc-pascal] HMAC_SHA1 and FPC

2013-03-22 Thread silvioprog
Hello, How to get HMAC_SHA1 using native functions of FPC? HMAC_SHA1: http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples_of_HMAC_.28MD5.2C_SHA1.2C_SHA256.29 Thank you! -- Silvio Clécio My public projects - github.com/silvioprog