X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fos_crypto%2Fsha1%2Fsha1_op.c;fp=src%2Fos_crypto%2Fsha1%2Fsha1_op.c;h=85a3a70fa999ec2478fc4f216e87c1a41e19b4e7;hp=99d74ec7c4e345efb5b00ef6d9eaa102fbfb85c4;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b diff --git a/src/os_crypto/sha1/sha1_op.c b/src/os_crypto/sha1/sha1_op.c old mode 100755 new mode 100644 index 99d74ec..85a3a70 --- a/src/os_crypto/sha1/sha1_op.c +++ b/src/os_crypto/sha1/sha1_op.c @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/os_crypto/sha1/sha1_op.c, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * @@ -10,14 +7,15 @@ * Foundation */ - #include #include + #include "sha1_op.h" +#include "headers/defs.h" -/* Openssl sha1 - * Only use if open ssl is not available. -#ifndef USE_OPENSSL +/* OpenSSL SHA-1 + * Only use if OpenSSL is not available +#ifndef LIBOPENSSL_ENABLED #include "sha.h" #include "sha_locl.h" #else @@ -28,42 +26,36 @@ #include "sha_locl.h" - -int OS_SHA1_File(char * fname, char * output) +int OS_SHA1_File(const char *fname, os_sha1 output, int mode) { SHA_CTX c; FILE *fp; - unsigned char buf[2048 +2]; + unsigned char buf[2048 + 2]; unsigned char md[SHA_DIGEST_LENGTH]; - int n; + size_t n; - memset(output,0, 65); + memset(output, 0, 65); buf[2049] = '\0'; - fp = fopen(fname,"r"); - if(!fp) - return(-1); + fp = fopen(fname, mode == OS_BINARY ? "rb" : "r"); + if (!fp) { + return (-1); + } SHA1_Init(&c); - while((n = fread(buf, 1, 2048, fp)) > 0) - { + while ((n = fread(buf, 1, 2048, fp)) > 0) { buf[n] = '\0'; - SHA1_Update(&c,buf,(unsigned long)n); + SHA1_Update(&c, buf, n); } - SHA1_Final(&(md[0]),&c); + SHA1_Final(&(md[0]), &c); - for (n=0; n