crypto: sun4i-ss - move from ablkcipher to skcipher API
Update the sun4i-ss driver to use the skcipher API instead of the old ablkcipher one. It's a bit more tricky than s/ablkcipher/skcipher/, but still nothing special and the driver's logic stays the same. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com> Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
d78867a94e
commit
317cbacf72
3 changed files with 221 additions and 224 deletions
|
@ -16,13 +16,13 @@
|
||||||
*/
|
*/
|
||||||
#include "sun4i-ss.h"
|
#include "sun4i-ss.h"
|
||||||
|
|
||||||
static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
|
static int sun4i_ss_opti_poll(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_ss_ctx *ss = op->ss;
|
struct sun4i_ss_ctx *ss = op->ss;
|
||||||
unsigned int ivsize = crypto_ablkcipher_ivsize(tfm);
|
unsigned int ivsize = crypto_skcipher_ivsize(tfm);
|
||||||
struct sun4i_cipher_req_ctx *ctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *ctx = skcipher_request_ctx(areq);
|
||||||
u32 mode = ctx->mode;
|
u32 mode = ctx->mode;
|
||||||
/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */
|
/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */
|
||||||
u32 rx_cnt = SS_RX_DEFAULT;
|
u32 rx_cnt = SS_RX_DEFAULT;
|
||||||
|
@ -31,17 +31,17 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
|
||||||
u32 v;
|
u32 v;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int ileft = areq->nbytes;
|
unsigned int ileft = areq->cryptlen;
|
||||||
unsigned int oleft = areq->nbytes;
|
unsigned int oleft = areq->cryptlen;
|
||||||
unsigned int todo;
|
unsigned int todo;
|
||||||
struct sg_mapping_iter mi, mo;
|
struct sg_mapping_iter mi, mo;
|
||||||
unsigned int oi, oo; /* offset for in and out */
|
unsigned int oi, oo; /* offset for in and out */
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!areq->nbytes)
|
if (!areq->cryptlen)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!areq->info) {
|
if (!areq->iv) {
|
||||||
dev_err_ratelimited(ss->dev, "ERROR: Empty IV\n");
|
dev_err_ratelimited(ss->dev, "ERROR: Empty IV\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,9 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
|
||||||
for (i = 0; i < op->keylen; i += 4)
|
for (i = 0; i < op->keylen; i += 4)
|
||||||
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
|
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
|
||||||
|
|
||||||
if (areq->info) {
|
if (areq->iv) {
|
||||||
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
||||||
v = *(u32 *)(areq->info + i * 4);
|
v = *(u32 *)(areq->iv + i * 4);
|
||||||
writel(v, ss->base + SS_IV0 + i * 4);
|
writel(v, ss->base + SS_IV0 + i * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
|
||||||
goto release_ss;
|
goto release_ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
ileft = areq->nbytes / 4;
|
ileft = areq->cryptlen / 4;
|
||||||
oleft = areq->nbytes / 4;
|
oleft = areq->cryptlen / 4;
|
||||||
oi = 0;
|
oi = 0;
|
||||||
oo = 0;
|
oo = 0;
|
||||||
do {
|
do {
|
||||||
|
@ -108,10 +108,10 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
} while (oleft);
|
} while (oleft);
|
||||||
|
|
||||||
if (areq->info) {
|
if (areq->iv) {
|
||||||
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
||||||
v = readl(ss->base + SS_IV0 + i * 4);
|
v = readl(ss->base + SS_IV0 + i * 4);
|
||||||
*(u32 *)(areq->info + i * 4) = v;
|
*(u32 *)(areq->iv + i * 4) = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,16 +124,16 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generic function that support SG with size not multiple of 4 */
|
/* Generic function that support SG with size not multiple of 4 */
|
||||||
static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
static int sun4i_ss_cipher_poll(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_ss_ctx *ss = op->ss;
|
struct sun4i_ss_ctx *ss = op->ss;
|
||||||
int no_chunk = 1;
|
int no_chunk = 1;
|
||||||
struct scatterlist *in_sg = areq->src;
|
struct scatterlist *in_sg = areq->src;
|
||||||
struct scatterlist *out_sg = areq->dst;
|
struct scatterlist *out_sg = areq->dst;
|
||||||
unsigned int ivsize = crypto_ablkcipher_ivsize(tfm);
|
unsigned int ivsize = crypto_skcipher_ivsize(tfm);
|
||||||
struct sun4i_cipher_req_ctx *ctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *ctx = skcipher_request_ctx(areq);
|
||||||
u32 mode = ctx->mode;
|
u32 mode = ctx->mode;
|
||||||
/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */
|
/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */
|
||||||
u32 rx_cnt = SS_RX_DEFAULT;
|
u32 rx_cnt = SS_RX_DEFAULT;
|
||||||
|
@ -142,8 +142,8 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
||||||
u32 spaces;
|
u32 spaces;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int ileft = areq->nbytes;
|
unsigned int ileft = areq->cryptlen;
|
||||||
unsigned int oleft = areq->nbytes;
|
unsigned int oleft = areq->cryptlen;
|
||||||
unsigned int todo;
|
unsigned int todo;
|
||||||
struct sg_mapping_iter mi, mo;
|
struct sg_mapping_iter mi, mo;
|
||||||
unsigned int oi, oo; /* offset for in and out */
|
unsigned int oi, oo; /* offset for in and out */
|
||||||
|
@ -154,10 +154,10 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
||||||
unsigned int obl = 0; /* length of data in bufo */
|
unsigned int obl = 0; /* length of data in bufo */
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!areq->nbytes)
|
if (!areq->cryptlen)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!areq->info) {
|
if (!areq->iv) {
|
||||||
dev_err_ratelimited(ss->dev, "ERROR: Empty IV\n");
|
dev_err_ratelimited(ss->dev, "ERROR: Empty IV\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -190,9 +190,9 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
||||||
for (i = 0; i < op->keylen; i += 4)
|
for (i = 0; i < op->keylen; i += 4)
|
||||||
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
|
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
|
||||||
|
|
||||||
if (areq->info) {
|
if (areq->iv) {
|
||||||
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
||||||
v = *(u32 *)(areq->info + i * 4);
|
v = *(u32 *)(areq->iv + i * 4);
|
||||||
writel(v, ss->base + SS_IV0 + i * 4);
|
writel(v, ss->base + SS_IV0 + i * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,8 +209,8 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto release_ss;
|
goto release_ss;
|
||||||
}
|
}
|
||||||
ileft = areq->nbytes;
|
ileft = areq->cryptlen;
|
||||||
oleft = areq->nbytes;
|
oleft = areq->cryptlen;
|
||||||
oi = 0;
|
oi = 0;
|
||||||
oo = 0;
|
oo = 0;
|
||||||
|
|
||||||
|
@ -257,8 +257,8 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
||||||
tx_cnt = SS_TXFIFO_SPACES(spaces);
|
tx_cnt = SS_TXFIFO_SPACES(spaces);
|
||||||
dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
|
dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
|
||||||
mode,
|
mode,
|
||||||
oi, mi.length, ileft, areq->nbytes, rx_cnt,
|
oi, mi.length, ileft, areq->cryptlen, rx_cnt,
|
||||||
oo, mo.length, oleft, areq->nbytes, tx_cnt, ob);
|
oo, mo.length, oleft, areq->cryptlen, tx_cnt, ob);
|
||||||
|
|
||||||
if (!tx_cnt)
|
if (!tx_cnt)
|
||||||
continue;
|
continue;
|
||||||
|
@ -300,10 +300,10 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
||||||
/* bufo must be fully used here */
|
/* bufo must be fully used here */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (areq->info) {
|
if (areq->iv) {
|
||||||
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
for (i = 0; i < 4 && i < ivsize / 4; i++) {
|
||||||
v = readl(ss->base + SS_IV0 + i * 4);
|
v = readl(ss->base + SS_IV0 + i * 4);
|
||||||
*(u32 *)(areq->info + i * 4) = v;
|
*(u32 *)(areq->iv + i * 4) = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,22 +317,22 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CBC AES */
|
/* CBC AES */
|
||||||
int sun4i_ss_cbc_aes_encrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_cbc_aes_encrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_AES | SS_CBC | SS_ENABLED | SS_ENCRYPTION |
|
rctx->mode = SS_OP_AES | SS_CBC | SS_ENABLED | SS_ENCRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
return sun4i_ss_cipher_poll(areq);
|
return sun4i_ss_cipher_poll(areq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sun4i_ss_cbc_aes_decrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_cbc_aes_decrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_AES | SS_CBC | SS_ENABLED | SS_DECRYPTION |
|
rctx->mode = SS_OP_AES | SS_CBC | SS_ENABLED | SS_DECRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
|
@ -340,22 +340,22 @@ int sun4i_ss_cbc_aes_decrypt(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECB AES */
|
/* ECB AES */
|
||||||
int sun4i_ss_ecb_aes_encrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_ecb_aes_encrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_AES | SS_ECB | SS_ENABLED | SS_ENCRYPTION |
|
rctx->mode = SS_OP_AES | SS_ECB | SS_ENABLED | SS_ENCRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
return sun4i_ss_cipher_poll(areq);
|
return sun4i_ss_cipher_poll(areq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sun4i_ss_ecb_aes_decrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_ecb_aes_decrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_AES | SS_ECB | SS_ENABLED | SS_DECRYPTION |
|
rctx->mode = SS_OP_AES | SS_ECB | SS_ENABLED | SS_DECRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
|
@ -363,22 +363,22 @@ int sun4i_ss_ecb_aes_decrypt(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CBC DES */
|
/* CBC DES */
|
||||||
int sun4i_ss_cbc_des_encrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_cbc_des_encrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_DES | SS_CBC | SS_ENABLED | SS_ENCRYPTION |
|
rctx->mode = SS_OP_DES | SS_CBC | SS_ENABLED | SS_ENCRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
return sun4i_ss_cipher_poll(areq);
|
return sun4i_ss_cipher_poll(areq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sun4i_ss_cbc_des_decrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_cbc_des_decrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_DES | SS_CBC | SS_ENABLED | SS_DECRYPTION |
|
rctx->mode = SS_OP_DES | SS_CBC | SS_ENABLED | SS_DECRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
|
@ -386,22 +386,22 @@ int sun4i_ss_cbc_des_decrypt(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECB DES */
|
/* ECB DES */
|
||||||
int sun4i_ss_ecb_des_encrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_ecb_des_encrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_DES | SS_ECB | SS_ENABLED | SS_ENCRYPTION |
|
rctx->mode = SS_OP_DES | SS_ECB | SS_ENABLED | SS_ENCRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
return sun4i_ss_cipher_poll(areq);
|
return sun4i_ss_cipher_poll(areq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sun4i_ss_ecb_des_decrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_ecb_des_decrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_DES | SS_ECB | SS_ENABLED | SS_DECRYPTION |
|
rctx->mode = SS_OP_DES | SS_ECB | SS_ENABLED | SS_DECRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
|
@ -409,22 +409,22 @@ int sun4i_ss_ecb_des_decrypt(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CBC 3DES */
|
/* CBC 3DES */
|
||||||
int sun4i_ss_cbc_des3_encrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_cbc_des3_encrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_3DES | SS_CBC | SS_ENABLED | SS_ENCRYPTION |
|
rctx->mode = SS_OP_3DES | SS_CBC | SS_ENABLED | SS_ENCRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
return sun4i_ss_cipher_poll(areq);
|
return sun4i_ss_cipher_poll(areq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sun4i_ss_cbc_des3_decrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_cbc_des3_decrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_3DES | SS_CBC | SS_ENABLED | SS_DECRYPTION |
|
rctx->mode = SS_OP_3DES | SS_CBC | SS_ENABLED | SS_DECRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
|
@ -432,22 +432,22 @@ int sun4i_ss_cbc_des3_decrypt(struct ablkcipher_request *areq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECB 3DES */
|
/* ECB 3DES */
|
||||||
int sun4i_ss_ecb_des3_encrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_ecb_des3_encrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_3DES | SS_ECB | SS_ENABLED | SS_ENCRYPTION |
|
rctx->mode = SS_OP_3DES | SS_ECB | SS_ENABLED | SS_ENCRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
return sun4i_ss_cipher_poll(areq);
|
return sun4i_ss_cipher_poll(areq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sun4i_ss_ecb_des3_decrypt(struct ablkcipher_request *areq)
|
int sun4i_ss_ecb_des3_decrypt(struct skcipher_request *areq)
|
||||||
{
|
{
|
||||||
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(areq);
|
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_cipher_req_ctx *rctx = ablkcipher_request_ctx(areq);
|
struct sun4i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
|
||||||
|
|
||||||
rctx->mode = SS_OP_3DES | SS_ECB | SS_ENABLED | SS_DECRYPTION |
|
rctx->mode = SS_OP_3DES | SS_ECB | SS_ENABLED | SS_DECRYPTION |
|
||||||
op->keymode;
|
op->keymode;
|
||||||
|
@ -457,24 +457,25 @@ int sun4i_ss_ecb_des3_decrypt(struct ablkcipher_request *areq)
|
||||||
int sun4i_ss_cipher_init(struct crypto_tfm *tfm)
|
int sun4i_ss_cipher_init(struct crypto_tfm *tfm)
|
||||||
{
|
{
|
||||||
struct sun4i_tfm_ctx *op = crypto_tfm_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_tfm_ctx(tfm);
|
||||||
struct crypto_alg *alg = tfm->__crt_alg;
|
|
||||||
struct sun4i_ss_alg_template *algt;
|
struct sun4i_ss_alg_template *algt;
|
||||||
|
|
||||||
memset(op, 0, sizeof(struct sun4i_tfm_ctx));
|
memset(op, 0, sizeof(struct sun4i_tfm_ctx));
|
||||||
|
|
||||||
algt = container_of(alg, struct sun4i_ss_alg_template, alg.crypto);
|
algt = container_of(tfm->__crt_alg, struct sun4i_ss_alg_template,
|
||||||
|
alg.crypto.base);
|
||||||
op->ss = algt->ss;
|
op->ss = algt->ss;
|
||||||
|
|
||||||
tfm->crt_ablkcipher.reqsize = sizeof(struct sun4i_cipher_req_ctx);
|
crypto_skcipher_set_reqsize(__crypto_skcipher_cast(tfm),
|
||||||
|
sizeof(struct sun4i_cipher_req_ctx));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check and set the AES key, prepare the mode to be used */
|
/* check and set the AES key, prepare the mode to be used */
|
||||||
int sun4i_ss_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
int sun4i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
unsigned int keylen)
|
unsigned int keylen)
|
||||||
{
|
{
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_ss_ctx *ss = op->ss;
|
struct sun4i_ss_ctx *ss = op->ss;
|
||||||
|
|
||||||
switch (keylen) {
|
switch (keylen) {
|
||||||
|
@ -489,7 +490,7 @@ int sun4i_ss_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(ss->dev, "ERROR: Invalid keylen %u\n", keylen);
|
dev_err(ss->dev, "ERROR: Invalid keylen %u\n", keylen);
|
||||||
crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
op->keylen = keylen;
|
op->keylen = keylen;
|
||||||
|
@ -498,10 +499,10 @@ int sun4i_ss_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check and set the DES key, prepare the mode to be used */
|
/* check and set the DES key, prepare the mode to be used */
|
||||||
int sun4i_ss_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
int sun4i_ss_des_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
unsigned int keylen)
|
unsigned int keylen)
|
||||||
{
|
{
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_ss_ctx *ss = op->ss;
|
struct sun4i_ss_ctx *ss = op->ss;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
u32 tmp[DES_EXPKEY_WORDS];
|
u32 tmp[DES_EXPKEY_WORDS];
|
||||||
|
@ -509,15 +510,15 @@ int sun4i_ss_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
||||||
|
|
||||||
if (unlikely(keylen != DES_KEY_SIZE)) {
|
if (unlikely(keylen != DES_KEY_SIZE)) {
|
||||||
dev_err(ss->dev, "Invalid keylen %u\n", keylen);
|
dev_err(ss->dev, "Invalid keylen %u\n", keylen);
|
||||||
crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = crypto_ablkcipher_get_flags(tfm);
|
flags = crypto_skcipher_get_flags(tfm);
|
||||||
|
|
||||||
ret = des_ekey(tmp, key);
|
ret = des_ekey(tmp, key);
|
||||||
if (unlikely(!ret) && (flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
if (unlikely(!ret) && (flags & CRYPTO_TFM_REQ_WEAK_KEY)) {
|
||||||
crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
|
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
|
||||||
dev_dbg(ss->dev, "Weak key %u\n", keylen);
|
dev_dbg(ss->dev, "Weak key %u\n", keylen);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -528,15 +529,15 @@ int sun4i_ss_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check and set the 3DES key, prepare the mode to be used */
|
/* check and set the 3DES key, prepare the mode to be used */
|
||||||
int sun4i_ss_des3_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
int sun4i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
unsigned int keylen)
|
unsigned int keylen)
|
||||||
{
|
{
|
||||||
struct sun4i_tfm_ctx *op = crypto_ablkcipher_ctx(tfm);
|
struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm);
|
||||||
struct sun4i_ss_ctx *ss = op->ss;
|
struct sun4i_ss_ctx *ss = op->ss;
|
||||||
|
|
||||||
if (unlikely(keylen != 3 * DES_KEY_SIZE)) {
|
if (unlikely(keylen != 3 * DES_KEY_SIZE)) {
|
||||||
dev_err(ss->dev, "Invalid keylen %u\n", keylen);
|
dev_err(ss->dev, "Invalid keylen %u\n", keylen);
|
||||||
crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
op->keylen = keylen;
|
op->keylen = keylen;
|
||||||
|
|
|
@ -83,134 +83,128 @@ static struct sun4i_ss_alg_template ss_algs[] = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.alg.crypto = {
|
.alg.crypto = {
|
||||||
.cra_name = "cbc(aes)",
|
.setkey = sun4i_ss_aes_setkey,
|
||||||
.cra_driver_name = "cbc-aes-sun4i-ss",
|
.encrypt = sun4i_ss_cbc_aes_encrypt,
|
||||||
.cra_priority = 300,
|
.decrypt = sun4i_ss_cbc_aes_decrypt,
|
||||||
.cra_blocksize = AES_BLOCK_SIZE,
|
.min_keysize = AES_MIN_KEY_SIZE,
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
.max_keysize = AES_MAX_KEY_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct sun4i_tfm_ctx),
|
.ivsize = AES_BLOCK_SIZE,
|
||||||
.cra_module = THIS_MODULE,
|
.base = {
|
||||||
.cra_alignmask = 3,
|
.cra_name = "cbc(aes)",
|
||||||
.cra_type = &crypto_ablkcipher_type,
|
.cra_driver_name = "cbc-aes-sun4i-ss",
|
||||||
.cra_init = sun4i_ss_cipher_init,
|
.cra_priority = 300,
|
||||||
.cra_ablkcipher = {
|
.cra_blocksize = AES_BLOCK_SIZE,
|
||||||
.min_keysize = AES_MIN_KEY_SIZE,
|
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.max_keysize = AES_MAX_KEY_SIZE,
|
.cra_ctxsize = sizeof(struct sun4i_tfm_ctx),
|
||||||
.ivsize = AES_BLOCK_SIZE,
|
.cra_module = THIS_MODULE,
|
||||||
.setkey = sun4i_ss_aes_setkey,
|
.cra_alignmask = 3,
|
||||||
.encrypt = sun4i_ss_cbc_aes_encrypt,
|
.cra_init = sun4i_ss_cipher_init,
|
||||||
.decrypt = sun4i_ss_cbc_aes_decrypt,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.alg.crypto = {
|
.alg.crypto = {
|
||||||
.cra_name = "ecb(aes)",
|
.setkey = sun4i_ss_aes_setkey,
|
||||||
.cra_driver_name = "ecb-aes-sun4i-ss",
|
.encrypt = sun4i_ss_ecb_aes_encrypt,
|
||||||
.cra_priority = 300,
|
.decrypt = sun4i_ss_ecb_aes_decrypt,
|
||||||
.cra_blocksize = AES_BLOCK_SIZE,
|
.min_keysize = AES_MIN_KEY_SIZE,
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
.max_keysize = AES_MAX_KEY_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct sun4i_tfm_ctx),
|
.ivsize = AES_BLOCK_SIZE,
|
||||||
.cra_module = THIS_MODULE,
|
.base = {
|
||||||
.cra_alignmask = 3,
|
.cra_name = "ecb(aes)",
|
||||||
.cra_type = &crypto_ablkcipher_type,
|
.cra_driver_name = "ecb-aes-sun4i-ss",
|
||||||
.cra_init = sun4i_ss_cipher_init,
|
.cra_priority = 300,
|
||||||
.cra_ablkcipher = {
|
.cra_blocksize = AES_BLOCK_SIZE,
|
||||||
.min_keysize = AES_MIN_KEY_SIZE,
|
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.max_keysize = AES_MAX_KEY_SIZE,
|
.cra_ctxsize = sizeof(struct sun4i_tfm_ctx),
|
||||||
.ivsize = AES_BLOCK_SIZE,
|
.cra_module = THIS_MODULE,
|
||||||
.setkey = sun4i_ss_aes_setkey,
|
.cra_alignmask = 3,
|
||||||
.encrypt = sun4i_ss_ecb_aes_encrypt,
|
.cra_init = sun4i_ss_cipher_init,
|
||||||
.decrypt = sun4i_ss_ecb_aes_decrypt,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.alg.crypto = {
|
.alg.crypto = {
|
||||||
.cra_name = "cbc(des)",
|
.setkey = sun4i_ss_des_setkey,
|
||||||
.cra_driver_name = "cbc-des-sun4i-ss",
|
.encrypt = sun4i_ss_cbc_des_encrypt,
|
||||||
.cra_priority = 300,
|
.decrypt = sun4i_ss_cbc_des_decrypt,
|
||||||
.cra_blocksize = DES_BLOCK_SIZE,
|
.min_keysize = DES_KEY_SIZE,
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
.max_keysize = DES_KEY_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
.ivsize = DES_BLOCK_SIZE,
|
||||||
.cra_module = THIS_MODULE,
|
.base = {
|
||||||
.cra_alignmask = 3,
|
.cra_name = "cbc(des)",
|
||||||
.cra_type = &crypto_ablkcipher_type,
|
.cra_driver_name = "cbc-des-sun4i-ss",
|
||||||
.cra_init = sun4i_ss_cipher_init,
|
.cra_priority = 300,
|
||||||
.cra_u.ablkcipher = {
|
.cra_blocksize = DES_BLOCK_SIZE,
|
||||||
.min_keysize = DES_KEY_SIZE,
|
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.max_keysize = DES_KEY_SIZE,
|
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
||||||
.ivsize = DES_BLOCK_SIZE,
|
.cra_module = THIS_MODULE,
|
||||||
.setkey = sun4i_ss_des_setkey,
|
.cra_alignmask = 3,
|
||||||
.encrypt = sun4i_ss_cbc_des_encrypt,
|
.cra_init = sun4i_ss_cipher_init,
|
||||||
.decrypt = sun4i_ss_cbc_des_decrypt,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.alg.crypto = {
|
.alg.crypto = {
|
||||||
.cra_name = "ecb(des)",
|
.setkey = sun4i_ss_des_setkey,
|
||||||
.cra_driver_name = "ecb-des-sun4i-ss",
|
.encrypt = sun4i_ss_ecb_des_encrypt,
|
||||||
.cra_priority = 300,
|
.decrypt = sun4i_ss_ecb_des_decrypt,
|
||||||
.cra_blocksize = DES_BLOCK_SIZE,
|
.min_keysize = DES_KEY_SIZE,
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
.max_keysize = DES_KEY_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
.base = {
|
||||||
.cra_module = THIS_MODULE,
|
.cra_name = "ecb(des)",
|
||||||
.cra_alignmask = 3,
|
.cra_driver_name = "ecb-des-sun4i-ss",
|
||||||
.cra_type = &crypto_ablkcipher_type,
|
.cra_priority = 300,
|
||||||
.cra_init = sun4i_ss_cipher_init,
|
.cra_blocksize = DES_BLOCK_SIZE,
|
||||||
.cra_u.ablkcipher = {
|
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.min_keysize = DES_KEY_SIZE,
|
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
||||||
.max_keysize = DES_KEY_SIZE,
|
.cra_module = THIS_MODULE,
|
||||||
.setkey = sun4i_ss_des_setkey,
|
.cra_alignmask = 3,
|
||||||
.encrypt = sun4i_ss_ecb_des_encrypt,
|
.cra_init = sun4i_ss_cipher_init,
|
||||||
.decrypt = sun4i_ss_ecb_des_decrypt,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.alg.crypto = {
|
.alg.crypto = {
|
||||||
.cra_name = "cbc(des3_ede)",
|
.setkey = sun4i_ss_des3_setkey,
|
||||||
.cra_driver_name = "cbc-des3-sun4i-ss",
|
.encrypt = sun4i_ss_cbc_des3_encrypt,
|
||||||
.cra_priority = 300,
|
.decrypt = sun4i_ss_cbc_des3_decrypt,
|
||||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
.min_keysize = DES3_EDE_KEY_SIZE,
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
.max_keysize = DES3_EDE_KEY_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
.ivsize = DES3_EDE_BLOCK_SIZE,
|
||||||
.cra_module = THIS_MODULE,
|
.base = {
|
||||||
.cra_alignmask = 3,
|
.cra_name = "cbc(des3_ede)",
|
||||||
.cra_type = &crypto_ablkcipher_type,
|
.cra_driver_name = "cbc-des3-sun4i-ss",
|
||||||
.cra_init = sun4i_ss_cipher_init,
|
.cra_priority = 300,
|
||||||
.cra_u.ablkcipher = {
|
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||||
.min_keysize = DES3_EDE_KEY_SIZE,
|
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.max_keysize = DES3_EDE_KEY_SIZE,
|
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
||||||
.ivsize = DES3_EDE_BLOCK_SIZE,
|
.cra_module = THIS_MODULE,
|
||||||
.setkey = sun4i_ss_des3_setkey,
|
.cra_alignmask = 3,
|
||||||
.encrypt = sun4i_ss_cbc_des3_encrypt,
|
.cra_init = sun4i_ss_cipher_init,
|
||||||
.decrypt = sun4i_ss_cbc_des3_decrypt,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.alg.crypto = {
|
.alg.crypto = {
|
||||||
.cra_name = "ecb(des3_ede)",
|
.setkey = sun4i_ss_des3_setkey,
|
||||||
.cra_driver_name = "ecb-des3-sun4i-ss",
|
.encrypt = sun4i_ss_ecb_des3_encrypt,
|
||||||
.cra_priority = 300,
|
.decrypt = sun4i_ss_ecb_des3_decrypt,
|
||||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
.min_keysize = DES3_EDE_KEY_SIZE,
|
||||||
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER,
|
.max_keysize = DES3_EDE_KEY_SIZE,
|
||||||
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
.ivsize = DES3_EDE_BLOCK_SIZE,
|
||||||
.cra_module = THIS_MODULE,
|
.base = {
|
||||||
.cra_alignmask = 3,
|
.cra_name = "ecb(des3_ede)",
|
||||||
.cra_type = &crypto_ablkcipher_type,
|
.cra_driver_name = "ecb-des3-sun4i-ss",
|
||||||
.cra_init = sun4i_ss_cipher_init,
|
.cra_priority = 300,
|
||||||
.cra_u.ablkcipher = {
|
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||||
.min_keysize = DES3_EDE_KEY_SIZE,
|
.cra_flags = CRYPTO_ALG_TYPE_SKCIPHER,
|
||||||
.max_keysize = DES3_EDE_KEY_SIZE,
|
.cra_ctxsize = sizeof(struct sun4i_req_ctx),
|
||||||
.ivsize = DES3_EDE_BLOCK_SIZE,
|
.cra_module = THIS_MODULE,
|
||||||
.setkey = sun4i_ss_des3_setkey,
|
.cra_alignmask = 3,
|
||||||
.encrypt = sun4i_ss_ecb_des3_encrypt,
|
.cra_init = sun4i_ss_cipher_init,
|
||||||
.decrypt = sun4i_ss_ecb_des3_decrypt,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -340,11 +334,11 @@ static int sun4i_ss_probe(struct platform_device *pdev)
|
||||||
for (i = 0; i < ARRAY_SIZE(ss_algs); i++) {
|
for (i = 0; i < ARRAY_SIZE(ss_algs); i++) {
|
||||||
ss_algs[i].ss = ss;
|
ss_algs[i].ss = ss;
|
||||||
switch (ss_algs[i].type) {
|
switch (ss_algs[i].type) {
|
||||||
case CRYPTO_ALG_TYPE_ABLKCIPHER:
|
case CRYPTO_ALG_TYPE_SKCIPHER:
|
||||||
err = crypto_register_alg(&ss_algs[i].alg.crypto);
|
err = crypto_register_skcipher(&ss_algs[i].alg.crypto);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(ss->dev, "Fail to register %s\n",
|
dev_err(ss->dev, "Fail to register %s\n",
|
||||||
ss_algs[i].alg.crypto.cra_name);
|
ss_algs[i].alg.crypto.base.cra_name);
|
||||||
goto error_alg;
|
goto error_alg;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -364,8 +358,8 @@ static int sun4i_ss_probe(struct platform_device *pdev)
|
||||||
i--;
|
i--;
|
||||||
for (; i >= 0; i--) {
|
for (; i >= 0; i--) {
|
||||||
switch (ss_algs[i].type) {
|
switch (ss_algs[i].type) {
|
||||||
case CRYPTO_ALG_TYPE_ABLKCIPHER:
|
case CRYPTO_ALG_TYPE_SKCIPHER:
|
||||||
crypto_unregister_alg(&ss_algs[i].alg.crypto);
|
crypto_unregister_skcipher(&ss_algs[i].alg.crypto);
|
||||||
break;
|
break;
|
||||||
case CRYPTO_ALG_TYPE_AHASH:
|
case CRYPTO_ALG_TYPE_AHASH:
|
||||||
crypto_unregister_ahash(&ss_algs[i].alg.hash);
|
crypto_unregister_ahash(&ss_algs[i].alg.hash);
|
||||||
|
@ -388,8 +382,8 @@ static int sun4i_ss_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(ss_algs); i++) {
|
for (i = 0; i < ARRAY_SIZE(ss_algs); i++) {
|
||||||
switch (ss_algs[i].type) {
|
switch (ss_algs[i].type) {
|
||||||
case CRYPTO_ALG_TYPE_ABLKCIPHER:
|
case CRYPTO_ALG_TYPE_SKCIPHER:
|
||||||
crypto_unregister_alg(&ss_algs[i].alg.crypto);
|
crypto_unregister_skcipher(&ss_algs[i].alg.crypto);
|
||||||
break;
|
break;
|
||||||
case CRYPTO_ALG_TYPE_AHASH:
|
case CRYPTO_ALG_TYPE_AHASH:
|
||||||
crypto_unregister_ahash(&ss_algs[i].alg.hash);
|
crypto_unregister_ahash(&ss_algs[i].alg.hash);
|
||||||
|
|
|
@ -24,9 +24,11 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <crypto/md5.h>
|
#include <crypto/md5.h>
|
||||||
|
#include <crypto/skcipher.h>
|
||||||
#include <crypto/sha.h>
|
#include <crypto/sha.h>
|
||||||
#include <crypto/hash.h>
|
#include <crypto/hash.h>
|
||||||
#include <crypto/internal/hash.h>
|
#include <crypto/internal/hash.h>
|
||||||
|
#include <crypto/internal/skcipher.h>
|
||||||
#include <crypto/aes.h>
|
#include <crypto/aes.h>
|
||||||
#include <crypto/des.h>
|
#include <crypto/des.h>
|
||||||
#include <crypto/internal/rng.h>
|
#include <crypto/internal/rng.h>
|
||||||
|
@ -140,7 +142,7 @@ struct sun4i_ss_alg_template {
|
||||||
u32 type;
|
u32 type;
|
||||||
u32 mode;
|
u32 mode;
|
||||||
union {
|
union {
|
||||||
struct crypto_alg crypto;
|
struct skcipher_alg crypto;
|
||||||
struct ahash_alg hash;
|
struct ahash_alg hash;
|
||||||
} alg;
|
} alg;
|
||||||
struct sun4i_ss_ctx *ss;
|
struct sun4i_ss_ctx *ss;
|
||||||
|
@ -177,25 +179,25 @@ int sun4i_hash_import_md5(struct ahash_request *areq, const void *in);
|
||||||
int sun4i_hash_export_sha1(struct ahash_request *areq, void *out);
|
int sun4i_hash_export_sha1(struct ahash_request *areq, void *out);
|
||||||
int sun4i_hash_import_sha1(struct ahash_request *areq, const void *in);
|
int sun4i_hash_import_sha1(struct ahash_request *areq, const void *in);
|
||||||
|
|
||||||
int sun4i_ss_cbc_aes_encrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_cbc_aes_encrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_cbc_aes_decrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_cbc_aes_decrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_ecb_aes_encrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_ecb_aes_encrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_ecb_aes_decrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_ecb_aes_decrypt(struct skcipher_request *areq);
|
||||||
|
|
||||||
int sun4i_ss_cbc_des_encrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_cbc_des_encrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_cbc_des_decrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_cbc_des_decrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_ecb_des_encrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_ecb_des_encrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_ecb_des_decrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_ecb_des_decrypt(struct skcipher_request *areq);
|
||||||
|
|
||||||
int sun4i_ss_cbc_des3_encrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_cbc_des3_encrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_cbc_des3_decrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_cbc_des3_decrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_ecb_des3_encrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_ecb_des3_encrypt(struct skcipher_request *areq);
|
||||||
int sun4i_ss_ecb_des3_decrypt(struct ablkcipher_request *areq);
|
int sun4i_ss_ecb_des3_decrypt(struct skcipher_request *areq);
|
||||||
|
|
||||||
int sun4i_ss_cipher_init(struct crypto_tfm *tfm);
|
int sun4i_ss_cipher_init(struct crypto_tfm *tfm);
|
||||||
int sun4i_ss_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
int sun4i_ss_aes_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
unsigned int keylen);
|
unsigned int keylen);
|
||||||
int sun4i_ss_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
int sun4i_ss_des_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
unsigned int keylen);
|
unsigned int keylen);
|
||||||
int sun4i_ss_des3_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
int sun4i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||||
unsigned int keylen);
|
unsigned int keylen);
|
||||||
|
|
Loading…
Add table
Reference in a new issue