0% found this document useful (0 votes)
229 views3 pages

Implementation of SHA-1 Algorithm, Using Verilog

The document summarizes the implementation of the SHA-1 hashing algorithm using Verilog. It begins by introducing SHA-1 and its purpose of generating a unique cryptographic signature for input data. It then describes: 1) How bitstrings, words, integers and hexadecimal representation are used. 2) The key word operations like AND, OR, XOR used. 3) The message padding process to create 512-bit blocks for processing. 4) The functions, constants, and processing steps to compute the message digest in 5 stages using logical and circular shift operations on words and chaining variables.

Uploaded by

Ankit Varshney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
229 views3 pages

Implementation of SHA-1 Algorithm, Using Verilog

The document summarizes the implementation of the SHA-1 hashing algorithm using Verilog. It begins by introducing SHA-1 and its purpose of generating a unique cryptographic signature for input data. It then describes: 1) How bitstrings, words, integers and hexadecimal representation are used. 2) The key word operations like AND, OR, XOR used. 3) The message padding process to create 512-bit blocks for processing. 4) The functions, constants, and processing steps to compute the message digest in 5 stages using logical and circular shift operations on words and chaining variables.

Uploaded by

Ankit Varshney
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Implementation of SHA-1 Algorithm, 

using Verilog
Ankit Varshney Anand Mahesh Kumar
Electronics and Communications Engineering Electronics and
MIT, Manipal Communications
Engineering
MIT, Manipal

​ SHA-1 is being defined in the National Institute


Abstract— a. A hexadecimal digit is what we call an element of this set
of Standards and Technology standard which is called ‘FIPS {0, 1, ... , 9, A, ... , F}. A hexadecimal digit is a way how we
180-4’. With the increase of hacking and theft of passwords represent four-bit string data.
and data we need methods to protect it. The need for
protection has led to development of encryption and anti-theft Examples:​ B = 1011, 5 = 0101.
algorithms and softwares

Keywords— SHA 1, Hashing, Verilog, Vivavdo, Encryption


A word is defined as a 4-byte string which is represented in
I. INTRODUCTION a series of 8 hexadecimal digits. To convert a word to 8
hexadecimal digits each 1 nibble string is converted to its
A cryptographic hash is defined as a ‘signature’ for the
hexadecimal alternative.
data or text we are using. Secure Hash Algorithm generates
a unique 20 byte or 160-bit signature for the text or data that Example:
has been input. We can also say that it is a way to condense
1110 1001 0000 0011 1111 1110 0010 0111 = E903FE27.
the message into 20 bytes. A hash can’t be called as
encryption as it can’t be reverted or decrypted back to the
original data or text that was input. It is basically a one-way
b. An integer may be represented using hexadecimal
cryptographic function that converts the text or data into a
notation in such a manner that the least significant digits
fixed 160-bit format. The 20 bytes condensed message in
appear on the right hand side
hash value is also called a message digest. This SHA 1
cryptographic hash algorithm was basically designed to Example: the integer 290 = 2​8​+2​5​+2​1 = 256+32+2 is
keep the data secured. The algorithm basically works by the represented by the hex word,
application of a hash function that includes some bitwise
00000122.
operation, compression functions, and modular additions.
The newly generated message is nothing like the original.
The most common application of this algorithm is to keep
c. The final padded message as known as ‘block’. It is a
passwords protected on the server-side as it will just store
512-bit message that is passed into the final SHA1 module
the hashed value instead of the original password given by
for further processing.
the user. So even if someone hacks into the server-side
database he will be just able to get out the hashed 20 bytes
data and if he uses it in the place of the password it will
2. Word Operations
produce a different hash value which won't match. This
algorithm also exhibits an avalanche effect as the The following logical operators used with words in the
modification of even a single letter can show a drastic upcoming hashing method:
change in the output. The other use of this algorithm is
Word operations
basically to identify whether a file has tampered or not, as
by the avalanche effect we’ll know that even if a slight A AND B = logical and of A and B
change was done in the document will change the hashed
A OR B = logical inclusive-or of A and B.
value.
A XOR B = logical exclusive-or of A and B.
II. METHEDOLOGY
NOT A = complement of A.

1.The implementation of bitstrings and integers here:


Example:
So the way we will be using the bitstrings and integers here
is as follows: 01101100101110011101001001111011
XOR 11100101110000010110100110111101
----------------------------------------------- are labeled W(0), W(1) and so on up to W(79) in the
sequence. One more word buffer TMP is also used as a
= 10001001011110001011101111000110
single word buffer.
The padded message thus obtained is then divided into
Here we have a circular left shift operation represented by 16 equal blocks each containing 32 bits and is thun used for
S​n(X)​, is an operation where the entire bit is shifted left in further processing.
such a manner that the right most digits are appended with
These values of the H are defined as described below:
zeros
H​0​ = 67452301
S​m(Y)​ = (Y << m) or can also be written as (Y >> 32-m).
H​1​ = EFCDAB89
In the given equation, Y << m is obtained as follows:
discard the most significant m bits of X and then fill the H, = 98BADCFE
result with m zeroes on the right . Y >> m is obtained by
H, = 10325476
discarding the least significant n bits of Y and then
concatenating the result with n zeroes on the left. Thus H, = C3D2E1F0.
S^m(Y) is equivalent to a circular shift of Y by m positions
to the left.
Now W(i) is processed as follows -
a. W(i) is divided into 16 equally sized words each of
3. Message Padding
32-bits in length - W(0), W(1),W(2),W(3),W(4) ... , W(15),
We use SHA1 to create a message digest out of the message where W(0) is the left-most word.
or the file that we input. This message or that file will be
b. For t = 16 to 79 let
considered as a bit string. the no. of bits will be considered
as the size of the message that we input. Luckily if the size W(t) = S​1​(W(t-3) ^ W(t-8) ^ W(t-14) ^ W(t-16)).
of the message is found to be multiple of 8 we can represent
This process is done for W(t) upto t = 80. This is the
in hexadecimal format. The purpose of padding here will be
standard set for the SHA1 algorithm.
to pad the message in multiples of 512. As SHA-1
sequentially processes these blocks to get the message c. Let,
digest.
A = H0,
4. Functions and Constants Used
B = H1,
We use logical functions f(0), f(1),..., f(79) in sequence
C = H2,
in SHA-1.
D = H3,
E = H4.
d. For t = 0 to 79 do
TMP = S​5​(A) + f(t;B,C,D) + E + W(t) + K(t);
E = D;
A sequence of constants are also used and are as defined D = C;
C = S​30​(B);
B = A;
A = TMP;

e. Let,
5. Computing the Message Digest H0 = H0 + A,
H1 = H1 + B,
Method H2 = H2 + C,
The message we padded during the padding process will H3 = H3 + D,
be used to get the block. A buffer has the 5 words labelled
as A, B, C, D, E. Another buffer has the 5 words labelled as H4 = H4 + E.
H1, H2, H3, H4, H0. The words of our 80-word sequence
On completing the processing of the padded message we
obtain the aforementioned variables (H0 - H4). These four
variables are concatenated as
H = H0 H1 H2 H3 H4
The variable ‘H’ thus obtained contains the final 160-bit
message that is known as the SHA1 Encoded Message of
the input message M(i).

III. APPLICATIONS
This entire algorithm could be implemented as a SOC. This
SOC has a wide range of applications including, Electronic
Lockers, Car Sharing Applications, Password storage and
Verification, Enabling secure data transfer, secure telephony
and video communications.

IV. CONCLUSION
The entire algorithm was tested using the simulation tool
Vivado. This thus proves that the algorithm can be run on
the appropriate FPGA for further testing and be made into a
SOC that can be used for a wide variety of applications as
mentioned in this report.

V. REFERENCES
[1]​https://www.ipa.go.jp/security/rfc/RFC3174EN.htm
[2] ​https://brlliant.org/wiki/secure-hashing-algorithms/
[3] ​https://www.forrestheller.com/
[4] ​http://www.sha1-online.com/

You might also like