.Net equivalent of OpenSSL's libeay32-library (HMAC based on SHA1)?

Discussion in 'ASP .Net Security' started by Kenneth Priisholm, May 11, 2004.

  1. Hi all.

    I need to implement a Hashed Message Authentication Code based on the SHA1
    algorithm, that is equivalent to OpenSSL's "libeay32"-library. I already
    tried implementing the off-the-shelf System.Security.Cryptography.HMACSHA1
    as showed below;

    class HmacSHA1Generator:
    {
    private System.Security.Cryptography.HMACSHA1 _hs;
    private System.Text.Encoding _e;

    public HmacSHA1Generator(System.Text.Encoding encoding)
    {
    _e = encoding;
    _hs = new HMACSHA1();
    }

    public byte[] Generate(string key, string data)
    {
    byte[] bKey = _e.GetBytes(key);
    byte[] bData = _e.GetBytes(data);
    _hs.Key = bKey;

    return _hs.ComputeHash(bData);
    }
    }

    This, however, does not give the same results as libeay32's output, and
    trying to use this library, both referencing direct from VS and installing
    it wth RegSvr32 fails, so this doesn't seem to be a viable road. So I'm
    kinda stuck here, wondering if anybody else has had the joy of trying to
    support the HMAC-functionality of libeay32?

    Best regards,
    //Ken
    Kenneth Priisholm, May 11, 2004
    #1
    1. Advertising

  2. I have not had to support the functionality you mention, however I have
    written a very basic .Net wrapper for openSSL. It involves a Win32 wrapper
    which abstracts some of the openSSL base calls into a more aggregated form,
    and then imported that into a .Net wrapper.

    Some of the structures are huge in openSSL and I did not want to try and
    convert/marshall all of them. Like I said, its a pretty basic
    implementation, but would be easily modified to do what you want. If you are
    interested, send me an email at -NOSPAM (obviously dont
    include the -NOSPAM part of my email address.) and I'll send it your way.

    There are third party components such as IP*Works SSL component but I have
    not personally used this to do what you mention.

    --
    - Paul Glavich
    Microsoft MVP - ASP.NET


    "Kenneth Priisholm" <kpr-at-2bm-dot-dk> wrote in message
    news:...
    > Hi all.
    >
    > I need to implement a Hashed Message Authentication Code based on the SHA1
    > algorithm, that is equivalent to OpenSSL's "libeay32"-library. I already
    > tried implementing the off-the-shelf System.Security.Cryptography.HMACSHA1
    > as showed below;
    >
    > class HmacSHA1Generator:
    > {
    > private System.Security.Cryptography.HMACSHA1 _hs;
    > private System.Text.Encoding _e;
    >
    > public HmacSHA1Generator(System.Text.Encoding encoding)
    > {
    > _e = encoding;
    > _hs = new HMACSHA1();
    > }
    >
    > public byte[] Generate(string key, string data)
    > {
    > byte[] bKey = _e.GetBytes(key);
    > byte[] bData = _e.GetBytes(data);
    > _hs.Key = bKey;
    >
    > return _hs.ComputeHash(bData);
    > }
    > }
    >
    > This, however, does not give the same results as libeay32's output, and
    > trying to use this library, both referencing direct from VS and installing
    > it wth RegSvr32 fails, so this doesn't seem to be a viable road. So I'm
    > kinda stuck here, wondering if anybody else has had the joy of trying to
    > support the HMAC-functionality of libeay32?
    >
    > Best regards,
    > //Ken
    >
    >
    Paul Glavich [MVP - ASP.NET], May 11, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ed

    portable sha1 hmac sources

    ed, Apr 6, 2006, in forum: C Programming
    Replies:
    2
    Views:
    351
    William Ahern
    Apr 8, 2006
  2. Replies:
    4
    Views:
    5,822
    Thomas J. Gritzan
    Sep 22, 2006
  3. LMZ
    Replies:
    5
    Views:
    522
    Martin v. Löwis
    Apr 6, 2008
  4. Adam Tauno Williams
    Replies:
    2
    Views:
    857
    Stefan Behnel
    Dec 30, 2010
  5. Ram  Prasad

    base64 encoded sha1() string in openssl

    Ram Prasad, Dec 22, 2011, in forum: C Programming
    Replies:
    2
    Views:
    673
    tom st denis
    Dec 22, 2011
Loading...

Share This Page