Cryptographic hash functions
หน้านี้ยังไม่ได้รับการแปล คุณกำลังดูเวอร์ชันต้นฉบับภาษาอังกฤษ
In this lesson we will look at cryptographic hash functions which see extensive use in quick validation and authentication.
By the end of the lesson we will have covered:
- What cryptographic hash functions are
- Python code examples demonstrating the use of hash functions
- A look at applications of cryptographic hashing
- The security of cryptographic hashing
- Threats to these algorithms from both classical and quantum computers
Introduction to cryptographic hashing
Hash functions represent a valuable construct in cryptography as they help enable validation with confidentiality. As such, hash functions form an important component of mechanisms for data authentication and integrity, such as hash-based message authentication codes (HMAC) and digital signatures. This article will discuss the basic ideas and security considerations underpinning cryptographic hash functions and outline potential vulnerabilities from the advent of quantum computing.
Basic rationale and design of hash functions
There are many situations where authentication and integrity verification need to be performed cheaply and without revealing private information to the party performing the validation.
For example, when downloading software from a remote server, an efficient mechanism is needed to verify that the software actually downloaded has not been modified since being created by the original author of the software. Similarly, when authenticating users of web applications, it would be desirable to use a mechanism that does not involve physically storing or transmitting the actual passwords, which can potentially compromise their confidentiality.
Cryptographic hash functions (CHFs) address such needs efficiently and securely.
Fundamentally, a cryptographic hash function takes an input (or message) of arbitrary length and returns a fixed-size string of n-bits as output. The output of a CHF is also referred to as a digest. A useful CHF should satisfy several key properties:
- Uniformity: The digests produced by a CHF should be distributed uniformly and should look random. The aim is to ensure the output leaks no information about the input.
- Determinism: For a given input, a CHF must always produce the same digest, that is, it must be deterministic.
- Irreversibility: A CHF is a one-way function in that, given a digest, it should be infeasible to invert the hashing and obtain the input.
- Approximate injectivity: While CHFs are many-to-one functions, they should appear to look like one-to one functions. This is achieved by combining an enormous output space size with the avalanche effect whereby tiny changes in the input lead to wildly divergent digests. This characteristic is known as approximate injectivity.
Given this, it's possible to validate a piece of data against the original instance by comparing a digest of the data to a digest of the original.
- If the two digests match, we can be confident with high probability that the data is identical to the original.
- If the digests differ, we can be sure that the data was tampered with or is otherwise inauthentic.
Since the CHF digests themselves do not reveal the actual contents of the data or the original, they enable validation while preserving privacy.
Mathematical description
A hash function can be defined as:
where