Home | History | Annotate | Line # | Download | only in libcrypto
      1      1.1  christos /*
      2      1.1  christos  * Special version of sha256.c that uses the libc SHA256 implementation
      3      1.1  christos  * of libc.
      4      1.1  christos  */
      5      1.1  christos 
      6      1.1  christos /* crypto/sha/sha256.c */
      7      1.1  christos /* ====================================================================
      8      1.1  christos  * Copyright (c) 2004 The OpenSSL Project.  All rights reserved
      9      1.1  christos  * according to the OpenSSL license [found in ../../LICENSE].
     10      1.1  christos  * ====================================================================
     11      1.1  christos  */
     12      1.1  christos #include <openssl/opensslconf.h>
     13      1.1  christos 
     14      1.1  christos #include <stdlib.h>
     15      1.1  christos #include <string.h>
     16      1.1  christos 
     17      1.1  christos #include <openssl/crypto.h>
     18      1.1  christos #include <openssl/sha.h>
     19      1.1  christos #include <openssl/opensslv.h>
     20      1.1  christos 
     21  1.1.1.2  christos #include "internal/cryptlib.h"
     22      1.1  christos 
     23      1.1  christos unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md)
     24      1.1  christos 	{
     25      1.1  christos 	SHA256_CTX c;
     26      1.1  christos 	static unsigned char m[SHA224_DIGEST_LENGTH];
     27      1.1  christos 
     28      1.1  christos 	if (md == NULL) md=m;
     29      1.1  christos 	SHA224_Init(&c);
     30      1.1  christos 	SHA224_Update(&c,d,n);
     31      1.1  christos 	SHA224_Final(md,&c);
     32      1.1  christos 	OPENSSL_cleanse(&c,sizeof(c));
     33      1.1  christos 	return(md);
     34      1.1  christos 	}
     35      1.1  christos 
     36      1.1  christos unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md)
     37      1.1  christos 	{
     38      1.1  christos 	SHA256_CTX c;
     39      1.1  christos 	static unsigned char m[SHA256_DIGEST_LENGTH];
     40      1.1  christos 
     41      1.1  christos 	if (md == NULL) md=m;
     42      1.1  christos 	SHA256_Init(&c);
     43      1.1  christos 	SHA256_Update(&c,d,n);
     44      1.1  christos 	SHA256_Final(md,&c);
     45      1.1  christos 	OPENSSL_cleanse(&c,sizeof(c));
     46      1.1  christos 	return(md);
     47      1.1  christos 	}
     48