All of lore.kernel.org
 help / color / mirror / Atom feed
* using arc4 algorithm of linux kernel crypto subsystem
@ 2012-07-24 10:18 Arif Hossain
  0 siblings, 0 replies; only message in thread
From: Arif Hossain @ 2012-07-24 10:18 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I'm trying to use the "arc4" algorithm to to encrypt a arbitrary data
stream from a module. But i'm a little clueless about how should i
approach it.the implementation is in <crypto/arc4.c>

$find . -type f -name '*.[ch]' -exec grep 'EXPORT_SYMBOL' {} \; | grep
'rc4'

returned nothing. So i guess there is no external interface to 
static void arc4_crypt(struct crypto_tfm *tfm, u8 *out, const u8 *in). 

The register function is defined as

static int __init arc4_init(void)
 {
         return crypto_register_alg(&arc4_alg);
 }

And there is a static instance of struct crypto_alg.

By these hints, I've come to conclusion that, I need a higher level
interface to access this algorithm. 

Only function which seems relevant in my case is :

EXPORT_SYMBOL_GPL(crypto_alloc_tfm);

from <crypto/api.c> :

void *crypto_alloc_tfm(const char *alg_name,
		       const struct crypto_type *frontend, u32 type, u32 mask)

it returns void * which is my first concern.

And also from <crypt/api.c>

crypto_alloc_tfm() will first attempt to locate an already loaded
algorithm.  If that fails and the kernel supports dynamically loadable
modules, it will then attempt to load a module of the same name or
alias.  If that fails it will send a query to any loaded crypto manager
to construct an algorithm on the fly.  A refcount is grabbed on the
algorithm which is then associated with the new transform.

The returned transform is of a non-determinate type.  Most people
should use one of the more specific allocation functions such as
crypto_alloc_blkcipher.

But no specific crypto_alloc_* i could find which will provide arc4
algorithm.

Second concern:

struct crypto_type in <include/crypto/algapi.h> is looking horrendous to
instantiate by hand. 

And lastly if get a tfm instance, how i use it to do actual encryption?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-24 10:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-24 10:18 using arc4 algorithm of linux kernel crypto subsystem Arif Hossain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.