Lines Matching +full:data +full:- +full:out

1 // SPDX-License-Identifier: GPL-2.0
3 * Crypto-API module for CRC-32 algorithms implemented with the
9 #define KMSG_COMPONENT "crc32-vx"
24 #define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
40 * DEFINE_CRC32_VX() - Define a CRC-32 function using the vector extension
42 * Creates a function to perform a particular CRC-32 computation. Depending
43 * on the message buffer, the hardware-accelerated or software implementation
50 unsigned char const *data, size_t datalen) \
56 return ___crc32_sw(crc, data, datalen); \
58 if ((unsigned long)data & VX_ALIGN_MASK) { \
59 prealign = VX_ALIGNMENT - \
60 ((unsigned long)data & VX_ALIGN_MASK); \
61 datalen -= prealign; \
62 crc = ___crc32_sw(crc, data, prealign); \
63 data = (void *)((unsigned long)data + prealign); \
70 crc = ___crc32_vx(crc, data, aligned); \
74 crc = ___crc32_sw(crc, data + aligned, remaining); \
88 mctx->key = 0; in DEFINE_CRC32_VX()
96 mctx->key = ~0; in crc32_vx_cra_init_invert()
102 struct crc_ctx *mctx = crypto_shash_ctx(desc->tfm); in crc32_vx_init()
105 ctx->crc = mctx->key; in crc32_vx_init()
114 if (newkeylen != sizeof(mctx->key)) in crc32_vx_setkey()
115 return -EINVAL; in crc32_vx_setkey()
116 mctx->key = le32_to_cpu(*(__le32 *)newkey); in crc32_vx_setkey()
125 if (newkeylen != sizeof(mctx->key)) in crc32be_vx_setkey()
126 return -EINVAL; in crc32be_vx_setkey()
127 mctx->key = be32_to_cpu(*(__be32 *)newkey); in crc32be_vx_setkey()
131 static int crc32le_vx_final(struct shash_desc *desc, u8 *out) in crc32le_vx_final() argument
135 *(__le32 *)out = cpu_to_le32p(&ctx->crc); in crc32le_vx_final()
139 static int crc32be_vx_final(struct shash_desc *desc, u8 *out) in crc32be_vx_final() argument
143 *(__be32 *)out = cpu_to_be32p(&ctx->crc); in crc32be_vx_final()
147 static int crc32c_vx_final(struct shash_desc *desc, u8 *out) in crc32c_vx_final() argument
155 *(__le32 *)out = ~cpu_to_le32p(&ctx->crc); in crc32c_vx_final()
159 static int __crc32le_vx_finup(u32 *crc, const u8 *data, unsigned int len, in __crc32le_vx_finup() argument
160 u8 *out) in __crc32le_vx_finup() argument
162 *(__le32 *)out = cpu_to_le32(crc32_le_vx(*crc, data, len)); in __crc32le_vx_finup()
166 static int __crc32be_vx_finup(u32 *crc, const u8 *data, unsigned int len, in __crc32be_vx_finup() argument
167 u8 *out) in __crc32be_vx_finup() argument
169 *(__be32 *)out = cpu_to_be32(crc32_be_vx(*crc, data, len)); in __crc32be_vx_finup()
173 static int __crc32c_vx_finup(u32 *crc, const u8 *data, unsigned int len, in __crc32c_vx_finup() argument
174 u8 *out) in __crc32c_vx_finup() argument
180 *(__le32 *)out = ~cpu_to_le32(crc32c_le_vx(*crc, data, len)); in __crc32c_vx_finup()
186 static int alg ## _vx_finup(struct shash_desc *desc, const u8 *data, \
187 unsigned int datalen, u8 *out) \
190 data, datalen, out); \
198 static int alg ## _vx_digest(struct shash_desc *desc, const u8 *data, \
199 unsigned int len, u8 *out) \
201 return __ ## alg ## _vx_finup(crypto_shash_ctx(desc->tfm), \
202 data, len, out); \
210 static int alg ## _vx_update(struct shash_desc *desc, const u8 *data, \
214 ctx->crc = func(ctx->crc, data, datalen); \
224 /* CRC-32 LE */
236 .cra_driver_name = "crc32-vx",
245 /* CRC-32 BE */
257 .cra_driver_name = "crc32be-vx",
266 /* CRC-32C LE */
278 .cra_driver_name = "crc32c-vx",
308 MODULE_ALIAS_CRYPTO("crc32-vx");
310 MODULE_ALIAS_CRYPTO("crc32c-vx");