Need HMAC-SHA1 implementation for C # Micro Framework

As in the title, I am looking for an implementation of HMAC-SHA1 for C #. This will work under the micro-framework, so I cannot use the built-in System.Security.Cryptography classes.

I have no problem migrating the library if I can understand the source code. I found the source for one in Javascript and confirmed that it matches the expected values, but I have problems with wrapping because I cannot always tell which types are values.

So, does anyone know of any C # (or Java (or other strongly typed) implementations there?

+4
source share
3 answers

The Bouncycastle C # Crypto Library contains the freely licensed C # source code. It should be trivial to retrieve the Org.BouncyCastle.Crypto.Digests.Sha1Digest and Org.BouncyCastle.Crypto.Macs.HMac and include them in your code. It doesn't seem to be dependent on these .NET classes, but I don't know which classes are included in the microarchitecture.

+4
source

You can have a C # version with the same API as Microsoft, using the code provided by the Mono project. The MIT X11 license is licensed, so it is easy to use in any project. Cm.:

https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Security.Cryptography/HMACSHA1.cs

https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Security.Cryptography/HMAC.cs

and related files. There are also unit tests that you can use to ensure proper operation on your platform.

+1
source

sphlib is an open source library that includes optimized code for many hash functions, including SHA-1, in both C and Java. The Java version also includes a common implementation of HMAC (you can use any of the hash functions implemented). Since the code is basic Java with only elementary whole operations (it should also work on J2ME platforms), translating it into C # should be easy (you just need to replace Java with ' >>> ' the unsigned right shift operator to cast to the corresponding unsigned type C # and then do the usual right shift).

0
source

All Articles