3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
18 * Only use if open ssl is not available.
23 #include <openssl/sha.h>
31 int OS_SHA1_File(char * fname, char * output)
35 unsigned char buf[2048 +2];
36 unsigned char md[SHA_DIGEST_LENGTH];
42 fp = fopen(fname,"r");
47 while((n = fread(buf, 1, 2048, fp)) > 0)
50 SHA1_Update(&c,buf,(unsigned long)n);
53 SHA1_Final(&(md[0]),&c);
55 for (n=0; n<SHA_DIGEST_LENGTH; n++)
57 snprintf(output, 3, "%02x", md[n]);