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

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

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

    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 Guest

  2. Similar Questions and Discussions

    1. authorize.net fingerprint generation with HMAC
      Hello, I am trying to integrate my website with authorize.net's payment gateway (my first time integrating with a gateway), and to do this I need...
    2. sha1 problem
      I'm I'm trying to compare 2 hash values using sha1 one written in vb.net and the other in Python. The value I get in my vb.net code does not...
    3. Javascript::SHA1 V 1.01
      The pure Perl module Javascript::SHA1 V 1.01 is available immediately from CPAN, and from http://savage.net.au/Perl-modules.html. On-line docs,...
    4. HMAC-MD5
      Hello all Is HMAC-MD5 supported on the .NET 1.1 framework? Some of the information that I have come across seems like it indicates that it is not...
    5. ~/Library/ vs ~/System/Library vs /User/Library/
      In article <110720031327074895%justin.c@se.net>, justin <justin.c@se.net> wrote: First off, you're a little bit confused. ~ means your home...
  3. #2

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

    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 [email]glav@aspalliance.com[/email]-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:egJaaY0NEHA.644@tk2msftngp13.phx.gbl...
    > 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] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139