Student Copy - Part A-Unit 1 (BCT)
Student Copy - Part A-Unit 1 (BCT)
Applications Of Cryptography:
1. Computer passwords
2. Digital Currencies
3. Secure web browsing
4. Electronic Signatures
5. Authentication
6. Cryptocurrencies
7. End-to-end encryption
Symmetric Key Cryptography
Symmetric key cryptography is a type of encryption scheme in which the similar key is used
both to encrypt and decrypt messages. Such an approach of encoding data has been largely used
in the previous decades to facilitate secret communication between governments and militaries.
Symmetric key cryptography schemes are usually categorized such as stream ciphers or block
ciphers.
Stream ciphers work on a single bit (byte or computer word) at a time and execute some form
of feedback structure so that the key is repeatedly changing.
A block cipher is so-called because the scheme encrypts one block of information at a time
utilizing the same key on each block. In general, the same plaintext block will continually
encrypt to the same ciphertext when using the similar key in a block cipher whereas the same
plaintext will encrypt to different ciphertext in a stream cipher.
Block ciphers can operate in one of several modes which are as follows −
Electronic Codebook (ECB) mode is the simplest application and the shared key
can be used to encrypt the plaintext block to form a ciphertext block. There are
two identical plaintext blocks will always create the same ciphertext block.
Although this is the most common mode of block ciphers, it is affected to multiple
brute-force attacks.
Cipher Block Chaining (CBC) mode insert a feedback structure to the
encryption scheme. In CBC, the plaintext is exclusively-ORed (XORed) with the
prior ciphertext block prior to encryption. In this mode, there are two identical
blocks of plaintext not encrypt to the similar ciphertext.
Cipher Feedback (CFB) mode is a block cipher implementation as a self-
synchronizing stream cipher. CFB mode enable data to be encrypted in units lower
than the block size, which can be beneficial in some applications including
encrypting interactive terminal input. If it is using 1-byte CFB mode.
Each incoming character is located into a shift register the similar size as the
block, encrypted, and the block transmitted. At the receiving side, the ciphertext is
decrypted and the more bits in the block are discarded.
Output Feedback (OFB) mode is a block cipher implementation conceptually
same to a synchronous stream cipher. OFB avoids the similar plaintext block from
making the same ciphertext block by using an internal feedback structure that is
independent of both the plaintext and ciphertext bitstreams.
Hash functions are extremely useful and appear in almost all information security applications.
A hash function is a mathematical function that converts a numerical input value into another
compressed numerical value. The input to the hash function is of arbitrary length but output is
always of fixed length.
Values returned by a hash function are called message digest or simply hash values. The
following picture illustrated hash function −
Features of Hash Functions
The typical features of hash functions are −
Fixed Length Output (Hash Value)
o Hash function coverts data of arbitrary length to a fixed length. This
process is often referred to as hashing the data.
o In general, the hash is much smaller than the input data, hence hash
functions are sometimes called compression functions.
o Since a hash is a smaller representation of a larger data, it is also
referred to as a digest.
o Hash function with n bit output is referred to as an n-bit hash
function. Popular hash functions generate values between 160 and
512 bits.
Efficiency of Operation
o Generally for any hash function h with input x, computation of h(x)
is a fast operation.
o Computationally hash functions are much faster than a symmetric
encryption.
Properties of Hash Functions
In order to be an effective cryptographic tool, the hash function is desired to possess following
properties −
Pre-Image Resistance
o This property means that it should be computationally hard to
reverse a hash function.
o In other words, if a hash function h produced a hash value z, then it
should be a difficult process to find any input value x that hashes to
z.
o This property protects against an attacker who only has a hash value
and is trying to find the input.
Second Pre-Image Resistance
o This property means given an input and its hash, it should be hard
to find a different input with the same hash.
o In other words, if a hash function h for an input x produces hash
value h(x), then it should be difficult to find any other input value y
such that h(y) = h(x).
o This property of hash function protects against an attacker who has
an input value and its hash, and wants to substitute different value
as legitimate value in place of original input value.
Collision Resistance
o This property means it should be hard to find two different inputs of
any length that result in the same hash. This property is also
referred to as collision free hash function.
o In other words, for a hash function h, it is hard to find any two
different inputs x and y such that h(x) = h(y).
o Since, hash function is compressing function with fixed hash length,
it is impossible for a hash function not to have collisions. This
property of collision free only confirms that these collisions should
be hard to find.
o This property makes it very difficult for an attacker to find two
input values with the same hash.
o Also, if a hash function is collision-resistant then it is second pre-
image resistant.
Design of Hashing Algorithms
At the heart of a hashing is a mathematical function that operates on two fixed-size blocks of
data to create a hash code. This hash function forms the part of the hashing algorithm.
The size of each data block varies depending on the algorithm. Typically the block sizes are from
128 bits to 512 bits. The following illustration demonstrates hash function −
Hashing algorithm involves rounds of above hash function like a block cipher. Each round takes
an input of a fixed size, typically a combination of the most recent message block and the output
of the last round.
This process is repeated for as many rounds as are required to hash the entire message.
Schematic of hashing algorithm is depicted in the following illustration −
Since, the hash value of first message block becomes an input to the second hash operation,
output of which alters the result of the third operation, and so on. This effect, known as
an avalanche effect of hashing.
Avalanche effect results in substantially different hash values for two messages that differ by
even a single bit of data.
Understand the difference between hash function and algorithm correctly. The hash function
generates a hash code by operating on two blocks of fixed-length binary data.
Hashing algorithm is a process for using the hash function, specifying how the message will be
broken up and how the results from previous message blocks are chained together.
Popular Hash Functions
Let us briefly see some popular hash functions −
Message Digest (MD)
MD5 was most popular and widely used hash function for quite some years.
The MD family comprises of hash functions MD2, MD4, MD5 and MD6. It was
adopted as Internet Standard RFC 1321. It is a 128-bit hash function.
MD5 digests have been widely used in the software world to provide assurance
about integrity of transferred file. For example, file servers often provide a pre-
computed MD5 checksum for the files, so that a user can compare the checksum
of the downloaded file to it.
In 2004, collisions were found in MD5. An analytical attack was reported to be
successful only in an hour by using computer cluster. This collision attack resulted
in compromised MD5 and hence it is no longer recommended for use.
Secure Hash Function (SHA)
Family of SHA comprise of four SHA algorithms; SHA-0, SHA-1, SHA-2, and SHA-3. Though
from same family, there are structurally different.
The original version is SHA-0, a 160-bit hash function, was published by the
National Institute of Standards and Technology (NIST) in 1993. It had few
weaknesses and did not become very popular. Later in 1995, SHA-1 was designed
to correct alleged weaknesses of SHA-0.
SHA-1 is the most widely used of the existing SHA hash functions. It is employed
in several widely used applications and protocols including Secure Socket Layer
(SSL) security.
In 2005, a method was found for uncovering collisions for SHA-1 within practical
time frame making long-term employability of SHA-1 doubtful.
SHA-2 family has four further SHA variants, SHA-224, SHA-256, SHA-384, and
SHA-512 depending up on number of bits in their hash value. No successful
attacks have yet been reported on SHA-2 hash function.
Though SHA-2 is a strong hash function. Though significantly different, its basic
design is still follows design of SHA-1. Hence, NIST called for new competitive
hash function designs.
In October 2012, the NIST chose the Keccak algorithm as the new SHA-3
standard. Keccak offers many benefits, such as efficient performance and good
resistance for attacks.
RIPEMD
The RIPEMD is an acronym for RACE Integrity Primitives Evaluation Message Digest. This set
of hash functions was designed by open research community and generally known as a family of
European hash functions.
The set includes RIPEMD, RIPEMD-128, and RIPEMD-160. There also exist
256, and 320-bit versions of this algorithm.
Original RIPEMD (128 bit) is based upon the design principles used in MD4 and
found to provide questionable security. RIPEMD 128-bit version came as a quick
fix replacement to overcome vulnerabilities on the original RIPEMD.
RIPEMD-160 is an improved version and the most widely used version in the
family. The 256 and 320-bit versions reduce the chance of accidental collision, but
do not have higher levels of security as compared to RIPEMD-128 and RIPEMD-
160 respectively.
Whirlpool
This is a 512-bit hash function.
It is derived from the modified version of Advanced Encryption Standard (AES).
One of the designer was Vincent Rijmen, a co-creator of the AES.
Three versions of Whirlpool have been released; namely WHIRLPOOL-0,
WHIRLPOOL-T, and WHIRLPOOL.
Properties Of Cryptography Hash Function
The ideal cryptographic hash function has the following main properties:
1. Deterministic: This means that the same message always results in the same hash.
2. Quick: It is quick to compute the hash value for any given message.
3. Avalanche Effect: This means that every minor change in the message results in a
major change in the hash value.
4. One-Way Function: You cannot reverse the cryptographic hash function to get to
the data.
5. Collision Resistance: It is infeasible to find two different messages that produce
the same hash value.
6. Non Predictable: The hash value shouldn’t be predictable from the given string and
vice versa.
Cracking Hash
We often hear the term Cracking a Hash, there are a couple of ways to do that:
Find an algorithm to generate a collision between two hashes. The more advance the
algorithm is, the more difficult it is to crack the hash.
Another way is to find an algorithm to identify a unique and different input that will
produce a given hash. It is similar to a collision, but instead of colliding, we are
focusing on finding the input using an algorithm.
Some common hashes we still use today that are considered “cracked” from a
cryptographic point of view are MD5(Message-Digest Algorithm) and SHA-
1(Secure Hash Algorithm 1). Keep in mind that these are technically broken Hashes
and never use for your security purposes.
An intruder can only see the hashes of passwords, even if he accessed the
password. He can neither logon using hash nor can he derive the password from
hash value since hash function possesses the property of pre-image resistance.
Digital Signature
A digital signature is a mathematical technique used to validate the authenticity and integrity
of a message, software, or digital document.
Currently, a website takes the user password as an input and then compares its hash to the
stored hash. Similarly, a bank requires your credit score to provide you the loan leaving your
privacy and information leak risk at the mercy of the host servers. If ZKP can be utilized, the
client’s password is unknown them to verifier and the login can still be authenticated. Before
ZKP, we always questioned the legitimacy of the prover or the soundness of the proof system,
but ZKP questions the morality of the verifier. What if the verifier tries to leak the
information?
Example-1: A Colour-blind friend and Two balls :
There are two friends Sachin and Sanchita, out of whom Sanchita is colour blind. Sachin has
two balls and he needs to prove that both the balls our of different colour. Sanchita switches
the balls randomly behind her back and shows it to Sachin who has to tell if the balls are
switched or not. If the balls are of the same colour and Sachin had given false information, the
probability of him answering correctly is 50%. When the activity is repeated several times, the
probability of Sachin giving the correct answer with the false information is significantly low.
Here Sachin is the “prover” and Sanchita is the “verifier”. Colour is the absolute information
or the algorithm to be executed, and it is proved of its soundness without revealing the
information that is the colour to the verifier.
Zero-Knowledge –
If the statement is true, the verifier will not know that the statement or was. Here
statement can be an absolute value or an algorithm.
Completeness –
If the statement is true then an honest verifier can be convinced eventually.
Soundness –
If the prover is dishonest, they can’t convince the verifier of the soundness of the
proof.
Blockchain is a list of blocks. Each block comprises some information associated with some
hash. Blockchain is used nowadays widely for transactions. It is an immutable, distributed, and
decentralized ledger. The working of Blockchain is as follows. Suppose a user wants to make
a transaction. A block is created and sent to other users. Users validate the block and the
transaction gets executed. The block is added and the users get incentives.
Although Blockchain is secured, still it has some loopholes. Hackers or malicious users take
advantage of these loopholes to perform their activities.
Double spending means the expenditure of the same digital currency twice or more
to avail the multiple services. It is a technical flaw that allows users to duplicate
money.
Since digital currencies are nothing but files, a malicious user can create multiple
copies of the same currency file and can use it in multiple places.
This issue can also occur if there is an alteration in the network or copies of the
currency are only used and not the original one.
There are also double spends that allow hackers to reverse transactions so that
transaction happens two times.
By doing this, the user loses money two times one for the fake block created by the
hacker and for the original block as well.
The hacker gets incentives as well for the fake blocks that have been mined and
confirmed.
Example: Suppose a user has 1 BTC. He/She wants to avail of services from merchant A and
merchant B. The user creates multiple copies of the same BTC and stores it. The user first
sends the original BTC to Merchant A and gets the service. Simultaneously, the user sends the
copied version of 1 BTC to Merchant B. Since the second transaction was not confirmed by
other miners, the merchant accepts the bitcoin and sends the service. But the cryptocurrency
that was sent is invalid. This is the case of Double Spending.
Types Of Double Spending Attacks
1. The first case is making duplicates of the same bitcoin and sending it to multiple
users.
2. The second case is performing the transaction and reversing the already sent
transaction after getting the service.
To tackle these double-spending issues, some security measures are taken. They are:
A user wants to spend 2 BTC. He/She can create multiple copies of the same
cryptocurrency.
The user can send the same cryptocurrency to two different addresses say ‘Bob’ and
‘Alice’.
Both of these transactions are sent to the pool of unconfirmed transactions.
The first transaction T1 would be approved via the confirmation mechanism.
The confirmation mechanism states that a minimum of six confirmations by miners
should be done for block validation. The block is added to the network.
Double Spending can be prevented using two approaches: Centralized and Decentralized
Centralized Approach: In this case, a secured third party is employed to verify the
transactions. The third-party can track each of the user’s balances. Suppose a user
makes a transaction. The third-party identifies the transaction with a unique
identity. Then it verifies the transaction and allows the transaction. The problem is
that suppose we want to make transactions with other countries where a third party
is not required. So in such cases, decentralized systems come into play. another
drawback is if the whole system fails, the users cannot have access.
Decentralized Approach: This approach is used by Bitcoin. In this, there is no
involvement of central authority. Each transaction is verified using powerful
algorithms. The decentralized approach proved to be more secure than the
centralized approach. Protocols are established and each protocol does its job at
each step. Therefore this also promotes transparency.
Double spending has been minimized to a large extent as companies are using many security
features. But we as users also have some responsibility so that such attacks don’t happen.
Any user should wait for a minimum of six confirmations of the transaction before
performing another transaction. In the blockchain, more the confirmations by
different users, lesser will be double spending attacks.
Users should keep their hardware resources safe so that hackers do not misuse them
for their own purposes. Often hackers target the hardware part because the hardware
is costly. If they somehow steal the hardware, they can roll back any transaction or
alter information.
Users should delete spam mails and avoid phishing to avoid unnecessary malware
attacks Phishing is a very common attack by hackers as hackers target login
credentials.
Software should be updated regularly with the latest antivirus installed. If the
software is not up to date then the bugs present can cause major damage.
With the increasing dependency on the blockchain, double spending attacks have also become
a major problem. Many companies have adopted security features.
Features like confirmation of the transaction by the nodes have been adopted. A
minimum of six confirmations is required to approve the transaction.
The blocks once created are immutable. They are made irreversible so that no
transaction is reverted back.
The network’s distributed ledger of transactions autonomously records each
transaction. Each node has a copy of all transactions that are being done in the
network.
Verification of each transaction’s authenticity is done by Blockchain protocols to
prevent double-spending. The concept of hashing is adopted. Here each block has a
unique hash.