-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew_Seed_Main.cpp
68 lines (63 loc) · 1.36 KB
/
New_Seed_Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* This file is a test case to SHA1 test which calls SHA1Input with an exact multiple
* of 512 bits, plus a few error test checks
*/
#include <stdio.h>
#include <string.h>
#include "New_Seed_Header.h"
/*
* Define test patterns
*/
#define TEST1 "mississippi"
//huffman-D5 8B 85 9A 2A C4 44 30 8D 5C 18 19 ED DC A0 77 23 3B B8 2D
/* an exact multiple of 512 bits */
char *testarray[1] =
{
TEST1
};
long int repeatcount[1] = { 1 };
/* Results of the 4 test cases */
/* Main function */
int main() {
SHA1Context sha;
int i, j, err;
uint8_t Message_Digest[20];
/* Perform SHA1 test */
for (j = 0; j < 1; ++j) {
err = SHA1Reset(&sha);
if (err)
{
fprintf(stderr, "SHA1Reset Error %d.\n", err);
break; /* out of for j loop */
}
for (i = 0; i < repeatcount[j]; ++i)
{
err = SHA1Input(&sha,
(const unsigned char *)testarray[j],
strlen(testarray[j]));
if (err)
{
fprintf(stderr, "SHA1Input Error %d.\n", err);
break; /* out of for i loop */
}
}
err = SHA1Result(&sha, Message_Digest);
if (err)
{
fprintf(stderr,
"SHA1Result Error %d, could not compute message digest.\n",
err);
}
else
{
printf("Our Observation - ");
for (i = 0; i < 20; ++i)
{
printf("%02X ", Message_Digest[i]);
}
printf("\n");
}
}
getchar();
return 0;
}