- if(check == -1)
- {// hashing stdin entries
- if(quiet == 1 || status == 1 || warn == 1)
- {
- if(quiet == 1)
- printf("skein%dsum: the --quiet option is meaningful only when verifying checksums\n",hashbitlen);
- if(status ==1)
- printf("skein%dsum: the --status option is meaningful only when verifying checksums\n",hashbitlen);
- if(warn == 1)
- printf("skein%dsum: the --warn option is meaningful only when verifying checksums\n",hashbitlen);
-
- printf("Try 'skein%dsum --help' for more information.\n",hashbitlen);
- exit(1);
- }
- if(number_files > 0)
- {// hashing files
- int index_files = 0;
- while(index_files < number_files)
- {
- if(HashTextMode(list_files[index_files],MsgDigest)!=-1)
- {
- if(tag == 1)
- {
- printf("skein%d_v%s (%s) = %s\n",hashbitlen,skeinVersion,list_files[index_files],MsgDigest);
- }
- else
- {
- printf("%s ",MsgDigest);
- printf("%s\n",list_files[index_files]);
- }
- }
- index_files++;
- }
- }
- else if(errorFound != 1)
- {
- HashStdin(MsgDigest, tag);
- }
- }
- else if(check == 1)
- {
- if(tag == 1)
- {
- printf("skein%dsum: the --tag option is meaningless when verifying checksums\n",hashbitlen);
- printf("Try 'skein%dsum --help' for more information\n",hashbitlen);
- exit(1);
- }
- int index_files = 0;
- while(index_files < number_files)
- {
- FILE *fp;
- char hash[500], file_name[100], file_tmp[100], MsgDigest_tmp[hashbitlen/2];
- int NoMatch = 0, NotProper = 0, Computed = 0;
- strcpy(file_name,list_files[index_files]);
- //show everything
- int line = 0;
- fp = fopen(file_name,"r");
- if(fp!=NULL)
- {
- while(fgets(hash,500,fp)!=NULL)
- {
- line ++;
- Computed++;
- unsigned int hashVersion = decomposeHashLine(hash,MsgDigest_tmp,file_tmp);
- if(hashVersion == -1)
- {
- printf("skein%d: %s is using newer version of skein%d algorithm\n",hashbitlen,file_tmp,hashbitlen);
- printf("You should update your algorithm\n");
- continue;
- }
- else if( hashVersion == 0)
- {
- printf("skein%d: %s is using an older version of skein%d algorithm\n",hashbitlen,file_tmp,hashbitlen);
- printf("You should use the older algorithm\n");
- continue;
- }
- else
- {
- if(!isProper(MsgDigest_tmp))
- {
- if(status != 1 && warn == 1)
- {
- printf("skein%dsum: %s: %d: improperly formatted skein%d checksum line\n",hashbitlen,file_tmp,line,hashbitlen);
- }
- NotProper ++;
- NoMatch ++;
- continue;
- }
- if(file_tmp[0] == '*')
- {
- int index_file_tmp = 0;
- for( ; file_tmp[index_file_tmp+1]!=0 ; index_file_tmp++)
- {
- file_tmp[index_file_tmp] = file_tmp[index_file_tmp + 1];
- }
- file_tmp[index_file_tmp] = 0;
- HashBinaryMode(file_tmp,MsgDigest);
- }
- else
- {
- HashTextMode(file_tmp,MsgDigest);
- }
-
- if(!strcmp(MsgDigest,MsgDigest_tmp))
- {
- if(quiet != 1)
- {
- printf("%s: OK\n",file_tmp);
- }
- }
- else
- {
- printf("%s: FAILED\n",file_tmp);
- NoMatch ++;
- }
- }
- }
- if(NoMatch)
- {
- printf("skein%dsum: WARNING: %d of %d computed checksums did NOT match\n",
- hashbitlen,NoMatch,Computed);
- }
- if(NotProper)
- {
- printf("skein%dsum: WARNING: %d line is improperly formatted\n",hashbitlen,NotProper);
- }
- }
- else
- {
- printf("skein%dsum: %s: No such file or directory\n",hashbitlen,file_name);
- }
- index_files++;