diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-17 14:22:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-17 14:22:54 -0400 |
commit | 70477371dc350746d10431d74f0f213a8d59924c (patch) | |
tree | 6271978b6e4ee4b1e6f22775ad7fc0930c09d3ee /drivers/block | |
parent | 09fd671ccb2475436bd5f597f751ca4a7d177aea (diff) | |
parent | 34074205bb9f04b416efb3cbedcd90f418c86200 (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/block')
-rw-r--r-- | drivers/block/cryptoloop.c | 48 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 16 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 16 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_nl.c | 59 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 56 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_worker.c | 43 |
6 files changed, 128 insertions, 110 deletions
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c index 99e773cb70d0..3d31761c0ed0 100644 --- a/drivers/block/cryptoloop.c +++ b/drivers/block/cryptoloop.c | |||
@@ -21,9 +21,9 @@ | |||
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | 23 | ||
24 | #include <crypto/skcipher.h> | ||
24 | #include <linux/init.h> | 25 | #include <linux/init.h> |
25 | #include <linux/string.h> | 26 | #include <linux/string.h> |
26 | #include <linux/crypto.h> | ||
27 | #include <linux/blkdev.h> | 27 | #include <linux/blkdev.h> |
28 | #include <linux/scatterlist.h> | 28 | #include <linux/scatterlist.h> |
29 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
@@ -46,7 +46,7 @@ cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info) | |||
46 | char *cipher; | 46 | char *cipher; |
47 | char *mode; | 47 | char *mode; |
48 | char *cmsp = cms; /* c-m string pointer */ | 48 | char *cmsp = cms; /* c-m string pointer */ |
49 | struct crypto_blkcipher *tfm; | 49 | struct crypto_skcipher *tfm; |
50 | 50 | ||
51 | /* encryption breaks for non sector aligned offsets */ | 51 | /* encryption breaks for non sector aligned offsets */ |
52 | 52 | ||
@@ -82,12 +82,12 @@ cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info) | |||
82 | *cmsp++ = ')'; | 82 | *cmsp++ = ')'; |
83 | *cmsp = 0; | 83 | *cmsp = 0; |
84 | 84 | ||
85 | tfm = crypto_alloc_blkcipher(cms, 0, CRYPTO_ALG_ASYNC); | 85 | tfm = crypto_alloc_skcipher(cms, 0, CRYPTO_ALG_ASYNC); |
86 | if (IS_ERR(tfm)) | 86 | if (IS_ERR(tfm)) |
87 | return PTR_ERR(tfm); | 87 | return PTR_ERR(tfm); |
88 | 88 | ||
89 | err = crypto_blkcipher_setkey(tfm, info->lo_encrypt_key, | 89 | err = crypto_skcipher_setkey(tfm, info->lo_encrypt_key, |
90 | info->lo_encrypt_key_size); | 90 | info->lo_encrypt_key_size); |
91 | 91 | ||
92 | if (err != 0) | 92 | if (err != 0) |
93 | goto out_free_tfm; | 93 | goto out_free_tfm; |
@@ -96,17 +96,14 @@ cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info) | |||
96 | return 0; | 96 | return 0; |
97 | 97 | ||
98 | out_free_tfm: | 98 | out_free_tfm: |
99 | crypto_free_blkcipher(tfm); | 99 | crypto_free_skcipher(tfm); |
100 | 100 | ||
101 | out: | 101 | out: |
102 | return err; | 102 | return err; |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | typedef int (*encdec_cbc_t)(struct blkcipher_desc *desc, | 106 | typedef int (*encdec_cbc_t)(struct skcipher_request *req); |
107 | struct scatterlist *sg_out, | ||
108 | struct scatterlist *sg_in, | ||
109 | unsigned int nsg); | ||
110 | 107 | ||
111 | static int | 108 | static int |
112 | cryptoloop_transfer(struct loop_device *lo, int cmd, | 109 | cryptoloop_transfer(struct loop_device *lo, int cmd, |
@@ -114,11 +111,8 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
114 | struct page *loop_page, unsigned loop_off, | 111 | struct page *loop_page, unsigned loop_off, |
115 | int size, sector_t IV) | 112 | int size, sector_t IV) |
116 | { | 113 | { |
117 | struct crypto_blkcipher *tfm = lo->key_data; | 114 | struct crypto_skcipher *tfm = lo->key_data; |
118 | struct blkcipher_desc desc = { | 115 | SKCIPHER_REQUEST_ON_STACK(req, tfm); |
119 | .tfm = tfm, | ||
120 | .flags = CRYPTO_TFM_REQ_MAY_SLEEP, | ||
121 | }; | ||
122 | struct scatterlist sg_out; | 116 | struct scatterlist sg_out; |
123 | struct scatterlist sg_in; | 117 | struct scatterlist sg_in; |
124 | 118 | ||
@@ -127,6 +121,10 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
127 | unsigned in_offs, out_offs; | 121 | unsigned in_offs, out_offs; |
128 | int err; | 122 | int err; |
129 | 123 | ||
124 | skcipher_request_set_tfm(req, tfm); | ||
125 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, | ||
126 | NULL, NULL); | ||
127 | |||
130 | sg_init_table(&sg_out, 1); | 128 | sg_init_table(&sg_out, 1); |
131 | sg_init_table(&sg_in, 1); | 129 | sg_init_table(&sg_in, 1); |
132 | 130 | ||
@@ -135,13 +133,13 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
135 | in_offs = raw_off; | 133 | in_offs = raw_off; |
136 | out_page = loop_page; | 134 | out_page = loop_page; |
137 | out_offs = loop_off; | 135 | out_offs = loop_off; |
138 | encdecfunc = crypto_blkcipher_crt(tfm)->decrypt; | 136 | encdecfunc = crypto_skcipher_decrypt; |
139 | } else { | 137 | } else { |
140 | in_page = loop_page; | 138 | in_page = loop_page; |
141 | in_offs = loop_off; | 139 | in_offs = loop_off; |
142 | out_page = raw_page; | 140 | out_page = raw_page; |
143 | out_offs = raw_off; | 141 | out_offs = raw_off; |
144 | encdecfunc = crypto_blkcipher_crt(tfm)->encrypt; | 142 | encdecfunc = crypto_skcipher_encrypt; |
145 | } | 143 | } |
146 | 144 | ||
147 | while (size > 0) { | 145 | while (size > 0) { |
@@ -152,10 +150,10 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
152 | sg_set_page(&sg_in, in_page, sz, in_offs); | 150 | sg_set_page(&sg_in, in_page, sz, in_offs); |
153 | sg_set_page(&sg_out, out_page, sz, out_offs); | 151 | sg_set_page(&sg_out, out_page, sz, out_offs); |
154 | 152 | ||
155 | desc.info = iv; | 153 | skcipher_request_set_crypt(req, &sg_in, &sg_out, sz, iv); |
156 | err = encdecfunc(&desc, &sg_out, &sg_in, sz); | 154 | err = encdecfunc(req); |
157 | if (err) | 155 | if (err) |
158 | return err; | 156 | goto out; |
159 | 157 | ||
160 | IV++; | 158 | IV++; |
161 | size -= sz; | 159 | size -= sz; |
@@ -163,7 +161,11 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
163 | out_offs += sz; | 161 | out_offs += sz; |
164 | } | 162 | } |
165 | 163 | ||
166 | return 0; | 164 | err = 0; |
165 | |||
166 | out: | ||
167 | skcipher_request_zero(req); | ||
168 | return err; | ||
167 | } | 169 | } |
168 | 170 | ||
169 | static int | 171 | static int |
@@ -175,9 +177,9 @@ cryptoloop_ioctl(struct loop_device *lo, int cmd, unsigned long arg) | |||
175 | static int | 177 | static int |
176 | cryptoloop_release(struct loop_device *lo) | 178 | cryptoloop_release(struct loop_device *lo) |
177 | { | 179 | { |
178 | struct crypto_blkcipher *tfm = lo->key_data; | 180 | struct crypto_skcipher *tfm = lo->key_data; |
179 | if (tfm != NULL) { | 181 | if (tfm != NULL) { |
180 | crypto_free_blkcipher(tfm); | 182 | crypto_free_skcipher(tfm); |
181 | lo->key_data = NULL; | 183 | lo->key_data = NULL; |
182 | return 0; | 184 | return 0; |
183 | } | 185 | } |
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 34bc84efc29e..c227fd4cad75 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -26,13 +26,13 @@ | |||
26 | #ifndef _DRBD_INT_H | 26 | #ifndef _DRBD_INT_H |
27 | #define _DRBD_INT_H | 27 | #define _DRBD_INT_H |
28 | 28 | ||
29 | #include <crypto/hash.h> | ||
29 | #include <linux/compiler.h> | 30 | #include <linux/compiler.h> |
30 | #include <linux/types.h> | 31 | #include <linux/types.h> |
31 | #include <linux/list.h> | 32 | #include <linux/list.h> |
32 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
33 | #include <linux/bitops.h> | 34 | #include <linux/bitops.h> |
34 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
35 | #include <linux/crypto.h> | ||
36 | #include <linux/ratelimit.h> | 36 | #include <linux/ratelimit.h> |
37 | #include <linux/tcp.h> | 37 | #include <linux/tcp.h> |
38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
@@ -724,11 +724,11 @@ struct drbd_connection { | |||
724 | 724 | ||
725 | struct list_head transfer_log; /* all requests not yet fully processed */ | 725 | struct list_head transfer_log; /* all requests not yet fully processed */ |
726 | 726 | ||
727 | struct crypto_hash *cram_hmac_tfm; | 727 | struct crypto_shash *cram_hmac_tfm; |
728 | struct crypto_hash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */ | 728 | struct crypto_ahash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */ |
729 | struct crypto_hash *peer_integrity_tfm; /* checksums we verify, only accessed from receiver thread */ | 729 | struct crypto_ahash *peer_integrity_tfm; /* checksums we verify, only accessed from receiver thread */ |
730 | struct crypto_hash *csums_tfm; | 730 | struct crypto_ahash *csums_tfm; |
731 | struct crypto_hash *verify_tfm; | 731 | struct crypto_ahash *verify_tfm; |
732 | void *int_dig_in; | 732 | void *int_dig_in; |
733 | void *int_dig_vv; | 733 | void *int_dig_vv; |
734 | 734 | ||
@@ -1524,8 +1524,8 @@ static inline void ov_out_of_sync_print(struct drbd_device *device) | |||
1524 | } | 1524 | } |
1525 | 1525 | ||
1526 | 1526 | ||
1527 | extern void drbd_csum_bio(struct crypto_hash *, struct bio *, void *); | 1527 | extern void drbd_csum_bio(struct crypto_ahash *, struct bio *, void *); |
1528 | extern void drbd_csum_ee(struct crypto_hash *, struct drbd_peer_request *, void *); | 1528 | extern void drbd_csum_ee(struct crypto_ahash *, struct drbd_peer_request *, void *); |
1529 | /* worker callbacks */ | 1529 | /* worker callbacks */ |
1530 | extern int w_e_end_data_req(struct drbd_work *, int); | 1530 | extern int w_e_end_data_req(struct drbd_work *, int); |
1531 | extern int w_e_end_rsdata_req(struct drbd_work *, int); | 1531 | extern int w_e_end_rsdata_req(struct drbd_work *, int); |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 5b43dfb79819..fa209773d494 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1340,7 +1340,7 @@ void drbd_send_ack_dp(struct drbd_peer_device *peer_device, enum drbd_packet cmd | |||
1340 | struct p_data *dp, int data_size) | 1340 | struct p_data *dp, int data_size) |
1341 | { | 1341 | { |
1342 | if (peer_device->connection->peer_integrity_tfm) | 1342 | if (peer_device->connection->peer_integrity_tfm) |
1343 | data_size -= crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm); | 1343 | data_size -= crypto_ahash_digestsize(peer_device->connection->peer_integrity_tfm); |
1344 | _drbd_send_ack(peer_device, cmd, dp->sector, cpu_to_be32(data_size), | 1344 | _drbd_send_ack(peer_device, cmd, dp->sector, cpu_to_be32(data_size), |
1345 | dp->block_id); | 1345 | dp->block_id); |
1346 | } | 1346 | } |
@@ -1629,7 +1629,7 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request * | |||
1629 | sock = &peer_device->connection->data; | 1629 | sock = &peer_device->connection->data; |
1630 | p = drbd_prepare_command(peer_device, sock); | 1630 | p = drbd_prepare_command(peer_device, sock); |
1631 | digest_size = peer_device->connection->integrity_tfm ? | 1631 | digest_size = peer_device->connection->integrity_tfm ? |
1632 | crypto_hash_digestsize(peer_device->connection->integrity_tfm) : 0; | 1632 | crypto_ahash_digestsize(peer_device->connection->integrity_tfm) : 0; |
1633 | 1633 | ||
1634 | if (!p) | 1634 | if (!p) |
1635 | return -EIO; | 1635 | return -EIO; |
@@ -1718,7 +1718,7 @@ int drbd_send_block(struct drbd_peer_device *peer_device, enum drbd_packet cmd, | |||
1718 | p = drbd_prepare_command(peer_device, sock); | 1718 | p = drbd_prepare_command(peer_device, sock); |
1719 | 1719 | ||
1720 | digest_size = peer_device->connection->integrity_tfm ? | 1720 | digest_size = peer_device->connection->integrity_tfm ? |
1721 | crypto_hash_digestsize(peer_device->connection->integrity_tfm) : 0; | 1721 | crypto_ahash_digestsize(peer_device->connection->integrity_tfm) : 0; |
1722 | 1722 | ||
1723 | if (!p) | 1723 | if (!p) |
1724 | return -EIO; | 1724 | return -EIO; |
@@ -2498,11 +2498,11 @@ void conn_free_crypto(struct drbd_connection *connection) | |||
2498 | { | 2498 | { |
2499 | drbd_free_sock(connection); | 2499 | drbd_free_sock(connection); |
2500 | 2500 | ||
2501 | crypto_free_hash(connection->csums_tfm); | 2501 | crypto_free_ahash(connection->csums_tfm); |
2502 | crypto_free_hash(connection->verify_tfm); | 2502 | crypto_free_ahash(connection->verify_tfm); |
2503 | crypto_free_hash(connection->cram_hmac_tfm); | 2503 | crypto_free_shash(connection->cram_hmac_tfm); |
2504 | crypto_free_hash(connection->integrity_tfm); | 2504 | crypto_free_ahash(connection->integrity_tfm); |
2505 | crypto_free_hash(connection->peer_integrity_tfm); | 2505 | crypto_free_ahash(connection->peer_integrity_tfm); |
2506 | kfree(connection->int_dig_in); | 2506 | kfree(connection->int_dig_in); |
2507 | kfree(connection->int_dig_vv); | 2507 | kfree(connection->int_dig_vv); |
2508 | 2508 | ||
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index c055c5e12f24..226eb0c9f0fb 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
@@ -2160,19 +2160,34 @@ check_net_options(struct drbd_connection *connection, struct net_conf *new_net_c | |||
2160 | } | 2160 | } |
2161 | 2161 | ||
2162 | struct crypto { | 2162 | struct crypto { |
2163 | struct crypto_hash *verify_tfm; | 2163 | struct crypto_ahash *verify_tfm; |
2164 | struct crypto_hash *csums_tfm; | 2164 | struct crypto_ahash *csums_tfm; |
2165 | struct crypto_hash *cram_hmac_tfm; | 2165 | struct crypto_shash *cram_hmac_tfm; |
2166 | struct crypto_hash *integrity_tfm; | 2166 | struct crypto_ahash *integrity_tfm; |
2167 | }; | 2167 | }; |
2168 | 2168 | ||
2169 | static int | 2169 | static int |
2170 | alloc_hash(struct crypto_hash **tfm, char *tfm_name, int err_alg) | 2170 | alloc_shash(struct crypto_shash **tfm, char *tfm_name, int err_alg) |
2171 | { | 2171 | { |
2172 | if (!tfm_name[0]) | 2172 | if (!tfm_name[0]) |
2173 | return NO_ERROR; | 2173 | return NO_ERROR; |
2174 | 2174 | ||
2175 | *tfm = crypto_alloc_hash(tfm_name, 0, CRYPTO_ALG_ASYNC); | 2175 | *tfm = crypto_alloc_shash(tfm_name, 0, 0); |
2176 | if (IS_ERR(*tfm)) { | ||
2177 | *tfm = NULL; | ||
2178 | return err_alg; | ||
2179 | } | ||
2180 | |||
2181 | return NO_ERROR; | ||
2182 | } | ||
2183 | |||
2184 | static int | ||
2185 | alloc_ahash(struct crypto_ahash **tfm, char *tfm_name, int err_alg) | ||
2186 | { | ||
2187 | if (!tfm_name[0]) | ||
2188 | return NO_ERROR; | ||
2189 | |||
2190 | *tfm = crypto_alloc_ahash(tfm_name, 0, CRYPTO_ALG_ASYNC); | ||
2176 | if (IS_ERR(*tfm)) { | 2191 | if (IS_ERR(*tfm)) { |
2177 | *tfm = NULL; | 2192 | *tfm = NULL; |
2178 | return err_alg; | 2193 | return err_alg; |
@@ -2187,24 +2202,24 @@ alloc_crypto(struct crypto *crypto, struct net_conf *new_net_conf) | |||
2187 | char hmac_name[CRYPTO_MAX_ALG_NAME]; | 2202 | char hmac_name[CRYPTO_MAX_ALG_NAME]; |
2188 | enum drbd_ret_code rv; | 2203 | enum drbd_ret_code rv; |
2189 | 2204 | ||
2190 | rv = alloc_hash(&crypto->csums_tfm, new_net_conf->csums_alg, | 2205 | rv = alloc_ahash(&crypto->csums_tfm, new_net_conf->csums_alg, |
2191 | ERR_CSUMS_ALG); | 2206 | ERR_CSUMS_ALG); |
2192 | if (rv != NO_ERROR) | 2207 | if (rv != NO_ERROR) |
2193 | return rv; | 2208 | return rv; |
2194 | rv = alloc_hash(&crypto->verify_tfm, new_net_conf->verify_alg, | 2209 | rv = alloc_ahash(&crypto->verify_tfm, new_net_conf->verify_alg, |
2195 | ERR_VERIFY_ALG); | 2210 | ERR_VERIFY_ALG); |
2196 | if (rv != NO_ERROR) | 2211 | if (rv != NO_ERROR) |
2197 | return rv; | 2212 | return rv; |
2198 | rv = alloc_hash(&crypto->integrity_tfm, new_net_conf->integrity_alg, | 2213 | rv = alloc_ahash(&crypto->integrity_tfm, new_net_conf->integrity_alg, |
2199 | ERR_INTEGRITY_ALG); | 2214 | ERR_INTEGRITY_ALG); |
2200 | if (rv != NO_ERROR) | 2215 | if (rv != NO_ERROR) |
2201 | return rv; | 2216 | return rv; |
2202 | if (new_net_conf->cram_hmac_alg[0] != 0) { | 2217 | if (new_net_conf->cram_hmac_alg[0] != 0) { |
2203 | snprintf(hmac_name, CRYPTO_MAX_ALG_NAME, "hmac(%s)", | 2218 | snprintf(hmac_name, CRYPTO_MAX_ALG_NAME, "hmac(%s)", |
2204 | new_net_conf->cram_hmac_alg); | 2219 | new_net_conf->cram_hmac_alg); |
2205 | 2220 | ||
2206 | rv = alloc_hash(&crypto->cram_hmac_tfm, hmac_name, | 2221 | rv = alloc_shash(&crypto->cram_hmac_tfm, hmac_name, |
2207 | ERR_AUTH_ALG); | 2222 | ERR_AUTH_ALG); |
2208 | } | 2223 | } |
2209 | 2224 | ||
2210 | return rv; | 2225 | return rv; |
@@ -2212,10 +2227,10 @@ alloc_crypto(struct crypto *crypto, struct net_conf *new_net_conf) | |||
2212 | 2227 | ||
2213 | static void free_crypto(struct crypto *crypto) | 2228 | static void free_crypto(struct crypto *crypto) |
2214 | { | 2229 | { |
2215 | crypto_free_hash(crypto->cram_hmac_tfm); | 2230 | crypto_free_shash(crypto->cram_hmac_tfm); |
2216 | crypto_free_hash(crypto->integrity_tfm); | 2231 | crypto_free_ahash(crypto->integrity_tfm); |
2217 | crypto_free_hash(crypto->csums_tfm); | 2232 | crypto_free_ahash(crypto->csums_tfm); |
2218 | crypto_free_hash(crypto->verify_tfm); | 2233 | crypto_free_ahash(crypto->verify_tfm); |
2219 | } | 2234 | } |
2220 | 2235 | ||
2221 | int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) | 2236 | int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) |
@@ -2292,23 +2307,23 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) | |||
2292 | rcu_assign_pointer(connection->net_conf, new_net_conf); | 2307 | rcu_assign_pointer(connection->net_conf, new_net_conf); |
2293 | 2308 | ||
2294 | if (!rsr) { | 2309 | if (!rsr) { |
2295 | crypto_free_hash(connection->csums_tfm); | 2310 | crypto_free_ahash(connection->csums_tfm); |
2296 | connection->csums_tfm = crypto.csums_tfm; | 2311 | connection->csums_tfm = crypto.csums_tfm; |
2297 | crypto.csums_tfm = NULL; | 2312 | crypto.csums_tfm = NULL; |
2298 | } | 2313 | } |
2299 | if (!ovr) { | 2314 | if (!ovr) { |
2300 | crypto_free_hash(connection->verify_tfm); | 2315 | crypto_free_ahash(connection->verify_tfm); |
2301 | connection->verify_tfm = crypto.verify_tfm; | 2316 | connection->verify_tfm = crypto.verify_tfm; |
2302 | crypto.verify_tfm = NULL; | 2317 | crypto.verify_tfm = NULL; |
2303 | } | 2318 | } |
2304 | 2319 | ||
2305 | crypto_free_hash(connection->integrity_tfm); | 2320 | crypto_free_ahash(connection->integrity_tfm); |
2306 | connection->integrity_tfm = crypto.integrity_tfm; | 2321 | connection->integrity_tfm = crypto.integrity_tfm; |
2307 | if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100) | 2322 | if (connection->cstate >= C_WF_REPORT_PARAMS && connection->agreed_pro_version >= 100) |
2308 | /* Do this without trying to take connection->data.mutex again. */ | 2323 | /* Do this without trying to take connection->data.mutex again. */ |
2309 | __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); | 2324 | __drbd_send_protocol(connection, P_PROTOCOL_UPDATE); |
2310 | 2325 | ||
2311 | crypto_free_hash(connection->cram_hmac_tfm); | 2326 | crypto_free_shash(connection->cram_hmac_tfm); |
2312 | connection->cram_hmac_tfm = crypto.cram_hmac_tfm; | 2327 | connection->cram_hmac_tfm = crypto.cram_hmac_tfm; |
2313 | 2328 | ||
2314 | mutex_unlock(&connection->resource->conf_update); | 2329 | mutex_unlock(&connection->resource->conf_update); |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 1957fe8601dc..050aaa1c0350 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -1627,7 +1627,7 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector, | |||
1627 | 1627 | ||
1628 | digest_size = 0; | 1628 | digest_size = 0; |
1629 | if (!trim && peer_device->connection->peer_integrity_tfm) { | 1629 | if (!trim && peer_device->connection->peer_integrity_tfm) { |
1630 | digest_size = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm); | 1630 | digest_size = crypto_ahash_digestsize(peer_device->connection->peer_integrity_tfm); |
1631 | /* | 1631 | /* |
1632 | * FIXME: Receive the incoming digest into the receive buffer | 1632 | * FIXME: Receive the incoming digest into the receive buffer |
1633 | * here, together with its struct p_data? | 1633 | * here, together with its struct p_data? |
@@ -1741,7 +1741,7 @@ static int recv_dless_read(struct drbd_peer_device *peer_device, struct drbd_req | |||
1741 | 1741 | ||
1742 | digest_size = 0; | 1742 | digest_size = 0; |
1743 | if (peer_device->connection->peer_integrity_tfm) { | 1743 | if (peer_device->connection->peer_integrity_tfm) { |
1744 | digest_size = crypto_hash_digestsize(peer_device->connection->peer_integrity_tfm); | 1744 | digest_size = crypto_ahash_digestsize(peer_device->connection->peer_integrity_tfm); |
1745 | err = drbd_recv_all_warn(peer_device->connection, dig_in, digest_size); | 1745 | err = drbd_recv_all_warn(peer_device->connection, dig_in, digest_size); |
1746 | if (err) | 1746 | if (err) |
1747 | return err; | 1747 | return err; |
@@ -3321,7 +3321,7 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in | |||
3321 | int p_proto, p_discard_my_data, p_two_primaries, cf; | 3321 | int p_proto, p_discard_my_data, p_two_primaries, cf; |
3322 | struct net_conf *nc, *old_net_conf, *new_net_conf = NULL; | 3322 | struct net_conf *nc, *old_net_conf, *new_net_conf = NULL; |
3323 | char integrity_alg[SHARED_SECRET_MAX] = ""; | 3323 | char integrity_alg[SHARED_SECRET_MAX] = ""; |
3324 | struct crypto_hash *peer_integrity_tfm = NULL; | 3324 | struct crypto_ahash *peer_integrity_tfm = NULL; |
3325 | void *int_dig_in = NULL, *int_dig_vv = NULL; | 3325 | void *int_dig_in = NULL, *int_dig_vv = NULL; |
3326 | 3326 | ||
3327 | p_proto = be32_to_cpu(p->protocol); | 3327 | p_proto = be32_to_cpu(p->protocol); |
@@ -3402,14 +3402,14 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in | |||
3402 | * change. | 3402 | * change. |
3403 | */ | 3403 | */ |
3404 | 3404 | ||
3405 | peer_integrity_tfm = crypto_alloc_hash(integrity_alg, 0, CRYPTO_ALG_ASYNC); | 3405 | peer_integrity_tfm = crypto_alloc_ahash(integrity_alg, 0, CRYPTO_ALG_ASYNC); |
3406 | if (!peer_integrity_tfm) { | 3406 | if (!peer_integrity_tfm) { |
3407 | drbd_err(connection, "peer data-integrity-alg %s not supported\n", | 3407 | drbd_err(connection, "peer data-integrity-alg %s not supported\n", |
3408 | integrity_alg); | 3408 | integrity_alg); |
3409 | goto disconnect; | 3409 | goto disconnect; |
3410 | } | 3410 | } |
3411 | 3411 | ||
3412 | hash_size = crypto_hash_digestsize(peer_integrity_tfm); | 3412 | hash_size = crypto_ahash_digestsize(peer_integrity_tfm); |
3413 | int_dig_in = kmalloc(hash_size, GFP_KERNEL); | 3413 | int_dig_in = kmalloc(hash_size, GFP_KERNEL); |
3414 | int_dig_vv = kmalloc(hash_size, GFP_KERNEL); | 3414 | int_dig_vv = kmalloc(hash_size, GFP_KERNEL); |
3415 | if (!(int_dig_in && int_dig_vv)) { | 3415 | if (!(int_dig_in && int_dig_vv)) { |
@@ -3439,7 +3439,7 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in | |||
3439 | mutex_unlock(&connection->resource->conf_update); | 3439 | mutex_unlock(&connection->resource->conf_update); |
3440 | mutex_unlock(&connection->data.mutex); | 3440 | mutex_unlock(&connection->data.mutex); |
3441 | 3441 | ||
3442 | crypto_free_hash(connection->peer_integrity_tfm); | 3442 | crypto_free_ahash(connection->peer_integrity_tfm); |
3443 | kfree(connection->int_dig_in); | 3443 | kfree(connection->int_dig_in); |
3444 | kfree(connection->int_dig_vv); | 3444 | kfree(connection->int_dig_vv); |
3445 | connection->peer_integrity_tfm = peer_integrity_tfm; | 3445 | connection->peer_integrity_tfm = peer_integrity_tfm; |
@@ -3457,7 +3457,7 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in | |||
3457 | disconnect_rcu_unlock: | 3457 | disconnect_rcu_unlock: |
3458 | rcu_read_unlock(); | 3458 | rcu_read_unlock(); |
3459 | disconnect: | 3459 | disconnect: |
3460 | crypto_free_hash(peer_integrity_tfm); | 3460 | crypto_free_ahash(peer_integrity_tfm); |
3461 | kfree(int_dig_in); | 3461 | kfree(int_dig_in); |
3462 | kfree(int_dig_vv); | 3462 | kfree(int_dig_vv); |
3463 | conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD); | 3463 | conn_request_state(connection, NS(conn, C_DISCONNECTING), CS_HARD); |
@@ -3469,15 +3469,15 @@ disconnect: | |||
3469 | * return: NULL (alg name was "") | 3469 | * return: NULL (alg name was "") |
3470 | * ERR_PTR(error) if something goes wrong | 3470 | * ERR_PTR(error) if something goes wrong |
3471 | * or the crypto hash ptr, if it worked out ok. */ | 3471 | * or the crypto hash ptr, if it worked out ok. */ |
3472 | static struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_device *device, | 3472 | static struct crypto_ahash *drbd_crypto_alloc_digest_safe(const struct drbd_device *device, |
3473 | const char *alg, const char *name) | 3473 | const char *alg, const char *name) |
3474 | { | 3474 | { |
3475 | struct crypto_hash *tfm; | 3475 | struct crypto_ahash *tfm; |
3476 | 3476 | ||
3477 | if (!alg[0]) | 3477 | if (!alg[0]) |
3478 | return NULL; | 3478 | return NULL; |
3479 | 3479 | ||
3480 | tfm = crypto_alloc_hash(alg, 0, CRYPTO_ALG_ASYNC); | 3480 | tfm = crypto_alloc_ahash(alg, 0, CRYPTO_ALG_ASYNC); |
3481 | if (IS_ERR(tfm)) { | 3481 | if (IS_ERR(tfm)) { |
3482 | drbd_err(device, "Can not allocate \"%s\" as %s (reason: %ld)\n", | 3482 | drbd_err(device, "Can not allocate \"%s\" as %s (reason: %ld)\n", |
3483 | alg, name, PTR_ERR(tfm)); | 3483 | alg, name, PTR_ERR(tfm)); |
@@ -3530,8 +3530,8 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i | |||
3530 | struct drbd_device *device; | 3530 | struct drbd_device *device; |
3531 | struct p_rs_param_95 *p; | 3531 | struct p_rs_param_95 *p; |
3532 | unsigned int header_size, data_size, exp_max_sz; | 3532 | unsigned int header_size, data_size, exp_max_sz; |
3533 | struct crypto_hash *verify_tfm = NULL; | 3533 | struct crypto_ahash *verify_tfm = NULL; |
3534 | struct crypto_hash *csums_tfm = NULL; | 3534 | struct crypto_ahash *csums_tfm = NULL; |
3535 | struct net_conf *old_net_conf, *new_net_conf = NULL; | 3535 | struct net_conf *old_net_conf, *new_net_conf = NULL; |
3536 | struct disk_conf *old_disk_conf = NULL, *new_disk_conf = NULL; | 3536 | struct disk_conf *old_disk_conf = NULL, *new_disk_conf = NULL; |
3537 | const int apv = connection->agreed_pro_version; | 3537 | const int apv = connection->agreed_pro_version; |
@@ -3678,14 +3678,14 @@ static int receive_SyncParam(struct drbd_connection *connection, struct packet_i | |||
3678 | if (verify_tfm) { | 3678 | if (verify_tfm) { |
3679 | strcpy(new_net_conf->verify_alg, p->verify_alg); | 3679 | strcpy(new_net_conf->verify_alg, p->verify_alg); |
3680 | new_net_conf->verify_alg_len = strlen(p->verify_alg) + 1; | 3680 | new_net_conf->verify_alg_len = strlen(p->verify_alg) + 1; |
3681 | crypto_free_hash(peer_device->connection->verify_tfm); | 3681 | crypto_free_ahash(peer_device->connection->verify_tfm); |
3682 | peer_device->connection->verify_tfm = verify_tfm; | 3682 | peer_device->connection->verify_tfm = verify_tfm; |
3683 | drbd_info(device, "using verify-alg: \"%s\"\n", p->verify_alg); | 3683 | drbd_info(device, "using verify-alg: \"%s\"\n", p->verify_alg); |
3684 | } | 3684 | } |
3685 | if (csums_tfm) { | 3685 | if (csums_tfm) { |
3686 | strcpy(new_net_conf->csums_alg, p->csums_alg); | 3686 | strcpy(new_net_conf->csums_alg, p->csums_alg); |
3687 | new_net_conf->csums_alg_len = strlen(p->csums_alg) + 1; | 3687 | new_net_conf->csums_alg_len = strlen(p->csums_alg) + 1; |
3688 | crypto_free_hash(peer_device->connection->csums_tfm); | 3688 | crypto_free_ahash(peer_device->connection->csums_tfm); |
3689 | peer_device->connection->csums_tfm = csums_tfm; | 3689 | peer_device->connection->csums_tfm = csums_tfm; |
3690 | drbd_info(device, "using csums-alg: \"%s\"\n", p->csums_alg); | 3690 | drbd_info(device, "using csums-alg: \"%s\"\n", p->csums_alg); |
3691 | } | 3691 | } |
@@ -3729,9 +3729,9 @@ disconnect: | |||
3729 | mutex_unlock(&connection->resource->conf_update); | 3729 | mutex_unlock(&connection->resource->conf_update); |
3730 | /* just for completeness: actually not needed, | 3730 | /* just for completeness: actually not needed, |
3731 | * as this is not reached if csums_tfm was ok. */ | 3731 | * as this is not reached if csums_tfm was ok. */ |
3732 | crypto_free_hash(csums_tfm); | 3732 | crypto_free_ahash(csums_tfm); |
3733 | /* but free the verify_tfm again, if csums_tfm did not work out */ | 3733 | /* but free the verify_tfm again, if csums_tfm did not work out */ |
3734 | crypto_free_hash(verify_tfm); | 3734 | crypto_free_ahash(verify_tfm); |
3735 | conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD); | 3735 | conn_request_state(peer_device->connection, NS(conn, C_DISCONNECTING), CS_HARD); |
3736 | return -EIO; | 3736 | return -EIO; |
3737 | } | 3737 | } |
@@ -4925,14 +4925,13 @@ static int drbd_do_auth(struct drbd_connection *connection) | |||
4925 | { | 4925 | { |
4926 | struct drbd_socket *sock; | 4926 | struct drbd_socket *sock; |
4927 | char my_challenge[CHALLENGE_LEN]; /* 64 Bytes... */ | 4927 | char my_challenge[CHALLENGE_LEN]; /* 64 Bytes... */ |
4928 | struct scatterlist sg; | ||
4929 | char *response = NULL; | 4928 | char *response = NULL; |
4930 | char *right_response = NULL; | 4929 | char *right_response = NULL; |
4931 | char *peers_ch = NULL; | 4930 | char *peers_ch = NULL; |
4932 | unsigned int key_len; | 4931 | unsigned int key_len; |
4933 | char secret[SHARED_SECRET_MAX]; /* 64 byte */ | 4932 | char secret[SHARED_SECRET_MAX]; /* 64 byte */ |
4934 | unsigned int resp_size; | 4933 | unsigned int resp_size; |
4935 | struct hash_desc desc; | 4934 | SHASH_DESC_ON_STACK(desc, connection->cram_hmac_tfm); |
4936 | struct packet_info pi; | 4935 | struct packet_info pi; |
4937 | struct net_conf *nc; | 4936 | struct net_conf *nc; |
4938 | int err, rv; | 4937 | int err, rv; |
@@ -4945,12 +4944,12 @@ static int drbd_do_auth(struct drbd_connection *connection) | |||
4945 | memcpy(secret, nc->shared_secret, key_len); | 4944 | memcpy(secret, nc->shared_secret, key_len); |
4946 | rcu_read_unlock(); | 4945 | rcu_read_unlock(); |
4947 | 4946 | ||
4948 | desc.tfm = connection->cram_hmac_tfm; | 4947 | desc->tfm = connection->cram_hmac_tfm; |
4949 | desc.flags = 0; | 4948 | desc->flags = 0; |
4950 | 4949 | ||
4951 | rv = crypto_hash_setkey(connection->cram_hmac_tfm, (u8 *)secret, key_len); | 4950 | rv = crypto_shash_setkey(connection->cram_hmac_tfm, (u8 *)secret, key_len); |
4952 | if (rv) { | 4951 | if (rv) { |
4953 | drbd_err(connection, "crypto_hash_setkey() failed with %d\n", rv); | 4952 | drbd_err(connection, "crypto_shash_setkey() failed with %d\n", rv); |
4954 | rv = -1; | 4953 | rv = -1; |
4955 | goto fail; | 4954 | goto fail; |
4956 | } | 4955 | } |
@@ -5011,7 +5010,7 @@ static int drbd_do_auth(struct drbd_connection *connection) | |||
5011 | goto fail; | 5010 | goto fail; |
5012 | } | 5011 | } |
5013 | 5012 | ||
5014 | resp_size = crypto_hash_digestsize(connection->cram_hmac_tfm); | 5013 | resp_size = crypto_shash_digestsize(connection->cram_hmac_tfm); |
5015 | response = kmalloc(resp_size, GFP_NOIO); | 5014 | response = kmalloc(resp_size, GFP_NOIO); |
5016 | if (response == NULL) { | 5015 | if (response == NULL) { |
5017 | drbd_err(connection, "kmalloc of response failed\n"); | 5016 | drbd_err(connection, "kmalloc of response failed\n"); |
@@ -5019,10 +5018,7 @@ static int drbd_do_auth(struct drbd_connection *connection) | |||
5019 | goto fail; | 5018 | goto fail; |
5020 | } | 5019 | } |
5021 | 5020 | ||
5022 | sg_init_table(&sg, 1); | 5021 | rv = crypto_shash_digest(desc, peers_ch, pi.size, response); |
5023 | sg_set_buf(&sg, peers_ch, pi.size); | ||
5024 | |||
5025 | rv = crypto_hash_digest(&desc, &sg, sg.length, response); | ||
5026 | if (rv) { | 5022 | if (rv) { |
5027 | drbd_err(connection, "crypto_hash_digest() failed with %d\n", rv); | 5023 | drbd_err(connection, "crypto_hash_digest() failed with %d\n", rv); |
5028 | rv = -1; | 5024 | rv = -1; |
@@ -5070,9 +5066,8 @@ static int drbd_do_auth(struct drbd_connection *connection) | |||
5070 | goto fail; | 5066 | goto fail; |
5071 | } | 5067 | } |
5072 | 5068 | ||
5073 | sg_set_buf(&sg, my_challenge, CHALLENGE_LEN); | 5069 | rv = crypto_shash_digest(desc, my_challenge, CHALLENGE_LEN, |
5074 | 5070 | right_response); | |
5075 | rv = crypto_hash_digest(&desc, &sg, sg.length, right_response); | ||
5076 | if (rv) { | 5071 | if (rv) { |
5077 | drbd_err(connection, "crypto_hash_digest() failed with %d\n", rv); | 5072 | drbd_err(connection, "crypto_hash_digest() failed with %d\n", rv); |
5078 | rv = -1; | 5073 | rv = -1; |
@@ -5091,6 +5086,7 @@ static int drbd_do_auth(struct drbd_connection *connection) | |||
5091 | kfree(peers_ch); | 5086 | kfree(peers_ch); |
5092 | kfree(response); | 5087 | kfree(response); |
5093 | kfree(right_response); | 5088 | kfree(right_response); |
5089 | shash_desc_zero(desc); | ||
5094 | 5090 | ||
5095 | return rv; | 5091 | return rv; |
5096 | } | 5092 | } |
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index eff716c27b1f..4d87499f0d54 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c | |||
@@ -274,51 +274,56 @@ void drbd_request_endio(struct bio *bio) | |||
274 | complete_master_bio(device, &m); | 274 | complete_master_bio(device, &m); |
275 | } | 275 | } |
276 | 276 | ||
277 | void drbd_csum_ee(struct crypto_hash *tfm, struct drbd_peer_request *peer_req, void *digest) | 277 | void drbd_csum_ee(struct crypto_ahash *tfm, struct drbd_peer_request *peer_req, void *digest) |
278 | { | 278 | { |
279 | struct hash_desc desc; | 279 | AHASH_REQUEST_ON_STACK(req, tfm); |
280 | struct scatterlist sg; | 280 | struct scatterlist sg; |
281 | struct page *page = peer_req->pages; | 281 | struct page *page = peer_req->pages; |
282 | struct page *tmp; | 282 | struct page *tmp; |
283 | unsigned len; | 283 | unsigned len; |
284 | 284 | ||
285 | desc.tfm = tfm; | 285 | ahash_request_set_tfm(req, tfm); |
286 | desc.flags = 0; | 286 | ahash_request_set_callback(req, 0, NULL, NULL); |
287 | 287 | ||
288 | sg_init_table(&sg, 1); | 288 | sg_init_table(&sg, 1); |
289 | crypto_hash_init(&desc); | 289 | crypto_ahash_init(req); |
290 | 290 | ||
291 | while ((tmp = page_chain_next(page))) { | 291 | while ((tmp = page_chain_next(page))) { |
292 | /* all but the last page will be fully used */ | 292 | /* all but the last page will be fully used */ |
293 | sg_set_page(&sg, page, PAGE_SIZE, 0); | 293 | sg_set_page(&sg, page, PAGE_SIZE, 0); |
294 | crypto_hash_update(&desc, &sg, sg.length); | 294 | ahash_request_set_crypt(req, &sg, NULL, sg.length); |
295 | crypto_ahash_update(req); | ||
295 | page = tmp; | 296 | page = tmp; |
296 | } | 297 | } |
297 | /* and now the last, possibly only partially used page */ | 298 | /* and now the last, possibly only partially used page */ |
298 | len = peer_req->i.size & (PAGE_SIZE - 1); | 299 | len = peer_req->i.size & (PAGE_SIZE - 1); |
299 | sg_set_page(&sg, page, len ?: PAGE_SIZE, 0); | 300 | sg_set_page(&sg, page, len ?: PAGE_SIZE, 0); |
300 | crypto_hash_update(&desc, &sg, sg.length); | 301 | ahash_request_set_crypt(req, &sg, digest, sg.length); |
301 | crypto_hash_final(&desc, digest); | 302 | crypto_ahash_finup(req); |
303 | ahash_request_zero(req); | ||
302 | } | 304 | } |
303 | 305 | ||
304 | void drbd_csum_bio(struct crypto_hash *tfm, struct bio *bio, void *digest) | 306 | void drbd_csum_bio(struct crypto_ahash *tfm, struct bio *bio, void *digest) |
305 | { | 307 | { |
306 | struct hash_desc desc; | 308 | AHASH_REQUEST_ON_STACK(req, tfm); |
307 | struct scatterlist sg; | 309 | struct scatterlist sg; |
308 | struct bio_vec bvec; | 310 | struct bio_vec bvec; |
309 | struct bvec_iter iter; | 311 | struct bvec_iter iter; |
310 | 312 | ||
311 | desc.tfm = tfm; | 313 | ahash_request_set_tfm(req, tfm); |
312 | desc.flags = 0; | 314 | ahash_request_set_callback(req, 0, NULL, NULL); |
313 | 315 | ||
314 | sg_init_table(&sg, 1); | 316 | sg_init_table(&sg, 1); |
315 | crypto_hash_init(&desc); | 317 | crypto_ahash_init(req); |
316 | 318 | ||
317 | bio_for_each_segment(bvec, bio, iter) { | 319 | bio_for_each_segment(bvec, bio, iter) { |
318 | sg_set_page(&sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset); | 320 | sg_set_page(&sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset); |
319 | crypto_hash_update(&desc, &sg, sg.length); | 321 | ahash_request_set_crypt(req, &sg, NULL, sg.length); |
322 | crypto_ahash_update(req); | ||
320 | } | 323 | } |
321 | crypto_hash_final(&desc, digest); | 324 | ahash_request_set_crypt(req, NULL, digest, 0); |
325 | crypto_ahash_final(req); | ||
326 | ahash_request_zero(req); | ||
322 | } | 327 | } |
323 | 328 | ||
324 | /* MAYBE merge common code with w_e_end_ov_req */ | 329 | /* MAYBE merge common code with w_e_end_ov_req */ |
@@ -337,7 +342,7 @@ static int w_e_send_csum(struct drbd_work *w, int cancel) | |||
337 | if (unlikely((peer_req->flags & EE_WAS_ERROR) != 0)) | 342 | if (unlikely((peer_req->flags & EE_WAS_ERROR) != 0)) |
338 | goto out; | 343 | goto out; |
339 | 344 | ||
340 | digest_size = crypto_hash_digestsize(peer_device->connection->csums_tfm); | 345 | digest_size = crypto_ahash_digestsize(peer_device->connection->csums_tfm); |
341 | digest = kmalloc(digest_size, GFP_NOIO); | 346 | digest = kmalloc(digest_size, GFP_NOIO); |
342 | if (digest) { | 347 | if (digest) { |
343 | sector_t sector = peer_req->i.sector; | 348 | sector_t sector = peer_req->i.sector; |
@@ -1113,7 +1118,7 @@ int w_e_end_csum_rs_req(struct drbd_work *w, int cancel) | |||
1113 | * a real fix would be much more involved, | 1118 | * a real fix would be much more involved, |
1114 | * introducing more locking mechanisms */ | 1119 | * introducing more locking mechanisms */ |
1115 | if (peer_device->connection->csums_tfm) { | 1120 | if (peer_device->connection->csums_tfm) { |
1116 | digest_size = crypto_hash_digestsize(peer_device->connection->csums_tfm); | 1121 | digest_size = crypto_ahash_digestsize(peer_device->connection->csums_tfm); |
1117 | D_ASSERT(device, digest_size == di->digest_size); | 1122 | D_ASSERT(device, digest_size == di->digest_size); |
1118 | digest = kmalloc(digest_size, GFP_NOIO); | 1123 | digest = kmalloc(digest_size, GFP_NOIO); |
1119 | } | 1124 | } |
@@ -1163,7 +1168,7 @@ int w_e_end_ov_req(struct drbd_work *w, int cancel) | |||
1163 | if (unlikely(cancel)) | 1168 | if (unlikely(cancel)) |
1164 | goto out; | 1169 | goto out; |
1165 | 1170 | ||
1166 | digest_size = crypto_hash_digestsize(peer_device->connection->verify_tfm); | 1171 | digest_size = crypto_ahash_digestsize(peer_device->connection->verify_tfm); |
1167 | digest = kmalloc(digest_size, GFP_NOIO); | 1172 | digest = kmalloc(digest_size, GFP_NOIO); |
1168 | if (!digest) { | 1173 | if (!digest) { |
1169 | err = 1; /* terminate the connection in case the allocation failed */ | 1174 | err = 1; /* terminate the connection in case the allocation failed */ |
@@ -1235,7 +1240,7 @@ int w_e_end_ov_reply(struct drbd_work *w, int cancel) | |||
1235 | di = peer_req->digest; | 1240 | di = peer_req->digest; |
1236 | 1241 | ||
1237 | if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) { | 1242 | if (likely((peer_req->flags & EE_WAS_ERROR) == 0)) { |
1238 | digest_size = crypto_hash_digestsize(peer_device->connection->verify_tfm); | 1243 | digest_size = crypto_ahash_digestsize(peer_device->connection->verify_tfm); |
1239 | digest = kmalloc(digest_size, GFP_NOIO); | 1244 | digest = kmalloc(digest_size, GFP_NOIO); |
1240 | if (digest) { | 1245 | if (digest) { |
1241 | drbd_csum_ee(peer_device->connection->verify_tfm, peer_req, digest); | 1246 | drbd_csum_ee(peer_device->connection->verify_tfm, peer_req, digest); |