File: sha256.h

package info (click to toggle)
erofs-utils 1.9-2
  • links: PTS
  • area: main
  • in suites:
  • size: 1,392 kB
  • sloc: ansic: 28,406; makefile: 203; sh: 33
file content (29 lines) | stat: -rw-r--r-- 699 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
#ifndef __EROFS_LIB_SHA256_H
#define __EROFS_LIB_SHA256_H

#include "erofs/defs.h"

#if defined(HAVE_OPENSSL) && defined(HAVE_OPENSSL_EVP_H)
#include <openssl/evp.h>
struct sha256_state {
	EVP_MD_CTX *ctx;
};
#define __USE_OPENSSL_SHA256
#else
struct sha256_state {
	u64 length;
	u32 state[8], curlen;
	u8 buf[64];
};
#endif

void erofs_sha256_init(struct sha256_state *md);
int erofs_sha256_process(struct sha256_state *md,
		const unsigned char *in, unsigned long inlen);
int erofs_sha256_done(struct sha256_state *md, unsigned char *out);

void erofs_sha256(const unsigned char *in, unsigned long in_size,
		  unsigned char out[32]);

#endif