crc32-vx.c (552c69b36ebd966186573b9c7a286b390935cce1) crc32-vx.c (674f368a952c48ede71784935a799a5205b92b6c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Crypto-API module for CRC-32 algorithms implemented with the
4 * z/Architecture Vector Extension Facility.
5 *
6 * Copyright IBM Corp. 2015
7 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
8 */

--- 97 unchanged lines hidden (view full) ---

106 return 0;
107}
108
109static int crc32_vx_setkey(struct crypto_shash *tfm, const u8 *newkey,
110 unsigned int newkeylen)
111{
112 struct crc_ctx *mctx = crypto_shash_ctx(tfm);
113
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Crypto-API module for CRC-32 algorithms implemented with the
4 * z/Architecture Vector Extension Facility.
5 *
6 * Copyright IBM Corp. 2015
7 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
8 */

--- 97 unchanged lines hidden (view full) ---

106 return 0;
107}
108
109static int crc32_vx_setkey(struct crypto_shash *tfm, const u8 *newkey,
110 unsigned int newkeylen)
111{
112 struct crc_ctx *mctx = crypto_shash_ctx(tfm);
113
114 if (newkeylen != sizeof(mctx->key)) {
115 crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
114 if (newkeylen != sizeof(mctx->key))
116 return -EINVAL;
115 return -EINVAL;
117 }
118 mctx->key = le32_to_cpu(*(__le32 *)newkey);
119 return 0;
120}
121
122static int crc32be_vx_setkey(struct crypto_shash *tfm, const u8 *newkey,
123 unsigned int newkeylen)
124{
125 struct crc_ctx *mctx = crypto_shash_ctx(tfm);
126
116 mctx->key = le32_to_cpu(*(__le32 *)newkey);
117 return 0;
118}
119
120static int crc32be_vx_setkey(struct crypto_shash *tfm, const u8 *newkey,
121 unsigned int newkeylen)
122{
123 struct crc_ctx *mctx = crypto_shash_ctx(tfm);
124
127 if (newkeylen != sizeof(mctx->key)) {
128 crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
125 if (newkeylen != sizeof(mctx->key))
129 return -EINVAL;
126 return -EINVAL;
130 }
131 mctx->key = be32_to_cpu(*(__be32 *)newkey);
132 return 0;
133}
134
135static int crc32le_vx_final(struct shash_desc *desc, u8 *out)
136{
137 struct crc_desc_ctx *ctx = shash_desc_ctx(desc);
138

--- 176 unchanged lines hidden ---
127 mctx->key = be32_to_cpu(*(__be32 *)newkey);
128 return 0;
129}
130
131static int crc32le_vx_final(struct shash_desc *desc, u8 *out)
132{
133 struct crc_desc_ctx *ctx = shash_desc_ctx(desc);
134

--- 176 unchanged lines hidden ---