From: aftnix@gmail.com (Arif Hossain)
To: kernelnewbies@lists.kernelnewbies.org
Subject: using arc4 algorithm of linux kernel crypto subsystem
Date: Tue, 24 Jul 2012 16:18:43 +0600 [thread overview]
Message-ID: <1343125123.26223.33.camel@localhost> (raw)
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?
reply other threads:[~2012-07-24 10:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343125123.26223.33.camel@localhost \
--to=aftnix@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.