handouts/ho01.tex
changeset 179 1cacbe5c67cf
parent 178 13c6bd6e3477
child 180 a95782c2f046
equal deleted inserted replaced
178:13c6bd6e3477 179:1cacbe5c67cf
   309 \pcode{3}, and also its hash. It does not take much trial and
   309 \pcode{3}, and also its hash. It does not take much trial and
   310 error to find out that we used the SHA-1 hashing functions and
   310 error to find out that we used the SHA-1 hashing functions and
   311 then graft a cookie accordingly. This is eased by the fact
   311 then graft a cookie accordingly. This is eased by the fact
   312 that for SHA-1 many strings and corresponding hashvalues are
   312 that for SHA-1 many strings and corresponding hashvalues are
   313 precalculated. Type, for example, into Google the hash value
   313 precalculated. Type, for example, into Google the hash value
   314 for \pcode{"hello wolrd"} and you will actually pretty quickly
   314 for \pcode{"hello world"} and you will actually pretty quickly
   315 find that it was generated by input string \pcode{"hello
   315 find that it was generated by input string \pcode{"hello
   316 wolrd"}. This defeats the purpose of a hashing functions and
   316 wolrd"}. This defeats the purpose of a hashing functions and
   317 thus would not help us for our web-applications. 
   317 thus would not help us for our web-applications. 
   318 
   318 
   319 
   319 
   332 \begin{figure}[p]
   332 \begin{figure}[p]
   333 \lstinputlisting{../progs/App4.js}
   333 \lstinputlisting{../progs/App4.js}
   334 \caption{\label{hashsalt}}
   334 \caption{\label{hashsalt}}
   335 \end{figure}
   335 \end{figure}
   336 
   336 
       
   337 \begin{center}\tt
       
   338 \begin{tabular}{l}
       
   339 1 + salt - 8189effef4d4f7411f4153b13ff72546dd682c69\\
       
   340 2 + salt - 1528375d5ceb7d71597053e6877cc570067a738f\\
       
   341 3 + salt - d646e213d4f87e3971d9dd6d9f435840eb6a1c06\\
       
   342 4 + salt - 5b9e85269e4461de0238a6bf463ed3f25778cbba\\
       
   343 ...\\
       
   344 \end{tabular}
       
   345 \end{center}
       
   346 
       
   347 \noindent These hashes allow us to read and set the value of
       
   348 the counter and give us confidence that the counter has not
       
   349 been tampered with. This of course depends on being able to
       
   350 keep the salt secret. 
       
   351 
       
   352 There is an interesting point to note with respect to the New
       
   353 York Times' way of checking the number visits. Essentially
       
   354 they have their `resource' unlocked at the beginning and lock
       
   355 it only when the data in the cookie states the allowed free
       
   356 number of visits are up. This can be easily circumvented by
       
   357 just deleting the cookie or by switching the browser. This
       
   358 would mean the New York Times will loose revenue whenever this
       
   359 kind of tampering occurs. In contrast, our web-application has
       
   360 the resource (discount) locked at the beginning and only
       
   361 unlocks it if the cookie data says so. If the cookie is
       
   362 deleted, well then the resource just does not get unlocked.
       
   363 No mayor harm will result.
       
   364 
       
   365 
       
   366 \subsection*{How to Store Passwords}
       
   367 
       
   368 While admittedly silly, the simple web-application in the
       
   369 previous section should help with the more important question
       
   370 of how passwords should be verified and stored. It is
       
   371 unbelievable that nowadays systems still do this with
       
   372 passwords in plain text. The idea behind such plain-text
       
   373 passwords is of course that if the user typed in \emph{foobar}
       
   374 as password, we need to verify whether it matches with the
       
   375 password that is stored for this user in the system. But doing
       
   376 this verification in plain text is really a bad idea.
       
   377 Unfortunately, evidence suggests, however, it is still a
       
   378 widespread practice. I leave you to it to think about why
       
   379 verifying passwords in plain text is a bad idea.
       
   380 
       
   381 Using hash functions we can do better.
       
   382 
   337 %The corresponding attack is called \emph{dictionary
   383 %The corresponding attack is called \emph{dictionary
   338 %attack}\ldots hashes are not reversed by brute force
   384 %attack}\ldots hashes are not reversed by brute force
   339 %calculations, that is trying out all possible combinations.
   385 %calculations, that is trying out all possible combinations.
   340 
   386 
   341 
   387