1 /*
2 * Copyright (C) 1998 by the FundsXpress, INC.
3 *
4 * All rights reserved.
5 *
6 * Export of this software from the United States of America may require
7 * a specific license from the United States Government. It is the
8 * responsibility of any person or organization contemplating export to
9 * obtain such a license before exporting.
10 *
11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12 * distribute this software and its documentation for any purpose and
13 * without fee is hereby granted, provided that the above copyright
14 * notice appear in all copies and that both that copyright notice and
15 * this permission notice appear in supporting documentation, and that
16 * the name of FundsXpress. not be used in advertising or publicity pertaining
17 * to distribution of the software without specific, written prior
18 * permission. FundsXpress makes no representations about the suitability of
19 * this software for any purpose. It is provided "as is" without express
20 * or implied warranty.
21 *
22 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
24 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 */
26
27 #include "k5-int.h"
28 #include "crc-32.h"
29 #include "hash_provider.h"
30
31 /* ARGSUSED */
32 static krb5_error_code
k5_crc32_hash(krb5_context context,unsigned int icount,krb5_const krb5_data * input,krb5_data * output)33 k5_crc32_hash(krb5_context context,
34 unsigned int icount, krb5_const krb5_data *input,
35 krb5_data *output)
36 {
37 unsigned long c, cn;
38 int i;
39
40 if (output->length != CRC32_CKSUM_LENGTH)
41 return(KRB5_CRYPTO_INTERNAL);
42
43 c = 0;
44 for (i=0; i<icount; i++) {
45 mit_crc32(input[i].data, input[i].length, &cn);
46 c ^= cn;
47 }
48
49 output->data[0] = c&0xff;
50 output->data[1] = (c>>8)&0xff;
51 output->data[2] = (c>>16)&0xff;
52 output->data[3] = (c>>24)&0xff;
53
54 return(0);
55 }
56
57 const struct krb5_hash_provider krb5int_hash_crc32 = {
58 CRC32_CKSUM_LENGTH,
59 1,
60 k5_crc32_hash
61 };
62