Skip to content

Commit

Permalink
crypto: add CONFIG_CRYPTO_SUNXI_CE_ADAPTER
Browse files Browse the repository at this point in the history
  • Loading branch information
scpcom committed Nov 14, 2021
1 parent a2d269a commit 5c23267
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 4 additions & 6 deletions crypto/algif_skcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#include <linux/net.h>
#include <net/sock.h>

#define SUNXI_CE_ADAPTER

static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg,
size_t size)
{
Expand Down Expand Up @@ -102,7 +100,7 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
goto free;
}
sg_init_table(areq->tsgl, areq->tsgl_entries);
#ifndef SUNXI_CE_ADAPTER
#ifndef CONFIG_CRYPTO_SUNXI_CE_ADAPTER
af_alg_pull_tsgl(sk, len, areq->tsgl, 0);
#else
af_alg_pull_tsgl(sk, ctx->used, areq->tsgl, 0);
Expand Down Expand Up @@ -245,7 +243,7 @@ static int skcipher_sendmsg_nokey(struct socket *sock, struct msghdr *msg,
int err;

err = skcipher_check_key(sock);
#ifndef SUNXI_CE_ADAPTER
#ifndef CONFIG_CRYPTO_SUNXI_CE_ADAPTER
if (err)
return err;
#endif
Expand All @@ -259,7 +257,7 @@ static ssize_t skcipher_sendpage_nokey(struct socket *sock, struct page *page,
int err;

err = skcipher_check_key(sock);
#ifndef SUNXI_CE_ADAPTER
#ifndef CONFIG_CRYPTO_SUNXI_CE_ADAPTER
if (err)
return err;
#endif
Expand All @@ -273,7 +271,7 @@ static int skcipher_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
int err;

err = skcipher_check_key(sock);
#ifndef SUNXI_CE_ADAPTER
#ifndef CONFIG_CRYPTO_SUNXI_CE_ADAPTER
if (err)
return err;
#endif
Expand Down
6 changes: 2 additions & 4 deletions crypto/skcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include "internal.h"

#define SUNXI_CE_ADAPTER

enum {
SKCIPHER_WALK_PHYS = 1 << 0,
SKCIPHER_WALK_SLOW = 1 << 1,
Expand Down Expand Up @@ -852,7 +850,7 @@ int crypto_skcipher_encrypt(struct skcipher_request *req)

crypto_stats_get(alg);
if (crypto_skcipher_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
#ifndef SUNXI_CE_ADAPTER
#ifndef CONFIG_CRYPTO_SUNXI_CE_ADAPTER
ret = -ENOKEY;
#else
ret = tfm->encrypt(req);
Expand All @@ -873,7 +871,7 @@ int crypto_skcipher_decrypt(struct skcipher_request *req)

crypto_stats_get(alg);
if (crypto_skcipher_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
#ifndef SUNXI_CE_ADAPTER
#ifndef CONFIG_CRYPTO_SUNXI_CE_ADAPTER
ret = -ENOKEY;
#else
ret = tfm->decrypt(req);
Expand Down
9 changes: 9 additions & 0 deletions drivers/crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,15 @@ config CRYPTO_DEV_SUNXI
CryptoEngine. It support some SoC of sun8i/sun50i series.
Select this if you want to use it.

config CRYPTO_SUNXI_CE_ADAPTER
bool "Support for Allwinner Sunxi CryptoEngine Adapter"
depends on ARCH_SUNXI
default y if ARCH_SUNXI
help
Allwinner Sunxi SoC have a crypto accelerator named
CryptoEngine Adapter.
Select this if you want to use it.

config CRYPTO_DEV_ROCKCHIP
tristate "Rockchip's Cryptographic Engine driver"
depends on OF && ARCH_ROCKCHIP
Expand Down

0 comments on commit 5c23267

Please sign in to comment.