Skip to content
Snippets Groups Projects
Select Git revision
  • v3.12-rc6
  • master default protected
  • objtool-32bit
  • objtool
  • v5.9
  • v5.9-rc8
  • v5.9-rc7
  • v5.9-rc6
  • v5.9-rc5
  • v5.9-rc4
  • v5.9-rc3
  • v5.9-rc2
  • v5.9-rc1
  • v5.8
  • v5.8-rc7
  • v5.8-rc6
  • v5.8-rc5
  • v5.8-rc4
  • v5.8-rc3
  • v5.8-rc2
  • v5.8-rc1
  • v5.7
  • v5.7-rc7
  • v5.7-rc6
24 results

crc32c.c

Blame
  • Forked from Jonas Rabenstein / Linux
    Source project has a limited visibility.
    crc32c.c 4.27 KiB
    /*
     * Cryptographic API.
     *
     * CRC32C chksum
     *
     *@Article{castagnoli-crc,
     * author =       { Guy Castagnoli and Stefan Braeuer and Martin Herrman},
     * title =        {{Optimization of Cyclic Redundancy-Check Codes with 24
     *                 and 32 Parity Bits}},
     * journal =      IEEE Transactions on Communication,
     * year =         {1993},
     * volume =       {41},
     * number =       {6},
     * pages =        {},
     * month =        {June},
     *}
     * Used by the iSCSI driver, possibly others, and derived from the
     * the iscsi-crc.c module of the linux-iscsi driver at
     * http://linux-iscsi.sourceforge.net.
     *
     * Following the example of lib/crc32, this function is intended to be
     * flexible and useful for all users.  Modules that currently have their
     * own crc32c, but hopefully may be able to use this one are:
     *  net/sctp (please add all your doco to here if you change to
     *            use this one!)
     *  <endoflist>
     *
     * Copyright (c) 2004 Cisco Systems, Inc.
     * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
     *
     * This program is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by the Free
     * Software Foundation; either version 2 of the License, or (at your option)
     * any later version.
     *
     */
    
    #include <crypto/internal/hash.h>
    #include <linux/init.h>
    #include <linux/module.h>
    #include <linux/string.h>
    #include <linux/kernel.h>
    #include <linux/crc32.h>
    
    #define CHKSUM_BLOCK_SIZE	1
    #define CHKSUM_DIGEST_SIZE	4
    
    struct chksum_ctx {
    	u32 key;
    };
    
    struct chksum_desc_ctx {
    	u32 crc;
    };
    
    /*
     * Steps through buffer one byte at at time, calculates reflected
     * crc using table.
     */
    
    static int chksum_init(struct shash_desc *desc)
    {
    	struct chksum_ctx *mctx = crypto_shash_ctx(desc->tfm);
    	struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
    
    	ctx->crc = mctx->key;
    
    	return 0;
    }