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 _SHA1_IMPL_H 27*10500SHai-May.Chao@Sun.COM #define _SHA1_IMPL_H 28*10500SHai-May.Chao@Sun.COM 29*10500SHai-May.Chao@Sun.COM 30*10500SHai-May.Chao@Sun.COM #ifdef __cplusplus 31*10500SHai-May.Chao@Sun.COM extern "C" { 32*10500SHai-May.Chao@Sun.COM #endif 33*10500SHai-May.Chao@Sun.COM 34*10500SHai-May.Chao@Sun.COM #include <fips/fips_post.h> 35*10500SHai-May.Chao@Sun.COM 36*10500SHai-May.Chao@Sun.COM #ifdef _KERNEL 37*10500SHai-May.Chao@Sun.COM #define SHA1_HASH_SIZE 20 /* SHA_1 digest length in bytes */ 38*10500SHai-May.Chao@Sun.COM #define SHA1_DIGEST_LENGTH 20 /* SHA1 digest length in bytes */ 39*10500SHai-May.Chao@Sun.COM #define SHA1_HMAC_BLOCK_SIZE 64 /* SHA1-HMAC block size */ 40*10500SHai-May.Chao@Sun.COM #define SHA1_HMAC_MIN_KEY_LEN 1 /* SHA1-HMAC min key length in bytes */ 41*10500SHai-May.Chao@Sun.COM #define SHA1_HMAC_MAX_KEY_LEN INT_MAX /* SHA1-HMAC max key length in bytes */ 42*10500SHai-May.Chao@Sun.COM #define SHA1_HMAC_INTS_PER_BLOCK (SHA1_HMAC_BLOCK_SIZE/sizeof (uint32_t)) 43*10500SHai-May.Chao@Sun.COM 44*10500SHai-May.Chao@Sun.COM /* 45*10500SHai-May.Chao@Sun.COM * CSPI information (entry points, provider info, etc.) 46*10500SHai-May.Chao@Sun.COM */ 47*10500SHai-May.Chao@Sun.COM typedef enum sha1_mech_type { 48*10500SHai-May.Chao@Sun.COM SHA1_MECH_INFO_TYPE, /* SUN_CKM_SHA1 */ 49*10500SHai-May.Chao@Sun.COM SHA1_HMAC_MECH_INFO_TYPE, /* SUN_CKM_SHA1_HMAC */ 50*10500SHai-May.Chao@Sun.COM SHA1_HMAC_GEN_MECH_INFO_TYPE /* SUN_CKM_SHA1_HMAC_GENERAL */ 51*10500SHai-May.Chao@Sun.COM } sha1_mech_type_t; 52*10500SHai-May.Chao@Sun.COM 53*10500SHai-May.Chao@Sun.COM /* 54*10500SHai-May.Chao@Sun.COM * Context for SHA1 mechanism. 55*10500SHai-May.Chao@Sun.COM */ 56*10500SHai-May.Chao@Sun.COM typedef struct sha1_ctx { 57*10500SHai-May.Chao@Sun.COM sha1_mech_type_t sc_mech_type; /* type of context */ 58*10500SHai-May.Chao@Sun.COM SHA1_CTX sc_sha1_ctx; /* SHA1 context */ 59*10500SHai-May.Chao@Sun.COM } sha1_ctx_t; 60*10500SHai-May.Chao@Sun.COM 61*10500SHai-May.Chao@Sun.COM /* 62*10500SHai-May.Chao@Sun.COM * Context for SHA1-HMAC and SHA1-HMAC-GENERAL mechanisms. 63*10500SHai-May.Chao@Sun.COM */ 64*10500SHai-May.Chao@Sun.COM typedef struct sha1_hmac_ctx { 65*10500SHai-May.Chao@Sun.COM sha1_mech_type_t hc_mech_type; /* type of context */ 66*10500SHai-May.Chao@Sun.COM uint32_t hc_digest_len; /* digest len in bytes */ 67*10500SHai-May.Chao@Sun.COM SHA1_CTX hc_icontext; /* inner SHA1 context */ 68*10500SHai-May.Chao@Sun.COM SHA1_CTX hc_ocontext; /* outer SHA1 context */ 69*10500SHai-May.Chao@Sun.COM } sha1_hmac_ctx_t; 70*10500SHai-May.Chao@Sun.COM 71*10500SHai-May.Chao@Sun.COM #endif 72*10500SHai-May.Chao@Sun.COM 73*10500SHai-May.Chao@Sun.COM extern int fips_sha1_post(void); 74*10500SHai-May.Chao@Sun.COM 75*10500SHai-May.Chao@Sun.COM /* SHA1 funtions */ 76*10500SHai-May.Chao@Sun.COM extern SHA1_CTX *fips_sha1_build_context(void); 77*10500SHai-May.Chao@Sun.COM extern int fips_sha1_hash(SHA1_CTX *, uchar_t *, ulong_t, uchar_t *); 78*10500SHai-May.Chao@Sun.COM 79*10500SHai-May.Chao@Sun.COM /* SHA1 HMAC functions */ 80*10500SHai-May.Chao@Sun.COM #ifndef _KERNEL 81*10500SHai-May.Chao@Sun.COM extern soft_hmac_ctx_t *fips_sha1_hmac_build_context(uint8_t *, 82*10500SHai-May.Chao@Sun.COM unsigned int); 83*10500SHai-May.Chao@Sun.COM extern CK_RV fips_hmac_sha1_hash(unsigned char *, uint8_t *, 84*10500SHai-May.Chao@Sun.COM unsigned int, uint8_t *, unsigned int); 85*10500SHai-May.Chao@Sun.COM #else 86*10500SHai-May.Chao@Sun.COM extern sha1_hmac_ctx_t *fips_sha1_hmac_build_context(uint8_t *, 87*10500SHai-May.Chao@Sun.COM unsigned int); 88*10500SHai-May.Chao@Sun.COM extern void fips_hmac_sha1_hash(sha1_hmac_ctx_t *, uint8_t *, 89*10500SHai-May.Chao@Sun.COM uint32_t, uint8_t *); 90*10500SHai-May.Chao@Sun.COM #endif 91*10500SHai-May.Chao@Sun.COM 92*10500SHai-May.Chao@Sun.COM #ifdef __cplusplus 93*10500SHai-May.Chao@Sun.COM } 94*10500SHai-May.Chao@Sun.COM #endif 95*10500SHai-May.Chao@Sun.COM 96*10500SHai-May.Chao@Sun.COM #endif /* _SHA1_IMPL_H */ 97