diff options
| author | John Kohl <jtkohl@mit.edu> | 1990-04-24 16:07:26 +0000 |
|---|---|---|
| committer | John Kohl <jtkohl@mit.edu> | 1990-04-24 16:07:26 +0000 |
| commit | 561b6bb211e4785bdb4b9ce3ad8b07cc13ec0789 (patch) | |
| tree | 7d9d0cefcf6508b383cd733e4de2ea968872f5a2 /src/lib/crypto | |
| parent | 9da4e4959362490ad5c81cfe8971beb39f4ac8be (diff) | |
| download | krb5-561b6bb211e4785bdb4b9ce3ad8b07cc13ec0789.tar.gz krb5-561b6bb211e4785bdb4b9ce3ad8b07cc13ec0789.tar.xz krb5-561b6bb211e4785bdb4b9ce3ad8b07cc13ec0789.zip | |
fix up for checksum interface
add copyright &such
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@571 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto')
| -rw-r--r-- | src/lib/crypto/crc32/crc.c | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/src/lib/crypto/crc32/crc.c b/src/lib/crypto/crc32/crc.c index 4bc611797..f80e55351 100644 --- a/src/lib/crypto/crc32/crc.c +++ b/src/lib/crypto/crc32/crc.c @@ -1,3 +1,24 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * <krb5/copyright.h>. + * + * CRC-32 routines + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_crc_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include <krb5/copyright.h> +#include <krb5/krb5.h> +#include <krb5/crc-32.h> + static u_long const crc_table[256] = { 0x00000000, 0x01080082, 0x02100104, 0x03180186, 0x04200208, 0x0528028a, 0x0630030c, 0x0738038e, @@ -65,19 +86,38 @@ static u_long const crc_table[256] = { 0xfbe07ff8, 0xfae87f7a, 0xf9f07efc, 0xf8f87e7e }; - -static u_long crc(d) - krb5_data *d; +static krb5_error_code +crc32_sum_func(in, out, seed, in_length, seed_length, outcksum) +krb5_pointer in; +krb5_pointer out; +krb5_pointer seed; +size_t in_length; +size_t seed_length; +krb5_checksum *outcksum; { + register u_char *data = (u_char *)in; register u_long c = 0; register int idx; int i; - for (i=0; i<d->length;i++) { - idx = (d->data[i] ^ c); + for (i=0; i<in_length;i++) { + idx = (data[i] ^ c); idx &= 0xff; c >>= 8; c ^= crc_table[idx]; } - return c; + /* c now holds the result */ + outcksum->checksum_type = CKSUMTYPE_CRC32; + outcksum->length = 4; + outcksum->contents[0] = c & 0xff; + outcksum->contents[1] = (c >> 8) & 0xff; + outcksum->contents[2] = (c >> 16) & 0xff; + outcksum->contents[3] = (c >> 24) & 0xff; + return 0; } + + +krb5_checksum_entry crc32_cksumtable_entry = { + &crc32_sum_func, + 4, /* CRC-32 is 4 octets */ +}; |
