title: HMAC_256 using Message Authentication Code on Solaris
body: <p>This problem is really leaving me astounded</p>
  
  <ol>
  <li>Take a input file and create a HMAC_256 value from it using a private key</li>
  <li>Base64 encode HMAC_256 hash</li>
  </ol>
  
  <p><strong>Code</strong></p>
  
  <pre><code>#Create HMAC-SHA2 hash from shell parameter
  filehash=`echo $1 | mac -a sha256_hmac -k test.key`
  echo "HMAC_SHA256 hash : "$filehash
  #Base64 encode filehash using openssl
  filehash_64=`echo "$filehash" | /usr/sfw/bin//openssl enc -base64 | tr '\n' ' ' | cut -d " " -f2 `
  echo "64 bit encoded hash : "$filehash_64
  </code></pre>
  
  <p>Using a test.key of</p>
  
  <blockquote>
    <p>Bob123</p>
  </blockquote>
  
  <p><strong>Shell Input</strong></p>
  
  <blockquote>
    <p>Hello</p>
  </blockquote>
  
  <p><strong>Shell Output</strong></p>
  
  <pre><code>SHA256 hash : 411796cfb1e6c30c1b39b589c79d6f8bf1fdde8d58fda4a6ec1e59538ecaa39a
  
  64 bit encoded hash : ZWMxZTU5NTM4ZWNhYTM5YQo=
  </code></pre>
  
  <hr>
  
  <p>However if I go to these sites and do a HMAC_256 test they both generate a different hash</p>
  
  <p><a href="http://asecuritysite.com/encryption/hmac" rel="nofollow">http://asecuritysite.com/encryption/hmac</a></p>
  
  <p><a href="http://jetcityorange.com/hmac/" rel="nofollow">http://jetcityorange.com/hmac/</a></p>
  
  <p>They both Output a HMAC_256 hash of</p>
  
  <blockquote>
    <p>a30410f584726f32ba3e6e823bfdecbdf28448d64e4ab8f11f6a2e66818b50fe</p>
  </blockquote>
  
  <p>Why are they generating a different hash? I am assuming they are correct as they both have the same.</p>
  
  <ul>
  <li>Does Solaris 10 have a bug with its MAC (Message Authentication Code)
  tool?</li>
  <li>Is it UTF8 or ASCII problem?</li>
  <li>Is it a server problem, Windows / Unix?</li>
  </ul>
  
  <p>I don't understand why I am generating a different hash to them, even though I am using the same hashing algorithm and key.</p>