1 /* 2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 #pragma ident "%Z%%M% %I% %E% SMI" 7 8 /* 9 * Copyright (C) 1998 by the FundsXpress, INC. 10 * 11 * All rights reserved. 12 * 13 * Export of this software from the United States of America may require 14 * a specific license from the United States Government. It is the 15 * responsibility of any person or organization contemplating export to 16 * obtain such a license before exporting. 17 * 18 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 19 * distribute this software and its documentation for any purpose and 20 * without fee is hereby granted, provided that the above copyright 21 * notice appear in all copies and that both that copyright notice and 22 * this permission notice appear in supporting documentation, and that 23 * the name of FundsXpress. not be used in advertising or publicity pertaining 24 * to distribution of the software without specific, written prior 25 * permission. FundsXpress makes no representations about the suitability of 26 * this software for any purpose. It is provided "as is" without express 27 * or implied warranty. 28 * 29 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 30 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 31 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 32 */ 33 34 /* Solaris Kerberos: 35 * this code is based on the 36 * usr/src/lib/gss_mechs/mech_krb5/crypto/hash_provider/hash_sha1.c 37 * file, but has been modified to use the Solaris resident sha1.o kernel 38 * module and associated header /usr/include/sys/sha1.h. 39 * This means that the SHA1* functions are called instead of shs*. 40 */ 41 42 #include <k5-int.h> 43 #include <hash_provider.h> 44 #include <sys/crypto/api.h> 45 46 static void 47 k5_sha1_hash_size(size_t *output) 48 { 49 KRB5_LOG0(KRB5_INFO, "k5_sha1_hash_size() start"); 50 *output = SHS_DIGESTSIZE; 51 } 52 53 static void 54 k5_sha1_block_size(size_t *output) 55 { 56 KRB5_LOG0(KRB5_INFO, "k5_sha1_block_size() start"); 57 *output = SHS_DATASIZE; 58 } 59 60 static krb5_error_code 61 k5_sha1_hash(krb5_context context, 62 unsigned int icount, krb5_const krb5_data *input, 63 krb5_data *output) 64 { 65 krb5_error_code ret = 0; 66 67 KRB5_LOG0(KRB5_INFO, "k5_sha1_hash() start"); 68 69 if (output->length != SHS_DIGESTSIZE) { 70 KRB5_LOG1(KRB5_ERR, "k5_sha1_hash() end error " 71 "output->length(%d) != SHS_DIGESTSIZE(%d)", 72 output->length, SHS_DIGESTSIZE); 73 return(KRB5_CRYPTO_INTERNAL); 74 } 75 76 if (k5_ef_hash(context, icount, input, output)) 77 ret = KRB5_KEF_ERROR; 78 79 KRB5_LOG0(KRB5_INFO, "k5_sha1_hash() end"); 80 return(ret); 81 } 82 83 const struct krb5_hash_provider krb5_hash_sha1 = { 84 k5_sha1_hash_size, 85 k5_sha1_block_size, 86 k5_sha1_hash 87 }; 88