From: Jouni Malinen <jkmaline@cc.hut.fi>
To: James Morris <jmorris@redhat.com>
Cc: Clay Haapala <chaapala@cisco.com>,
"David S. Miller" <davem@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: Crypto API and keyed non-HMAC digest algorithms / Michael MIC
Date: Tue, 9 Mar 2004 19:40:14 -0800 [thread overview]
Message-ID: <20040310034014.GA3739@jm.kir.nu> (raw)
In-Reply-To: <Xine.LNX.4.44.0403091532020.27586-100000@thoron.boston.redhat.com>
> On Tue, 9 Mar 2004, Clay Haapala wrote:
> > I had the same thought in my attempt at adding CRC32C to the crypto
> > routines, that what was needed was "digests + setkey". But I didn't
> > want to add the key baggage to digests, and so created a new alg type
> > (CHKSUM), with pretty much identical code to digest, but with a
> > modified init and a new setkey interface.
On Tue, Mar 09, 2004 at 03:32:58PM -0500, James Morris wrote:
> I think that adding a setkey method for digests is the simplest approach.
I took a quick look at the CRC32C patch and it looked like the only
needed change for the digest type was the new handler for setting a
32-bit seed. I used setkey handler that takes an arbitrary key data and
length (Michael MIC uses 64-bit key/seed). As far as I could tell, this
setkey function should be enough for CRC32C needs, too. Clay, please let
me know if I missed something here. James, please consider merging this
into Linux 2.6 tree if there are no issues with CRC32C.
The patch below includes only the setkey addition from my previous
patch. This is against current linus-2.5 BK tree. I will re-diff and
send Michael MIC portion of the patch separately. Re-diffing was needed
anyway, since ARC4 addition had a small conflict with the Michael MIC
patch.
You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.
===================================================================
ChangeSet@1.1689, 2004-03-09 18:54:50-08:00, jkmaline@cc.hut.fi
Added support for using keyed digest with an optional dit_setkey handler.
This does not change the behavior of the existing digest algorithms, but
allows new ones to add setkey handler that can be used to initialize the
algorithm with a key or seed. setkey is to be called after init, but before
any of the update call(s).
crypto/digest.c | 10 ++++++++++
crypto/tcrypt.c | 4 ++++
crypto/tcrypt.h | 2 ++
include/linux/crypto.h | 13 +++++++++++++
4 files changed, 29 insertions(+)
diff -Nru a/crypto/digest.c b/crypto/digest.c
--- a/crypto/digest.c Tue Mar 9 18:58:22 2004
+++ b/crypto/digest.c Tue Mar 9 18:58:22 2004
@@ -42,6 +42,15 @@
tfm->__crt_alg->cra_digest.dia_final(crypto_tfm_ctx(tfm), out);
}
+static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+{
+ u32 flags;
+ if (tfm->__crt_alg->cra_digest.dia_setkey == NULL)
+ return -1;
+ return tfm->__crt_alg->cra_digest.dia_setkey(crypto_tfm_ctx(tfm),
+ key, keylen, &flags);
+}
+
static void digest(struct crypto_tfm *tfm,
struct scatterlist *sg, unsigned int nsg, u8 *out)
{
@@ -72,6 +81,7 @@
ops->dit_update = update;
ops->dit_final = final;
ops->dit_digest = digest;
+ ops->dit_setkey = setkey;
return crypto_alloc_hmac_block(tfm);
}
diff -Nru a/crypto/tcrypt.c b/crypto/tcrypt.c
--- a/crypto/tcrypt.c Tue Mar 9 18:58:22 2004
+++ b/crypto/tcrypt.c Tue Mar 9 18:58:22 2004
@@ -112,6 +112,10 @@
sg[0].length = hash_tv[i].psize;
crypto_digest_init (tfm);
+ if (tfm->crt_u.digest.dit_setkey) {
+ crypto_digest_setkey (tfm, hash_tv[i].key,
+ hash_tv[i].ksize);
+ }
crypto_digest_update (tfm, sg, 1);
crypto_digest_final (tfm, result);
diff -Nru a/crypto/tcrypt.h b/crypto/tcrypt.h
--- a/crypto/tcrypt.h Tue Mar 9 18:58:22 2004
+++ b/crypto/tcrypt.h Tue Mar 9 18:58:22 2004
@@ -30,6 +30,8 @@
char digest[MAX_DIGEST_SIZE];
unsigned char np;
unsigned char tap[MAX_TAP];
+ char key[128]; /* only used with keyed hash algorithms */
+ unsigned char ksize;
};
struct hmac_testvec {
diff -Nru a/include/linux/crypto.h b/include/linux/crypto.h
--- a/include/linux/crypto.h Tue Mar 9 18:58:22 2004
+++ b/include/linux/crypto.h Tue Mar 9 18:58:22 2004
@@ -76,6 +76,8 @@
void (*dia_init)(void *ctx);
void (*dia_update)(void *ctx, const u8 *data, unsigned int len);
void (*dia_final)(void *ctx, u8 *out);
+ int (*dia_setkey)(void *ctx, const u8 *key,
+ unsigned int keylen, u32 *flags);
};
struct compress_alg {
@@ -157,6 +159,8 @@
void (*dit_final)(struct crypto_tfm *tfm, u8 *out);
void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg,
unsigned int nsg, u8 *out);
+ int (*dit_setkey)(struct crypto_tfm *tfm,
+ const u8 *key, unsigned int keylen);
#ifdef CONFIG_CRYPTO_HMAC
void *dit_hmac_block;
#endif
@@ -280,6 +284,15 @@
{
BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
tfm->crt_digest.dit_digest(tfm, sg, nsg, out);
+}
+
+static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
+ const u8 *key, unsigned int keylen)
+{
+ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
+ if (tfm->crt_digest.dit_setkey == NULL)
+ return -1;
+ return tfm->crt_digest.dit_setkey(tfm, key, keylen);
}
static inline int crypto_cipher_setkey(struct crypto_tfm *tfm,
===================================================================
This BitKeeper patch contains the following changesets:
1.1689
## Wrapped with gzip_uu ##
M'XL( $Z$3D ]586T_C.!1^CG^%5R.MVBY-[<1IDR(0<T$L&C0@!AY&LZ/(
M==PFT,;=V(%AI_/?]^324B!<=QX6ETOK.-_Y?/R=2_H&GVJ9#:VS\QF?)JE$
M;_"?2INA)80=Y\8>)S!SK!3,]/[NG<UZH_.>3OE<Q\IT'=M#</F(&Q'C"YGI
MH45M=S5CKN9R:!WO[IT>O#U&:&L+OX]Y.I&?I<%;6\BH[()/([W#33Q5J6TR
MGNJ9--P6:K98+5TXA#CP\NC )5Y_0?N$#1:"1I1R1F5$'.;WV37:?"Z" ;&5
MCJ:VRB8W@1AQ*2&4N)ZWH)X[<-$'3&W:]P-,6(^X/1)@Z@\]-O1(E_A#0O#2
M,SLKC^ _&.X2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=-W.M VSB]JIK"DF!%N1##6K>).SW(D<O<66$4&JER
M3'-G<J]*_DMCA&97._-")KD!+VM;RP?@7-"+3ZM'"O#JH$X\Y'G5UGT-HJG:
MOENB:?;,2[0S\ OM%#6SU;FN7>W6A4HBW(&Z=;O0HCJIK(^&V@L%&63965:U
M?>H%ZX96>>V^\MYDY@D5'RPYT-@&91E=]1+%R9>KFO+GO0SN$F@<3^Q#WIWN
MA8>?UIL"",*P>%PO.P/\&SRI'W\Y.CD,WQ[LA2=?CG;##_M[NY]/VNN-2U$>
I[A2'IW0KC3=6E6.M#P%;JV\21"S%N<YG6R/6'Y$Q<=&_I7&6K[@0
--
Jouni Malinen PGP id EFC895FA
next prev parent reply other threads:[~2004-03-10 3:42 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-06 18:46 Crypto API and keyed non-HMAC digest algorithms / Michael MIC Jouni Malinen
2004-03-08 14:45 ` James Morris
2004-03-09 3:37 ` Jouni Malinen
2004-03-09 5:55 ` James Morris
2004-03-09 17:30 ` Clay Haapala
2004-03-09 20:32 ` James Morris
2004-03-10 3:40 ` Jouni Malinen [this message]
2004-03-10 4:02 ` [PATCH] Crypto API and " Jouni Malinen
2004-03-10 4:21 ` Crypto API and keyed non-HMAC digest algorithms / " James Morris
2004-03-10 5:34 ` Jouni Malinen
2004-03-10 15:45 ` James Morris
2004-03-11 3:00 ` Jouni Malinen
2004-03-11 4:06 ` James Morris
2004-03-11 6:08 ` Jouni Malinen
2004-03-11 16:34 ` Clay Haapala
2004-03-11 20:14 ` James Morris
2004-03-18 23:05 ` Clay Haapala
2004-03-21 15:08 ` James Morris
2004-03-22 16:49 ` [PATCH] lib/libcrc32c implementation Clay Haapala
2004-03-22 17:00 ` Jeff Garzik
2004-03-22 17:27 ` Clay Haapala
2004-03-22 17:36 ` Jeff Garzik
2004-03-26 16:36 ` James Morris
2004-03-26 16:59 ` Clay Haapala
2004-03-26 18:16 ` James Morris
2004-03-30 17:32 ` [PATCH] lib/libcrc32c Clay Haapala
2004-03-30 18:43 ` Bartlomiej Zolnierkiewicz
2004-03-30 19:11 ` Clay Haapala
2004-03-30 19:23 ` Matt Domsch
2004-03-30 19:33 ` Clay Haapala
2004-03-31 21:03 ` [PATCH] lib/libcrc32c, revised 040331 Clay Haapala
2004-04-19 21:37 ` [PATCH] lib/libcrc32c, revised 040419 Clay Haapala
2004-04-23 23:42 ` David S. Miller
2004-04-27 19:46 ` [PATCH] lib/libcrc32c, revised 040427 Clay Haapala
2004-04-27 19:49 ` David S. Miller
2004-04-27 20:00 ` Clay Haapala
2004-04-27 21:49 ` Clay Haapala
2004-04-27 21:50 ` David S. Miller
2004-04-28 15:14 ` [PATCH] lib/libcrc32c, revised 040428, with compiler.h included Clay Haapala
2004-04-28 19:29 ` David S. Miller
2004-04-27 19:55 ` [PATCH] lib/crc32.c: to use compiler.h defines Clay Haapala
2004-04-28 15:19 ` [PATCH] lib/crc32.c: uses (and includes) compiler.h Clay Haapala
2004-04-28 19:30 ` David S. Miller
2004-03-30 19:49 ` [PATCH] lib/libcrc32c Bartlomiej Zolnierkiewicz
2004-03-31 15:28 ` Clay Haapala
2004-03-30 17:40 ` [PATCH] crypto/crc32c implementation Clay Haapala
2004-04-19 21:31 ` [PATCH] crypto/crc32c implementation, updated 040419 Clay Haapala
2004-04-19 23:36 ` David S. Miller
2004-04-20 13:20 ` James Morris
2004-03-22 16:56 ` [PATCH] crypto/crc32c support Clay Haapala
2004-03-11 6:11 ` Crypto API and keyed non-HMAC digest algorithms / Michael MIC Jouni Malinen
2004-03-10 16:04 ` Clay Haapala
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=20040310034014.GA3739@jm.kir.nu \
--to=jkmaline@cc.hut.fi \
--cc=chaapala@cisco.com \
--cc=davem@redhat.com \
--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