Lines Matching refs:ctx
188 struct atmel_aes_base_ctx *ctx;
421 static struct atmel_aes_dev *atmel_aes_find_dev(struct atmel_aes_base_ctx *ctx)
427 if (!ctx->dd) {
432 ctx->dd = aes_dd;
434 aes_dd = ctx->dd;
517 atmel_aes_ctr_ctx_cast(struct atmel_aes_base_ctx *ctx)
519 return container_of(ctx, struct atmel_aes_ctr_ctx, base);
524 struct atmel_aes_ctr_ctx *ctx = atmel_aes_ctr_ctx_cast(dd->ctx);
533 * here, ctx->blocks contains the number of blocks of the last fragment
536 for (i = 0; i < ctx->blocks; i++)
537 crypto_inc((u8 *)ctx->iv, AES_BLOCK_SIZE);
539 memcpy(req->iv, ctx->iv, ivsize);
548 if (dd->ctx->is_aead)
555 if (!err && !dd->ctx->is_aead &&
607 dd->ctx->key, dd->ctx->keylen);
679 if (!IS_ALIGNED(len, dd->ctx->block_size))
687 if (!IS_ALIGNED(len, dd->ctx->block_size))
696 if (!IS_ALIGNED(sg->length, dd->ctx->block_size))
741 padlen = atmel_aes_padlen(len, dd->ctx->block_size);
875 switch (dd->ctx->block_size) {
943 struct atmel_aes_base_ctx *ctx;
967 ctx = crypto_tfm_ctx(areq->tfm);
970 dd->ctx = ctx;
974 /* WARNING: ctx->start() MAY change dd->is_async. */
975 err = ctx->start(dd);
992 dd->ctx->block_size != AES_BLOCK_SIZE);
1013 struct atmel_aes_ctr_ctx *ctx = atmel_aes_ctr_ctx_cast(dd->ctx);
1022 ctx->offset += dd->total;
1023 if (ctx->offset >= req->cryptlen)
1027 datalen = req->cryptlen - ctx->offset;
1028 ctx->blocks = DIV_ROUND_UP(datalen, AES_BLOCK_SIZE);
1029 ctr = be32_to_cpu(ctx->iv[3]);
1033 end = start + ctx->blocks - 1;
1035 if (ctx->blocks >> 16 || end < start) {
1044 src = scatterwalk_ffwd(ctx->src, req->src, ctx->offset);
1046 scatterwalk_ffwd(ctx->dst, req->dst, ctx->offset));
1049 atmel_aes_write_ctrl(dd, use_dma, ctx->iv);
1055 ctx->iv[3] = cpu_to_be32(ctr);
1056 crypto_inc((u8 *)ctx->iv, AES_BLOCK_SIZE);
1069 struct atmel_aes_ctr_ctx *ctx = atmel_aes_ctr_ctx_cast(dd->ctx);
1080 memcpy(ctx->iv, req->iv, AES_BLOCK_SIZE);
1081 ctx->offset = 0;
1089 struct atmel_aes_base_ctx *ctx = crypto_skcipher_ctx(skcipher);
1095 ctx->block_size = CFB8_BLOCK_SIZE;
1099 ctx->block_size = CFB16_BLOCK_SIZE;
1103 ctx->block_size = CFB32_BLOCK_SIZE;
1107 ctx->block_size = CFB64_BLOCK_SIZE;
1111 ctx->block_size = AES_BLOCK_SIZE;
1114 ctx->is_aead = false;
1116 dd = atmel_aes_find_dev(ctx);
1139 struct atmel_aes_base_ctx *ctx = crypto_skcipher_ctx(tfm);
1146 memcpy(ctx->key, key, keylen);
1147 ctx->keylen = keylen;
1244 struct atmel_aes_ctx *ctx = crypto_skcipher_ctx(tfm);
1247 ctx->base.start = atmel_aes_start;
1254 struct atmel_aes_ctx *ctx = crypto_skcipher_ctx(tfm);
1257 ctx->base.start = atmel_aes_ctr_start;
1410 atmel_aes_gcm_ctx_cast(struct atmel_aes_base_ctx *ctx)
1412 return container_of(ctx, struct atmel_aes_gcm_ctx, base);
1420 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1424 ctx->ghash_in = ghash_in;
1425 ctx->ghash_out = ghash_out;
1426 ctx->ghash_resume = resume;
1434 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1441 if (ctx->ghash_in)
1442 atmel_aes_write_block(dd, AES_GHASHR(0), ctx->ghash_in);
1449 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1467 atmel_aes_read_block(dd, AES_GHASHR(0), ctx->ghash_out);
1469 return ctx->ghash_resume(dd);
1475 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1492 memcpy(ctx->j0, iv, ivsize);
1493 ctx->j0[3] = cpu_to_be32(1);
1507 NULL, ctx->j0, atmel_aes_gcm_process);
1512 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1520 ctx->textlen = req->cryptlen - (enc ? 0 : authsize);
1526 if (likely(req->assoclen != 0 || ctx->textlen != 0))
1535 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1537 __be32 j0_lsw, *j0 = ctx->j0;
1548 atmel_aes_write(dd, AES_CLENR, ctx->textlen);
1570 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1572 bool use_dma = (ctx->textlen >= ATMEL_AES_DMA_THRESHOLD);
1591 if (unlikely(ctx->textlen == 0))
1595 src = scatterwalk_ffwd(ctx->src, req->src, req->assoclen);
1597 scatterwalk_ffwd(ctx->dst, req->dst, req->assoclen));
1608 return atmel_aes_dma_start(dd, src, dst, ctx->textlen,
1612 return atmel_aes_cpu_start(dd, src, dst, ctx->textlen,
1618 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1633 atmel_aes_read_block(dd, AES_GHASHR(0), ctx->ghash);
1636 data[1] = cpu_to_be64(ctx->textlen * 8);
1639 ctx->ghash, ctx->ghash, atmel_aes_gcm_tag);
1644 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1654 atmel_aes_write_ctrl(dd, false, ctx->j0);
1657 atmel_aes_write_block(dd, AES_IDATAR(0), ctx->ghash);
1663 struct atmel_aes_gcm_ctx *ctx = atmel_aes_gcm_ctx_cast(dd->ctx);
1667 u32 offset, authsize, itag[4], *otag = ctx->tag;
1672 atmel_aes_read_block(dd, AES_TAGR(0), ctx->tag);
1674 atmel_aes_read_block(dd, AES_ODATAR(0), ctx->tag);
1676 offset = req->assoclen + ctx->textlen;
1692 struct atmel_aes_base_ctx *ctx;
1696 ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
1697 ctx->block_size = AES_BLOCK_SIZE;
1698 ctx->is_aead = true;
1700 dd = atmel_aes_find_dev(ctx);
1713 struct atmel_aes_base_ctx *ctx = crypto_aead_ctx(tfm);
1720 memcpy(ctx->key, key, keylen);
1721 ctx->keylen = keylen;
1744 struct atmel_aes_gcm_ctx *ctx = crypto_aead_ctx(tfm);
1747 ctx->base.start = atmel_aes_gcm_start;
1773 atmel_aes_xts_ctx_cast(struct atmel_aes_base_ctx *ctx)
1775 return container_of(ctx, struct atmel_aes_xts_ctx, base);
1782 struct atmel_aes_xts_ctx *ctx = atmel_aes_xts_ctx_cast(dd->ctx);
1799 ctx->key2, ctx->base.keylen);
1845 struct atmel_aes_xts_ctx *ctx = crypto_skcipher_ctx(tfm);
1852 memcpy(ctx->base.key, key, keylen/2);
1853 memcpy(ctx->key2, key + keylen/2, keylen/2);
1854 ctx->base.keylen = keylen/2;
1871 struct atmel_aes_xts_ctx *ctx = crypto_skcipher_ctx(tfm);
1874 ctx->base.start = atmel_aes_xts_start;
1921 struct atmel_aes_authenc_ctx *ctx = crypto_aead_ctx(tfm);
1930 return atmel_sha_authenc_schedule(&rctx->auth_req, ctx->auth,
2042 struct atmel_aes_authenc_ctx *ctx = crypto_aead_ctx(tfm);
2049 if (keys.enckeylen > sizeof(ctx->base.key))
2053 err = atmel_sha_authenc_setkey(ctx->auth,
2062 ctx->base.keylen = keys.enckeylen;
2063 memcpy(ctx->base.key, keys.enckey, keys.enckeylen);
2076 struct atmel_aes_authenc_ctx *ctx = crypto_aead_ctx(tfm);
2079 ctx->auth = atmel_sha_authenc_spawn(auth_mode);
2080 if (IS_ERR(ctx->auth))
2081 return PTR_ERR(ctx->auth);
2085 ctx->base.start = atmel_aes_authenc_start;
2117 struct atmel_aes_authenc_ctx *ctx = crypto_aead_ctx(tfm);
2119 atmel_sha_authenc_free(ctx->auth);
2127 struct atmel_aes_base_ctx *ctx = crypto_aead_ctx(tfm);
2146 ctx->block_size = AES_BLOCK_SIZE;
2147 ctx->is_aead = true;
2149 dd = atmel_aes_find_dev(ctx);