|
|
@ -44,7 +44,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@@ -213,7 +214,7 @@ int crypto4xx_rfc3686_encrypt(struct abl
|
|
|
|
@@ -214,7 +215,7 @@ int crypto4xx_rfc3686_encrypt(struct abl
|
|
|
|
|
|
|
|
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
|
|
|
|
req->nbytes, iv, AES_IV_SIZE,
|
|
|
|
req->nbytes, iv, AES_IV_SIZE,
|
|
|
@ -53,7 +53,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int crypto4xx_rfc3686_decrypt(struct ablkcipher_request *req)
|
|
|
|
int crypto4xx_rfc3686_decrypt(struct ablkcipher_request *req)
|
|
|
|
@@ -227,7 +228,7 @@ int crypto4xx_rfc3686_decrypt(struct abl
|
|
|
|
@@ -228,7 +229,7 @@ int crypto4xx_rfc3686_decrypt(struct abl
|
|
|
|
|
|
|
|
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
|
|
|
|
req->nbytes, iv, AES_IV_SIZE,
|
|
|
|
req->nbytes, iv, AES_IV_SIZE,
|
|
|
@ -62,7 +62,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@@ -239,11 +240,13 @@ static int crypto4xx_hash_alg_init(struc
|
|
|
|
@@ -240,11 +241,13 @@ static int crypto4xx_hash_alg_init(struc
|
|
|
|
unsigned char hm)
|
|
|
|
unsigned char hm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct crypto_alg *alg = tfm->__crt_alg;
|
|
|
|
struct crypto_alg *alg = tfm->__crt_alg;
|
|
|
@ -77,7 +77,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
ctx->dev = my_alg->dev;
|
|
|
|
ctx->dev = my_alg->dev;
|
|
|
|
|
|
|
|
|
|
|
|
/* Create SA */
|
|
|
|
/* Create SA */
|
|
|
|
@@ -300,7 +303,7 @@ int crypto4xx_hash_update(struct ahash_r
|
|
|
|
@@ -301,7 +304,7 @@ int crypto4xx_hash_update(struct ahash_r
|
|
|
|
|
|
|
|
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
|
|
|
|
req->nbytes, NULL, 0, ctx->sa_in,
|
|
|
|
req->nbytes, NULL, 0, ctx->sa_in,
|
|
|
@ -86,7 +86,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int crypto4xx_hash_final(struct ahash_request *req)
|
|
|
|
int crypto4xx_hash_final(struct ahash_request *req)
|
|
|
|
@@ -319,7 +322,7 @@ int crypto4xx_hash_digest(struct ahash_r
|
|
|
|
@@ -320,7 +323,7 @@ int crypto4xx_hash_digest(struct ahash_r
|
|
|
|
|
|
|
|
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
|
|
|
|
return crypto4xx_build_pd(&req->base, ctx, req->src, &dst,
|
|
|
|
req->nbytes, NULL, 0, ctx->sa_in,
|
|
|
|
req->nbytes, NULL, 0, ctx->sa_in,
|
|
|
@ -95,7 +95,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@@ -330,5 +333,3 @@ int crypto4xx_sha1_alg_init(struct crypt
|
|
|
|
@@ -331,5 +334,3 @@ int crypto4xx_sha1_alg_init(struct crypt
|
|
|
|
return crypto4xx_hash_alg_init(tfm, SA_HASH160_LEN, SA_HASH_ALG_SHA1,
|
|
|
|
return crypto4xx_hash_alg_init(tfm, SA_HASH160_LEN, SA_HASH_ALG_SHA1,
|
|
|
|
SA_HASH_MODE_HASH);
|
|
|
|
SA_HASH_MODE_HASH);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -125,7 +125,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
struct pd_uinfo *pd_uinfo,
|
|
|
|
struct pd_uinfo *pd_uinfo,
|
|
|
|
struct ce_pd *pd)
|
|
|
|
struct ce_pd *pd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -543,11 +545,9 @@ static u32 crypto4xx_ablkcipher_done(str
|
|
|
|
@@ -552,11 +554,9 @@ static u32 crypto4xx_ablkcipher_done(str
|
|
|
|
if (pd_uinfo->state & PD_ENTRY_BUSY)
|
|
|
|
if (pd_uinfo->state & PD_ENTRY_BUSY)
|
|
|
|
ablkcipher_request_complete(ablk_req, -EINPROGRESS);
|
|
|
|
ablkcipher_request_complete(ablk_req, -EINPROGRESS);
|
|
|
|
ablkcipher_request_complete(ablk_req, 0);
|
|
|
|
ablkcipher_request_complete(ablk_req, 0);
|
|
|
@ -138,7 +138,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
struct pd_uinfo *pd_uinfo)
|
|
|
|
struct pd_uinfo *pd_uinfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct crypto4xx_ctx *ctx;
|
|
|
|
struct crypto4xx_ctx *ctx;
|
|
|
|
@@ -563,20 +563,88 @@ static u32 crypto4xx_ahash_done(struct c
|
|
|
|
@@ -572,20 +572,88 @@ static u32 crypto4xx_ahash_done(struct c
|
|
|
|
if (pd_uinfo->state & PD_ENTRY_BUSY)
|
|
|
|
if (pd_uinfo->state & PD_ENTRY_BUSY)
|
|
|
|
ahash_request_complete(ahash_req, -EINPROGRESS);
|
|
|
|
ahash_request_complete(ahash_req, -EINPROGRESS);
|
|
|
|
ahash_request_complete(ahash_req, 0);
|
|
|
|
ahash_request_complete(ahash_req, 0);
|
|
|
@ -234,7 +234,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void crypto4xx_stop_all(struct crypto4xx_core_device *core_dev)
|
|
|
|
static void crypto4xx_stop_all(struct crypto4xx_core_device *core_dev)
|
|
|
|
@@ -612,8 +680,10 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
@@ -621,8 +689,10 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
const unsigned int datalen,
|
|
|
|
const unsigned int datalen,
|
|
|
|
const __le32 *iv, const u32 iv_len,
|
|
|
|
const __le32 *iv, const u32 iv_len,
|
|
|
|
const struct dynamic_sa_ctl *req_sa,
|
|
|
|
const struct dynamic_sa_ctl *req_sa,
|
|
|
@ -246,7 +246,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
struct crypto4xx_device *dev = ctx->dev;
|
|
|
|
struct crypto4xx_device *dev = ctx->dev;
|
|
|
|
struct dynamic_sa_ctl *sa;
|
|
|
|
struct dynamic_sa_ctl *sa;
|
|
|
|
struct ce_gd *gd;
|
|
|
|
struct ce_gd *gd;
|
|
|
|
@@ -627,18 +697,25 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
@@ -636,18 +706,25 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
unsigned int nbytes = datalen;
|
|
|
|
unsigned int nbytes = datalen;
|
|
|
|
size_t offset_to_sr_ptr;
|
|
|
|
size_t offset_to_sr_ptr;
|
|
|
|
u32 gd_idx = 0;
|
|
|
|
u32 gd_idx = 0;
|
|
|
@ -279,7 +279,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
if (sg_is_last(dst)) {
|
|
|
|
if (sg_is_last(dst)) {
|
|
|
|
num_sd = 0;
|
|
|
|
num_sd = 0;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@@ -724,6 +801,7 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
@@ -733,6 +810,7 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
sa = pd_uinfo->sa_va;
|
|
|
|
sa = pd_uinfo->sa_va;
|
|
|
|
memcpy(sa, req_sa, sa_len * 4);
|
|
|
|
memcpy(sa, req_sa, sa_len * 4);
|
|
|
|
|
|
|
|
|
|
|
@ -287,7 +287,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
offset_to_sr_ptr = get_dynamic_sa_offset_state_ptr_field(sa);
|
|
|
|
offset_to_sr_ptr = get_dynamic_sa_offset_state_ptr_field(sa);
|
|
|
|
*(u32 *)((unsigned long)sa + offset_to_sr_ptr) = pd_uinfo->sr_pa;
|
|
|
|
*(u32 *)((unsigned long)sa + offset_to_sr_ptr) = pd_uinfo->sr_pa;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -830,7 +908,7 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
@@ -839,7 +917,7 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
((crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AHASH) |
|
|
|
|
((crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AHASH) |
|
|
|
|
(crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AEAD) ?
|
|
|
|
(crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AEAD) ?
|
|
|
|
PD_CTL_HASH_FINAL : 0);
|
|
|
|
PD_CTL_HASH_FINAL : 0);
|
|
|
@ -296,7 +296,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
pd_uinfo->state = PD_ENTRY_INUSE | (is_busy ? PD_ENTRY_BUSY : 0);
|
|
|
|
pd_uinfo->state = PD_ENTRY_INUSE | (is_busy ? PD_ENTRY_BUSY : 0);
|
|
|
|
|
|
|
|
|
|
|
|
wmb();
|
|
|
|
wmb();
|
|
|
|
@@ -843,40 +921,68 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
@@ -852,40 +930,68 @@ int crypto4xx_build_pd(struct crypto_asy
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Algorithm Registration Functions
|
|
|
|
* Algorithm Registration Functions
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -385,7 +385,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
{
|
|
|
|
{
|
|
|
|
struct crypto4xx_alg *alg;
|
|
|
|
struct crypto4xx_alg *alg;
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
@@ -891,6 +997,10 @@ int crypto4xx_register_alg(struct crypto
|
|
|
|
@@ -900,6 +1006,10 @@ int crypto4xx_register_alg(struct crypto
|
|
|
|
alg->dev = sec_dev;
|
|
|
|
alg->dev = sec_dev;
|
|
|
|
|
|
|
|
|
|
|
|
switch (alg->alg.type) {
|
|
|
|
switch (alg->alg.type) {
|
|
|
@ -396,7 +396,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
case CRYPTO_ALG_TYPE_AHASH:
|
|
|
|
case CRYPTO_ALG_TYPE_AHASH:
|
|
|
|
rc = crypto_register_ahash(&alg->alg.u.hash);
|
|
|
|
rc = crypto_register_ahash(&alg->alg.u.hash);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
@@ -920,6 +1030,10 @@ static void crypto4xx_unregister_alg(str
|
|
|
|
@@ -929,6 +1039,10 @@ static void crypto4xx_unregister_alg(str
|
|
|
|
crypto_unregister_ahash(&alg->alg.u.hash);
|
|
|
|
crypto_unregister_ahash(&alg->alg.u.hash);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -407,7 +407,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
default:
|
|
|
|
default:
|
|
|
|
crypto_unregister_alg(&alg->alg.u.cipher);
|
|
|
|
crypto_unregister_alg(&alg->alg.u.cipher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -973,7 +1087,7 @@ static irqreturn_t crypto4xx_ce_interrup
|
|
|
|
@@ -982,7 +1096,7 @@ static irqreturn_t crypto4xx_ce_interrup
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Supported Crypto Algorithms
|
|
|
|
* Supported Crypto Algorithms
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -416,7 +416,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
/* Crypto AES modes */
|
|
|
|
/* Crypto AES modes */
|
|
|
|
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = {
|
|
|
|
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = {
|
|
|
|
.cra_name = "cbc(aes)",
|
|
|
|
.cra_name = "cbc(aes)",
|
|
|
|
@@ -985,8 +1099,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
@@ -994,8 +1108,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
@ -427,7 +427,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_u = {
|
|
|
|
.cra_u = {
|
|
|
|
.ablkcipher = {
|
|
|
|
.ablkcipher = {
|
|
|
|
@@ -1009,8 +1123,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
@@ -1018,8 +1132,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
@ -438,7 +438,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_u = {
|
|
|
|
.cra_u = {
|
|
|
|
.ablkcipher = {
|
|
|
|
.ablkcipher = {
|
|
|
|
@@ -1033,8 +1147,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
@@ -1042,8 +1156,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
@ -449,7 +449,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_u = {
|
|
|
|
.cra_u = {
|
|
|
|
.ablkcipher = {
|
|
|
|
.ablkcipher = {
|
|
|
|
@@ -1059,8 +1173,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
@@ -1068,8 +1182,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
@ -460,7 +460,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_u = {
|
|
|
|
.cra_u = {
|
|
|
|
.ablkcipher = {
|
|
|
|
.ablkcipher = {
|
|
|
|
@@ -1082,8 +1196,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
@@ -1091,8 +1205,8 @@ struct crypto4xx_alg_common crypto4xx_al
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_blocksize = AES_BLOCK_SIZE,
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_ctxsize = sizeof(struct crypto4xx_ctx),
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
|
.cra_type = &crypto_ablkcipher_type,
|
|
|
@ -471,7 +471,7 @@ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_module = THIS_MODULE,
|
|
|
|
.cra_u = {
|
|
|
|
.cra_u = {
|
|
|
|
.ablkcipher = {
|
|
|
|
.ablkcipher = {
|
|
|
|
@@ -1149,6 +1263,7 @@ static int crypto4xx_probe(struct platfo
|
|
|
|
@@ -1158,6 +1272,7 @@ static int crypto4xx_probe(struct platfo
|
|
|
|
core_dev->device = dev;
|
|
|
|
core_dev->device = dev;
|
|
|
|
spin_lock_init(&core_dev->lock);
|
|
|
|
spin_lock_init(&core_dev->lock);
|
|
|
|
INIT_LIST_HEAD(&core_dev->dev->alg_list);
|
|
|
|
INIT_LIST_HEAD(&core_dev->dev->alg_list);
|
|
|
|