hmac

Why would HMAC SHA-1 return a different digest with the same input?

I am trying to build a working encrypted signature for the Amazon S3 web service, writing a connection library using Objective C. I have run into HMAC SHA-1 digest problems with the ObjC code, so I'm putting that to the side and looking at existing, working Perl code, to try to troubleshoot digest creation. I am testing HMAC SHA-1 dig...

HMACSHA1.ComputeHash() thread-safety question

hello, i am asking myself if it would be dangerous on a asp.net page´s codebehind to use an static (Shared) variable which holds an HMACSHA1-instance. the problem is that the same HMACSHA1-instance would be used by all the asp.net worker-process´ threads when processing multiple simultaneous requests on the same asp.net-page. all (HMAC...

Why do I get wrong results for hmac in Python but not Perl?

I'm trying to compute hmac using sha-512. The Perl code: use Digest::SHA qw(hmac_sha512_hex); $key = "\x0b"x20; $data = "Hi There"; $hash = hmac_sha512_hex($data, $key); print "$hash\n"; and gives the correct hash of 87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cde daa833b7d6b8a702038b274eaea3f4e4be9d914eeb6...

How to set the crypto key for Python's MD5 module?

What is the Python equivalent of following Perl code? hmac_md5_hex($login . "^" . $seq . "^" . $time . "^" . $amo . "^", $CryptoKey); The Python hashlib.md5 doesn't seem to take an "cryptographic key" argument. It only accepts 1 argument. ...

iPhone and HMAC-SHA-1 encoding

im trying to get a call to amazon web service and im stuck on getting the signature, looked at this but i still have a question on it. using this example what is the NSData *keyData; NSData *clearTextData ? what do i need to pass for these two values? /* inputs: NSData *keyData; NSData *clearTextData */ uint8_t digest[CC_S...

Objective-C sample code for HMAC-SHA1

I need to generate HMAC-SHA1 in Objective C. But i didnt find anything that works. I tried with CommonCrypto, using CCHMAC, but didnt works. I need to generate a hmac and after generate HOTP number. Somebody have any example code in Objective C or C? ...

The correct way to encrypt a string using HmacSHA256 in VB.NET

Hello, I need to create a keyed hash for a string of XML to send to a 3rd party. This is the code I am using but it is producing a different hash then the example the 3rd party has sent me. I have been through all the tutorials I can find and re-read MSDN again and again, what am I doing wrong? Or should I suspect a problem at the other...

Calculate HMAC-SHA256 digest in Coldfusion using Java

We are trying to calculate a HMAC-SHA256 digest in Coldfusion and we are using the HMAC CFC, but in one case it is producing a different result for the digest compared to ones generated in different languages - have tried the same data using Ruby & PHP and get the expected result. I have also tried the CF_HMAC custom tag it is based on a...

migrate from C#.net 2.0 to php so the hash value of the password - how to resolve?

Hi we previously use a C#.net 2.0 to create a web app. Users password were hashed and stored in database using the following code. private const string encryptionKey = "AE09F72B007CAAB5"; HMACSHA1 hash = new HMACSHA1(); hash.Key = HexToByte(encryptionKey); encodedPassword = Convert.ToBase64String( hash.ComputeHash(Encoding.Unicod...

Scala HMAC-SHA1 signing?

I was wondering if there would be a way to get a HMAC-SHA1 signature in scala without having to compile a java class with the code everyone use in java. Any ideas? ...

is HMACSHA1 defined for messages of zero length?

I have an edge case. I'm building code that reads binary datafiles produced by a commercial, closed source tool. The information on the data format is specified in a document. For data integrity checks, the vendor's spec calls for an HMAC based on SHA1, using a key derived from a password as per RFC2898. Many programming environments h...

HMAC-SHA-512 implemention for ActionScript

Hello everyone, As mentioned by the title, I would like to find an implementation for HMAC-SHA-512 written for ActionScript. I was able to find a library that provide HMAC-SHA-256 with other functions, however, I am looking for HMAC-SHA-512 specifically. Thank you Edit: Or, since actionscript and javascript have the same origin, can ...

Ruby and PHP HMACs not agreeing

I'm trying to create an HMAC in Ruby and then verify it in PHP. Ruby: require 'openssl' message = "A522EBF2-5083-484D-99D9-AA97CE49FC6C,1234567890,/api/comic/aWh62,GET" key = "3D2143BD-6F86-449F-992C-65ADC97B968B" hash = OpenSSL::HMAC.hexdigest('sha256', message, key) p hash PHP: <?php $message = "A522EBF2-5083-484D-99D9-AA...

How to create MD5 hash with HMAC module in Ruby?

Hi all, Using Google + Bing didn't yield an answer to what should be a simple question: How are you supposed to use the HMAC module in Ruby to create a HMAC with MD5 (that uses a secret)? The HMAC docs seem awfully thin. Thanks! ...

java equivalent to php's hmac-SHA1

I'm looking for a java equivalent to this php call: hash_hmac('sha1', "test", "secret") I tried this, using java.crypto.Mac, but the two do not agree: String mykey = "secret"; String test = "test"; try { Mac mac = Mac.getInstance("HmacSHA1"); SecretKeySpec secret = new SecretKeySpec(mykey.getBytes(),"HmacSHA1"); mac.init(...

Best way to generate a hash signature (HMAC) for XMLSerialized objects in .NET?

I need to generate a HMAC for objects that I am serializing using the XMLSerializer found in the .NET framework. Each object will contain a property called "HMAC" that will contain a hash of the object's values itself but excluding the "HMAC" field. I've found this question that mentions a built-in solution within the CLR but doesn't ela...

HMAC - Implementation of PHP algorithm in Objective-C

Hi, I have to implement the HMAC MD5 in my iPhone app. The PHP version of the algorithm (implemented server side for verification) is here and I can't modify it (it's an API) function hmac($key, $data) { $b = 64; // byte length for md5 if (strlen($key) > $b) { $key = pack("H*",md5($key)); } $key = str_pad($key, $b, chr(0x00)); ...

How are these 2 lines of PHP different?

Assuming we have a salt that's in the database and that has been generated like this $salt = time(); What is the difference between these 2 lines. $pass1 = hash('sha1', $password . $salt); $pass2 = hash_hmac('sha1', $password, $salt); They don't produce the same output. The first one, the hash function takes 2 params, while the h...

What is the auth_tkt cookie format?

The Apache module auth_tkt creates authentication cookies that can be verified cryptographically so a web server can generate REMOTE_USER without consulting a database. What is the specification for auth_tkt cookies? ...

How to Detect Diferences between GET and POST ViewModel Values in a form?

I have a single view that handles a lot of Models of type VoyagesViewModel, in that view the user can create a new voyage or edit all the active voyages, so i have different instances of the same object type in that view. each form contains something like: <% = Html.Hidden("Voyages["+ i +"].VoyageDetails[" + i2 + "].Id", location.Id)%> ...