6 #include <openssl/sha.h>
7 #include <openssl/err.h>
8 #include <openssl/fips.h>
11 int main(int argc
, char *argv
[])
13 printf("No FIPS SHA1 support\n");
18 #define MAX_TEST_BITS 103432
20 static void dump(const unsigned char *b
,int n
)
26 static void bitfill(unsigned char *buf
,int bit
,int b
,int n
)
28 for( ; n
> 0 ; --n
,++bit
)
30 assert(bit
< MAX_TEST_BITS
);
31 buf
[bit
/8]|=b
<< (7-bit
%8);
35 void montecarlo(unsigned char *seed
,int n
)
38 unsigned char m
[10240];
41 for(j
=0 ; j
< 100 ; ++j
)
43 for(i
=1 ; i
<= 50000 ; ++i
)
45 memset(m
+n
,'\0',j
/4+3);
62 int main(int argc
,char **argv
)
69 fprintf(stderr
,"%s <test vector file>\n",argv
[0]);
73 if(!FIPS_mode_set(1,argv
[0]))
75 ERR_load_crypto_strings();
76 ERR_print_errors(BIO_new_fp(stderr
,BIO_NOCLOSE
));
79 fp
=fopen(argv
[1],"r");
88 unsigned char buf
[MAX_TEST_BITS
/8];
99 if(!strcmp(line
,"D>"))
102 if(!isdigit(line
[0]))
112 fgets(line
+n
-1,sizeof(line
)-n
+1,fp
);
114 /* printf("line=%s\n",line); */
122 memset(buf
,'\0',sizeof buf
);
123 for(bit
=0,p
=strtok(NULL
," ") ; p
&& *p
!= '^' ; p
=strtok(NULL
," "))
126 bitfill(buf
,bit
,b
,atoi(p
));
131 assert((bit
%8) == 0);
132 /* dump(buf,bit/8); */
141 montecarlo(buf
,bit
/8);