Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>HMAC is a construct for turning a hash function, like SHA1, into a <a href="http://en.wikipedia.org/wiki/Message_authentication_code" rel="nofollow noreferrer">Message Authentication Code</a> (MAC). </p> <p>Normal hash functions don't have any secret data associated with it. This means that anyone can compute the digest, assuming they have the original input. HMAC uses a secret key, so that only those in possession of the key can compute outputs. </p> <p>Suppose I have a file, file.txt. I want to send this to you, and we need to make sure nobody tampers with it. Sorry, I have no clever way to represent this with just text.</p> <pre><code>me -&gt; file.txt -&gt; you me -&gt; SHA1(file.txt) -&gt; you </code></pre> <p>Then you verify the result by computing your own SHA1 digest, and verifying it matches what I sent you. </p> <p>Now suppose an attacker was in the middle. Unfortunately, because there is no secret involved, the attacker can modify the file, and compute his own file/digest pair. When you compute your version, it'll match what he sent you, and you'll be none the wiser. </p> <pre><code>me -&gt; file.txt -&gt; attacker -&gt; modified.txt -&gt; you me -&gt; SHA1(file.txt) -&gt; attacker -&gt; SHA1(modified.txt) -&gt; you </code></pre> <p>With HMAC, we add a secret key to the computation. </p> <pre><code>me -&gt; file.txt -&gt; you me -&gt; SHA1_HMAC(file.txt, our_secret) -&gt; you </code></pre> <p>When you compute your version, you apply the secret key as well, and the result matches. The attacker, without knowledge of the key, can't replace the digest. </p> <pre><code>me -&gt; file.txt -&gt; attacker -&gt; modified.txt -&gt; you me -&gt; SHA1(file.txt) -&gt; attacker -&gt; SHA1_HMAC(modified.txt, // DOESN'T KNOW KEY) -&gt; you </code></pre> <p>HMAC is a very specific way of adding the secret key. Unfortunately, simple methods of just concatenating a key to the end of the file, or pre-pending it before hashing, are vulnerable to different attacks (length extension attacks, for example). </p> <p>The B64 is Base64 encoding the output, to make it pretty. </p> <p>What this code is ultimately doing is taking some input, and some secret key, and computing a 160-bit digest, and base64 encoding the result. </p> <p>There is an implementation of <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.hmacsha1.aspx" rel="nofollow noreferrer">SHA1 HMAC in .NET</a></p> <p><a href="https://stackoverflow.com/questions/169907/how-do-i-base64-encode-a-string-efficiently-using-excel-vba">This</a> looks like an implementation of Base64 for VBA</p> <p>I hope this answers it well enough, or clear enough. If the text is confusing, please let me know. I tried a couple routes of how to express it, and none of them seemed that clear. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload