Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objectives Secure Hash Algorithm : is a cryptographic hash function designed by

ID: 3738575 • Letter: O

Question

Objectives

Secure Hash Algorithm: is a cryptographic hash function designed by the United States National Security Agency and is a U.S. Federal Information Processing Standard published by the United States.

Research

Write C++ Program showing how it works

How do one-way hash functions work?

Research various methods security could be used on hash functions and write a report on it.

List the different methods you identified in your search.

Project Deliverables

Projects reports are expected to be 2 pages long. Don't stretch the report just to meet a particular page number, nor feel constrained if it needs to be longer to get your key points and results across.

A good report must answer the standard questions about any research project.

Prepare a class PowerPoint Presentation and DEMO. (50% of your grade is based on successful DEMO with documentation)

Explanation / Answer

/*

Program : SHA1

Name : Veerendra Patil H V

*/

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<math.h>
#include<stdlib.h>
#define rotateleft(x,n) ((x<<n) | (x>>(32-n)))
#define rotateright(x,n) ((x>>n) | (x<<(32-n)))

using namespace std;

//function for SHA1
void SecuredHash1(unsigned char * strParam)
{
unsigned long int h0,h1,h2,h3,h4,a,b,c,d,e,f,k,temp;
h0 = 0x67452301;//initialize hex decimal values
h1 = 0xEFCDAB89;
h2 = 0x98BADCFE;
h3 = 0x10325476;
h4 = 0xC3D2E1F0;
unsigned char * strptr;//str pointer
int i, j;//index variables
strptr = (unsigned char *)malloc(strlen((const char *)strParam)+100);//allocate memory
strcpy((char *)strptr,(const char *)strParam); //copy strparam to strptr
int current_length = strlen((const char *)strptr); //find length
int original_length = current_length;
strptr[current_length] = 0x80;
strptr[current_length + 1] = '';//null character assignemnt
char ic = strptr[current_length];
current_length++;
int ib = current_length % 64;

if(ib<56)
ib = 56-ib;
else
ib = 120 - ib;
for( i=0;i < ib;i++)
{
strptr[current_length]=0x00;
current_length++;
}
strptr[current_length + 1]='';
for(i=0;i<6;i++)
{
strptr[current_length]=0x0;
current_length++;
}
strptr[current_length] = (original_length * 8) / 0x100 ;
current_length++;
strptr[current_length] = (original_length * 8) % 0x100;
current_length++;
strptr[current_length+i]='';
int number_of_chunks = current_length/64;
unsigned long int word[80];
for(i=0;i<number_of_chunks;i++)
{
for( j=0;j<16;j++)
{
word[j] = strptr[i*64 + j*4 + 0] * 0x1000000 + strptr[i*64 + j*4 + 1] * 0x10000 + strptr[i*64 + j*4 + 2] * 0x100 + strptr[i*64 + j*4 + 3];
}
for(j=16;j<80;j++)
{
word[j] = rotateleft((word[j-3] ^ word[j-8] ^ word[j-14] ^ word[j-16]),1);
}
a = h0;
b = h1;
c = h2;
d = h3;
e = h4;
for(int m=0;m<80;m++)
{
if(m<=19)
{
f = (b & c) | ((~b) & d);
k = 0x5A827999;
}
else if(m<=39)
{
f = b ^ c ^ d;
k = 0x6ED9EBA1;
}
else if(m<=59)
{
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDC;
}
else
{
f = b ^ c ^ d;
k = 0xCA62C1D6;
}
temp = (rotateleft(a,5) + f + e + k + word[m]) & 0xFFFFFFFF;
e = d;
d = c;
c = rotateleft(b,30);
b = a;
a = temp;
}
h0 = h0 + a;
h1 = h1 + b;
h2 = h2 + c;
h3 = h3 + d;
h4 = h4 + e;
}
cout<<" ";
cout<<hex<<h0<<" "<<h1<<" "<<h2<<" "<<h4<<" "<<h4;//display SHA1 code
cout<<" ";
}
int main()
{
SecuredHash1((unsigned char *)"Veerendra Patil");
return 0;
}

A restricted hash work, otherwise called a message process, unique mark or pressure work, is a scientific capacity which takes a variable-length input string and changes over it into a settled length double arrangement. Moreover, a restricted hash work is planned such that it is difficult to turn around the procedure, that is, to discover a string that hashes to a given esteem (thus the name one-way.) A great hash work likewise makes it elusive two strings that would create a similar hash esteem.

All advanced hash calculations create hash estimations of 128 bits and higher.

Indeed, even a slight change in an information string should cause the hash an incentive to change radically. Regardless of whether 1 bit is flipped in the info string, at any rate half of the bits in the hash esteem will flip subsequently. This is called a torrential slide impact.

Hash Algorithms.

Microsoft cryptographic suppliers bolster these hash calculations: MD4, MD5, SHA and SHA256.

MD4 and MD5

Both MD4 and MD5 were concocted by Ron Rivest. MD remains for Message Digest. The two calculations create 128-bit hash values. MD5 is an enhanced rendition of MD4.

SHA

SHA remains for Secure Hash Algorithm. It was composed by NIST and NSA. SHA produces 160-piece hash esteems, longer than MD4 and MD5. SHA is for the most part thought to be more secure that different calculations and is the prescribed hash calculation.

SHA256