K
Kenneth Priisholm
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
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