Thread (6 messages) read the whole thread 6 messages, 3 authors, 2007-09-22

Re: [PATCH 1/1]: CTR mode implementation

From: Joy Latten <hidden>
Date: 2007-09-22 00:18:46

On Thu, 2007-09-20 at 16:19 +0800, Herbert Xu wrote:
On Wed, Sep 19, 2007 at 05:51:15PM -0500, Joy Latten wrote:
quoted
predictability into my sessions? I could truncate the salt
in my counter block to 2 bytes and put 2 bytes of the IV for
blocksizes of 8... does that sound, ok?
Or am I totally misunderstanding it all?
I suggest that you make these parameters to your CTR template.
So instead of requesting for "ctr(aes)", you could request for
"ctr(aes, 4, 8)" where 4 is the length of the nonce in the
counter block and 8 is the length of the IV.  The counter
itself would then be calculated as block_size - 4 - 8.
Ok, pretty much had this coded up when it dawned on me
maybe I should include the nonce as parameter too.
Whenever you use ctr, it is a given you need the nonce.
Couldn't the user of the api, separate the nonce from 
the key and pass it in the template? It would solve
my problem about sometimes the keylen is bigger than 
max-key-length for the algorithm with the additional bytes 
for nonce. So, I could pass in ctr(aes, nonce, noncesize, ivsize).
Let me know if this sounds ok or did I miss something important?
quoted
quoted
quoted
+static int crypto_ctr_encrypt(struct blkcipher_desc *desc,
+			      struct scatterlist *dst, struct scatterlist *src,
+			      unsigned int nbytes)
+{
+	struct blkcipher_walk walk;
+	struct crypto_blkcipher *tfm = desc->tfm;
+	struct crypto_ctr_ctx *ctx = crypto_blkcipher_ctx(tfm);
+	struct crypto_cipher *child = ctx->child;
+	u8 *counterblk = ctx->ctrblk;
We need to support simultaneous calls to the same tfm so you
need to allocate this somewhere else.  Just use the original
IV since it should be of the right length.
Just to make sure I understand what you meant, you mean just use
ctx->ctrblk directly?
No I mean that you can't use anything from the ctx as the same
ctx may be used by multiple calls at the same time.  You'd have
to allocate it on the stack or via kmalloc.
Ok, I get it. Thanks. :-)
I will try using the original IV as you first suggested.

Joy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help