summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 14:22:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 14:22:54 -0400
commit70477371dc350746d10431d74f0f213a8d59924c (patch)
tree6271978b6e4ee4b1e6f22775ad7fc0930c09d3ee /drivers/target
parent09fd671ccb2475436bd5f597f751ca4a7d177aea (diff)
parent34074205bb9f04b416efb3cbedcd90f418c86200 (diff)
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: "Here is the crypto update for 4.6: API: - Convert remaining crypto_hash users to shash or ahash, also convert blkcipher/ablkcipher users to skcipher. - Remove crypto_hash interface. - Remove crypto_pcomp interface. - Add crypto engine for async cipher drivers. - Add akcipher documentation. - Add skcipher documentation. Algorithms: - Rename crypto/crc32 to avoid name clash with lib/crc32. - Fix bug in keywrap where we zero the wrong pointer. Drivers: - Support T5/M5, T7/M7 SPARC CPUs in n2 hwrng driver. - Add PIC32 hwrng driver. - Support BCM6368 in bcm63xx hwrng driver. - Pack structs for 32-bit compat users in qat. - Use crypto engine in omap-aes. - Add support for sama5d2x SoCs in atmel-sha. - Make atmel-sha available again. - Make sahara hashing available again. - Make ccp hashing available again. - Make sha1-mb available again. - Add support for multiple devices in ccp. - Improve DMA performance in caam. - Add hashing support to rockchip" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (116 commits) crypto: qat - remove redundant arbiter configuration crypto: ux500 - fix checks of error code returned by devm_ioremap_resource() crypto: atmel - fix checks of error code returned by devm_ioremap_resource() crypto: qat - Change the definition of icp_qat_uof_regtype hwrng: exynos - use __maybe_unused to hide pm functions crypto: ccp - Add abstraction for device-specific calls crypto: ccp - CCP versioning support crypto: ccp - Support for multiple CCPs crypto: ccp - Remove check for x86 family and model crypto: ccp - memset request context to zero during import lib/mpi: use "static inline" instead of "extern inline" lib/mpi: avoid assembler warning hwrng: bcm63xx - fix non device tree compatibility crypto: testmgr - allow rfc3686 aes-ctr variants in fips mode. crypto: qat - The AE id should be less than the maximal AE number lib/mpi: Endianness fix crypto: rockchip - add hash support for crypto engine in rk3288 crypto: xts - fix compile errors crypto: doc - add skcipher API documentation crypto: doc - update AEAD AD handling ...
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/iscsi/iscsi_target.c86
-rw-r--r--drivers/target/iscsi/iscsi_target_auth.c98
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c45
3 files changed, 111 insertions, 118 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 576a7a43470c..961202f4e9aa 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -16,9 +16,9 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 ******************************************************************************/ 17 ******************************************************************************/
18 18
19#include <crypto/hash.h>
19#include <linux/string.h> 20#include <linux/string.h>
20#include <linux/kthread.h> 21#include <linux/kthread.h>
21#include <linux/crypto.h>
22#include <linux/completion.h> 22#include <linux/completion.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
@@ -1190,7 +1190,7 @@ iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1190} 1190}
1191 1191
1192static u32 iscsit_do_crypto_hash_sg( 1192static u32 iscsit_do_crypto_hash_sg(
1193 struct hash_desc *hash, 1193 struct ahash_request *hash,
1194 struct iscsi_cmd *cmd, 1194 struct iscsi_cmd *cmd,
1195 u32 data_offset, 1195 u32 data_offset,
1196 u32 data_length, 1196 u32 data_length,
@@ -1201,7 +1201,7 @@ static u32 iscsit_do_crypto_hash_sg(
1201 struct scatterlist *sg; 1201 struct scatterlist *sg;
1202 unsigned int page_off; 1202 unsigned int page_off;
1203 1203
1204 crypto_hash_init(hash); 1204 crypto_ahash_init(hash);
1205 1205
1206 sg = cmd->first_data_sg; 1206 sg = cmd->first_data_sg;
1207 page_off = cmd->first_data_sg_off; 1207 page_off = cmd->first_data_sg_off;
@@ -1209,7 +1209,8 @@ static u32 iscsit_do_crypto_hash_sg(
1209 while (data_length) { 1209 while (data_length) {
1210 u32 cur_len = min_t(u32, data_length, (sg->length - page_off)); 1210 u32 cur_len = min_t(u32, data_length, (sg->length - page_off));
1211 1211
1212 crypto_hash_update(hash, sg, cur_len); 1212 ahash_request_set_crypt(hash, sg, NULL, cur_len);
1213 crypto_ahash_update(hash);
1213 1214
1214 data_length -= cur_len; 1215 data_length -= cur_len;
1215 page_off = 0; 1216 page_off = 0;
@@ -1221,33 +1222,34 @@ static u32 iscsit_do_crypto_hash_sg(
1221 struct scatterlist pad_sg; 1222 struct scatterlist pad_sg;
1222 1223
1223 sg_init_one(&pad_sg, pad_bytes, padding); 1224 sg_init_one(&pad_sg, pad_bytes, padding);
1224 crypto_hash_update(hash, &pad_sg, padding); 1225 ahash_request_set_crypt(hash, &pad_sg, (u8 *)&data_crc,
1226 padding);
1227 crypto_ahash_finup(hash);
1228 } else {
1229 ahash_request_set_crypt(hash, NULL, (u8 *)&data_crc, 0);
1230 crypto_ahash_final(hash);
1225 } 1231 }
1226 crypto_hash_final(hash, (u8 *) &data_crc);
1227 1232
1228 return data_crc; 1233 return data_crc;
1229} 1234}
1230 1235
1231static void iscsit_do_crypto_hash_buf( 1236static void iscsit_do_crypto_hash_buf(
1232 struct hash_desc *hash, 1237 struct ahash_request *hash,
1233 const void *buf, 1238 const void *buf,
1234 u32 payload_length, 1239 u32 payload_length,
1235 u32 padding, 1240 u32 padding,
1236 u8 *pad_bytes, 1241 u8 *pad_bytes,
1237 u8 *data_crc) 1242 u8 *data_crc)
1238{ 1243{
1239 struct scatterlist sg; 1244 struct scatterlist sg[2];
1240 1245
1241 crypto_hash_init(hash); 1246 sg_init_table(sg, ARRAY_SIZE(sg));
1247 sg_set_buf(sg, buf, payload_length);
1248 sg_set_buf(sg + 1, pad_bytes, padding);
1242 1249
1243 sg_init_one(&sg, buf, payload_length); 1250 ahash_request_set_crypt(hash, sg, data_crc, payload_length + padding);
1244 crypto_hash_update(hash, &sg, payload_length);
1245 1251
1246 if (padding) { 1252 crypto_ahash_digest(hash);
1247 sg_init_one(&sg, pad_bytes, padding);
1248 crypto_hash_update(hash, &sg, padding);
1249 }
1250 crypto_hash_final(hash, data_crc);
1251} 1253}
1252 1254
1253int 1255int
@@ -1422,7 +1424,7 @@ iscsit_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1422 if (conn->conn_ops->DataDigest) { 1424 if (conn->conn_ops->DataDigest) {
1423 u32 data_crc; 1425 u32 data_crc;
1424 1426
1425 data_crc = iscsit_do_crypto_hash_sg(&conn->conn_rx_hash, cmd, 1427 data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd,
1426 be32_to_cpu(hdr->offset), 1428 be32_to_cpu(hdr->offset),
1427 payload_length, padding, 1429 payload_length, padding,
1428 cmd->pad_bytes); 1430 cmd->pad_bytes);
@@ -1682,7 +1684,7 @@ static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1682 } 1684 }
1683 1685
1684 if (conn->conn_ops->DataDigest) { 1686 if (conn->conn_ops->DataDigest) {
1685 iscsit_do_crypto_hash_buf(&conn->conn_rx_hash, 1687 iscsit_do_crypto_hash_buf(conn->conn_rx_hash,
1686 ping_data, payload_length, 1688 ping_data, payload_length,
1687 padding, cmd->pad_bytes, 1689 padding, cmd->pad_bytes,
1688 (u8 *)&data_crc); 1690 (u8 *)&data_crc);
@@ -2101,7 +2103,7 @@ iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
2101 goto reject; 2103 goto reject;
2102 2104
2103 if (conn->conn_ops->DataDigest) { 2105 if (conn->conn_ops->DataDigest) {
2104 iscsit_do_crypto_hash_buf(&conn->conn_rx_hash, 2106 iscsit_do_crypto_hash_buf(conn->conn_rx_hash,
2105 text_in, payload_length, 2107 text_in, payload_length,
2106 padding, (u8 *)&pad_bytes, 2108 padding, (u8 *)&pad_bytes,
2107 (u8 *)&data_crc); 2109 (u8 *)&data_crc);
@@ -2440,7 +2442,7 @@ static int iscsit_handle_immediate_data(
2440 if (conn->conn_ops->DataDigest) { 2442 if (conn->conn_ops->DataDigest) {
2441 u32 data_crc; 2443 u32 data_crc;
2442 2444
2443 data_crc = iscsit_do_crypto_hash_sg(&conn->conn_rx_hash, cmd, 2445 data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd,
2444 cmd->write_data_done, length, padding, 2446 cmd->write_data_done, length, padding,
2445 cmd->pad_bytes); 2447 cmd->pad_bytes);
2446 2448
@@ -2553,7 +2555,7 @@ static int iscsit_send_conn_drop_async_message(
2553 if (conn->conn_ops->HeaderDigest) { 2555 if (conn->conn_ops->HeaderDigest) {
2554 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2556 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2555 2557
2556 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2558 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr,
2557 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2559 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2558 2560
2559 cmd->tx_size += ISCSI_CRC_LEN; 2561 cmd->tx_size += ISCSI_CRC_LEN;
@@ -2683,7 +2685,7 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2683 if (conn->conn_ops->HeaderDigest) { 2685 if (conn->conn_ops->HeaderDigest) {
2684 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2686 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2685 2687
2686 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 2688 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, cmd->pdu,
2687 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2689 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2688 2690
2689 iov[0].iov_len += ISCSI_CRC_LEN; 2691 iov[0].iov_len += ISCSI_CRC_LEN;
@@ -2711,7 +2713,7 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2711 cmd->padding); 2713 cmd->padding);
2712 } 2714 }
2713 if (conn->conn_ops->DataDigest) { 2715 if (conn->conn_ops->DataDigest) {
2714 cmd->data_crc = iscsit_do_crypto_hash_sg(&conn->conn_tx_hash, cmd, 2716 cmd->data_crc = iscsit_do_crypto_hash_sg(conn->conn_tx_hash, cmd,
2715 datain.offset, datain.length, cmd->padding, cmd->pad_bytes); 2717 datain.offset, datain.length, cmd->padding, cmd->pad_bytes);
2716 2718
2717 iov[iov_count].iov_base = &cmd->data_crc; 2719 iov[iov_count].iov_base = &cmd->data_crc;
@@ -2857,7 +2859,7 @@ iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2857 if (conn->conn_ops->HeaderDigest) { 2859 if (conn->conn_ops->HeaderDigest) {
2858 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2860 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2859 2861
2860 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, &cmd->pdu[0], 2862 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, &cmd->pdu[0],
2861 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2863 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2862 2864
2863 iov[0].iov_len += ISCSI_CRC_LEN; 2865 iov[0].iov_len += ISCSI_CRC_LEN;
@@ -2915,7 +2917,7 @@ static int iscsit_send_unsolicited_nopin(
2915 if (conn->conn_ops->HeaderDigest) { 2917 if (conn->conn_ops->HeaderDigest) {
2916 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2918 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2917 2919
2918 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2920 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr,
2919 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2921 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2920 2922
2921 tx_size += ISCSI_CRC_LEN; 2923 tx_size += ISCSI_CRC_LEN;
@@ -2963,7 +2965,7 @@ iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2963 if (conn->conn_ops->HeaderDigest) { 2965 if (conn->conn_ops->HeaderDigest) {
2964 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2966 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
2965 2967
2966 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2968 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr,
2967 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2969 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
2968 2970
2969 iov[0].iov_len += ISCSI_CRC_LEN; 2971 iov[0].iov_len += ISCSI_CRC_LEN;
@@ -2993,7 +2995,7 @@ iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
2993 " padding bytes.\n", padding); 2995 " padding bytes.\n", padding);
2994 } 2996 }
2995 if (conn->conn_ops->DataDigest) { 2997 if (conn->conn_ops->DataDigest) {
2996 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2998 iscsit_do_crypto_hash_buf(conn->conn_tx_hash,
2997 cmd->buf_ptr, cmd->buf_ptr_size, 2999 cmd->buf_ptr, cmd->buf_ptr_size,
2998 padding, (u8 *)&cmd->pad_bytes, 3000 padding, (u8 *)&cmd->pad_bytes,
2999 (u8 *)&cmd->data_crc); 3001 (u8 *)&cmd->data_crc);
@@ -3049,7 +3051,7 @@ static int iscsit_send_r2t(
3049 if (conn->conn_ops->HeaderDigest) { 3051 if (conn->conn_ops->HeaderDigest) {
3050 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3052 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3051 3053
3052 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3054 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr,
3053 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3055 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3054 3056
3055 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3057 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN;
@@ -3239,7 +3241,7 @@ static int iscsit_send_response(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3239 } 3241 }
3240 3242
3241 if (conn->conn_ops->DataDigest) { 3243 if (conn->conn_ops->DataDigest) {
3242 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3244 iscsit_do_crypto_hash_buf(conn->conn_tx_hash,
3243 cmd->sense_buffer, 3245 cmd->sense_buffer,
3244 (cmd->se_cmd.scsi_sense_length + padding), 3246 (cmd->se_cmd.scsi_sense_length + padding),
3245 0, NULL, (u8 *)&cmd->data_crc); 3247 0, NULL, (u8 *)&cmd->data_crc);
@@ -3262,7 +3264,7 @@ static int iscsit_send_response(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3262 if (conn->conn_ops->HeaderDigest) { 3264 if (conn->conn_ops->HeaderDigest) {
3263 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3265 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3264 3266
3265 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 3267 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, cmd->pdu,
3266 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3268 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3267 3269
3268 iov[0].iov_len += ISCSI_CRC_LEN; 3270 iov[0].iov_len += ISCSI_CRC_LEN;
@@ -3332,7 +3334,7 @@ iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)
3332 if (conn->conn_ops->HeaderDigest) { 3334 if (conn->conn_ops->HeaderDigest) {
3333 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3335 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3334 3336
3335 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3337 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr,
3336 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3338 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3337 3339
3338 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3340 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN;
@@ -3601,7 +3603,7 @@ static int iscsit_send_text_rsp(
3601 if (conn->conn_ops->HeaderDigest) { 3603 if (conn->conn_ops->HeaderDigest) {
3602 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3604 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3603 3605
3604 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3606 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr,
3605 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3607 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3606 3608
3607 iov[0].iov_len += ISCSI_CRC_LEN; 3609 iov[0].iov_len += ISCSI_CRC_LEN;
@@ -3611,7 +3613,7 @@ static int iscsit_send_text_rsp(
3611 } 3613 }
3612 3614
3613 if (conn->conn_ops->DataDigest) { 3615 if (conn->conn_ops->DataDigest) {
3614 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3616 iscsit_do_crypto_hash_buf(conn->conn_tx_hash,
3615 cmd->buf_ptr, text_length, 3617 cmd->buf_ptr, text_length,
3616 0, NULL, (u8 *)&cmd->data_crc); 3618 0, NULL, (u8 *)&cmd->data_crc);
3617 3619
@@ -3668,7 +3670,7 @@ static int iscsit_send_reject(
3668 if (conn->conn_ops->HeaderDigest) { 3670 if (conn->conn_ops->HeaderDigest) {
3669 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3671 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN];
3670 3672
3671 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3673 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr,
3672 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3674 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest);
3673 3675
3674 iov[0].iov_len += ISCSI_CRC_LEN; 3676 iov[0].iov_len += ISCSI_CRC_LEN;
@@ -3678,7 +3680,7 @@ static int iscsit_send_reject(
3678 } 3680 }
3679 3681
3680 if (conn->conn_ops->DataDigest) { 3682 if (conn->conn_ops->DataDigest) {
3681 iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->buf_ptr, 3683 iscsit_do_crypto_hash_buf(conn->conn_tx_hash, cmd->buf_ptr,
3682 ISCSI_HDR_LEN, 0, NULL, (u8 *)&cmd->data_crc); 3684 ISCSI_HDR_LEN, 0, NULL, (u8 *)&cmd->data_crc);
3683 3685
3684 iov[iov_count].iov_base = &cmd->data_crc; 3686 iov[iov_count].iov_base = &cmd->data_crc;
@@ -4145,7 +4147,7 @@ int iscsi_target_rx_thread(void *arg)
4145 goto transport_err; 4147 goto transport_err;
4146 } 4148 }
4147 4149
4148 iscsit_do_crypto_hash_buf(&conn->conn_rx_hash, 4150 iscsit_do_crypto_hash_buf(conn->conn_rx_hash,
4149 buffer, ISCSI_HDR_LEN, 4151 buffer, ISCSI_HDR_LEN,
4150 0, NULL, (u8 *)&checksum); 4152 0, NULL, (u8 *)&checksum);
4151 4153
@@ -4359,10 +4361,14 @@ int iscsit_close_connection(
4359 */ 4361 */
4360 iscsit_check_conn_usage_count(conn); 4362 iscsit_check_conn_usage_count(conn);
4361 4363
4362 if (conn->conn_rx_hash.tfm) 4364 ahash_request_free(conn->conn_tx_hash);
4363 crypto_free_hash(conn->conn_rx_hash.tfm); 4365 if (conn->conn_rx_hash) {
4364 if (conn->conn_tx_hash.tfm) 4366 struct crypto_ahash *tfm;
4365 crypto_free_hash(conn->conn_tx_hash.tfm); 4367
4368 tfm = crypto_ahash_reqtfm(conn->conn_rx_hash);
4369 ahash_request_free(conn->conn_rx_hash);
4370 crypto_free_ahash(tfm);
4371 }
4366 4372
4367 free_cpumask_var(conn->conn_cpumask); 4373 free_cpumask_var(conn->conn_cpumask);
4368 4374
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
index 47e249dccb5f..667406fcf4d3 100644
--- a/drivers/target/iscsi/iscsi_target_auth.c
+++ b/drivers/target/iscsi/iscsi_target_auth.c
@@ -16,9 +16,9 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 ******************************************************************************/ 17 ******************************************************************************/
18 18
19#include <crypto/hash.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/string.h> 21#include <linux/string.h>
21#include <linux/crypto.h>
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/scatterlist.h> 23#include <linux/scatterlist.h>
24 24
@@ -185,9 +185,8 @@ static int chap_server_compute_md5(
185 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH]; 185 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH];
186 size_t compare_len; 186 size_t compare_len;
187 struct iscsi_chap *chap = conn->auth_protocol; 187 struct iscsi_chap *chap = conn->auth_protocol;
188 struct crypto_hash *tfm; 188 struct crypto_shash *tfm = NULL;
189 struct hash_desc desc; 189 struct shash_desc *desc = NULL;
190 struct scatterlist sg;
191 int auth_ret = -1, ret, challenge_len; 190 int auth_ret = -1, ret, challenge_len;
192 191
193 memset(identifier, 0, 10); 192 memset(identifier, 0, 10);
@@ -245,52 +244,47 @@ static int chap_server_compute_md5(
245 pr_debug("[server] Got CHAP_R=%s\n", chap_r); 244 pr_debug("[server] Got CHAP_R=%s\n", chap_r);
246 chap_string_to_hex(client_digest, chap_r, strlen(chap_r)); 245 chap_string_to_hex(client_digest, chap_r, strlen(chap_r));
247 246
248 tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); 247 tfm = crypto_alloc_shash("md5", 0, 0);
249 if (IS_ERR(tfm)) { 248 if (IS_ERR(tfm)) {
250 pr_err("Unable to allocate struct crypto_hash\n"); 249 tfm = NULL;
250 pr_err("Unable to allocate struct crypto_shash\n");
251 goto out; 251 goto out;
252 } 252 }
253 desc.tfm = tfm;
254 desc.flags = 0;
255 253
256 ret = crypto_hash_init(&desc); 254 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(tfm), GFP_KERNEL);
257 if (ret < 0) { 255 if (!desc) {
258 pr_err("crypto_hash_init() failed\n"); 256 pr_err("Unable to allocate struct shash_desc\n");
259 crypto_free_hash(tfm);
260 goto out; 257 goto out;
261 } 258 }
262 259
263 sg_init_one(&sg, &chap->id, 1); 260 desc->tfm = tfm;
264 ret = crypto_hash_update(&desc, &sg, 1); 261 desc->flags = 0;
262
263 ret = crypto_shash_init(desc);
265 if (ret < 0) { 264 if (ret < 0) {
266 pr_err("crypto_hash_update() failed for id\n"); 265 pr_err("crypto_shash_init() failed\n");
267 crypto_free_hash(tfm);
268 goto out; 266 goto out;
269 } 267 }
270 268
271 sg_init_one(&sg, &auth->password, strlen(auth->password)); 269 ret = crypto_shash_update(desc, &chap->id, 1);
272 ret = crypto_hash_update(&desc, &sg, strlen(auth->password));
273 if (ret < 0) { 270 if (ret < 0) {
274 pr_err("crypto_hash_update() failed for password\n"); 271 pr_err("crypto_shash_update() failed for id\n");
275 crypto_free_hash(tfm);
276 goto out; 272 goto out;
277 } 273 }
278 274
279 sg_init_one(&sg, chap->challenge, CHAP_CHALLENGE_LENGTH); 275 ret = crypto_shash_update(desc, (char *)&auth->password,
280 ret = crypto_hash_update(&desc, &sg, CHAP_CHALLENGE_LENGTH); 276 strlen(auth->password));
281 if (ret < 0) { 277 if (ret < 0) {
282 pr_err("crypto_hash_update() failed for challenge\n"); 278 pr_err("crypto_shash_update() failed for password\n");
283 crypto_free_hash(tfm);
284 goto out; 279 goto out;
285 } 280 }
286 281
287 ret = crypto_hash_final(&desc, server_digest); 282 ret = crypto_shash_finup(desc, chap->challenge,
283 CHAP_CHALLENGE_LENGTH, server_digest);
288 if (ret < 0) { 284 if (ret < 0) {
289 pr_err("crypto_hash_final() failed for server digest\n"); 285 pr_err("crypto_shash_finup() failed for challenge\n");
290 crypto_free_hash(tfm);
291 goto out; 286 goto out;
292 } 287 }
293 crypto_free_hash(tfm);
294 288
295 chap_binaryhex_to_asciihex(response, server_digest, MD5_SIGNATURE_SIZE); 289 chap_binaryhex_to_asciihex(response, server_digest, MD5_SIGNATURE_SIZE);
296 pr_debug("[server] MD5 Server Digest: %s\n", response); 290 pr_debug("[server] MD5 Server Digest: %s\n", response);
@@ -306,9 +300,8 @@ static int chap_server_compute_md5(
306 * authentication is not enabled. 300 * authentication is not enabled.
307 */ 301 */
308 if (!auth->authenticate_target) { 302 if (!auth->authenticate_target) {
309 kfree(challenge); 303 auth_ret = 0;
310 kfree(challenge_binhex); 304 goto out;
311 return 0;
312 } 305 }
313 /* 306 /*
314 * Get CHAP_I. 307 * Get CHAP_I.
@@ -372,58 +365,37 @@ static int chap_server_compute_md5(
372 /* 365 /*
373 * Generate CHAP_N and CHAP_R for mutual authentication. 366 * Generate CHAP_N and CHAP_R for mutual authentication.
374 */ 367 */
375 tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); 368 ret = crypto_shash_init(desc);
376 if (IS_ERR(tfm)) {
377 pr_err("Unable to allocate struct crypto_hash\n");
378 goto out;
379 }
380 desc.tfm = tfm;
381 desc.flags = 0;
382
383 ret = crypto_hash_init(&desc);
384 if (ret < 0) { 369 if (ret < 0) {
385 pr_err("crypto_hash_init() failed\n"); 370 pr_err("crypto_shash_init() failed\n");
386 crypto_free_hash(tfm);
387 goto out; 371 goto out;
388 } 372 }
389 373
390 /* To handle both endiannesses */ 374 /* To handle both endiannesses */
391 id_as_uchar = id; 375 id_as_uchar = id;
392 sg_init_one(&sg, &id_as_uchar, 1); 376 ret = crypto_shash_update(desc, &id_as_uchar, 1);
393 ret = crypto_hash_update(&desc, &sg, 1);
394 if (ret < 0) { 377 if (ret < 0) {
395 pr_err("crypto_hash_update() failed for id\n"); 378 pr_err("crypto_shash_update() failed for id\n");
396 crypto_free_hash(tfm);
397 goto out; 379 goto out;
398 } 380 }
399 381
400 sg_init_one(&sg, auth->password_mutual, 382 ret = crypto_shash_update(desc, auth->password_mutual,
401 strlen(auth->password_mutual)); 383 strlen(auth->password_mutual));
402 ret = crypto_hash_update(&desc, &sg, strlen(auth->password_mutual));
403 if (ret < 0) { 384 if (ret < 0) {
404 pr_err("crypto_hash_update() failed for" 385 pr_err("crypto_shash_update() failed for"
405 " password_mutual\n"); 386 " password_mutual\n");
406 crypto_free_hash(tfm);
407 goto out; 387 goto out;
408 } 388 }
409 /* 389 /*
410 * Convert received challenge to binary hex. 390 * Convert received challenge to binary hex.
411 */ 391 */
412 sg_init_one(&sg, challenge_binhex, challenge_len); 392 ret = crypto_shash_finup(desc, challenge_binhex, challenge_len,
413 ret = crypto_hash_update(&desc, &sg, challenge_len); 393 digest);
414 if (ret < 0) { 394 if (ret < 0) {
415 pr_err("crypto_hash_update() failed for ma challenge\n"); 395 pr_err("crypto_shash_finup() failed for ma challenge\n");
416 crypto_free_hash(tfm);
417 goto out; 396 goto out;
418 } 397 }
419 398
420 ret = crypto_hash_final(&desc, digest);
421 if (ret < 0) {
422 pr_err("crypto_hash_final() failed for ma digest\n");
423 crypto_free_hash(tfm);
424 goto out;
425 }
426 crypto_free_hash(tfm);
427 /* 399 /*
428 * Generate CHAP_N and CHAP_R. 400 * Generate CHAP_N and CHAP_R.
429 */ 401 */
@@ -440,6 +412,8 @@ static int chap_server_compute_md5(
440 pr_debug("[server] Sending CHAP_R=0x%s\n", response); 412 pr_debug("[server] Sending CHAP_R=0x%s\n", response);
441 auth_ret = 0; 413 auth_ret = 0;
442out: 414out:
415 kzfree(desc);
416 crypto_free_shash(tfm);
443 kfree(challenge); 417 kfree(challenge);
444 kfree(challenge_binhex); 418 kfree(challenge_binhex);
445 return auth_ret; 419 return auth_ret;
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index 96e78c823d13..8436d56c5f0c 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -16,9 +16,9 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 ******************************************************************************/ 17 ******************************************************************************/
18 18
19#include <crypto/hash.h>
19#include <linux/string.h> 20#include <linux/string.h>
20#include <linux/kthread.h> 21#include <linux/kthread.h>
21#include <linux/crypto.h>
22#include <linux/idr.h> 22#include <linux/idr.h>
23#include <scsi/iscsi_proto.h> 23#include <scsi/iscsi_proto.h>
24#include <target/target_core_base.h> 24#include <target/target_core_base.h>
@@ -115,27 +115,36 @@ out_login:
115 */ 115 */
116int iscsi_login_setup_crypto(struct iscsi_conn *conn) 116int iscsi_login_setup_crypto(struct iscsi_conn *conn)
117{ 117{
118 struct crypto_ahash *tfm;
119
118 /* 120 /*
119 * Setup slicing by CRC32C algorithm for RX and TX libcrypto contexts 121 * Setup slicing by CRC32C algorithm for RX and TX libcrypto contexts
120 * which will default to crc32c_intel.ko for cpu_has_xmm4_2, or fallback 122 * which will default to crc32c_intel.ko for cpu_has_xmm4_2, or fallback
121 * to software 1x8 byte slicing from crc32c.ko 123 * to software 1x8 byte slicing from crc32c.ko
122 */ 124 */
123 conn->conn_rx_hash.flags = 0; 125 tfm = crypto_alloc_ahash("crc32c", 0, CRYPTO_ALG_ASYNC);
124 conn->conn_rx_hash.tfm = crypto_alloc_hash("crc32c", 0, 126 if (IS_ERR(tfm)) {
125 CRYPTO_ALG_ASYNC); 127 pr_err("crypto_alloc_ahash() failed\n");
126 if (IS_ERR(conn->conn_rx_hash.tfm)) {
127 pr_err("crypto_alloc_hash() failed for conn_rx_tfm\n");
128 return -ENOMEM; 128 return -ENOMEM;
129 } 129 }
130 130
131 conn->conn_tx_hash.flags = 0; 131 conn->conn_rx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
132 conn->conn_tx_hash.tfm = crypto_alloc_hash("crc32c", 0, 132 if (!conn->conn_rx_hash) {
133 CRYPTO_ALG_ASYNC); 133 pr_err("ahash_request_alloc() failed for conn_rx_hash\n");
134 if (IS_ERR(conn->conn_tx_hash.tfm)) { 134 crypto_free_ahash(tfm);
135 pr_err("crypto_alloc_hash() failed for conn_tx_tfm\n"); 135 return -ENOMEM;
136 crypto_free_hash(conn->conn_rx_hash.tfm); 136 }
137 ahash_request_set_callback(conn->conn_rx_hash, 0, NULL, NULL);
138
139 conn->conn_tx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
140 if (!conn->conn_tx_hash) {
141 pr_err("ahash_request_alloc() failed for conn_tx_hash\n");
142 ahash_request_free(conn->conn_rx_hash);
143 conn->conn_rx_hash = NULL;
144 crypto_free_ahash(tfm);
137 return -ENOMEM; 145 return -ENOMEM;
138 } 146 }
147 ahash_request_set_callback(conn->conn_tx_hash, 0, NULL, NULL);
139 148
140 return 0; 149 return 0;
141} 150}
@@ -1174,10 +1183,14 @@ old_sess_out:
1174 iscsit_dec_session_usage_count(conn->sess); 1183 iscsit_dec_session_usage_count(conn->sess);
1175 } 1184 }
1176 1185
1177 if (!IS_ERR(conn->conn_rx_hash.tfm)) 1186 ahash_request_free(conn->conn_tx_hash);
1178 crypto_free_hash(conn->conn_rx_hash.tfm); 1187 if (conn->conn_rx_hash) {
1179 if (!IS_ERR(conn->conn_tx_hash.tfm)) 1188 struct crypto_ahash *tfm;
1180 crypto_free_hash(conn->conn_tx_hash.tfm); 1189
1190 tfm = crypto_ahash_reqtfm(conn->conn_rx_hash);
1191 ahash_request_free(conn->conn_rx_hash);
1192 crypto_free_ahash(tfm);
1193 }
1181 1194
1182 free_cpumask_var(conn->conn_cpumask); 1195 free_cpumask_var(conn->conn_cpumask);
1183 1196