Cryptography Reference
In-Depth Information
> SHA256 := proc(message, messagetype::name := text)
local m;
m := messagetobytes(message, messagetype);
bytestohexstring(sha256(m))
end proc:
Examples 5.2
1. We compute the example 'One Block Message Sample' in [148]:
> SHA256("abc");
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
2. The example labeled 'Two Block Message Sample' in [148] is the following:
> SHA256("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
3. An example involving both a text string and a file is the following. We first create
the file in the current directory:
> sha256txt:="This string is written to the file sha256file in order to test SHA-256":
> bytestofile(convert(sha256txt, bytes), "sha256file");
70 bytes saved to sha256file
Next, we compute the hashes for the string sha256txt and the file “sha256
file” ; of course, since the file only contains this string, these values will be
equal:
> SHA256(sha256txt);
"89c20c495a6b5ae462b08dd4e4791be989731d0402ca7773796995fe8ee9098b"
> SHA256("sha256file", file);
"89c20c495a6b5ae462b08dd4e4791be989731d0402ca7773796995fe8ee9098b"
Exercise 5.13 In a similar way to the preceding implementation of SHA-256, give
Maple implementations of the remaining functions in the SHA-2 family, namely,
SHA-224, SHA-384 and SHA-512, following [74].
5.6.5 MACs with Hash Functions: HMAC
The idea of using unkeyed cryptographic hash functions to construct a MAC is quite
recent and one of the motivations is that some popular hash functions such as SHA-1
and SHA-2 are noticeably faster than block ciphers in software and hence MACs
based on them are also significantly faster than, say, CBC-MAC and its variants.
One of the problems that arises when trying to apply this idea is that unkeyed hash
functions do not have secret keys, which is a necessary ingredient of a MAC. Several
methods of combining a hash function with a secret key to obtain a MAC have been
proposed and the one which is, by far, the most popular is called HMAC (for hash-
based MAC ). HMAC was introduced by Bellare, Canetti and Krawczyk in 1996 [13]
and has recently been standardized by several bodies, in particular as the Internet
standard RFC 2104 [124], as an ISO standard (ISO/IEC 9797-2), and also by NIST
[76]. Apart from being very simple and efficient, one of the advantages of HMAC
is that it has a reductionist security proof under reasonable assumptions about the
strength of the underlying hash function.
 
Search WWH ::




Custom Search