3 *@Article{castagnoli-crc,
4 * author = { Guy Castagnoli and Stefan Braeuer and Martin Herrman},
5 * title = {{Optimization of Cyclic Redundancy-Check Codes with 24
6 * and 32 Parity Bits}},
7 * journal = IEEE Transactions on Communication,
14 * Used by the iSCSI driver, possibly others, and derived from the
15 * the iscsi-crc.c module of the linux-iscsi driver at
16 * http://linux-iscsi.sourceforge.net.
18 * Following the example of lib/crc32, this function is intended to be
19 * flexible and useful for all users. Modules that currently have their
20 * own crc32c, but hopefully may be able to use this one are:
21 * net/sctp (please add all your doco to here if you change to
25 * Copyright (c) 2004 Cisco Systems, Inc.
27 * This program is free software; you can redistribute it and/or modify it
28 * under the terms of the GNU General Public License as published by the Free
29 * Software Foundation; either version 2 of the License, or (at your option)
34 #include <crypto/hash.h>
35 #include <linux/err.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/module.h>
40 static struct crypto_shash
*tfm
;
42 u32
crc32c(u32 crc
, const void *address
, unsigned int length
)
45 struct shash_desc shash
;
46 char ctx
[crypto_shash_descsize(tfm
)];
52 *(u32
*)desc
.ctx
= crc
;
54 err
= crypto_shash_update(&desc
.shash
, address
, length
);
57 return *(u32
*)desc
.ctx
;
60 EXPORT_SYMBOL(crc32c
);
62 static int __init
libcrc32c_mod_init(void)
64 tfm
= crypto_alloc_shash("crc32c", 0, 0);
71 static void __exit
libcrc32c_mod_fini(void)
73 crypto_free_shash(tfm
);
76 module_init(libcrc32c_mod_init
);
77 module_exit(libcrc32c_mod_fini
);
79 MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>");
80 MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations");
81 MODULE_LICENSE("GPL");
This page took 0.035111 seconds and 5 git commands to generate.