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