Add warning for external consumers of dmu_tx_callback_register
[zfs.git] / include / sys / sha2.h
blobb344eb9d5ff2563d95358b5114cd4c958499eaa0
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
26 #ifndef _SYS_SHA2_H
27 #define _SYS_SHA2_H
29 #ifdef _KERNEL
30 #include <sys/types.h>
31 #else
32 #include <stdint.h>
33 #include <stdlib.h>
34 #endif
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #define SHA224_BLOCK_LENGTH 64
41 #define SHA256_BLOCK_LENGTH 64
42 #define SHA384_BLOCK_LENGTH 128
43 #define SHA512_BLOCK_LENGTH 128
45 #define SHA224_DIGEST_LENGTH 28
46 #define SHA256_DIGEST_LENGTH 32
47 #define SHA384_DIGEST_LENGTH 48
48 #define SHA512_DIGEST_LENGTH 64
50 #define SHA512_224_DIGEST_LENGTH 28
51 #define SHA512_256_DIGEST_LENGTH 32
53 #define SHA256_HMAC_BLOCK_SIZE 64
54 #define SHA512_HMAC_BLOCK_SIZE 128
56 /* sha256 context */
57 typedef struct {
58 uint32_t state[8];
59 uint64_t count[2];
60 uint8_t wbuf[64];
62 /* const sha256_ops_t *ops */
63 const void *ops;
64 } sha256_ctx;
66 /* sha512 context */
67 typedef struct {
68 uint64_t state[8];
69 uint64_t count[2];
70 uint8_t wbuf[128];
72 /* const sha256_ops_t *ops */
73 const void *ops;
74 } sha512_ctx;
76 /* SHA2 context */
77 typedef struct {
78 union {
79 sha256_ctx sha256;
80 sha512_ctx sha512;
83 /* algorithm type */
84 int algotype;
85 } SHA2_CTX;
87 /* SHA2 algorithm types */
88 typedef enum sha2_mech_type {
89 SHA512_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA512_HMAC */
91 /* Not true KCF mech types; used by direct callers to SHA2Init */
92 SHA256,
93 SHA512,
94 SHA512_256,
95 } sha2_mech_type_t;
97 /* SHA2 Init function */
98 extern void SHA2Init(int algotype, SHA2_CTX *ctx);
100 /* SHA2 Update function */
101 extern void SHA2Update(SHA2_CTX *ctx, const void *data, size_t len);
103 /* SHA2 Final function */
104 extern void SHA2Final(void *digest, SHA2_CTX *ctx);
106 #ifdef __cplusplus
108 #endif
110 #endif /* SYS_SHA2_H */