tags: cryptography

Hashing

A hash function is function that given the plaintext message gives a fixed size value. A good hash function is that when applied to large set of inputs will produce different outputs that are evenly distributed and random.

A hash function should be non-reversible, i.e. it is infeasible to find a the message that produces the same hash except by brute-forcing, and infeasible to find two messages that map to the same hash, for more refer to the reference page 328.

Typically the input is padded to a size that is a multiple of some fixed length and then passed to a function that produces the hash value. The padding could include the length of the original message in bits.

A hashing attack can be done by applying some specific modifications that retain the same hash value.

SHA-512 hash function

The SHA-512 is a hash function that works on messages sizes that are less then in size. The message is first padded with a message that has a bit that is 1 and followed by there, It is padded until its size is congruent 896 modulo 1024. The selection of this number is to add the value of the length of the message in the end that is 128 bits in size, so the total message has a size that is a multiple of 1024 bits in length. More steps are in the reference page 344.

NOTE: addition is done modulo .

While hashing is good to know if data is corrupted or no, it is not enough for data-integrity, because simply the attacker can change the hash to match its fraudulent message. The receivers sees the hash and the fraudulent message and thinks everything is OK.

Message authenticating codes

It is the same as hashing but a symmetric key is used to ensure security, MACs are not used in data signing but hashes that are signed with the private-key are used instead.

MAC algorithms