Commit cb3f3817 authored by Corentin LABBE's avatar Corentin LABBE Committed by Herbert Xu

crypto: omap - Use GCM IV size constant

This patch replace GCM IV size value by their constant name.
Signed-off-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8f6acb7f
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/omap-dma.h> #include <linux/omap-dma.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <crypto/aes.h> #include <crypto/aes.h>
#include <crypto/gcm.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <crypto/skcipher.h> #include <crypto/skcipher.h>
#include <crypto/internal/aead.h> #include <crypto/internal/aead.h>
...@@ -311,7 +312,7 @@ static int omap_aes_gcm_crypt(struct aead_request *req, unsigned long mode) ...@@ -311,7 +312,7 @@ static int omap_aes_gcm_crypt(struct aead_request *req, unsigned long mode)
int err, assoclen; int err, assoclen;
memset(rctx->auth_tag, 0, sizeof(rctx->auth_tag)); memset(rctx->auth_tag, 0, sizeof(rctx->auth_tag));
memcpy(rctx->iv + 12, &counter, 4); memcpy(rctx->iv + GCM_AES_IV_SIZE, &counter, 4);
err = do_encrypt_iv(req, (u32 *)rctx->auth_tag, (u32 *)rctx->iv); err = do_encrypt_iv(req, (u32 *)rctx->auth_tag, (u32 *)rctx->iv);
if (err) if (err)
...@@ -339,7 +340,7 @@ int omap_aes_gcm_encrypt(struct aead_request *req) ...@@ -339,7 +340,7 @@ int omap_aes_gcm_encrypt(struct aead_request *req)
{ {
struct omap_aes_reqctx *rctx = aead_request_ctx(req); struct omap_aes_reqctx *rctx = aead_request_ctx(req);
memcpy(rctx->iv, req->iv, 12); memcpy(rctx->iv, req->iv, GCM_AES_IV_SIZE);
return omap_aes_gcm_crypt(req, FLAGS_ENCRYPT | FLAGS_GCM); return omap_aes_gcm_crypt(req, FLAGS_ENCRYPT | FLAGS_GCM);
} }
...@@ -347,7 +348,7 @@ int omap_aes_gcm_decrypt(struct aead_request *req) ...@@ -347,7 +348,7 @@ int omap_aes_gcm_decrypt(struct aead_request *req)
{ {
struct omap_aes_reqctx *rctx = aead_request_ctx(req); struct omap_aes_reqctx *rctx = aead_request_ctx(req);
memcpy(rctx->iv, req->iv, 12); memcpy(rctx->iv, req->iv, GCM_AES_IV_SIZE);
return omap_aes_gcm_crypt(req, FLAGS_GCM); return omap_aes_gcm_crypt(req, FLAGS_GCM);
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <crypto/aes.h> #include <crypto/aes.h>
#include <crypto/gcm.h>
#include <crypto/engine.h> #include <crypto/engine.h>
#include <crypto/internal/skcipher.h> #include <crypto/internal/skcipher.h>
#include <crypto/internal/aead.h> #include <crypto/internal/aead.h>
...@@ -767,7 +768,7 @@ static struct aead_alg algs_aead_gcm[] = { ...@@ -767,7 +768,7 @@ static struct aead_alg algs_aead_gcm[] = {
}, },
.init = omap_aes_gcm_cra_init, .init = omap_aes_gcm_cra_init,
.exit = omap_aes_gcm_cra_exit, .exit = omap_aes_gcm_cra_exit,
.ivsize = 12, .ivsize = GCM_AES_IV_SIZE,
.maxauthsize = AES_BLOCK_SIZE, .maxauthsize = AES_BLOCK_SIZE,
.setkey = omap_aes_gcm_setkey, .setkey = omap_aes_gcm_setkey,
.encrypt = omap_aes_gcm_encrypt, .encrypt = omap_aes_gcm_encrypt,
...@@ -788,7 +789,7 @@ static struct aead_alg algs_aead_gcm[] = { ...@@ -788,7 +789,7 @@ static struct aead_alg algs_aead_gcm[] = {
.init = omap_aes_gcm_cra_init, .init = omap_aes_gcm_cra_init,
.exit = omap_aes_gcm_cra_exit, .exit = omap_aes_gcm_cra_exit,
.maxauthsize = AES_BLOCK_SIZE, .maxauthsize = AES_BLOCK_SIZE,
.ivsize = 8, .ivsize = GCM_RFC4106_IV_SIZE,
.setkey = omap_aes_4106gcm_setkey, .setkey = omap_aes_4106gcm_setkey,
.encrypt = omap_aes_4106gcm_encrypt, .encrypt = omap_aes_4106gcm_encrypt,
.decrypt = omap_aes_4106gcm_decrypt, .decrypt = omap_aes_4106gcm_decrypt,
......
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