* CRYPTO_TFM_REQ_MASK and CRYPTO_TFM_RES_MASK
@ 2009-12-11 15:05 Dimitrios Siganos
2009-12-11 15:28 ` Dimitrios Siganos
0 siblings, 1 reply; 3+ messages in thread
From: Dimitrios Siganos @ 2009-12-11 15:05 UTC (permalink / raw)
To: linux-crypto
Hi,
Could someone explain what the masks CRYPTO_TFM_REQ_MASK and
CRYPTO_TFM_RES_MASK do and why they must be manipulated before and after
crypto_cipher_setkey(...)?
Here is an example use (from crypto_pcbc_setkey):
crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
CRYPTO_TFM_REQ_MASK);
err = crypto_cipher_setkey(child, key, keylen);
crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
CRYPTO_TFM_RES_MASK);
It would be very useful if someone added some comments to these
definitions (found in linux/crypto.h):
/*
* Transform masks and values (for crt_flags).
*/
#define CRYPTO_TFM_REQ_MASK 0x000fff00
#define CRYPTO_TFM_RES_MASK 0xfff00000
#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
#define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200
#define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000
#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000
Thanks,
Dimitris
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: CRYPTO_TFM_REQ_MASK and CRYPTO_TFM_RES_MASK
2009-12-11 15:05 CRYPTO_TFM_REQ_MASK and CRYPTO_TFM_RES_MASK Dimitrios Siganos
@ 2009-12-11 15:28 ` Dimitrios Siganos
2009-12-12 8:22 ` Herbert Xu
0 siblings, 1 reply; 3+ messages in thread
From: Dimitrios Siganos @ 2009-12-11 15:28 UTC (permalink / raw)
To: linux-crypto
After sending the email, I realised what's happening...
crypto_cipher_setkey seems to be used that way only when a child cipher
is used by another (parent) cipher as a way to delegate work.
It seems that crypto_cipher_setkey accepts a number of request flags
CRYPTO_TFM_REQ_* which must be passed to the child object and after
completion of crypto_cipher_setkey, it returns some results flags
CRYPTO_TFM_RES_* back which must be passed to the parent object.
So the flag manipulation before and after is because we are using an
internal cipher object to delegate the work.
Please correct me, if I am wrong.
Dimitris
Dimitrios Siganos wrote:
> Hi,
>
> Could someone explain what the masks CRYPTO_TFM_REQ_MASK and
> CRYPTO_TFM_RES_MASK do and why they must be manipulated before and
> after crypto_cipher_setkey(...)?
>
> Here is an example use (from crypto_pcbc_setkey):
> crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
> crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
> CRYPTO_TFM_REQ_MASK);
> err = crypto_cipher_setkey(child, key, keylen);
> crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
> CRYPTO_TFM_RES_MASK);
>
> It would be very useful if someone added some comments to these
> definitions (found in linux/crypto.h):
>
> /*
> * Transform masks and values (for crt_flags).
> */
> #define CRYPTO_TFM_REQ_MASK 0x000fff00
> #define CRYPTO_TFM_RES_MASK 0xfff00000
>
> #define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
> #define CRYPTO_TFM_REQ_MAY_SLEEP 0x00000200
> #define CRYPTO_TFM_REQ_MAY_BACKLOG 0x00000400
> #define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
> #define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
> #define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
> #define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000
> #define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000
>
> Thanks,
> Dimitris
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-crypto" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: CRYPTO_TFM_REQ_MASK and CRYPTO_TFM_RES_MASK
2009-12-11 15:28 ` Dimitrios Siganos
@ 2009-12-12 8:22 ` Herbert Xu
0 siblings, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2009-12-12 8:22 UTC (permalink / raw)
To: Dimitrios Siganos; +Cc: linux-crypto
Dimitrios Siganos <dimitris@siganos.org> wrote:
> After sending the email, I realised what's happening...
> crypto_cipher_setkey seems to be used that way only when a child cipher
> is used by another (parent) cipher as a way to delegate work.
>
> It seems that crypto_cipher_setkey accepts a number of request flags
> CRYPTO_TFM_REQ_* which must be passed to the child object and after
> completion of crypto_cipher_setkey, it returns some results flags
> CRYPTO_TFM_RES_* back which must be passed to the parent object.
>
> So the flag manipulation before and after is because we are using an
> internal cipher object to delegate the work.
You're absolutely correct. Feel free to send patches to add
comments too.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-12-12 8:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-11 15:05 CRYPTO_TFM_REQ_MASK and CRYPTO_TFM_RES_MASK Dimitrios Siganos
2009-12-11 15:28 ` Dimitrios Siganos
2009-12-12 8:22 ` Herbert Xu
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.