1 /* @(#) $Id: ./src/os_crypto/sha1/sha1_op.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
19 * Only use if open ssl is not available.
24 #include <openssl/sha.h>
32 int OS_SHA1_File(char * fname, char * output)
36 unsigned char buf[2048 +2];
37 unsigned char md[SHA_DIGEST_LENGTH];
43 fp = fopen(fname,"r");
48 while((n = fread(buf, 1, 2048, fp)) > 0)
51 SHA1_Update(&c,buf,(unsigned long)n);
54 SHA1_Final(&(md[0]),&c);
56 for (n=0; n<SHA_DIGEST_LENGTH; n++)
58 snprintf(output, 3, "%02x", md[n]);