Commit 9f31eb6e authored by Gilad Ben-Yossef's avatar Gilad Ben-Yossef Committed by Herbert Xu

crypto: ccree - zero out internal struct before use

We did not zero out the internal struct before use causing problem
in some rare error code paths.
Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 03963cae
...@@ -2095,6 +2095,8 @@ static int cc_aead_encrypt(struct aead_request *req) ...@@ -2095,6 +2095,8 @@ static int cc_aead_encrypt(struct aead_request *req)
struct aead_req_ctx *areq_ctx = aead_request_ctx(req); struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
int rc; int rc;
memset(areq_ctx, 0, sizeof(*areq_ctx));
/* No generated IV required */ /* No generated IV required */
areq_ctx->backup_iv = req->iv; areq_ctx->backup_iv = req->iv;
areq_ctx->backup_giv = NULL; areq_ctx->backup_giv = NULL;
...@@ -2124,6 +2126,8 @@ static int cc_rfc4309_ccm_encrypt(struct aead_request *req) ...@@ -2124,6 +2126,8 @@ static int cc_rfc4309_ccm_encrypt(struct aead_request *req)
goto out; goto out;
} }
memset(areq_ctx, 0, sizeof(*areq_ctx));
/* No generated IV required */ /* No generated IV required */
areq_ctx->backup_iv = req->iv; areq_ctx->backup_iv = req->iv;
areq_ctx->backup_giv = NULL; areq_ctx->backup_giv = NULL;
...@@ -2143,6 +2147,8 @@ static int cc_aead_decrypt(struct aead_request *req) ...@@ -2143,6 +2147,8 @@ static int cc_aead_decrypt(struct aead_request *req)
struct aead_req_ctx *areq_ctx = aead_request_ctx(req); struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
int rc; int rc;
memset(areq_ctx, 0, sizeof(*areq_ctx));
/* No generated IV required */ /* No generated IV required */
areq_ctx->backup_iv = req->iv; areq_ctx->backup_iv = req->iv;
areq_ctx->backup_giv = NULL; areq_ctx->backup_giv = NULL;
...@@ -2170,6 +2176,8 @@ static int cc_rfc4309_ccm_decrypt(struct aead_request *req) ...@@ -2170,6 +2176,8 @@ static int cc_rfc4309_ccm_decrypt(struct aead_request *req)
goto out; goto out;
} }
memset(areq_ctx, 0, sizeof(*areq_ctx));
/* No generated IV required */ /* No generated IV required */
areq_ctx->backup_iv = req->iv; areq_ctx->backup_iv = req->iv;
areq_ctx->backup_giv = NULL; areq_ctx->backup_giv = NULL;
...@@ -2287,6 +2295,8 @@ static int cc_rfc4106_gcm_encrypt(struct aead_request *req) ...@@ -2287,6 +2295,8 @@ static int cc_rfc4106_gcm_encrypt(struct aead_request *req)
goto out; goto out;
} }
memset(areq_ctx, 0, sizeof(*areq_ctx));
/* No generated IV required */ /* No generated IV required */
areq_ctx->backup_iv = req->iv; areq_ctx->backup_iv = req->iv;
areq_ctx->backup_giv = NULL; areq_ctx->backup_giv = NULL;
...@@ -2310,6 +2320,8 @@ static int cc_rfc4543_gcm_encrypt(struct aead_request *req) ...@@ -2310,6 +2320,8 @@ static int cc_rfc4543_gcm_encrypt(struct aead_request *req)
struct aead_req_ctx *areq_ctx = aead_request_ctx(req); struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
int rc; int rc;
memset(areq_ctx, 0, sizeof(*areq_ctx));
//plaintext is not encryped with rfc4543 //plaintext is not encryped with rfc4543
areq_ctx->plaintext_authenticate_only = true; areq_ctx->plaintext_authenticate_only = true;
...@@ -2342,6 +2354,8 @@ static int cc_rfc4106_gcm_decrypt(struct aead_request *req) ...@@ -2342,6 +2354,8 @@ static int cc_rfc4106_gcm_decrypt(struct aead_request *req)
goto out; goto out;
} }
memset(areq_ctx, 0, sizeof(*areq_ctx));
/* No generated IV required */ /* No generated IV required */
areq_ctx->backup_iv = req->iv; areq_ctx->backup_iv = req->iv;
areq_ctx->backup_giv = NULL; areq_ctx->backup_giv = NULL;
...@@ -2365,6 +2379,8 @@ static int cc_rfc4543_gcm_decrypt(struct aead_request *req) ...@@ -2365,6 +2379,8 @@ static int cc_rfc4543_gcm_decrypt(struct aead_request *req)
struct aead_req_ctx *areq_ctx = aead_request_ctx(req); struct aead_req_ctx *areq_ctx = aead_request_ctx(req);
int rc; int rc;
memset(areq_ctx, 0, sizeof(*areq_ctx));
//plaintext is not decryped with rfc4543 //plaintext is not decryped with rfc4543
areq_ctx->plaintext_authenticate_only = true; areq_ctx->plaintext_authenticate_only = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment