logo
logo
Sign in

Hashing and Digital Signatures

avatar
Logan Siberus
Hashing and Digital Signatures

Hashing and digital signatures are two widely used cybersecurity techniques for ensuring file integrity. Let’s explore each in detail.


Hashing

Hashing is used to verify whether a file has been tampered with. Imagine you’ve just received a crucial document. Thanks to hashing, you can easily check if it matches the file that was initially sent to you or if someone altered it in the meanwhile. But how does it all work?



Let’s say one of your colleagues needs to send you a file. He can use a hashing function to create a ‘hash’ and then store both the file and the corresponding hash together. Once you will need to download the file, you will also have to download its ‘hash.’ You will then be able to check whether the document you just downloaded has been modified by independently recalculating its ‘hash.’ After obtaining your hash, you can compare it to the one you downloaded with the file and see if they match. If they do, it’s all good! You can fully trust your document. If they don’t, the integrity of the file has been compromised. This means that someone has modified the original document, which is no longer reliable.



A few extra things to keep in mind

The file size changes, but the hash size doesn’t: even though your file can be any size, its corresponding hash, also called message digest, will always have a fixed size.

Hash functions are one-way: Like one-way streets, when using hash functions, files should only move in one direction. In other words, users should not be able to get the original document from the hash by reversing the hashing function.

One input for one output: Hashing functions should be able to generate a unique hash for every file. If the same hash is created for different files, we say a collision has happened. Hashing functions responsible for many collisions are highly unreliable.

Digital signatures

Similarly to standard signatures, the main benefit of digital signatures is the guarantee that a particular document or set of files comes from a specific source. In other words, that a specific source endorses the file that has been sent to you. However, unlike standard signatures, no pen and paper are needed for this process, only a so-called private key. Let’s try to understand digital signatures and how they work.


How digital signatures work



Like standard hashing, the first step is the calculation of the file hash made by the source. However, we now have an extra step, namely the digital signature. The source signs the hash with its private key, encrypting it. You can think of it as a literal key closing a digital locker inside which the now encrypted hash is being stored. You can download both the original file and the hash locked in the special box. After downloading everything, you can independently recalculate the hash connected to the document. But how can he compare it to the encrypted hash? Your hash is stored inside a locked box, remember? The answer is easy. The source can provide its users with a public key that can be used to open that box, namely to decrypt your hash. You can, therefore, imagine a digital signature as a locker that first gets locked by the source thanks to a private key and that can be opened again by the receiver only provided that he’s in possession of the right key, namely a public one, which must be sent to him by the source. Now, everything left to do is compare the two and see if they match.


A few extra things to keep in mind

Digital signatures are always done using private keys.

Only the source can access the private key, while a single public key can be distributed to thousands of users.

Anything that is encrypted with a private key can only be decrypted with a public key and vice versa.

Confidentiality can also be offered by encrypting the entire file using the private key and the hash.

Some popular hashing solutions

MD4 (Message-Digest Algorithm) and SHA-2 (Secure Hash Algorithm) are two famous hashing solutions. The former always creates 128-bit fixed-size output hashes regardless of the input. However, it suffered from collisions in the past, meaning it is not fully reliable. The latter is still popular and, unlike MD4, can give outputs of different sizes.


If you liked this article, please checkout our cyber security courses: https://learn.logixacademy.com

collect
0
avatar
Logan Siberus
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more