public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: linux-kernel@vger.kernel.org
Cc: Fruhwirth Clemens <clemens@endorphin.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	cryptoapi@lists.logix.cz, James Morris <jmorris@redhat.com>,
	David Miller <davem@davemloft.net>, Andrew Morton <akpm@osdl.org>,
	Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Subject: [0/many] Acrypto - asynchronous crypto layer for linux kernel 2.6
Date: Mon, 7 Mar 2005 23:37:32 +0300	[thread overview]
Message-ID: <11102278521318@2ka.mipt.ru> (raw)
In-Reply-To: 



I'm pleased to announce asynchronous crypto layer for Linux kernel 2.6.
It supports following features:
- multiple asynchronous crypto device queues
- crypto session routing
- crypto session binding
- modular load balancing
- crypto session batching genetically implemented by design
- crypto session priority
- different kinds of crypto operation(RNG, asymmetrical crypto, HMAC and
any other)

Some design notes:
acrypto has one main crypto session queue, into which each
newly allocated session is inserted and this is a place where load
balancing searches it's food. When new session is being prepared for
insertion it calls load balancer's ->find_device() method, which should
return suitable device(current simple_lb load balancer returns device
with the lowest load(device has the least number of session in it's
queue)) if it exists. After crypto_device being returned acrypto creates
new crypto routing entry which points to returned device and adds it to
crypto session routing queue. Crypto session is being inserted into
device's queue according to it's priority and it is crypto device driver
that should process it's session list according to session's priority.

Each crypto load balancer must implement 2 methods: 
->rehash() and ->find_device() which may be called from any context and
under spinlock.
->rehash() method should be called to remix crypto sessions in device's
queues, for example if driver decides that it's device is broken it
marks itself as broken and load balancer(or scheduler if you like)
should remove all sessions from this queue to some other devices. 
If session can not be completed scheduler must mark it as broken and
complete it(by calling first broke_session() and then complete_session()
and stop_process_session()). Consumer must check if operation was
successful(and therefore session is not broken).
->find_device() method should return appropriate crypto device.
Since load balancers may be loaded and unloaded without any restriction,
one may create it's own crypto load balancers, which may use
crpypto session's (crypto_data) private area to select appropriate device,
for example, one may store process' pid in private area and write it's own
crypto load balancer which will select private crypto device for given PID,
and the rest of the cypto system to process other requests.

For crypto session to be successfully allocated crypto consumer must
provide two structures - struct crypto_session_initializer and struct crypto_data.
struct crypto_session_initializer contains data needed to find
appropriate device, like type of operation, mode of operation, some
flags(for example SESSION_BINDED, which means that session must be bound
to specified in bdev field crypto device, it is useful for TCPA/TPM),
session priority and callback which will be called after all routing for
given session are finished.
struct crypto_data contains scatterlists for src, dst, key and iv.
It also has void *priv field and it's size which is allocated and may be
used by any crypto agent(for example VIA PadLock driver uses it to store
aes_ctx field, crypto_session can use this field to store some pointers
needed in ->callback()).
Actually callback will be called from work queue context, but I suppose it is
better to not assume calling context.
->callback() will be called after all crypto routing for given session
are done with the same parameters as were provided in initialisation
time(if session has only one routing callback will be called with
original parameters, but if it has several routes callback will be
called with parameters from the latest processed one). I believe crypto
callback should not know about crypto sessions, routings, device and so
on, proper restriction is always a good idea.

Crypto routing.
This feature allows the same session to be processed by several
devices/algorithms. For example if you need to encrypt data and then
sign it in TPM device you can create one route to encryption device and
then route it to TPM device, or this can be used for tweakable cipher
encryption without 2-atomic-maps restriction.

Crypto device.
It can be either software emulator or hardware accelerator chip(like
HIFN 79*/83* or Via PadLock ACE/RNG, or even TPM device like each IBM
ThinkPad or some HP laptops have.
It can be registered with asynchronous crypto layer and must provide
some data for it:
->data_ready() method - it is called each time new session is added to
device's queue.
Array of struct crypto_capability and it's amount - 
struct crypto_capability describes each operation given device can
handle, and has a maximum session queue length parameter.
Note: this structure can [be extended to] include "rate" parameter to
show absolute speed of given operation in some units, which therefore
can be used by scheduler(load balancer) for proper device selection.
Actually queue length can somehow reflects device's "speed".
Note2: it can be calculated using ptime parameter of the session initializer - 
it is time given session was processed in crypto device.

Acrypto has full userspace support through ioctl and direct process' vmas and pages access.
It is done using ioctl() with 2 copyings from+to userspace data.
Session processing contains of 3 major parts:
1. Session creation. CRYPTO_SESSION_ALLOC ioctl.
User must provide special structure which has src, dst, key and iv data sizes 
and crypto initializer(crypto operation, mode, type and priority).
2. Data filling. User must call several CRYPTO_FILL_DATA ioctls.
Each one requires data size and data type(structure crypto_user_data) and data itself.
3. Finish. User must call CRYPTO_SESSION_ADD ioctl with pointer to the are whre crypting result must be stored.
The latter ioctl will sleep while session is being processed.

Second userspace communication mechanism is based on direct access to the process' 
vmas and pages from acrypto, pointers are transferred using special kernel connector structure.
Obviously it can not be used with the most hardware, but I like the idea itself.

Currently supported HIFN 7955(small load testing), via padlock driver(not tested), 
driver for CE-InfoSys FastCrypt PCI card equipped with a SuperCrypt CE99C003B chip(not tested).


             reply	other threads:[~2005-03-07 21:16 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-07 20:37 Evgeniy Polyakov [this message]
2005-03-07 20:37 ` [??/many] list of files to be sent in a next couple of e-mails with small description Evgeniy Polyakov
2005-03-07 20:37   ` [??/many] acrypto benchmarks vs cryptoloop vs dm_crypt Evgeniy Polyakov
2005-03-07 20:37     ` [??/many] iok.c - simple example of the userspace acrypto usage [IOCTL] Evgeniy Polyakov
2005-03-07 20:37       ` [??/many] ucon_crypto.c - simple example of the userspace acrypto usage [DIRECT ACCESS] Evgeniy Polyakov
2005-03-07 20:37         ` [1/many] acrypto: Kconfig Evgeniy Polyakov
2005-03-07 20:37           ` [2/many] acrypto: Makefile Evgeniy Polyakov
2005-03-07 20:37             ` [3/many] acrypto: acrypto.h Evgeniy Polyakov
2005-03-07 20:37               ` [4/many] acrypto: async_provider.c Evgeniy Polyakov
2005-03-07 20:37                 ` [5/many] acrypto: crypto_conn.c Evgeniy Polyakov
2005-03-07 20:37                   ` [6/many] acrypto: crypto_conn.h Evgeniy Polyakov
2005-03-07 20:37                     ` [7/many] acrypto: crypto_def.h Evgeniy Polyakov
2005-03-07 20:37                       ` [8/many] acrypto: crypto_dev.c Evgeniy Polyakov
2005-03-07 20:37                         ` [9/many] acrypto: crypto_lb.c Evgeniy Polyakov
2005-03-07 20:37                           ` [10/many] acrypto: crypto_lb.h Evgeniy Polyakov
2005-03-07 20:37                             ` [11/many] acrypto: crypto_main.c Evgeniy Polyakov
2005-03-07 20:37                               ` [12/many] acrypto: crypto_route.h Evgeniy Polyakov
2005-03-07 20:37                                 ` [13/many] acrypto: crypto_stat.c Evgeniy Polyakov
2005-03-07 20:37                                   ` [14/many] acrypto: crypto_stat.h Evgeniy Polyakov
2005-03-07 20:37                                     ` [15/many] acrypto: crypto_user.c Evgeniy Polyakov
2005-03-07 20:37                                       ` [16/many] acrypto: crypto_user.h Evgeniy Polyakov
2005-03-07 20:37                                         ` [17/many] acrypto: crypto_user_direct.c Evgeniy Polyakov
2005-03-07 20:37                                           ` [18/many] acrypto: crypto_user_direct.h Evgeniy Polyakov
2005-03-07 20:37                                             ` [19/many] acrypto: crypto_user_ioctl.c Evgeniy Polyakov
2005-03-07 20:37                                               ` [20/many] acrypto: crypto_user_ioctl.h Evgeniy Polyakov
2005-03-07 20:37                                                 ` [21/many] acrypto: simple_lb.c Evgeniy Polyakov
2005-03-07 20:37                                                   ` [22/many] arch: alpha config Evgeniy Polyakov
2005-03-07 20:37                                                     ` [23/many] arch: arm config Evgeniy Polyakov
2005-03-07 20:37                                                       ` [24/many] arch: arm26 config Evgeniy Polyakov
2005-03-07 20:37                                                         ` [25/many] arch: cris config Evgeniy Polyakov
2005-03-07 20:37                                                           ` [26/many] arch: frv config Evgeniy Polyakov
2005-03-07 20:37                                                             ` [27/many] arch: h8300 config Evgeniy Polyakov
2005-03-07 20:37                                                               ` [28/many] arch: i386 config Evgeniy Polyakov
2005-03-07 20:37                                                                 ` [29/many] arch: ia64 config Evgeniy Polyakov
2005-03-07 20:37                                                                   ` [30/many] arch: m32r config Evgeniy Polyakov
2005-03-07 20:37                                                                     ` [31/many] arch: m68k config Evgeniy Polyakov
2005-03-07 20:37                                                                       ` [32/many] arch: m68knommu config Evgeniy Polyakov
2005-03-07 20:37                                                                         ` [33/many] arch: mips config Evgeniy Polyakov
2005-03-07 20:37                                                                           ` [34/many] arch: parisc config Evgeniy Polyakov
2005-03-07 20:37                                                                             ` [35/many] arch: ppc config Evgeniy Polyakov
2005-03-07 20:37                                                                               ` [36/many] arch: ppc64 config Evgeniy Polyakov
2005-03-07 20:37                                                                                 ` [37/many] arch: s390 config Evgeniy Polyakov
2005-03-07 20:37                                                                                   ` [38/many] arch: sh config Evgeniy Polyakov
2005-03-07 20:37                                                                                     ` [39/many] arch: sh64 config Evgeniy Polyakov
2005-03-07 20:37                                                                                       ` [40/many] arch: sparc config Evgeniy Polyakov
2005-03-07 20:37                                                                                         ` [41/many] arch: sparc64 config Evgeniy Polyakov
2005-03-07 20:37                                                                                           ` [42/many] arch: um config Evgeniy Polyakov
2005-03-07 20:37                                                                                             ` [43/many] arch: v850 config Evgeniy Polyakov
2005-03-07 20:37                                                                                               ` [44/many] arch: x86_64 config Evgeniy Polyakov
2005-03-07 20:37                                                                                                 ` [1/5] bd: Asynchronous block device Evgeniy Polyakov
2005-03-07 20:37                                                                                                   ` [2/5] bd: userspace utility to control asynchronous " Evgeniy Polyakov
2005-03-07 20:37                                                                                                     ` [4/5] bd: script for binding file and acrypto filters Evgeniy Polyakov
2005-03-07 20:37                                                                                                       ` [5/5] bd: script for unbinding any filters Evgeniy Polyakov
2005-03-08 15:16                                                                                                   ` [1/5] bd: Asynchronous block device Evgeniy Polyakov
2005-03-15 17:27                                         ` [16/many] acrypto: crypto_user.h Randy.Dunlap
2005-03-15 16:24                               ` [11/many] acrypto: crypto_main.c Randy.Dunlap
2005-03-16  4:58                                 ` Evgeniy Polyakov
2005-03-08 18:02                           ` [UPDATE PATCH 9/many] acrypto: crypto_lb.c Nishanth Aravamudan
2005-03-08 18:33                             ` Evgeniy Polyakov
2005-03-10 19:18                           ` [9/many] " Randy.Dunlap
2005-03-07 22:40                         ` [8/many] acrypto: crypto_dev.c Nish Aravamudan
2005-03-07 23:14                           ` Evgeniy Polyakov
2005-03-07 22:51                             ` Nish Aravamudan
2005-03-07 23:27                               ` Evgeniy Polyakov
2005-03-08  1:46                                 ` [UPDATE PATCH 8/many] " Nishanth Aravamudan
2005-03-08  9:40                                   ` Evgeniy Polyakov
2005-03-07 23:37                         ` [8/many] " Randy.Dunlap
2005-03-08  0:05                           ` Evgeniy Polyakov
2005-03-07 23:50               ` [3/many] acrypto: acrypto.h Randy.Dunlap
2005-03-08  0:34                 ` Evgeniy Polyakov
2005-03-07 23:33           ` [1/many] acrypto: Kconfig Randy.Dunlap
2005-03-08  0:03             ` Evgeniy Polyakov
2005-03-07 21:13 ` [0/many] Acrypto - asynchronous crypto layer for linux kernel 2.6 Fruhwirth Clemens
2005-03-07 21:49   ` Evgeniy Polyakov
2005-03-08 13:24     ` Joshua Jackson
2005-03-10 10:27       ` Evgeniy Polyakov
2005-03-08  5:08 ` Kyle Moffett
2005-03-08  9:37   ` Evgeniy Polyakov
2005-03-08 12:22     ` Kyle Moffett
2005-03-08 13:07       ` Evgeniy Polyakov
2005-03-08 14:46         ` Kyle Moffett
2005-03-08 15:24           ` Evgeniy Polyakov
2005-03-10 12:42   ` Christophe Saout
2005-03-08 10:30 ` Herbert Xu

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=11102278521318@2ka.mipt.ru \
    --to=johnpol@2ka.mipt.ru \
    --cc=akpm@osdl.org \
    --cc=clemens@endorphin.org \
    --cc=cryptoapi@lists.logix.cz \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=jmorris@redhat.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox