Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: keembay - Use new crypto_engine_op interface

Use the new crypto_engine_op interface where the callback is stored
in the algorithm object.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+360 -370
+209 -218
drivers/crypto/intel/keembay/keembay-ocs-aes-core.c
··· 5 5 * Copyright (C) 2018-2020 Intel Corporation 6 6 */ 7 7 8 - #include <linux/clk.h> 9 - #include <linux/completion.h> 10 - #include <linux/crypto.h> 11 - #include <linux/dma-mapping.h> 12 - #include <linux/interrupt.h> 13 - #include <linux/io.h> 14 - #include <linux/module.h> 15 - #include <linux/of.h> 16 - #include <linux/platform_device.h> 17 - #include <linux/types.h> 18 - 19 8 #include <crypto/aes.h> 20 9 #include <crypto/engine.h> 21 10 #include <crypto/gcm.h> 22 - #include <crypto/scatterwalk.h> 23 - 24 11 #include <crypto/internal/aead.h> 25 12 #include <crypto/internal/skcipher.h> 13 + #include <crypto/scatterwalk.h> 14 + #include <linux/clk.h> 15 + #include <linux/completion.h> 16 + #include <linux/dma-mapping.h> 17 + #include <linux/err.h> 18 + #include <linux/interrupt.h> 19 + #include <linux/io.h> 20 + #include <linux/kernel.h> 21 + #include <linux/module.h> 22 + #include <linux/of.h> 23 + #include <linux/platform_device.h> 24 + #include <linux/string.h> 26 25 27 26 #include "ocs-aes.h" 28 27 ··· 37 38 38 39 /** 39 40 * struct ocs_aes_tctx - OCS AES Transform context 40 - * @engine_ctx: Engine context. 41 41 * @aes_dev: The OCS AES device. 42 42 * @key: AES/SM4 key. 43 43 * @key_len: The length (in bytes) of @key. ··· 45 47 * @use_fallback: Whether or not fallback cipher should be used. 46 48 */ 47 49 struct ocs_aes_tctx { 48 - struct crypto_engine_ctx engine_ctx; 49 50 struct ocs_aes_dev *aes_dev; 50 51 u8 key[OCS_AES_KEYSIZE_256]; 51 52 unsigned int key_len; ··· 1145 1148 return kmb_ocs_aead_common(req, OCS_SM4, OCS_DECRYPT, OCS_MODE_CCM); 1146 1149 } 1147 1150 1148 - static inline int ocs_common_init(struct ocs_aes_tctx *tctx) 1149 - { 1150 - tctx->engine_ctx.op.do_one_request = kmb_ocs_aes_sk_do_one_request; 1151 - 1152 - return 0; 1153 - } 1154 - 1155 1151 static int ocs_aes_init_tfm(struct crypto_skcipher *tfm) 1156 1152 { 1157 1153 const char *alg_name = crypto_tfm_alg_name(&tfm->base); ··· 1160 1170 1161 1171 crypto_skcipher_set_reqsize(tfm, sizeof(struct ocs_aes_rctx)); 1162 1172 1163 - return ocs_common_init(tctx); 1173 + return 0; 1164 1174 } 1165 1175 1166 1176 static int ocs_sm4_init_tfm(struct crypto_skcipher *tfm) 1167 1177 { 1168 - struct ocs_aes_tctx *tctx = crypto_skcipher_ctx(tfm); 1169 - 1170 1178 crypto_skcipher_set_reqsize(tfm, sizeof(struct ocs_aes_rctx)); 1171 1179 1172 - return ocs_common_init(tctx); 1180 + return 0; 1173 1181 } 1174 1182 1175 1183 static inline void clear_key(struct ocs_aes_tctx *tctx) ··· 1192 1204 } 1193 1205 } 1194 1206 1195 - static inline int ocs_common_aead_init(struct ocs_aes_tctx *tctx) 1196 - { 1197 - tctx->engine_ctx.op.do_one_request = kmb_ocs_aes_aead_do_one_request; 1198 - 1199 - return 0; 1200 - } 1201 - 1202 1207 static int ocs_aes_aead_cra_init(struct crypto_aead *tfm) 1203 1208 { 1204 1209 const char *alg_name = crypto_tfm_alg_name(&tfm->base); ··· 1210 1229 (sizeof(struct aead_request) + 1211 1230 crypto_aead_reqsize(tctx->sw_cipher.aead)))); 1212 1231 1213 - return ocs_common_aead_init(tctx); 1232 + return 0; 1214 1233 } 1215 1234 1216 1235 static int kmb_ocs_aead_ccm_setauthsize(struct crypto_aead *tfm, ··· 1238 1257 1239 1258 static int ocs_sm4_aead_cra_init(struct crypto_aead *tfm) 1240 1259 { 1241 - struct ocs_aes_tctx *tctx = crypto_aead_ctx(tfm); 1242 - 1243 1260 crypto_aead_set_reqsize(tfm, sizeof(struct ocs_aes_rctx)); 1244 1261 1245 - return ocs_common_aead_init(tctx); 1262 + return 0; 1246 1263 } 1247 1264 1248 1265 static void ocs_aead_cra_exit(struct crypto_aead *tfm) ··· 1255 1276 } 1256 1277 } 1257 1278 1258 - static struct skcipher_alg algs[] = { 1279 + static struct skcipher_engine_alg algs[] = { 1259 1280 #ifdef CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_ECB 1260 1281 { 1261 - .base.cra_name = "ecb(aes)", 1262 - .base.cra_driver_name = "ecb-aes-keembay-ocs", 1263 - .base.cra_priority = KMB_OCS_PRIORITY, 1264 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1265 - CRYPTO_ALG_KERN_DRIVER_ONLY | 1266 - CRYPTO_ALG_NEED_FALLBACK, 1267 - .base.cra_blocksize = AES_BLOCK_SIZE, 1268 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1269 - .base.cra_module = THIS_MODULE, 1270 - .base.cra_alignmask = 0, 1282 + .base.base.cra_name = "ecb(aes)", 1283 + .base.base.cra_driver_name = "ecb-aes-keembay-ocs", 1284 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1285 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1286 + CRYPTO_ALG_KERN_DRIVER_ONLY | 1287 + CRYPTO_ALG_NEED_FALLBACK, 1288 + .base.base.cra_blocksize = AES_BLOCK_SIZE, 1289 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1290 + .base.base.cra_module = THIS_MODULE, 1291 + .base.base.cra_alignmask = 0, 1271 1292 1272 - .min_keysize = OCS_AES_MIN_KEY_SIZE, 1273 - .max_keysize = OCS_AES_MAX_KEY_SIZE, 1274 - .setkey = kmb_ocs_aes_set_key, 1275 - .encrypt = kmb_ocs_aes_ecb_encrypt, 1276 - .decrypt = kmb_ocs_aes_ecb_decrypt, 1277 - .init = ocs_aes_init_tfm, 1278 - .exit = ocs_exit_tfm, 1293 + .base.min_keysize = OCS_AES_MIN_KEY_SIZE, 1294 + .base.max_keysize = OCS_AES_MAX_KEY_SIZE, 1295 + .base.setkey = kmb_ocs_aes_set_key, 1296 + .base.encrypt = kmb_ocs_aes_ecb_encrypt, 1297 + .base.decrypt = kmb_ocs_aes_ecb_decrypt, 1298 + .base.init = ocs_aes_init_tfm, 1299 + .base.exit = ocs_exit_tfm, 1300 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1279 1301 }, 1280 1302 #endif /* CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_ECB */ 1281 1303 { 1282 - .base.cra_name = "cbc(aes)", 1283 - .base.cra_driver_name = "cbc-aes-keembay-ocs", 1284 - .base.cra_priority = KMB_OCS_PRIORITY, 1285 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1286 - CRYPTO_ALG_KERN_DRIVER_ONLY | 1287 - CRYPTO_ALG_NEED_FALLBACK, 1288 - .base.cra_blocksize = AES_BLOCK_SIZE, 1289 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1290 - .base.cra_module = THIS_MODULE, 1291 - .base.cra_alignmask = 0, 1304 + .base.base.cra_name = "cbc(aes)", 1305 + .base.base.cra_driver_name = "cbc-aes-keembay-ocs", 1306 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1307 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1308 + CRYPTO_ALG_KERN_DRIVER_ONLY | 1309 + CRYPTO_ALG_NEED_FALLBACK, 1310 + .base.base.cra_blocksize = AES_BLOCK_SIZE, 1311 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1312 + .base.base.cra_module = THIS_MODULE, 1313 + .base.base.cra_alignmask = 0, 1292 1314 1293 - .min_keysize = OCS_AES_MIN_KEY_SIZE, 1294 - .max_keysize = OCS_AES_MAX_KEY_SIZE, 1295 - .ivsize = AES_BLOCK_SIZE, 1296 - .setkey = kmb_ocs_aes_set_key, 1297 - .encrypt = kmb_ocs_aes_cbc_encrypt, 1298 - .decrypt = kmb_ocs_aes_cbc_decrypt, 1299 - .init = ocs_aes_init_tfm, 1300 - .exit = ocs_exit_tfm, 1315 + .base.min_keysize = OCS_AES_MIN_KEY_SIZE, 1316 + .base.max_keysize = OCS_AES_MAX_KEY_SIZE, 1317 + .base.ivsize = AES_BLOCK_SIZE, 1318 + .base.setkey = kmb_ocs_aes_set_key, 1319 + .base.encrypt = kmb_ocs_aes_cbc_encrypt, 1320 + .base.decrypt = kmb_ocs_aes_cbc_decrypt, 1321 + .base.init = ocs_aes_init_tfm, 1322 + .base.exit = ocs_exit_tfm, 1323 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1301 1324 }, 1302 1325 { 1303 - .base.cra_name = "ctr(aes)", 1304 - .base.cra_driver_name = "ctr-aes-keembay-ocs", 1305 - .base.cra_priority = KMB_OCS_PRIORITY, 1306 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1307 - CRYPTO_ALG_KERN_DRIVER_ONLY | 1308 - CRYPTO_ALG_NEED_FALLBACK, 1309 - .base.cra_blocksize = 1, 1310 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1311 - .base.cra_module = THIS_MODULE, 1312 - .base.cra_alignmask = 0, 1326 + .base.base.cra_name = "ctr(aes)", 1327 + .base.base.cra_driver_name = "ctr-aes-keembay-ocs", 1328 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1329 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1330 + CRYPTO_ALG_KERN_DRIVER_ONLY | 1331 + CRYPTO_ALG_NEED_FALLBACK, 1332 + .base.base.cra_blocksize = 1, 1333 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1334 + .base.base.cra_module = THIS_MODULE, 1335 + .base.base.cra_alignmask = 0, 1313 1336 1314 - .min_keysize = OCS_AES_MIN_KEY_SIZE, 1315 - .max_keysize = OCS_AES_MAX_KEY_SIZE, 1316 - .ivsize = AES_BLOCK_SIZE, 1317 - .setkey = kmb_ocs_aes_set_key, 1318 - .encrypt = kmb_ocs_aes_ctr_encrypt, 1319 - .decrypt = kmb_ocs_aes_ctr_decrypt, 1320 - .init = ocs_aes_init_tfm, 1321 - .exit = ocs_exit_tfm, 1337 + .base.min_keysize = OCS_AES_MIN_KEY_SIZE, 1338 + .base.max_keysize = OCS_AES_MAX_KEY_SIZE, 1339 + .base.ivsize = AES_BLOCK_SIZE, 1340 + .base.setkey = kmb_ocs_aes_set_key, 1341 + .base.encrypt = kmb_ocs_aes_ctr_encrypt, 1342 + .base.decrypt = kmb_ocs_aes_ctr_decrypt, 1343 + .base.init = ocs_aes_init_tfm, 1344 + .base.exit = ocs_exit_tfm, 1345 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1322 1346 }, 1323 1347 #ifdef CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_CTS 1324 1348 { 1325 - .base.cra_name = "cts(cbc(aes))", 1326 - .base.cra_driver_name = "cts-aes-keembay-ocs", 1327 - .base.cra_priority = KMB_OCS_PRIORITY, 1328 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1329 - CRYPTO_ALG_KERN_DRIVER_ONLY | 1330 - CRYPTO_ALG_NEED_FALLBACK, 1331 - .base.cra_blocksize = AES_BLOCK_SIZE, 1332 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1333 - .base.cra_module = THIS_MODULE, 1334 - .base.cra_alignmask = 0, 1349 + .base.base.cra_name = "cts(cbc(aes))", 1350 + .base.base.cra_driver_name = "cts-aes-keembay-ocs", 1351 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1352 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1353 + CRYPTO_ALG_KERN_DRIVER_ONLY | 1354 + CRYPTO_ALG_NEED_FALLBACK, 1355 + .base.base.cra_blocksize = AES_BLOCK_SIZE, 1356 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1357 + .base.base.cra_module = THIS_MODULE, 1358 + .base.base.cra_alignmask = 0, 1335 1359 1336 - .min_keysize = OCS_AES_MIN_KEY_SIZE, 1337 - .max_keysize = OCS_AES_MAX_KEY_SIZE, 1338 - .ivsize = AES_BLOCK_SIZE, 1339 - .setkey = kmb_ocs_aes_set_key, 1340 - .encrypt = kmb_ocs_aes_cts_encrypt, 1341 - .decrypt = kmb_ocs_aes_cts_decrypt, 1342 - .init = ocs_aes_init_tfm, 1343 - .exit = ocs_exit_tfm, 1360 + .base.min_keysize = OCS_AES_MIN_KEY_SIZE, 1361 + .base.max_keysize = OCS_AES_MAX_KEY_SIZE, 1362 + .base.ivsize = AES_BLOCK_SIZE, 1363 + .base.setkey = kmb_ocs_aes_set_key, 1364 + .base.encrypt = kmb_ocs_aes_cts_encrypt, 1365 + .base.decrypt = kmb_ocs_aes_cts_decrypt, 1366 + .base.init = ocs_aes_init_tfm, 1367 + .base.exit = ocs_exit_tfm, 1368 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1344 1369 }, 1345 1370 #endif /* CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_CTS */ 1346 1371 #ifdef CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_ECB 1347 1372 { 1348 - .base.cra_name = "ecb(sm4)", 1349 - .base.cra_driver_name = "ecb-sm4-keembay-ocs", 1350 - .base.cra_priority = KMB_OCS_PRIORITY, 1351 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1352 - CRYPTO_ALG_KERN_DRIVER_ONLY, 1353 - .base.cra_blocksize = AES_BLOCK_SIZE, 1354 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1355 - .base.cra_module = THIS_MODULE, 1356 - .base.cra_alignmask = 0, 1373 + .base.base.cra_name = "ecb(sm4)", 1374 + .base.base.cra_driver_name = "ecb-sm4-keembay-ocs", 1375 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1376 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1377 + CRYPTO_ALG_KERN_DRIVER_ONLY, 1378 + .base.base.cra_blocksize = AES_BLOCK_SIZE, 1379 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1380 + .base.base.cra_module = THIS_MODULE, 1381 + .base.base.cra_alignmask = 0, 1357 1382 1358 - .min_keysize = OCS_SM4_KEY_SIZE, 1359 - .max_keysize = OCS_SM4_KEY_SIZE, 1360 - .setkey = kmb_ocs_sm4_set_key, 1361 - .encrypt = kmb_ocs_sm4_ecb_encrypt, 1362 - .decrypt = kmb_ocs_sm4_ecb_decrypt, 1363 - .init = ocs_sm4_init_tfm, 1364 - .exit = ocs_exit_tfm, 1383 + .base.min_keysize = OCS_SM4_KEY_SIZE, 1384 + .base.max_keysize = OCS_SM4_KEY_SIZE, 1385 + .base.setkey = kmb_ocs_sm4_set_key, 1386 + .base.encrypt = kmb_ocs_sm4_ecb_encrypt, 1387 + .base.decrypt = kmb_ocs_sm4_ecb_decrypt, 1388 + .base.init = ocs_sm4_init_tfm, 1389 + .base.exit = ocs_exit_tfm, 1390 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1365 1391 }, 1366 1392 #endif /* CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_ECB */ 1367 1393 { 1368 - .base.cra_name = "cbc(sm4)", 1369 - .base.cra_driver_name = "cbc-sm4-keembay-ocs", 1370 - .base.cra_priority = KMB_OCS_PRIORITY, 1371 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1372 - CRYPTO_ALG_KERN_DRIVER_ONLY, 1373 - .base.cra_blocksize = AES_BLOCK_SIZE, 1374 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1375 - .base.cra_module = THIS_MODULE, 1376 - .base.cra_alignmask = 0, 1394 + .base.base.cra_name = "cbc(sm4)", 1395 + .base.base.cra_driver_name = "cbc-sm4-keembay-ocs", 1396 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1397 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1398 + CRYPTO_ALG_KERN_DRIVER_ONLY, 1399 + .base.base.cra_blocksize = AES_BLOCK_SIZE, 1400 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1401 + .base.base.cra_module = THIS_MODULE, 1402 + .base.base.cra_alignmask = 0, 1377 1403 1378 - .min_keysize = OCS_SM4_KEY_SIZE, 1379 - .max_keysize = OCS_SM4_KEY_SIZE, 1380 - .ivsize = AES_BLOCK_SIZE, 1381 - .setkey = kmb_ocs_sm4_set_key, 1382 - .encrypt = kmb_ocs_sm4_cbc_encrypt, 1383 - .decrypt = kmb_ocs_sm4_cbc_decrypt, 1384 - .init = ocs_sm4_init_tfm, 1385 - .exit = ocs_exit_tfm, 1404 + .base.min_keysize = OCS_SM4_KEY_SIZE, 1405 + .base.max_keysize = OCS_SM4_KEY_SIZE, 1406 + .base.ivsize = AES_BLOCK_SIZE, 1407 + .base.setkey = kmb_ocs_sm4_set_key, 1408 + .base.encrypt = kmb_ocs_sm4_cbc_encrypt, 1409 + .base.decrypt = kmb_ocs_sm4_cbc_decrypt, 1410 + .base.init = ocs_sm4_init_tfm, 1411 + .base.exit = ocs_exit_tfm, 1412 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1386 1413 }, 1387 1414 { 1388 - .base.cra_name = "ctr(sm4)", 1389 - .base.cra_driver_name = "ctr-sm4-keembay-ocs", 1390 - .base.cra_priority = KMB_OCS_PRIORITY, 1391 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1392 - CRYPTO_ALG_KERN_DRIVER_ONLY, 1393 - .base.cra_blocksize = 1, 1394 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1395 - .base.cra_module = THIS_MODULE, 1396 - .base.cra_alignmask = 0, 1415 + .base.base.cra_name = "ctr(sm4)", 1416 + .base.base.cra_driver_name = "ctr-sm4-keembay-ocs", 1417 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1418 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1419 + CRYPTO_ALG_KERN_DRIVER_ONLY, 1420 + .base.base.cra_blocksize = 1, 1421 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1422 + .base.base.cra_module = THIS_MODULE, 1423 + .base.base.cra_alignmask = 0, 1397 1424 1398 - .min_keysize = OCS_SM4_KEY_SIZE, 1399 - .max_keysize = OCS_SM4_KEY_SIZE, 1400 - .ivsize = AES_BLOCK_SIZE, 1401 - .setkey = kmb_ocs_sm4_set_key, 1402 - .encrypt = kmb_ocs_sm4_ctr_encrypt, 1403 - .decrypt = kmb_ocs_sm4_ctr_decrypt, 1404 - .init = ocs_sm4_init_tfm, 1405 - .exit = ocs_exit_tfm, 1425 + .base.min_keysize = OCS_SM4_KEY_SIZE, 1426 + .base.max_keysize = OCS_SM4_KEY_SIZE, 1427 + .base.ivsize = AES_BLOCK_SIZE, 1428 + .base.setkey = kmb_ocs_sm4_set_key, 1429 + .base.encrypt = kmb_ocs_sm4_ctr_encrypt, 1430 + .base.decrypt = kmb_ocs_sm4_ctr_decrypt, 1431 + .base.init = ocs_sm4_init_tfm, 1432 + .base.exit = ocs_exit_tfm, 1433 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1406 1434 }, 1407 1435 #ifdef CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_CTS 1408 1436 { 1409 - .base.cra_name = "cts(cbc(sm4))", 1410 - .base.cra_driver_name = "cts-sm4-keembay-ocs", 1411 - .base.cra_priority = KMB_OCS_PRIORITY, 1412 - .base.cra_flags = CRYPTO_ALG_ASYNC | 1413 - CRYPTO_ALG_KERN_DRIVER_ONLY, 1414 - .base.cra_blocksize = AES_BLOCK_SIZE, 1415 - .base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1416 - .base.cra_module = THIS_MODULE, 1417 - .base.cra_alignmask = 0, 1437 + .base.base.cra_name = "cts(cbc(sm4))", 1438 + .base.base.cra_driver_name = "cts-sm4-keembay-ocs", 1439 + .base.base.cra_priority = KMB_OCS_PRIORITY, 1440 + .base.base.cra_flags = CRYPTO_ALG_ASYNC | 1441 + CRYPTO_ALG_KERN_DRIVER_ONLY, 1442 + .base.base.cra_blocksize = AES_BLOCK_SIZE, 1443 + .base.base.cra_ctxsize = sizeof(struct ocs_aes_tctx), 1444 + .base.base.cra_module = THIS_MODULE, 1445 + .base.base.cra_alignmask = 0, 1418 1446 1419 - .min_keysize = OCS_SM4_KEY_SIZE, 1420 - .max_keysize = OCS_SM4_KEY_SIZE, 1421 - .ivsize = AES_BLOCK_SIZE, 1422 - .setkey = kmb_ocs_sm4_set_key, 1423 - .encrypt = kmb_ocs_sm4_cts_encrypt, 1424 - .decrypt = kmb_ocs_sm4_cts_decrypt, 1425 - .init = ocs_sm4_init_tfm, 1426 - .exit = ocs_exit_tfm, 1447 + .base.min_keysize = OCS_SM4_KEY_SIZE, 1448 + .base.max_keysize = OCS_SM4_KEY_SIZE, 1449 + .base.ivsize = AES_BLOCK_SIZE, 1450 + .base.setkey = kmb_ocs_sm4_set_key, 1451 + .base.encrypt = kmb_ocs_sm4_cts_encrypt, 1452 + .base.decrypt = kmb_ocs_sm4_cts_decrypt, 1453 + .base.init = ocs_sm4_init_tfm, 1454 + .base.exit = ocs_exit_tfm, 1455 + .op.do_one_request = kmb_ocs_aes_sk_do_one_request, 1427 1456 } 1428 1457 #endif /* CONFIG_CRYPTO_DEV_KEEMBAY_OCS_AES_SM4_CTS */ 1429 1458 }; 1430 1459 1431 - static struct aead_alg algs_aead[] = { 1460 + static struct aead_engine_alg algs_aead[] = { 1432 1461 { 1433 - .base = { 1462 + .base.base = { 1434 1463 .cra_name = "gcm(aes)", 1435 1464 .cra_driver_name = "gcm-aes-keembay-ocs", 1436 1465 .cra_priority = KMB_OCS_PRIORITY, ··· 1450 1463 .cra_alignmask = 0, 1451 1464 .cra_module = THIS_MODULE, 1452 1465 }, 1453 - .init = ocs_aes_aead_cra_init, 1454 - .exit = ocs_aead_cra_exit, 1455 - .ivsize = GCM_AES_IV_SIZE, 1456 - .maxauthsize = AES_BLOCK_SIZE, 1457 - .setauthsize = kmb_ocs_aead_gcm_setauthsize, 1458 - .setkey = kmb_ocs_aes_aead_set_key, 1459 - .encrypt = kmb_ocs_aes_gcm_encrypt, 1460 - .decrypt = kmb_ocs_aes_gcm_decrypt, 1466 + .base.init = ocs_aes_aead_cra_init, 1467 + .base.exit = ocs_aead_cra_exit, 1468 + .base.ivsize = GCM_AES_IV_SIZE, 1469 + .base.maxauthsize = AES_BLOCK_SIZE, 1470 + .base.setauthsize = kmb_ocs_aead_gcm_setauthsize, 1471 + .base.setkey = kmb_ocs_aes_aead_set_key, 1472 + .base.encrypt = kmb_ocs_aes_gcm_encrypt, 1473 + .base.decrypt = kmb_ocs_aes_gcm_decrypt, 1474 + .op.do_one_request = kmb_ocs_aes_aead_do_one_request, 1461 1475 }, 1462 1476 { 1463 - .base = { 1477 + .base.base = { 1464 1478 .cra_name = "ccm(aes)", 1465 1479 .cra_driver_name = "ccm-aes-keembay-ocs", 1466 1480 .cra_priority = KMB_OCS_PRIORITY, ··· 1473 1485 .cra_alignmask = 0, 1474 1486 .cra_module = THIS_MODULE, 1475 1487 }, 1476 - .init = ocs_aes_aead_cra_init, 1477 - .exit = ocs_aead_cra_exit, 1478 - .ivsize = AES_BLOCK_SIZE, 1479 - .maxauthsize = AES_BLOCK_SIZE, 1480 - .setauthsize = kmb_ocs_aead_ccm_setauthsize, 1481 - .setkey = kmb_ocs_aes_aead_set_key, 1482 - .encrypt = kmb_ocs_aes_ccm_encrypt, 1483 - .decrypt = kmb_ocs_aes_ccm_decrypt, 1488 + .base.init = ocs_aes_aead_cra_init, 1489 + .base.exit = ocs_aead_cra_exit, 1490 + .base.ivsize = AES_BLOCK_SIZE, 1491 + .base.maxauthsize = AES_BLOCK_SIZE, 1492 + .base.setauthsize = kmb_ocs_aead_ccm_setauthsize, 1493 + .base.setkey = kmb_ocs_aes_aead_set_key, 1494 + .base.encrypt = kmb_ocs_aes_ccm_encrypt, 1495 + .base.decrypt = kmb_ocs_aes_ccm_decrypt, 1496 + .op.do_one_request = kmb_ocs_aes_aead_do_one_request, 1484 1497 }, 1485 1498 { 1486 - .base = { 1499 + .base.base = { 1487 1500 .cra_name = "gcm(sm4)", 1488 1501 .cra_driver_name = "gcm-sm4-keembay-ocs", 1489 1502 .cra_priority = KMB_OCS_PRIORITY, ··· 1495 1506 .cra_alignmask = 0, 1496 1507 .cra_module = THIS_MODULE, 1497 1508 }, 1498 - .init = ocs_sm4_aead_cra_init, 1499 - .exit = ocs_aead_cra_exit, 1500 - .ivsize = GCM_AES_IV_SIZE, 1501 - .maxauthsize = AES_BLOCK_SIZE, 1502 - .setauthsize = kmb_ocs_aead_gcm_setauthsize, 1503 - .setkey = kmb_ocs_sm4_aead_set_key, 1504 - .encrypt = kmb_ocs_sm4_gcm_encrypt, 1505 - .decrypt = kmb_ocs_sm4_gcm_decrypt, 1509 + .base.init = ocs_sm4_aead_cra_init, 1510 + .base.exit = ocs_aead_cra_exit, 1511 + .base.ivsize = GCM_AES_IV_SIZE, 1512 + .base.maxauthsize = AES_BLOCK_SIZE, 1513 + .base.setauthsize = kmb_ocs_aead_gcm_setauthsize, 1514 + .base.setkey = kmb_ocs_sm4_aead_set_key, 1515 + .base.encrypt = kmb_ocs_sm4_gcm_encrypt, 1516 + .base.decrypt = kmb_ocs_sm4_gcm_decrypt, 1517 + .op.do_one_request = kmb_ocs_aes_aead_do_one_request, 1506 1518 }, 1507 1519 { 1508 - .base = { 1520 + .base.base = { 1509 1521 .cra_name = "ccm(sm4)", 1510 1522 .cra_driver_name = "ccm-sm4-keembay-ocs", 1511 1523 .cra_priority = KMB_OCS_PRIORITY, ··· 1517 1527 .cra_alignmask = 0, 1518 1528 .cra_module = THIS_MODULE, 1519 1529 }, 1520 - .init = ocs_sm4_aead_cra_init, 1521 - .exit = ocs_aead_cra_exit, 1522 - .ivsize = AES_BLOCK_SIZE, 1523 - .maxauthsize = AES_BLOCK_SIZE, 1524 - .setauthsize = kmb_ocs_aead_ccm_setauthsize, 1525 - .setkey = kmb_ocs_sm4_aead_set_key, 1526 - .encrypt = kmb_ocs_sm4_ccm_encrypt, 1527 - .decrypt = kmb_ocs_sm4_ccm_decrypt, 1530 + .base.init = ocs_sm4_aead_cra_init, 1531 + .base.exit = ocs_aead_cra_exit, 1532 + .base.ivsize = AES_BLOCK_SIZE, 1533 + .base.maxauthsize = AES_BLOCK_SIZE, 1534 + .base.setauthsize = kmb_ocs_aead_ccm_setauthsize, 1535 + .base.setkey = kmb_ocs_sm4_aead_set_key, 1536 + .base.encrypt = kmb_ocs_sm4_ccm_encrypt, 1537 + .base.decrypt = kmb_ocs_sm4_ccm_decrypt, 1538 + .op.do_one_request = kmb_ocs_aes_aead_do_one_request, 1528 1539 } 1529 1540 }; 1530 1541 1531 1542 static void unregister_aes_algs(struct ocs_aes_dev *aes_dev) 1532 1543 { 1533 - crypto_unregister_aeads(algs_aead, ARRAY_SIZE(algs_aead)); 1534 - crypto_unregister_skciphers(algs, ARRAY_SIZE(algs)); 1544 + crypto_engine_unregister_aeads(algs_aead, ARRAY_SIZE(algs_aead)); 1545 + crypto_engine_unregister_skciphers(algs, ARRAY_SIZE(algs)); 1535 1546 } 1536 1547 1537 1548 static int register_aes_algs(struct ocs_aes_dev *aes_dev) ··· 1543 1552 * If any algorithm fails to register, all preceding algorithms that 1544 1553 * were successfully registered will be automatically unregistered. 1545 1554 */ 1546 - ret = crypto_register_aeads(algs_aead, ARRAY_SIZE(algs_aead)); 1555 + ret = crypto_engine_register_aeads(algs_aead, ARRAY_SIZE(algs_aead)); 1547 1556 if (ret) 1548 1557 return ret; 1549 1558 1550 - ret = crypto_register_skciphers(algs, ARRAY_SIZE(algs)); 1559 + ret = crypto_engine_register_skciphers(algs, ARRAY_SIZE(algs)); 1551 1560 if (ret) 1552 - crypto_unregister_aeads(algs_aead, ARRAY_SIZE(algs)); 1561 + crypto_engine_unregister_aeads(algs_aead, ARRAY_SIZE(algs)); 1553 1562 1554 1563 return ret; 1555 1564 }
+33 -38
drivers/crypto/intel/keembay/keembay-ocs-ecc.c
··· 7 7 8 8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 9 10 + #include <crypto/ecc_curve.h> 11 + #include <crypto/ecdh.h> 12 + #include <crypto/engine.h> 13 + #include <crypto/internal/ecc.h> 14 + #include <crypto/internal/kpp.h> 15 + #include <crypto/kpp.h> 16 + #include <crypto/rng.h> 10 17 #include <linux/clk.h> 11 18 #include <linux/completion.h> 12 - #include <linux/crypto.h> 13 - #include <linux/delay.h> 19 + #include <linux/err.h> 14 20 #include <linux/fips.h> 15 21 #include <linux/interrupt.h> 16 22 #include <linux/io.h> 17 23 #include <linux/iopoll.h> 18 24 #include <linux/irq.h> 25 + #include <linux/kernel.h> 19 26 #include <linux/module.h> 20 27 #include <linux/of.h> 21 28 #include <linux/platform_device.h> 22 29 #include <linux/scatterlist.h> 23 - #include <linux/slab.h> 24 - #include <linux/types.h> 25 - 26 - #include <crypto/ecc_curve.h> 27 - #include <crypto/ecdh.h> 28 - #include <crypto/engine.h> 29 - #include <crypto/kpp.h> 30 - #include <crypto/rng.h> 31 - 32 - #include <crypto/internal/ecc.h> 33 - #include <crypto/internal/kpp.h> 30 + #include <linux/string.h> 34 31 35 32 #define DRV_NAME "keembay-ocs-ecc" 36 33 ··· 92 95 93 96 /** 94 97 * struct ocs_ecc_ctx - Transformation context. 95 - * @engine_ctx: Crypto engine ctx. 96 98 * @ecc_dev: The ECC driver associated with this context. 97 99 * @curve: The elliptic curve used by this transformation. 98 100 * @private_key: The private key. 99 101 */ 100 102 struct ocs_ecc_ctx { 101 - struct crypto_engine_ctx engine_ctx; 102 103 struct ocs_ecc_dev *ecc_dev; 103 104 const struct ecc_curve *curve; 104 105 u64 private_key[KMB_ECC_VLI_MAX_DIGITS]; ··· 789 794 if (!tctx->curve) 790 795 return -EOPNOTSUPP; 791 796 792 - tctx->engine_ctx.op.do_one_request = kmb_ocs_ecc_do_one_request; 793 - 794 797 return 0; 795 798 } 796 799 ··· 821 828 return digits_to_bytes(tctx->curve->g.ndigits) * 2; 822 829 } 823 830 824 - static struct kpp_alg ocs_ecdh_p256 = { 825 - .set_secret = kmb_ocs_ecdh_set_secret, 826 - .generate_public_key = kmb_ocs_ecdh_generate_public_key, 827 - .compute_shared_secret = kmb_ocs_ecdh_compute_shared_secret, 828 - .init = kmb_ocs_ecdh_nist_p256_init_tfm, 829 - .exit = kmb_ocs_ecdh_exit_tfm, 830 - .max_size = kmb_ocs_ecdh_max_size, 831 - .base = { 831 + static struct kpp_engine_alg ocs_ecdh_p256 = { 832 + .base.set_secret = kmb_ocs_ecdh_set_secret, 833 + .base.generate_public_key = kmb_ocs_ecdh_generate_public_key, 834 + .base.compute_shared_secret = kmb_ocs_ecdh_compute_shared_secret, 835 + .base.init = kmb_ocs_ecdh_nist_p256_init_tfm, 836 + .base.exit = kmb_ocs_ecdh_exit_tfm, 837 + .base.max_size = kmb_ocs_ecdh_max_size, 838 + .base.base = { 832 839 .cra_name = "ecdh-nist-p256", 833 840 .cra_driver_name = "ecdh-nist-p256-keembay-ocs", 834 841 .cra_priority = KMB_OCS_ECC_PRIORITY, 835 842 .cra_module = THIS_MODULE, 836 843 .cra_ctxsize = sizeof(struct ocs_ecc_ctx), 837 844 }, 845 + .op.do_one_request = kmb_ocs_ecc_do_one_request, 838 846 }; 839 847 840 - static struct kpp_alg ocs_ecdh_p384 = { 841 - .set_secret = kmb_ocs_ecdh_set_secret, 842 - .generate_public_key = kmb_ocs_ecdh_generate_public_key, 843 - .compute_shared_secret = kmb_ocs_ecdh_compute_shared_secret, 844 - .init = kmb_ocs_ecdh_nist_p384_init_tfm, 845 - .exit = kmb_ocs_ecdh_exit_tfm, 846 - .max_size = kmb_ocs_ecdh_max_size, 847 - .base = { 848 + static struct kpp_engine_alg ocs_ecdh_p384 = { 849 + .base.set_secret = kmb_ocs_ecdh_set_secret, 850 + .base.generate_public_key = kmb_ocs_ecdh_generate_public_key, 851 + .base.compute_shared_secret = kmb_ocs_ecdh_compute_shared_secret, 852 + .base.init = kmb_ocs_ecdh_nist_p384_init_tfm, 853 + .base.exit = kmb_ocs_ecdh_exit_tfm, 854 + .base.max_size = kmb_ocs_ecdh_max_size, 855 + .base.base = { 848 856 .cra_name = "ecdh-nist-p384", 849 857 .cra_driver_name = "ecdh-nist-p384-keembay-ocs", 850 858 .cra_priority = KMB_OCS_ECC_PRIORITY, 851 859 .cra_module = THIS_MODULE, 852 860 .cra_ctxsize = sizeof(struct ocs_ecc_ctx), 853 861 }, 862 + .op.do_one_request = kmb_ocs_ecc_do_one_request, 854 863 }; 855 864 856 865 static irqreturn_t ocs_ecc_irq_handler(int irq, void *dev_id) ··· 934 939 } 935 940 936 941 /* Register the KPP algo. */ 937 - rc = crypto_register_kpp(&ocs_ecdh_p256); 942 + rc = crypto_engine_register_kpp(&ocs_ecdh_p256); 938 943 if (rc) { 939 944 dev_err(dev, 940 945 "Could not register OCS algorithms with Crypto API\n"); 941 946 goto cleanup; 942 947 } 943 948 944 - rc = crypto_register_kpp(&ocs_ecdh_p384); 949 + rc = crypto_engine_register_kpp(&ocs_ecdh_p384); 945 950 if (rc) { 946 951 dev_err(dev, 947 952 "Could not register OCS algorithms with Crypto API\n"); ··· 951 956 return 0; 952 957 953 958 ocs_ecdh_p384_error: 954 - crypto_unregister_kpp(&ocs_ecdh_p256); 959 + crypto_engine_unregister_kpp(&ocs_ecdh_p256); 955 960 956 961 cleanup: 957 962 crypto_engine_exit(ecc_dev->engine); ··· 970 975 971 976 ecc_dev = platform_get_drvdata(pdev); 972 977 973 - crypto_unregister_kpp(&ocs_ecdh_p384); 974 - crypto_unregister_kpp(&ocs_ecdh_p256); 978 + crypto_engine_unregister_kpp(&ocs_ecdh_p384); 979 + crypto_engine_unregister_kpp(&ocs_ecdh_p256); 975 980 976 981 spin_lock(&ocs_ecc.lock); 977 982 list_del(&ecc_dev->list);
+118 -114
drivers/crypto/intel/keembay/keembay-ocs-hcu-core.c
··· 5 5 * Copyright (C) 2018-2020 Intel Corporation 6 6 */ 7 7 8 - #include <linux/completion.h> 9 - #include <linux/delay.h> 10 - #include <linux/dma-mapping.h> 11 - #include <linux/interrupt.h> 12 - #include <linux/module.h> 13 - #include <linux/of_device.h> 14 - 15 8 #include <crypto/engine.h> 9 + #include <crypto/hmac.h> 10 + #include <crypto/internal/hash.h> 16 11 #include <crypto/scatterwalk.h> 17 12 #include <crypto/sha2.h> 18 13 #include <crypto/sm3.h> 19 - #include <crypto/hmac.h> 20 - #include <crypto/internal/hash.h> 14 + #include <linux/completion.h> 15 + #include <linux/dma-mapping.h> 16 + #include <linux/err.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/kernel.h> 19 + #include <linux/module.h> 20 + #include <linux/of_device.h> 21 + #include <linux/string.h> 21 22 22 23 #include "ocs-hcu.h" 23 24 ··· 35 34 36 35 /** 37 36 * struct ocs_hcu_ctx: OCS HCU Transform context. 38 - * @engine_ctx: Crypto Engine context. 39 37 * @hcu_dev: The OCS HCU device used by the transformation. 40 38 * @key: The key (used only for HMAC transformations). 41 39 * @key_len: The length of the key. ··· 42 42 * @is_hmac_tfm: Whether or not this is a HMAC transformation. 43 43 */ 44 44 struct ocs_hcu_ctx { 45 - struct crypto_engine_ctx engine_ctx; 46 45 struct ocs_hcu_dev *hcu_dev; 47 46 u8 key[SHA512_BLOCK_SIZE]; 48 47 size_t key_len; ··· 823 824 { 824 825 crypto_ahash_set_reqsize_dma(__crypto_ahash_cast(tfm), 825 826 sizeof(struct ocs_hcu_rctx)); 826 - 827 - /* Init context to 0. */ 828 - memzero_explicit(ctx, sizeof(*ctx)); 829 - /* Set engine ops. */ 830 - ctx->engine_ctx.op.do_one_request = kmb_ocs_hcu_do_one_request; 831 827 } 832 828 833 829 static int kmb_ocs_hcu_sha_cra_init(struct crypto_tfm *tfm) ··· 877 883 memzero_explicit(ctx->key, sizeof(ctx->key)); 878 884 } 879 885 880 - static struct ahash_alg ocs_hcu_algs[] = { 886 + static struct ahash_engine_alg ocs_hcu_algs[] = { 881 887 #ifdef CONFIG_CRYPTO_DEV_KEEMBAY_OCS_HCU_HMAC_SHA224 882 888 { 883 - .init = kmb_ocs_hcu_init, 884 - .update = kmb_ocs_hcu_update, 885 - .final = kmb_ocs_hcu_final, 886 - .finup = kmb_ocs_hcu_finup, 887 - .digest = kmb_ocs_hcu_digest, 888 - .export = kmb_ocs_hcu_export, 889 - .import = kmb_ocs_hcu_import, 890 - .halg = { 889 + .base.init = kmb_ocs_hcu_init, 890 + .base.update = kmb_ocs_hcu_update, 891 + .base.final = kmb_ocs_hcu_final, 892 + .base.finup = kmb_ocs_hcu_finup, 893 + .base.digest = kmb_ocs_hcu_digest, 894 + .base.export = kmb_ocs_hcu_export, 895 + .base.import = kmb_ocs_hcu_import, 896 + .base.halg = { 891 897 .digestsize = SHA224_DIGEST_SIZE, 892 898 .statesize = sizeof(struct ocs_hcu_rctx), 893 899 .base = { ··· 901 907 .cra_module = THIS_MODULE, 902 908 .cra_init = kmb_ocs_hcu_sha_cra_init, 903 909 } 904 - } 910 + }, 911 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 905 912 }, 906 913 { 907 - .init = kmb_ocs_hcu_init, 908 - .update = kmb_ocs_hcu_update, 909 - .final = kmb_ocs_hcu_final, 910 - .finup = kmb_ocs_hcu_finup, 911 - .digest = kmb_ocs_hcu_digest, 912 - .export = kmb_ocs_hcu_export, 913 - .import = kmb_ocs_hcu_import, 914 - .setkey = kmb_ocs_hcu_setkey, 915 - .halg = { 914 + .base.init = kmb_ocs_hcu_init, 915 + .base.update = kmb_ocs_hcu_update, 916 + .base.final = kmb_ocs_hcu_final, 917 + .base.finup = kmb_ocs_hcu_finup, 918 + .base.digest = kmb_ocs_hcu_digest, 919 + .base.export = kmb_ocs_hcu_export, 920 + .base.import = kmb_ocs_hcu_import, 921 + .base.setkey = kmb_ocs_hcu_setkey, 922 + .base.halg = { 916 923 .digestsize = SHA224_DIGEST_SIZE, 917 924 .statesize = sizeof(struct ocs_hcu_rctx), 918 925 .base = { ··· 928 933 .cra_init = kmb_ocs_hcu_hmac_cra_init, 929 934 .cra_exit = kmb_ocs_hcu_hmac_cra_exit, 930 935 } 931 - } 936 + }, 937 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 932 938 }, 933 939 #endif /* CONFIG_CRYPTO_DEV_KEEMBAY_OCS_HCU_HMAC_SHA224 */ 934 940 { 935 - .init = kmb_ocs_hcu_init, 936 - .update = kmb_ocs_hcu_update, 937 - .final = kmb_ocs_hcu_final, 938 - .finup = kmb_ocs_hcu_finup, 939 - .digest = kmb_ocs_hcu_digest, 940 - .export = kmb_ocs_hcu_export, 941 - .import = kmb_ocs_hcu_import, 942 - .halg = { 941 + .base.init = kmb_ocs_hcu_init, 942 + .base.update = kmb_ocs_hcu_update, 943 + .base.final = kmb_ocs_hcu_final, 944 + .base.finup = kmb_ocs_hcu_finup, 945 + .base.digest = kmb_ocs_hcu_digest, 946 + .base.export = kmb_ocs_hcu_export, 947 + .base.import = kmb_ocs_hcu_import, 948 + .base.halg = { 943 949 .digestsize = SHA256_DIGEST_SIZE, 944 950 .statesize = sizeof(struct ocs_hcu_rctx), 945 951 .base = { ··· 954 958 .cra_module = THIS_MODULE, 955 959 .cra_init = kmb_ocs_hcu_sha_cra_init, 956 960 } 957 - } 961 + }, 962 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 958 963 }, 959 964 { 960 - .init = kmb_ocs_hcu_init, 961 - .update = kmb_ocs_hcu_update, 962 - .final = kmb_ocs_hcu_final, 963 - .finup = kmb_ocs_hcu_finup, 964 - .digest = kmb_ocs_hcu_digest, 965 - .export = kmb_ocs_hcu_export, 966 - .import = kmb_ocs_hcu_import, 967 - .setkey = kmb_ocs_hcu_setkey, 968 - .halg = { 965 + .base.init = kmb_ocs_hcu_init, 966 + .base.update = kmb_ocs_hcu_update, 967 + .base.final = kmb_ocs_hcu_final, 968 + .base.finup = kmb_ocs_hcu_finup, 969 + .base.digest = kmb_ocs_hcu_digest, 970 + .base.export = kmb_ocs_hcu_export, 971 + .base.import = kmb_ocs_hcu_import, 972 + .base.setkey = kmb_ocs_hcu_setkey, 973 + .base.halg = { 969 974 .digestsize = SHA256_DIGEST_SIZE, 970 975 .statesize = sizeof(struct ocs_hcu_rctx), 971 976 .base = { ··· 981 984 .cra_init = kmb_ocs_hcu_hmac_cra_init, 982 985 .cra_exit = kmb_ocs_hcu_hmac_cra_exit, 983 986 } 984 - } 987 + }, 988 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 985 989 }, 986 990 { 987 - .init = kmb_ocs_hcu_init, 988 - .update = kmb_ocs_hcu_update, 989 - .final = kmb_ocs_hcu_final, 990 - .finup = kmb_ocs_hcu_finup, 991 - .digest = kmb_ocs_hcu_digest, 992 - .export = kmb_ocs_hcu_export, 993 - .import = kmb_ocs_hcu_import, 994 - .halg = { 991 + .base.init = kmb_ocs_hcu_init, 992 + .base.update = kmb_ocs_hcu_update, 993 + .base.final = kmb_ocs_hcu_final, 994 + .base.finup = kmb_ocs_hcu_finup, 995 + .base.digest = kmb_ocs_hcu_digest, 996 + .base.export = kmb_ocs_hcu_export, 997 + .base.import = kmb_ocs_hcu_import, 998 + .base.halg = { 995 999 .digestsize = SM3_DIGEST_SIZE, 996 1000 .statesize = sizeof(struct ocs_hcu_rctx), 997 1001 .base = { ··· 1006 1008 .cra_module = THIS_MODULE, 1007 1009 .cra_init = kmb_ocs_hcu_sm3_cra_init, 1008 1010 } 1009 - } 1011 + }, 1012 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 1010 1013 }, 1011 1014 { 1012 - .init = kmb_ocs_hcu_init, 1013 - .update = kmb_ocs_hcu_update, 1014 - .final = kmb_ocs_hcu_final, 1015 - .finup = kmb_ocs_hcu_finup, 1016 - .digest = kmb_ocs_hcu_digest, 1017 - .export = kmb_ocs_hcu_export, 1018 - .import = kmb_ocs_hcu_import, 1019 - .setkey = kmb_ocs_hcu_setkey, 1020 - .halg = { 1015 + .base.init = kmb_ocs_hcu_init, 1016 + .base.update = kmb_ocs_hcu_update, 1017 + .base.final = kmb_ocs_hcu_final, 1018 + .base.finup = kmb_ocs_hcu_finup, 1019 + .base.digest = kmb_ocs_hcu_digest, 1020 + .base.export = kmb_ocs_hcu_export, 1021 + .base.import = kmb_ocs_hcu_import, 1022 + .base.setkey = kmb_ocs_hcu_setkey, 1023 + .base.halg = { 1021 1024 .digestsize = SM3_DIGEST_SIZE, 1022 1025 .statesize = sizeof(struct ocs_hcu_rctx), 1023 1026 .base = { ··· 1033 1034 .cra_init = kmb_ocs_hcu_hmac_sm3_cra_init, 1034 1035 .cra_exit = kmb_ocs_hcu_hmac_cra_exit, 1035 1036 } 1036 - } 1037 + }, 1038 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 1037 1039 }, 1038 1040 { 1039 - .init = kmb_ocs_hcu_init, 1040 - .update = kmb_ocs_hcu_update, 1041 - .final = kmb_ocs_hcu_final, 1042 - .finup = kmb_ocs_hcu_finup, 1043 - .digest = kmb_ocs_hcu_digest, 1044 - .export = kmb_ocs_hcu_export, 1045 - .import = kmb_ocs_hcu_import, 1046 - .halg = { 1041 + .base.init = kmb_ocs_hcu_init, 1042 + .base.update = kmb_ocs_hcu_update, 1043 + .base.final = kmb_ocs_hcu_final, 1044 + .base.finup = kmb_ocs_hcu_finup, 1045 + .base.digest = kmb_ocs_hcu_digest, 1046 + .base.export = kmb_ocs_hcu_export, 1047 + .base.import = kmb_ocs_hcu_import, 1048 + .base.halg = { 1047 1049 .digestsize = SHA384_DIGEST_SIZE, 1048 1050 .statesize = sizeof(struct ocs_hcu_rctx), 1049 1051 .base = { ··· 1058 1058 .cra_module = THIS_MODULE, 1059 1059 .cra_init = kmb_ocs_hcu_sha_cra_init, 1060 1060 } 1061 - } 1061 + }, 1062 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 1062 1063 }, 1063 1064 { 1064 - .init = kmb_ocs_hcu_init, 1065 - .update = kmb_ocs_hcu_update, 1066 - .final = kmb_ocs_hcu_final, 1067 - .finup = kmb_ocs_hcu_finup, 1068 - .digest = kmb_ocs_hcu_digest, 1069 - .export = kmb_ocs_hcu_export, 1070 - .import = kmb_ocs_hcu_import, 1071 - .setkey = kmb_ocs_hcu_setkey, 1072 - .halg = { 1065 + .base.init = kmb_ocs_hcu_init, 1066 + .base.update = kmb_ocs_hcu_update, 1067 + .base.final = kmb_ocs_hcu_final, 1068 + .base.finup = kmb_ocs_hcu_finup, 1069 + .base.digest = kmb_ocs_hcu_digest, 1070 + .base.export = kmb_ocs_hcu_export, 1071 + .base.import = kmb_ocs_hcu_import, 1072 + .base.setkey = kmb_ocs_hcu_setkey, 1073 + .base.halg = { 1073 1074 .digestsize = SHA384_DIGEST_SIZE, 1074 1075 .statesize = sizeof(struct ocs_hcu_rctx), 1075 1076 .base = { ··· 1085 1084 .cra_init = kmb_ocs_hcu_hmac_cra_init, 1086 1085 .cra_exit = kmb_ocs_hcu_hmac_cra_exit, 1087 1086 } 1088 - } 1087 + }, 1088 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 1089 1089 }, 1090 1090 { 1091 - .init = kmb_ocs_hcu_init, 1092 - .update = kmb_ocs_hcu_update, 1093 - .final = kmb_ocs_hcu_final, 1094 - .finup = kmb_ocs_hcu_finup, 1095 - .digest = kmb_ocs_hcu_digest, 1096 - .export = kmb_ocs_hcu_export, 1097 - .import = kmb_ocs_hcu_import, 1098 - .halg = { 1091 + .base.init = kmb_ocs_hcu_init, 1092 + .base.update = kmb_ocs_hcu_update, 1093 + .base.final = kmb_ocs_hcu_final, 1094 + .base.finup = kmb_ocs_hcu_finup, 1095 + .base.digest = kmb_ocs_hcu_digest, 1096 + .base.export = kmb_ocs_hcu_export, 1097 + .base.import = kmb_ocs_hcu_import, 1098 + .base.halg = { 1099 1099 .digestsize = SHA512_DIGEST_SIZE, 1100 1100 .statesize = sizeof(struct ocs_hcu_rctx), 1101 1101 .base = { ··· 1110 1108 .cra_module = THIS_MODULE, 1111 1109 .cra_init = kmb_ocs_hcu_sha_cra_init, 1112 1110 } 1113 - } 1111 + }, 1112 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 1114 1113 }, 1115 1114 { 1116 - .init = kmb_ocs_hcu_init, 1117 - .update = kmb_ocs_hcu_update, 1118 - .final = kmb_ocs_hcu_final, 1119 - .finup = kmb_ocs_hcu_finup, 1120 - .digest = kmb_ocs_hcu_digest, 1121 - .export = kmb_ocs_hcu_export, 1122 - .import = kmb_ocs_hcu_import, 1123 - .setkey = kmb_ocs_hcu_setkey, 1124 - .halg = { 1115 + .base.init = kmb_ocs_hcu_init, 1116 + .base.update = kmb_ocs_hcu_update, 1117 + .base.final = kmb_ocs_hcu_final, 1118 + .base.finup = kmb_ocs_hcu_finup, 1119 + .base.digest = kmb_ocs_hcu_digest, 1120 + .base.export = kmb_ocs_hcu_export, 1121 + .base.import = kmb_ocs_hcu_import, 1122 + .base.setkey = kmb_ocs_hcu_setkey, 1123 + .base.halg = { 1125 1124 .digestsize = SHA512_DIGEST_SIZE, 1126 1125 .statesize = sizeof(struct ocs_hcu_rctx), 1127 1126 .base = { ··· 1137 1134 .cra_init = kmb_ocs_hcu_hmac_cra_init, 1138 1135 .cra_exit = kmb_ocs_hcu_hmac_cra_exit, 1139 1136 } 1140 - } 1137 + }, 1138 + .op.do_one_request = kmb_ocs_hcu_do_one_request, 1141 1139 }, 1142 1140 }; 1143 1141 ··· 1159 1155 if (!hcu_dev) 1160 1156 return -ENODEV; 1161 1157 1162 - crypto_unregister_ahashes(ocs_hcu_algs, ARRAY_SIZE(ocs_hcu_algs)); 1158 + crypto_engine_unregister_ahashes(ocs_hcu_algs, ARRAY_SIZE(ocs_hcu_algs)); 1163 1159 1164 1160 rc = crypto_engine_exit(hcu_dev->engine); 1165 1161 ··· 1227 1223 1228 1224 /* Security infrastructure guarantees OCS clock is enabled. */ 1229 1225 1230 - rc = crypto_register_ahashes(ocs_hcu_algs, ARRAY_SIZE(ocs_hcu_algs)); 1226 + rc = crypto_engine_register_ahashes(ocs_hcu_algs, ARRAY_SIZE(ocs_hcu_algs)); 1231 1227 if (rc) { 1232 1228 dev_err(dev, "Could not register algorithms.\n"); 1233 1229 goto cleanup;