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]
23 * Copyright (c) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
30 #include <sys/types.h>
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
62 /* const sha256_ops_t *ops */
72 /* const sha256_ops_t *ops */
87 /* SHA2 algorithm types */
88 typedef enum sha2_mech_type
{
89 SHA256_MECH_INFO_TYPE
, /* SUN_CKM_SHA256 */
90 SHA256_HMAC_MECH_INFO_TYPE
, /* SUN_CKM_SHA256_HMAC */
91 SHA256_HMAC_GEN_MECH_INFO_TYPE
, /* SUN_CKM_SHA256_HMAC_GENERAL */
92 SHA384_MECH_INFO_TYPE
, /* SUN_CKM_SHA384 */
93 SHA384_HMAC_MECH_INFO_TYPE
, /* SUN_CKM_SHA384_HMAC */
94 SHA384_HMAC_GEN_MECH_INFO_TYPE
, /* SUN_CKM_SHA384_HMAC_GENERAL */
95 SHA512_MECH_INFO_TYPE
, /* SUN_CKM_SHA512 */
96 SHA512_HMAC_MECH_INFO_TYPE
, /* SUN_CKM_SHA512_HMAC */
97 SHA512_HMAC_GEN_MECH_INFO_TYPE
, /* SUN_CKM_SHA512_HMAC_GENERAL */
98 SHA512_224_MECH_INFO_TYPE
, /* SUN_CKM_SHA512_224 */
99 SHA512_256_MECH_INFO_TYPE
/* SUN_CKM_SHA512_256 */
103 #define SHA256_HMAC 1
104 #define SHA256_HMAC_GEN 2
106 #define SHA384_HMAC 4
107 #define SHA384_HMAC_GEN 5
109 #define SHA512_HMAC 7
110 #define SHA512_HMAC_GEN 8
112 #define SHA512_256 10
114 /* SHA2 Init function */
115 extern void SHA2Init(int algotype
, SHA2_CTX
*ctx
);
117 /* SHA2 Update function */
118 extern void SHA2Update(SHA2_CTX
*ctx
, const void *data
, size_t len
);
120 /* SHA2 Final function */
121 extern void SHA2Final(void *digest
, SHA2_CTX
*ctx
);
127 #endif /* SYS_SHA2_H */