HMAC_SHA1 and FPC

classic Classic list List threaded Threaded
57 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

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 <[hidden email]>
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:


The code used in comparison:

uses
  HMAC, cHash;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  b, e: TDateTime;
  x: string;
begin
  b := now;
  for i := 0 to 300000 do
    x := HMACSHA1('secret', 'The quick brown fox jumped over the lazy dog.');
  e := now;
  Edit1.Text := 'HMAC: ' + FormatDateTime('hh:nn:ss:zzz', b - e);
  b := now;
  for i := 0 to 300000 do
    x := SHA1DigestToHex(CalcHMAC_SHA1('secret', 'The quick brown fox jumped over the lazy dog.'));
  e := now;
  Edit1.Text := Edit1.Text + ' cHash: ' + FormatDateTime('hh:nn:ss:zzz', b - e);
end;

I reinvented the wheel, but I can run faster now. :)

Thanks guys!

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Sven Barth-2
In reply to this post by silvioprog
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 you haven't
done already? E.g. these: http://tools.ietf.org/html/rfc4231

If that works satisfactory you could create a bug report and we could
include it in the hash package.

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Sven Barth-2
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 run your unit through some test vectors if you haven't
> done already? E.g. these: http://tools.ietf.org/html/rfc4231

Oops. Wrong link. I meant this one: http://tools.ietf.org/html/rfc2202 
(contains also test vectors for HMAC-MD5).

> If that works satisfactory you could create a bug report and we could
> include it in the hash package.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
In reply to this post by Sven Barth-2
2013/3/24 Sven Barth <[hidden email]>
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 you haven't done already? E.g. these: http://tools.ietf.org/html/rfc4231

If that works satisfactory you could create a bug report and we could include it in the hash package.

Regards,
Sven

Yes. I'll try to implement it now! :)

For SHA1 this is the final implementation: http://pastebin.com/t4e3tvXa

Now I'll implement it for MD5 conforming http://tools.ietf.org/html/rfc2202, create some samples showing HMACMD5 and HMACSHA1 and finally create a bug report.

Thank you very much Sven! :)

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Sven Barth-2
On 24.03.2013 19:35, silvioprog wrote:

> 2013/3/24 Sven Barth <[hidden email]
> <mailto:[hidden email]>>
>
>     On 24.03.2013 16:59, silvioprog wrote:
>
>         My function is more fast that cHash
>         (http://fundementals.__sourceforge.net/dl.html
>         <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 you
>     haven't done already? E.g. these:
>     http://tools.ietf.org/html/__rfc4231
>     <http://tools.ietf.org/html/rfc4231>
>
>     If that works satisfactory you could create a bug report and we
>     could include it in the hash package.
>
>     Regards,
>     Sven
>
>
> Yes. I'll try to implement it now! :)
>
> For SHA1 this is the final implementation: http://pastebin.com/t4e3tvXa
>
> Now I'll implement it for MD5 conforming
> http://tools.ietf.org/html/rfc2202, create some samples showing HMACMD5
> and HMACSHA1 and finally create a bug report.
>
> Thank you very much Sven! :)

Some comments:
- Maybe you should have HMACSHA1 return a TSHA1Digest; if the user wants
a String she can use SHA1Print herself (and HMACMD5 should consequently
return a TMD5Digest) [Note: this will work, because the digest always
has a fixed length for MD5 and SHA1 and this is also true for HMAC as
you can see in the test vectors in RFC2202)
- I'm not that happy with SHA1Raw and the constants being exported in
the interface...

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
2013/3/24 Sven Barth <[hidden email]>
On 24.03.2013 19:35, silvioprog wrote:
2013/3/24 Sven Barth <[hidden email]
<mailto:[hidden email]>>


    On 24.03.2013 16:59, silvioprog wrote:

        My function is more fast that cHash
        (http://fundementals.__sourceforge.net/dl.html
        <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 you
    haven't done already? E.g. these:
    http://tools.ietf.org/html/__rfc4231

    <http://tools.ietf.org/html/rfc4231>

    If that works satisfactory you could create a bug report and we
    could include it in the hash package.

    Regards,
    Sven


Yes. I'll try to implement it now! :)

For SHA1 this is the final implementation: http://pastebin.com/t4e3tvXa

Now I'll implement it for MD5 conforming
http://tools.ietf.org/html/rfc2202, create some samples showing HMACMD5
and HMACSHA1 and finally create a bug report.

Thank you very much Sven! :)

Some comments:
- Maybe you should have HMACSHA1 return a TSHA1Digest; if the user wants a String she can use SHA1Print herself (and HMACMD5 should consequently return a TMD5Digest) [Note: this will work, because the digest always has a fixed length for MD5 and SHA1 and this is also true for HMAC as you can see in the test vectors in RFC2202)

Hm... You are right. Those looking for more speed might prefer TSHA1Digest. I'll use TSHA1Digest instead string.

So, I'm tested the test cases and all worked fine, ex (test 2):

=====
test_case =     2
key =           "Jefe"
key_len =       4
data =          "what do ya want for nothing?"
data_len =      28
digest =        0xeffcdf6ae5eb2fa2d27416d5f184df9c259a7c79
=====

  with TFileStream.Create('test.txt', fmCreate) do
  try
    X := HMACSHA1('Jefe', 'what do ya want for nothing?');
    Write(Pointer(X)^, Length(X));
  finally
    Free;
  end;

Content in test.txt: effcdf6ae5eb2fa2d27416d5f184df9c259a7c79. Perfect! :-*

- I'm not that happy with SHA1Raw and the constants being exported in the interface...

:/ I also think not. I'll remove it from the interface.

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Sven Barth-2
On 24.03.2013 21:06, silvioprog wrote:

> 2013/3/24 Sven Barth <[hidden email]
> <mailto:[hidden email]>>
>
>     On 24.03.2013 19:35, silvioprog wrote:
>
>         2013/3/24 Sven Barth <[hidden email]
>         <mailto:[hidden email]>
>         <mailto:[hidden email]
>         <mailto:[hidden email]>>>
>
>
>              On 24.03.2013 16:59, silvioprog wrote:
>
>                  My function is more fast that cHash
>                  (http://fundementals.__sourcef__orge.net/dl.html
>         <http://sourceforge.net/dl.html>
>                  <http://fundementals.__sourceforge.net/dl.html
>         <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 you
>              haven't done already? E.g. these:
>         http://tools.ietf.org/html/____rfc4231
>         <http://tools.ietf.org/html/__rfc4231>
>
>              <http://tools.ietf.org/html/__rfc4231
>         <http://tools.ietf.org/html/rfc4231>>
>
>              If that works satisfactory you could create a bug report and we
>              could include it in the hash package.
>
>              Regards,
>              Sven
>
>
>         Yes. I'll try to implement it now! :)
>
>         For SHA1 this is the final implementation:
>         http://pastebin.com/t4e3tvXa
>
>         Now I'll implement it for MD5 conforming
>         http://tools.ietf.org/html/__rfc2202
>         <http://tools.ietf.org/html/rfc2202>, create some samples
>         showing HMACMD5
>         and HMACSHA1 and finally create a bug report.
>
>         Thank you very much Sven! :)
>
>
>     Some comments:
>     - Maybe you should have HMACSHA1 return a TSHA1Digest; if the user
>     wants a String she can use SHA1Print herself (and HMACMD5 should
>     consequently return a TMD5Digest) [Note: this will work, because the
>     digest always has a fixed length for MD5 and SHA1 and this is also
>     true for HMAC as you can see in the test vectors in RFC2202)
>
>
> Hm... You are right. Those looking for more speed might
> prefer TSHA1Digest. I'll use TSHA1Digest instead string.

Thank you.

>     - I'm not that happy with SHA1Raw and the constants being exported
>     in the interface...
>
>
> :/ I also think not. I'll remove it from the interface.

Thank you as well :)

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
Done for SHA1! :)

Attachment the ZIP file with src, example and test case.

Now, I'll implement support for MD5!

Thank guys!

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

hmac-sha1only.zip (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

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 projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
Oops ...

2013/3/25 silvioprog <[hidden email]>
[...]
(seven for MD5 and nine for SHA1), ...

... seven for both.

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Lukas Gebauer
In reply to this post by silvioprog
> 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 jumped over the lazy
dog.', 'secret')));




--
Lukas Gebauer.

http://synapse.ararat.cz/ - Ararat Synapse - TCP/IP Lib.
http://geoget.ararat.cz/ - Geocaching solution

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
2013/3/25 Lukas Gebauer <[hidden email]>
> 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 jumped over the lazy
dog.', 'secret')));

--
Lukas Gebauer.

http://synapse.ararat.cz/ - Ararat Synapse - TCP/IP Lib.
http://geoget.ararat.cz/ - Geocaching solution

Hello Lukas, thank you very much for the information friend. :)

I've a friend who uses Synapse with Delphi and I'll indicate this routine! ;)

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
In reply to this post by Sven Barth-2
2013/3/24 Sven Barth <[hidden email]>
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 you haven't done already? E.g. these: http://tools.ietf.org/html/rfc4231

If that works satisfactory you could create a bug report and we could include it in the hash package.

Regards,
Sven

Done.


The patch includes source, examples and test cases (7 for MD5 and 7 for SHA1).

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Anthony Walter-3
In reply to this post by silvioprog
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 := external 'libssl.so'}
  {$define libeay := external 'libssl.so'}
  {$else}
 {$define libssl := external 'libssl32.dll'}
    {$define libeay := external 'libeay32.dll'}
  {$endif}
{$endif}

function SSL_library_init: Integer; cdecl; libssl;
procedure SSL_load_error_strings; cdecl; libssl;
function SSLv23_client_method: TSSLMethod; cdecl; libssl;
function SSL_CTX_new(method: TSSLMethod): TSSLCtx; cdecl; libssl;
procedure SSL_CTX_free(context: TSSLCtx); cdecl; libssl;
function SSL_new(context: TSSLCtx): TSSL; cdecl; libssl;
function SSL_shutdown(ssl: TSSL): LongInt; cdecl; libssl;
procedure SSL_free(ssl: TSSL); cdecl; libssl;
function SSL_set_fd(ssl: TSSL; socket: LongInt): LongBool; cdecl; libssl;
function SSL_connect(ssl: TSSL): LongBool; cdecl; libssl;
function SSL_write(ssl: TSSL; buffer: Pointer; size: LongWord): LongInt; cdecl; libssl;
function SSL_read(ssl: TSSL; buffer: Pointer; size: LongWord): LongInt; cdecl; libssl;
function SSL_get_error(ssl: TSSL; ret_code: Integer): Integer; cdecl; libssl;

{ Hashing routines }

function MD5_Init(out context: TMD5Ctx): LongBool; cdecl; libeay;
function MD5_Update(var context: TMD5Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function MD5_Final(out digest: TMD5Digest; var context: TMD5Ctx): LongBool; cdecl; libeay;
function SHA1_Init(out context: TSHA1Ctx): LongBool; cdecl; libeay;
function SHA1_Update(var context: TSHA1Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function SHA1_Final(out digest: TSHA1Digest; var context: TSHA1Ctx): LongBool; cdecl; libeay;
function SHA256_Init(out context: TSHA256Ctx): LongBool; cdecl; libeay;
function SHA256_Update(var context: TSHA256Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function SHA256_Final(out digest: TSHA256Digest; var context: TSHA256Ctx): LongBool; cdecl; libeay;
function SHA512_Init(out context: TSHA512Ctx): LongBool; cdecl; libeay;
function SHA512_Update(var context: TSHA512Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function SHA512_Final(out digest: TSHA512Digest; var context: TSHA512Ctx): LongBool; cdecl; libeay;
function EVP_md5: TEVPMethod; cdecl; libeay;
function EVP_sha1: TEVPMethod; cdecl; libeay;
function EVP_sha256: TEVPMethod; cdecl; libeay;
function EVP_sha512: TEVPMethod; cdecl; libeay;
procedure HMAC_CTX_init(out context: THMACCtx); cdecl; libeay;
procedure HMAC_CTX_cleanup(var context: THMACCtx); cdecl; libeay;
function HMAC_Init_ex(var context: THMACCtx; key: Pointer; size: Cardinal; method: TEVPMethod; engine: Pointer): LongBool; cdecl; libeay;
function HMAC_Update(var context: THMACCtx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function HMAC_Final(var context: THMACCtx; digest: Pointer; var digestSize: LongWord): LongBool; cdecl; libeay;

implementation

{$ifdef static}
{$linklib libssl.a}
{$linklib libcrypto.a}
{$endif}
            

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
2013/3/26 Anthony Walter <[hidden email]>
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 := external 'libssl.so'}
  {$define libeay := external 'libssl.so'}
  {$else}
 {$define libssl := external 'libssl32.dll'}
    {$define libeay := external 'libeay32.dll'}
  {$endif}
{$endif}

function SSL_library_init: Integer; cdecl; libssl;
procedure SSL_load_error_strings; cdecl; libssl;
function SSLv23_client_method: TSSLMethod; cdecl; libssl;
function SSL_CTX_new(method: TSSLMethod): TSSLCtx; cdecl; libssl;
procedure SSL_CTX_free(context: TSSLCtx); cdecl; libssl;
function SSL_new(context: TSSLCtx): TSSL; cdecl; libssl;
function SSL_shutdown(ssl: TSSL): LongInt; cdecl; libssl;
procedure SSL_free(ssl: TSSL); cdecl; libssl;
function SSL_set_fd(ssl: TSSL; socket: LongInt): LongBool; cdecl; libssl;
function SSL_connect(ssl: TSSL): LongBool; cdecl; libssl;
function SSL_write(ssl: TSSL; buffer: Pointer; size: LongWord): LongInt; cdecl; libssl;
function SSL_read(ssl: TSSL; buffer: Pointer; size: LongWord): LongInt; cdecl; libssl;
function SSL_get_error(ssl: TSSL; ret_code: Integer): Integer; cdecl; libssl;

{ Hashing routines }

function MD5_Init(out context: TMD5Ctx): LongBool; cdecl; libeay;
function MD5_Update(var context: TMD5Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function MD5_Final(out digest: TMD5Digest; var context: TMD5Ctx): LongBool; cdecl; libeay;
function SHA1_Init(out context: TSHA1Ctx): LongBool; cdecl; libeay;
function SHA1_Update(var context: TSHA1Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function SHA1_Final(out digest: TSHA1Digest; var context: TSHA1Ctx): LongBool; cdecl; libeay;
function SHA256_Init(out context: TSHA256Ctx): LongBool; cdecl; libeay;
function SHA256_Update(var context: TSHA256Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function SHA256_Final(out digest: TSHA256Digest; var context: TSHA256Ctx): LongBool; cdecl; libeay;
function SHA512_Init(out context: TSHA512Ctx): LongBool; cdecl; libeay;
function SHA512_Update(var context: TSHA512Ctx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function SHA512_Final(out digest: TSHA512Digest; var context: TSHA512Ctx): LongBool; cdecl; libeay;
function EVP_md5: TEVPMethod; cdecl; libeay;
function EVP_sha1: TEVPMethod; cdecl; libeay;
function EVP_sha256: TEVPMethod; cdecl; libeay;
function EVP_sha512: TEVPMethod; cdecl; libeay;
procedure HMAC_CTX_init(out context: THMACCtx); cdecl; libeay;
procedure HMAC_CTX_cleanup(var context: THMACCtx); cdecl; libeay;
function HMAC_Init_ex(var context: THMACCtx; key: Pointer; size: Cardinal; method: TEVPMethod; engine: Pointer): LongBool; cdecl; libeay;
function HMAC_Update(var context: THMACCtx; data: Pointer; size: Cardinal): LongBool; cdecl; libeay;
function HMAC_Final(var context: THMACCtx; digest: Pointer; var digestSize: LongWord): LongBool; cdecl; libeay;

implementation

{$ifdef static}
{$linklib libssl.a}
{$linklib libcrypto.a}
{$endif}

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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Anthony Walter-3
On Mon, Mar 25, 2013 at 11:24 PM, silvioprog <[hidden email]> 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 files for Win 32 and 64 on Linux. 

...  download the sources from here http://www.openssl.org/source/ then ... 

sudo apt-get install mingw-w64

... goto the OpenSSL source directory and ...

CROSS_COMPILE="i686-w64-mingw32-" ./Configure mingw64 no-asm shared
make
CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure mingw64 no-asm shared
make

... and copy libcrypto.a and libssl.a to a FPC lib path ...

Now you can compile for Win 32/64 using OpenSSL static lib files.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
2013/3/26 Anthony Walter <[hidden email]>
On Mon, Mar 25, 2013 at 11:24 PM, silvioprog <[hidden email]> 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 files for Win 32 and 64 on Linux. 

...  download the sources from here http://www.openssl.org/source/ then ... 

sudo apt-get install mingw-w64

... goto the OpenSSL source directory and ...

CROSS_COMPILE="i686-w64-mingw32-" ./Configure mingw64 no-asm shared
make
CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure mingw64 no-asm shared
make

... and copy libcrypto.a and libssl.a to a FPC lib path ...

Now you can compile for Win 32/64 using OpenSSL static lib files.

o.o'

Don't know why so much work if you can use it directly from the FCL.

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Anthony Walter-3
On Tue, Mar 26, 2013 at 12:23 AM, silvioprog <[hidden email]> 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 link to external shared object files, which further reduces project build size and system resources

Side benefit: OpenSSL also provides a simple secure socket implementation, which many times pairs nicely along with SHA/HMAC

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

silvioprog
2013/3/26 Anthony Walter <[hidden email]>
On Tue, Mar 26, 2013 at 12:23 AM, silvioprog <[hidden email]> 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 link to external shared object files, which further reduces project build size and system resources

Side benefit: OpenSSL also provides a simple secure socket implementation, which many times pairs nicely along with SHA/HMAC

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 of Core, because for me the final answer is theirs.

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: HMAC_SHA1 and FPC

Anthony Walter-3
On Tue, Mar 26, 2013 at 1:20 AM, silvioprog <[hidden email]> 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 of Core, because for me the final answer is theirs.

--
Silvio Clécio
My public projects - github.com/silvioprog

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

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 which works, and possibly part of the operating system, rather than recreating that which already exists.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
123