xref: /third_party/FreeBSD/sys/crypto/sha2/sha256.h (revision f9f848fa)
1f9f848faSopenharmony_ci/*-
2f9f848faSopenharmony_ci * Copyright 2005 Colin Percival
3f9f848faSopenharmony_ci * All rights reserved.
4f9f848faSopenharmony_ci *
5f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without
6f9f848faSopenharmony_ci * modification, are permitted provided that the following conditions
7f9f848faSopenharmony_ci * are met:
8f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright
9f9f848faSopenharmony_ci *    notice, this list of conditions and the following disclaimer.
10f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
11f9f848faSopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
12f9f848faSopenharmony_ci *    documentation and/or other materials provided with the distribution.
13f9f848faSopenharmony_ci *
14f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15f9f848faSopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16f9f848faSopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17f9f848faSopenharmony_ci * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18f9f848faSopenharmony_ci * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19f9f848faSopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20f9f848faSopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21f9f848faSopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22f9f848faSopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23f9f848faSopenharmony_ci * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24f9f848faSopenharmony_ci * SUCH DAMAGE.
25f9f848faSopenharmony_ci */
26f9f848faSopenharmony_ci
27f9f848faSopenharmony_ci#ifndef _SHA256_H_
28f9f848faSopenharmony_ci#define _SHA256_H_
29f9f848faSopenharmony_ci
30f9f848faSopenharmony_ci#ifndef _KERNEL
31f9f848faSopenharmony_ci#include <sys/types.h>
32f9f848faSopenharmony_ci#endif
33f9f848faSopenharmony_ci
34f9f848faSopenharmony_ci#define SHA256_BLOCK_LENGTH		64
35f9f848faSopenharmony_ci#define SHA256_DIGEST_LENGTH		32
36f9f848faSopenharmony_ci#define SHA256_DIGEST_STRING_LENGTH	(SHA256_DIGEST_LENGTH * 2 + 1)
37f9f848faSopenharmony_ci
38f9f848faSopenharmony_citypedef struct SHA256Context {
39f9f848faSopenharmony_ci	uint32_t state[8];
40f9f848faSopenharmony_ci	uint64_t count;
41f9f848faSopenharmony_ci	uint8_t buf[SHA256_BLOCK_LENGTH];
42f9f848faSopenharmony_ci} SHA256_CTX;
43f9f848faSopenharmony_ci
44f9f848faSopenharmony_ci__BEGIN_DECLS
45f9f848faSopenharmony_ci
46f9f848faSopenharmony_ci/* Ensure libmd symbols do not clash with libcrypto */
47f9f848faSopenharmony_ci
48f9f848faSopenharmony_ci#ifndef SHA256_Init
49f9f848faSopenharmony_ci#define SHA256_Init		_libmd_SHA256_Init
50f9f848faSopenharmony_ci#endif
51f9f848faSopenharmony_ci#ifndef SHA256_Update
52f9f848faSopenharmony_ci#define SHA256_Update		_libmd_SHA256_Update
53f9f848faSopenharmony_ci#endif
54f9f848faSopenharmony_ci#ifndef SHA256_Final
55f9f848faSopenharmony_ci#define SHA256_Final		_libmd_SHA256_Final
56f9f848faSopenharmony_ci#endif
57f9f848faSopenharmony_ci#ifndef SHA256_End
58f9f848faSopenharmony_ci#define SHA256_End		_libmd_SHA256_End
59f9f848faSopenharmony_ci#endif
60f9f848faSopenharmony_ci#ifndef SHA256_Fd
61f9f848faSopenharmony_ci#define SHA256_Fd		_libmd_SHA256_Fd
62f9f848faSopenharmony_ci#endif
63f9f848faSopenharmony_ci#ifndef SHA256_FdChunk
64f9f848faSopenharmony_ci#define SHA256_FdChunk		_libmd_SHA256_FdChunk
65f9f848faSopenharmony_ci#endif
66f9f848faSopenharmony_ci#ifndef SHA256_File
67f9f848faSopenharmony_ci#define SHA256_File		_libmd_SHA256_File
68f9f848faSopenharmony_ci#endif
69f9f848faSopenharmony_ci#ifndef SHA256_FileChunk
70f9f848faSopenharmony_ci#define SHA256_FileChunk	_libmd_SHA256_FileChunk
71f9f848faSopenharmony_ci#endif
72f9f848faSopenharmony_ci#ifndef SHA256_Data
73f9f848faSopenharmony_ci#define SHA256_Data		_libmd_SHA256_Data
74f9f848faSopenharmony_ci#endif
75f9f848faSopenharmony_ci
76f9f848faSopenharmony_ci#ifndef SHA256_Transform
77f9f848faSopenharmony_ci#define SHA256_Transform	_libmd_SHA256_Transform
78f9f848faSopenharmony_ci#endif
79f9f848faSopenharmony_ci#ifndef SHA256_version
80f9f848faSopenharmony_ci#define SHA256_version		_libmd_SHA256_version
81f9f848faSopenharmony_ci#endif
82f9f848faSopenharmony_ci
83f9f848faSopenharmony_civoid	SHA256_Init(SHA256_CTX *);
84f9f848faSopenharmony_civoid	SHA256_Update(SHA256_CTX *, const void *, size_t);
85f9f848faSopenharmony_civoid	SHA256_Final(unsigned char [__min_size(SHA256_DIGEST_LENGTH)],
86f9f848faSopenharmony_ci    SHA256_CTX *);
87f9f848faSopenharmony_ci#ifndef _KERNEL
88f9f848faSopenharmony_cichar   *SHA256_End(SHA256_CTX *, char *);
89f9f848faSopenharmony_cichar   *SHA256_Data(const void *, unsigned int, char *);
90f9f848faSopenharmony_cichar   *SHA256_Fd(int, char *);
91f9f848faSopenharmony_cichar   *SHA256_FdChunk(int, char *, off_t, off_t);
92f9f848faSopenharmony_cichar   *SHA256_File(const char *, char *);
93f9f848faSopenharmony_cichar   *SHA256_FileChunk(const char *, char *, off_t, off_t);
94f9f848faSopenharmony_ci#endif
95f9f848faSopenharmony_ci__END_DECLS
96f9f848faSopenharmony_ci
97f9f848faSopenharmony_ci#endif /* !_SHA256_H_ */
98