~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/libcrc32c.c

Version: ~ [ linux-5.15-rc5 ] ~ [ linux-5.14.11 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.72 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.152 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.210 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.250 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.286 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.288 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* 
  2  * CRC32C
  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,
  8  * year =         {1993},
  9  * volume =       {41},
 10  * number =       {6},
 11  * pages =        {},
 12  * month =        {June},
 13  *}
 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.
 17  *
 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
 22  *            use this one!)
 23  *  <endoflist>
 24  *
 25  * Copyright (c) 2004 Cisco Systems, Inc.
 26  * 
 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) 
 30  * any later version.
 31  *
 32  */
 33 
 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>
 39 #include <linux/crc32c.h>
 40 
 41 static struct crypto_shash *tfm;
 42 
 43 u32 crc32c(u32 crc, const void *address, unsigned int length)
 44 {
 45         SHASH_DESC_ON_STACK(shash, tfm);
 46         u32 *ctx = (u32 *)shash_desc_ctx(shash);
 47         int err;
 48 
 49         shash->tfm = tfm;
 50         shash->flags = 0;
 51         *ctx = crc;
 52 
 53         err = crypto_shash_update(shash, address, length);
 54         BUG_ON(err);
 55 
 56         return *ctx;
 57 }
 58 
 59 EXPORT_SYMBOL(crc32c);
 60 
 61 static int __init libcrc32c_mod_init(void)
 62 {
 63         tfm = crypto_alloc_shash("crc32c", 0, 0);
 64         return PTR_ERR_OR_ZERO(tfm);
 65 }
 66 
 67 static void __exit libcrc32c_mod_fini(void)
 68 {
 69         crypto_free_shash(tfm);
 70 }
 71 
 72 module_init(libcrc32c_mod_init);
 73 module_exit(libcrc32c_mod_fini);
 74 
 75 MODULE_AUTHOR("Clay Haapala <chaapala@cisco.com>");
 76 MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations");
 77 MODULE_LICENSE("GPL");
 78 MODULE_SOFTDEP("pre: crc32c");
 79 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp