1 /*
2 * Special version of sha256.c that uses the libc SHA256 implementation
3 * of libc.
4 */
5
6 /* crypto/sha/sha256.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
SHA224(const unsigned char * d,size_t n,unsigned char * md)23 unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md)
24 {
25 SHA256_CTX c;
26 static unsigned char m[SHA224_DIGEST_LENGTH];
27
28 if (md == NULL) md=m;
29 SHA224_Init(&c);
30 SHA224_Update(&c,d,n);
31 SHA224_Final(md,&c);
32 OPENSSL_cleanse(&c,sizeof(c));
33 return(md);
34 }
35
SHA256(const unsigned char * d,size_t n,unsigned char * md)36 unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md)
37 {
38 SHA256_CTX c;
39 static unsigned char m[SHA256_DIGEST_LENGTH];
40
41 if (md == NULL) md=m;
42 SHA256_Init(&c);
43 SHA256_Update(&c,d,n);
44 SHA256_Final(md,&c);
45 OPENSSL_cleanse(&c,sizeof(c));
46 return(md);
47 }
48