1 /*
2 * Special version of sha512.c that uses the libc SHA512 implementation
3 * of libc.
4 */
5
6 /* crypto/sha/sha512.c */
7 /* ====================================================================
8 * Copyright (c) 2004 The OpenSSL Project. All rights reserved
9 * according to the OpenSSL license [found in ../../LICENSE].
10 * ====================================================================
11 */
12 #include <openssl/opensslconf.h>
13
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include <openssl/crypto.h>
18 #include <openssl/sha.h>
19 #include <openssl/opensslv.h>
20
21 #include "internal/cryptlib.h"
22
SHA384(const unsigned char * d,size_t n,unsigned char * md)23 unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md)
24 {
25 SHA512_CTX c;
26 static unsigned char m[SHA384_DIGEST_LENGTH];
27
28 if (md == NULL) md=m;
29 SHA384_Init(&c);
30 SHA384_Update(&c, d, n);
31 SHA384_Final(md, &c);
32 OPENSSL_cleanse(&c, sizeof(c));
33 return(md);
34 }
35
SHA512(const unsigned char * d,size_t n,unsigned char * md)36 unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md)
37 {
38 SHA512_CTX c;
39 static unsigned char m[SHA512_DIGEST_LENGTH];
40
41 if (md == NULL) md=m;
42 SHA512_Init(&c);
43 SHA512_Update(&c,d,n);
44 SHA512_Final(md,&c);
45 OPENSSL_cleanse(&c,sizeof(c));
46 return(md);
47 }
48