提交 67df58a3 编写于 作者: S Sabrina Dubroca 提交者: Steffen Klassert

ah: use crypto_memneq to check the ICV

Signed-off-by: NSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
上级 24d472e4
#define pr_fmt(fmt) "IPsec: " fmt #define pr_fmt(fmt) "IPsec: " fmt
#include <crypto/algapi.h>
#include <crypto/hash.h> #include <crypto/hash.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -277,7 +278,7 @@ static void ah_input_done(struct crypto_async_request *base, int err) ...@@ -277,7 +278,7 @@ static void ah_input_done(struct crypto_async_request *base, int err)
auth_data = ah_tmp_auth(work_iph, ihl); auth_data = ah_tmp_auth(work_iph, ihl);
icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len); icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len);
err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG: 0; err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
if (err) if (err)
goto out; goto out;
...@@ -413,7 +414,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb) ...@@ -413,7 +414,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
goto out_free; goto out_free;
} }
err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG: 0; err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
if (err) if (err)
goto out_free; goto out_free;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define pr_fmt(fmt) "IPv6: " fmt #define pr_fmt(fmt) "IPv6: " fmt
#include <crypto/algapi.h>
#include <crypto/hash.h> #include <crypto/hash.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -481,7 +482,7 @@ static void ah6_input_done(struct crypto_async_request *base, int err) ...@@ -481,7 +482,7 @@ static void ah6_input_done(struct crypto_async_request *base, int err)
auth_data = ah_tmp_auth(work_iph, hdr_len); auth_data = ah_tmp_auth(work_iph, hdr_len);
icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len); icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len);
err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0; err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
if (err) if (err)
goto out; goto out;
...@@ -627,7 +628,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) ...@@ -627,7 +628,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
goto out_free; goto out_free;
} }
err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0; err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
if (err) if (err)
goto out_free; goto out_free;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册