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