Hello Phil,
 I've applied patches 1-3, but I haven't applied this one. That is
because this will make the driver not compatible with the original
openbsd interface (we'll have structures with different content). I'd
suggest extensions like those to be added as a new ioctl that can be
checked for existence using an ifdef.

regards,
Nikos


On 12/13/2010 05:55 PM, Phil Sutter wrote:
> Each crypto_tfm object contains fields with verbose names for the
> chosen algorithm and it's driver, which is potentially interesting for
> userspace to know. This patch exports them to the later as part of
> struct session_op.
> ---
>  cryptodev.h      |    9 +++++++++
>  cryptodev_main.c |   15 +++++++++++++++
>  2 files changed, 24 insertions(+), 0 deletions(-)
> 
> diff --git a/cryptodev.h b/cryptodev.h
> index f367262..a20f1d2 100644
> --- a/cryptodev.h
> +++ b/cryptodev.h
> @@ -68,6 +68,9 @@ enum cryptodev_crypto_op_t {
>  /* Values for hashes/MAC */
>  #define AALG_MAX_RESULT_LEN          64
>  
> +/* maximum length of verbose alg names (depends on CRYPTO_MAX_ALG_NAME) */
> +#define CRYPTODEV_MAX_ALG_NAME               64
> +
>  /* input of CIOCGSESSION */
>  struct session_op {
>       /* Specify either cipher or mac
> @@ -83,6 +86,12 @@ struct session_op {
>       __u32   ses;            /* session identifier */
>  
>       __u16   alignmask;      /* alignment constraints */
> +
> +     /* verbose names for the requested ciphers */
> +     struct alg_info {
> +             char cra_name[CRYPTODEV_MAX_ALG_NAME];
> +             char cra_driver_name[CRYPTODEV_MAX_ALG_NAME];
> +     } cipher_info, hash_info;
>  };
>  
>  #define      COP_ENCRYPT     0
> diff --git a/cryptodev_main.c b/cryptodev_main.c
> index e869557..2c322a4 100644
> --- a/cryptodev_main.c
> +++ b/cryptodev_main.c
> @@ -32,6 +32,7 @@
>   *
>   */
>  
> +#include <crypto/hash.h>
>  #include <linux/crypto.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> @@ -126,6 +127,14 @@ struct csession {
>  /* cryptodev's own workqueue, keeps crypto tasks from disturbing the force */
>  static struct workqueue_struct *cryptodev_wq;
>  
> +static inline void tfm_info_to_alg_info(struct alg_info *dst, struct 
> crypto_tfm *tfm)
> +{
> +     snprintf(dst->cra_name, CRYPTODEV_MAX_ALG_NAME,
> +                     "%s", crypto_tfm_alg_name(tfm));
> +     snprintf(dst->cra_driver_name, CRYPTODEV_MAX_ALG_NAME,
> +                     "%s", crypto_tfm_alg_driver_name(tfm));
> +}
> +
>  /* Prepare session for future use. */
>  static int
>  crypto_create_session(struct fcrypt *fcr, struct session_op *sop)
> @@ -260,6 +269,9 @@ crypto_create_session(struct fcrypt *fcr, struct 
> session_op *sop)
>                       ret = -EINVAL;
>                       goto error_cipher;
>               }
> +
> +             tfm_info_to_alg_info(&sop->cipher_info,
> +                             crypto_ablkcipher_tfm(ses_new->cdata.async.s));
>       }
>  
>       if (hash_name) {
> @@ -288,6 +300,9 @@ crypto_create_session(struct fcrypt *fcr, struct 
> session_op *sop)
>                       ret = -EINVAL;
>                       goto error_hash;
>               }
> +
> +             tfm_info_to_alg_info(&sop->hash_info,
> +                             crypto_ahash_tfm(ses_new->hdata.async.s));
>       }
>  
>       sop->alignmask = ses_new->alignmask = max(ses_new->cdata.alignmask,


_______________________________________________
Cryptodev-linux-devel mailing list
Cryptodev-linux-devel@gna.org
https://mail.gna.org/listinfo/cryptodev-linux-devel

Reply via email to