1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_SHA2_H 28 #define _SYS_SHA2_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/types.h> /* for uint_* */ 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #define SHA256 0 39 #define SHA256_HMAC 1 40 #define SHA256_HMAC_GEN 2 41 #define SHA384 3 42 #define SHA384_HMAC 4 43 #define SHA384_HMAC_GEN 5 44 #define SHA512 6 45 #define SHA512_HMAC 7 46 #define SHA512_HMAC_GEN 8 47 48 /* SHA2 context. */ 49 typedef struct { 50 uint32_t algotype; /* Algorithm Type */ 51 52 /* state (ABCDEFGH) */ 53 union { 54 uint32_t s32[8]; /* for SHA256 */ 55 uint64_t s64[8]; /* for SHA384/512 */ 56 } state; 57 /* number of bits */ 58 union { 59 uint32_t c32[2]; /* for SHA256 , modulo 2^64 */ 60 uint64_t c64[2]; /* for SHA384/512, modulo 2^128 */ 61 } count; 62 union { 63 uint8_t buf8[128]; /* undigested input */ 64 uint32_t buf32[32]; /* realigned input */ 65 uint64_t buf64[16]; /* realigned input */ 66 } buf_un; 67 } SHA2_CTX; 68 69 extern void SHA2Init(uint64_t mech, SHA2_CTX *); 70 71 extern void SHA2Update(SHA2_CTX *, const uint8_t *, uint32_t); 72 73 extern void SHA2Final(uint8_t *, SHA2_CTX *); 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* _SYS_SHA2_H */ 80