mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
tcp: Use ahash
This patch replaces uses of the long obsolete hash interface with ahash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5821c76970
commit
cf80e0e47e
5 changed files with 55 additions and 41 deletions
|
@ -66,7 +66,7 @@
|
|||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
#include <linux/crypto.h>
|
||||
#include <crypto/hash.h>
|
||||
#include <linux/scatterlist.h>
|
||||
|
||||
static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb);
|
||||
|
@ -540,7 +540,8 @@ static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
|
|||
bp->len = cpu_to_be32(nbytes);
|
||||
|
||||
sg_init_one(&sg, bp, sizeof(*bp));
|
||||
return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp));
|
||||
ahash_request_set_crypt(hp->md5_req, &sg, NULL, sizeof(*bp));
|
||||
return crypto_ahash_update(hp->md5_req);
|
||||
}
|
||||
|
||||
static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
|
||||
|
@ -548,14 +549,14 @@ static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
|
|||
const struct tcphdr *th)
|
||||
{
|
||||
struct tcp_md5sig_pool *hp;
|
||||
struct hash_desc *desc;
|
||||
struct ahash_request *req;
|
||||
|
||||
hp = tcp_get_md5sig_pool();
|
||||
if (!hp)
|
||||
goto clear_hash_noput;
|
||||
desc = &hp->md5_desc;
|
||||
req = hp->md5_req;
|
||||
|
||||
if (crypto_hash_init(desc))
|
||||
if (crypto_ahash_init(req))
|
||||
goto clear_hash;
|
||||
if (tcp_v6_md5_hash_pseudoheader(hp, daddr, saddr, th->doff << 2))
|
||||
goto clear_hash;
|
||||
|
@ -563,7 +564,8 @@ static int tcp_v6_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
|
|||
goto clear_hash;
|
||||
if (tcp_md5_hash_key(hp, key))
|
||||
goto clear_hash;
|
||||
if (crypto_hash_final(desc, md5_hash))
|
||||
ahash_request_set_crypt(req, NULL, md5_hash, 0);
|
||||
if (crypto_ahash_final(req))
|
||||
goto clear_hash;
|
||||
|
||||
tcp_put_md5sig_pool();
|
||||
|
@ -583,7 +585,7 @@ static int tcp_v6_md5_hash_skb(char *md5_hash,
|
|||
{
|
||||
const struct in6_addr *saddr, *daddr;
|
||||
struct tcp_md5sig_pool *hp;
|
||||
struct hash_desc *desc;
|
||||
struct ahash_request *req;
|
||||
const struct tcphdr *th = tcp_hdr(skb);
|
||||
|
||||
if (sk) { /* valid for establish/request sockets */
|
||||
|
@ -598,9 +600,9 @@ static int tcp_v6_md5_hash_skb(char *md5_hash,
|
|||
hp = tcp_get_md5sig_pool();
|
||||
if (!hp)
|
||||
goto clear_hash_noput;
|
||||
desc = &hp->md5_desc;
|
||||
req = hp->md5_req;
|
||||
|
||||
if (crypto_hash_init(desc))
|
||||
if (crypto_ahash_init(req))
|
||||
goto clear_hash;
|
||||
|
||||
if (tcp_v6_md5_hash_pseudoheader(hp, daddr, saddr, skb->len))
|
||||
|
@ -611,7 +613,8 @@ static int tcp_v6_md5_hash_skb(char *md5_hash,
|
|||
goto clear_hash;
|
||||
if (tcp_md5_hash_key(hp, key))
|
||||
goto clear_hash;
|
||||
if (crypto_hash_final(desc, md5_hash))
|
||||
ahash_request_set_crypt(req, NULL, md5_hash, 0);
|
||||
if (crypto_ahash_final(req))
|
||||
goto clear_hash;
|
||||
|
||||
tcp_put_md5sig_pool();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue