Option to set current cert to server certificate.
[openssl.git] / crypto / sha / sha1_one.c
index cf381fa39386a5db80691a8c3b297cc0635206e9..c56ec94020e180600f534e68c3402839ca330a79 100644 (file)
@@ -1,5 +1,5 @@
 /* crypto/sha/sha1_one.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
  */
 
 #include <stdio.h>
-#include "cryptlib.h"
-#include "sha.h"
+#include <string.h>
+#include <openssl/crypto.h>
+#include <openssl/sha.h>
 
-unsigned char *SHA1(d, n, md)
-unsigned char *d;
-unsigned long n;
-unsigned char *md;
+#ifndef OPENSSL_NO_SHA1
+unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)
        {
        SHA_CTX c;
        static unsigned char m[SHA_DIGEST_LENGTH];
 
        if (md == NULL) md=m;
-       SHA1_Init(&c);
+       if (!SHA1_Init(&c))
+               return NULL;
        SHA1_Update(&c,d,n);
        SHA1_Final(md,&c);
-       memset(&c,0,sizeof(c));
+       OPENSSL_cleanse(&c,sizeof(c));
        return(md);
        }
+#endif