1*10500SHai-May.Chao@Sun.COM /* 2*10500SHai-May.Chao@Sun.COM * CDDL HEADER START 3*10500SHai-May.Chao@Sun.COM * 4*10500SHai-May.Chao@Sun.COM * The contents of this file are subject to the terms of the 5*10500SHai-May.Chao@Sun.COM * Common Development and Distribution License (the "License"). 6*10500SHai-May.Chao@Sun.COM * You may not use this file except in compliance with the License. 7*10500SHai-May.Chao@Sun.COM * 8*10500SHai-May.Chao@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*10500SHai-May.Chao@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*10500SHai-May.Chao@Sun.COM * See the License for the specific language governing permissions 11*10500SHai-May.Chao@Sun.COM * and limitations under the License. 12*10500SHai-May.Chao@Sun.COM * 13*10500SHai-May.Chao@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*10500SHai-May.Chao@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*10500SHai-May.Chao@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*10500SHai-May.Chao@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*10500SHai-May.Chao@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*10500SHai-May.Chao@Sun.COM * 19*10500SHai-May.Chao@Sun.COM * CDDL HEADER END 20*10500SHai-May.Chao@Sun.COM */ 21*10500SHai-May.Chao@Sun.COM /* 22*10500SHai-May.Chao@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*10500SHai-May.Chao@Sun.COM * Use is subject to license terms. 24*10500SHai-May.Chao@Sun.COM */ 25*10500SHai-May.Chao@Sun.COM 26*10500SHai-May.Chao@Sun.COM #ifndef _SHA2_IMPL_H 27*10500SHai-May.Chao@Sun.COM #define _SHA2_IMPL_H 28*10500SHai-May.Chao@Sun.COM 29*10500SHai-May.Chao@Sun.COM #ifdef __cplusplus 30*10500SHai-May.Chao@Sun.COM extern "C" { 31*10500SHai-May.Chao@Sun.COM #endif 32*10500SHai-May.Chao@Sun.COM 33*10500SHai-May.Chao@Sun.COM #include <fips/fips_post.h> 34*10500SHai-May.Chao@Sun.COM 35*10500SHai-May.Chao@Sun.COM typedef enum { 36*10500SHai-May.Chao@Sun.COM SHA1_TYPE, 37*10500SHai-May.Chao@Sun.COM SHA256_TYPE, 38*10500SHai-May.Chao@Sun.COM SHA384_TYPE, 39*10500SHai-May.Chao@Sun.COM SHA512_TYPE 40*10500SHai-May.Chao@Sun.COM } sha2_mech_t; 41*10500SHai-May.Chao@Sun.COM 42*10500SHai-May.Chao@Sun.COM #ifdef _KERNEL 43*10500SHai-May.Chao@Sun.COM 44*10500SHai-May.Chao@Sun.COM /* 45*10500SHai-May.Chao@Sun.COM * Context for SHA2 mechanism. 46*10500SHai-May.Chao@Sun.COM */ 47*10500SHai-May.Chao@Sun.COM typedef struct sha2_ctx { 48*10500SHai-May.Chao@Sun.COM sha2_mech_type_t sc_mech_type; /* type of context */ 49*10500SHai-May.Chao@Sun.COM SHA2_CTX sc_sha2_ctx; /* SHA2 context */ 50*10500SHai-May.Chao@Sun.COM } sha2_ctx_t; 51*10500SHai-May.Chao@Sun.COM 52*10500SHai-May.Chao@Sun.COM /* 53*10500SHai-May.Chao@Sun.COM * Context for SHA2 HMAC and HMAC GENERAL mechanisms. 54*10500SHai-May.Chao@Sun.COM */ 55*10500SHai-May.Chao@Sun.COM typedef struct sha2_hmac_ctx { 56*10500SHai-May.Chao@Sun.COM sha2_mech_type_t hc_mech_type; /* type of context */ 57*10500SHai-May.Chao@Sun.COM uint32_t hc_digest_len; /* digest len in bytes */ 58*10500SHai-May.Chao@Sun.COM SHA2_CTX hc_icontext; /* inner SHA2 context */ 59*10500SHai-May.Chao@Sun.COM SHA2_CTX hc_ocontext; /* outer SHA2 context */ 60*10500SHai-May.Chao@Sun.COM } sha2_hmac_ctx_t; 61*10500SHai-May.Chao@Sun.COM 62*10500SHai-May.Chao@Sun.COM #endif 63*10500SHai-May.Chao@Sun.COM 64*10500SHai-May.Chao@Sun.COM extern int fips_sha2_post(void); 65*10500SHai-May.Chao@Sun.COM extern int fips_sha2_hash(SHA2_CTX *, uchar_t *, ulong_t, uchar_t *); 66*10500SHai-May.Chao@Sun.COM 67*10500SHai-May.Chao@Sun.COM #ifndef _KERNEL 68*10500SHai-May.Chao@Sun.COM /* SHA2 funtions */ 69*10500SHai-May.Chao@Sun.COM extern SHA2_CTX *fips_sha2_build_context(CK_MECHANISM_TYPE); 70*10500SHai-May.Chao@Sun.COM 71*10500SHai-May.Chao@Sun.COM /* SHA2 HMAC functions */ 72*10500SHai-May.Chao@Sun.COM extern soft_hmac_ctx_t *fips_sha2_hmac_build_context(CK_MECHANISM_TYPE, 73*10500SHai-May.Chao@Sun.COM uint8_t *, unsigned int); 74*10500SHai-May.Chao@Sun.COM extern CK_RV fips_hmac_sha2_hash(unsigned char *, uint8_t *, 75*10500SHai-May.Chao@Sun.COM unsigned int, uint8_t *, unsigned int, CK_MECHANISM_TYPE); 76*10500SHai-May.Chao@Sun.COM #else 77*10500SHai-May.Chao@Sun.COM 78*10500SHai-May.Chao@Sun.COM extern SHA2_CTX *fips_sha2_build_context(sha2_mech_t); 79*10500SHai-May.Chao@Sun.COM extern sha2_hmac_ctx_t *fips_sha2_hmac_build_context(sha2_mech_t, 80*10500SHai-May.Chao@Sun.COM uint8_t *, unsigned int); 81*10500SHai-May.Chao@Sun.COM extern void fips_hmac_sha2_hash(sha2_hmac_ctx_t *, uint8_t *, uint32_t, 82*10500SHai-May.Chao@Sun.COM uint8_t *, sha2_mech_t); 83*10500SHai-May.Chao@Sun.COM #endif 84*10500SHai-May.Chao@Sun.COM 85*10500SHai-May.Chao@Sun.COM #ifdef __cplusplus 86*10500SHai-May.Chao@Sun.COM } 87*10500SHai-May.Chao@Sun.COM #endif 88*10500SHai-May.Chao@Sun.COM 89*10500SHai-May.Chao@Sun.COM #endif /* _SHA2_IMPL_H */ 90