+/* Return: -1 = some errors/mismatches, 1 = all ok */
+int VerifyHashesFromFile(FILE *fp, int status, int warn, int quiet)
+{
+ char hash[PATH_MAX + hashbitlen/4 + 4];
+ char MsgDigest_tmp[hashbitlen/2];
+ int NoMatch = 0, NotProper = 0, Computed = 0;
+ int line = 0;
+
+ while (fgets(hash, sizeof(hash)-1, fp))
+ {
+ char file_tmp[PATH_MAX];
+ line ++;
+ Computed++;
+ int hashVersion = decomposeHashLine(hash,MsgDigest_tmp,file_tmp);
+ if (hashVersion == -1)
+ {
+ WARN("%s is using newer version of skein%d algorithm\n"
+ "You should update your algorithm\n",
+ file_tmp, hashbitlen);
+ continue;
+ }
+ else if (hashVersion == 0)
+ {
+ WARN("%s is using an older version of skein%d algorithm\n"
+ "You should use the older algorithm\n",
+ file_tmp, hashbitlen);
+ continue;
+ }
+ else if (!isProper(MsgDigest_tmp))
+ {
+ if(status != 1 && warn == 1)
+ WARN("%s: %d: improperly formatted skein%d checksum line\n",file_tmp,line,hashbitlen);
+ NotProper ++;
+ NoMatch ++;
+ }
+ else if (HashMatch(MsgDigest_tmp, file_tmp, quiet) <= 0)
+ {
+ NoMatch++;
+ }
+ }
+ if(NoMatch)
+ {
+ WARN("WARNING: %d of %d computed checksums did NOT match\n",
+ NoMatch, Computed);
+ }
+ if(NotProper)
+ {
+ WARN("WARNING: %d line is improperly formatted\n", NotProper);
+ }
+ return (NotProper || NoMatch) ? -1 : 1;
+}
+
+void PrintStringHash(const char *s)
+{
+ unsigned char output[hashbitlen/4];
+ char digest[hashbitlen/4 + 1];
+ Hash(hashbitlen, s, strlen(s) * 8, output);
+ hash2hexstr(output, digest);
+ printf("%s -%s\n", digest, s);
+}
+