Change crypto "provider" structures to hold numeric values instead of function
authorKen Raeburn <raeburn@mit.edu>
Tue, 22 Jul 2003 19:09:32 +0000 (19:09 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 22 Jul 2003 19:09:32 +0000 (19:09 +0000)
pointers for key sizes, block sizes, etc., when the values are always constant
for each encryption or hash mechanism.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15714 dc483132-0cff-0310-8789-dd5450dbe970

43 files changed:
src/include/ChangeLog
src/include/k5-int.h
src/lib/crypto/ChangeLog
src/lib/crypto/arcfour/ChangeLog
src/lib/crypto/arcfour/arcfour.c
src/lib/crypto/block_size.c
src/lib/crypto/checksum_length.c
src/lib/crypto/combine_keys.c
src/lib/crypto/dk/ChangeLog
src/lib/crypto/dk/checksum.c
src/lib/crypto/dk/derive.c
src/lib/crypto/dk/dk_decrypt.c
src/lib/crypto/dk/dk_encrypt.c
src/lib/crypto/dk/stringtokey.c
src/lib/crypto/enc_provider/ChangeLog
src/lib/crypto/enc_provider/aes.c
src/lib/crypto/enc_provider/arcfour.c
src/lib/crypto/enc_provider/des.c
src/lib/crypto/enc_provider/des3.c
src/lib/crypto/hash_provider/ChangeLog
src/lib/crypto/hash_provider/hash_crc32.c
src/lib/crypto/hash_provider/hash_md4.c
src/lib/crypto/hash_provider/hash_md5.c
src/lib/crypto/hash_provider/hash_sha1.c
src/lib/crypto/hmac.c
src/lib/crypto/keyhash_provider/ChangeLog
src/lib/crypto/keyhash_provider/descbc.c
src/lib/crypto/keyhash_provider/hmac_md5.c
src/lib/crypto/keyhash_provider/k5_md4des.c
src/lib/crypto/keyhash_provider/k5_md5des.c
src/lib/crypto/keyhash_provider/t_cksum.c
src/lib/crypto/make_checksum.c
src/lib/crypto/make_random_key.c
src/lib/crypto/old/ChangeLog
src/lib/crypto/old/old_decrypt.c
src/lib/crypto/old/old_encrypt.c
src/lib/crypto/pbkdf2.c
src/lib/crypto/raw/ChangeLog
src/lib/crypto/raw/raw_encrypt.c
src/lib/crypto/string_to_key.c
src/lib/crypto/t_hmac.c
src/lib/crypto/yarrow/ChangeLog
src/lib/crypto/yarrow/ycipher.c

index eb2606dea648ee785837cb8d08e231a8fd1ea324..4f8012c3ac8fb63067bbde2be604b9597214b8cd 100644 (file)
@@ -2,6 +2,9 @@
 
        * k5-int.h (krb5int_zap_data, zap): New macros; call memset with
        volatile cast for now.
+       (struct krb5_enc_provider, struct krb5_hash_provider, struct
+       krb5_keyhash_provider): Use numeric values for block size,
+       key size, hash size, etc, instead of function pointers.
 
 2003-07-21  Alexandra Ellwood  <lxs@mit.edu>
 
index 3c2e382f82338e8ec1edd8f5eb9bd65aaf27bd00..2be8ce590044e7ac5dc16a37c97e08a3df0441a0 100644 (file)
@@ -565,11 +565,9 @@ krb5int_locate_server (krb5_context,
 /* new encryption provider api */
 
 struct krb5_enc_provider {
-    void (*block_size) (size_t *output);
-
     /* keybytes is the input size to make_key; 
        keylength is the output size */
-    void (*keysize) (size_t *keybytes, size_t *keylength);
+    size_t block_size, keybytes, keylength;
 
     /* cipher-state == 0 fresh state thrown away at end */
     krb5_error_code (*encrypt) (const krb5_keyblock *key,
@@ -592,9 +590,7 @@ struct krb5_enc_provider {
 };
 
 struct krb5_hash_provider {
-    void (*hash_size) (size_t *output);
-
-    void (*block_size) (size_t *output);
+    size_t hashsize, blocksize;
 
     /* this takes multiple inputs to avoid lots of copying. */
     krb5_error_code (*hash) (unsigned int icount, const krb5_data *input,
@@ -602,7 +598,7 @@ struct krb5_hash_provider {
 };
 
 struct krb5_keyhash_provider {
-    void (*hash_size) (size_t *output);
+    size_t hashsize;
 
     krb5_error_code (*hash) (const krb5_keyblock *key,
                             krb5_keyusage keyusage,
index a1f135c09b773a59aa51104af1dd831602fb05ec..e02d9790e26854045853d42a85e3ab0b02fa4657 100644 (file)
@@ -1,4 +1,17 @@
-2003-07-13  Kenneth Raeburn  <raeburn@mit.edu>
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * block_size.c (krb5_c_block_size): Read new numeric fields for
+       key/block/hash sizes instead of calling functions.
+       * checksum_length.c (krb5_c_checksum_length): Likewise.
+       * combine_keys.c (krb5int_c_combine_keys, dr): Likewise.
+       * hmac.c (krb5_hmac): Likewise.
+       * make_checksum.c (krb5_c_make_checksum): Likewise.
+       * make_random_key.c (krb5_c_make_random_key): Likewise.
+       * pbkdf2.c (hmac1): Likewise.
+       * string_to_key.c (krb5_c_string_to_key_with_params): Likewise.
+       * t_hmac.c (hmac1): Likewise.
+
+2003-07-13  Ken Raeburn  <raeburn@mit.edu>
 
        * pbkdf2.c (foo): Never call com_err.
 
index 3a536e30c9491bd865bf7211c78839e692bf1cd0..3f901cbcfe1f9f90d898333fc90b22ba63926715 100644 (file)
@@ -1,3 +1,9 @@
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * arcfour.c (krb5_arcfour_encrypt_length, krb5_arcfour_encrypt,
+       krb5_arcfour_decrypt): Use new numeric fields for block/hash/key
+       sizes instead of calling functions.
+
 2003-07-17  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBNAME) [##WIN16##]: Don't define.
index a6759700a93352feda2a71b8bef84410893e9424..67e0f9189408b856d3004e08da84699c32d9ff77 100644 (file)
@@ -19,9 +19,8 @@ krb5_arcfour_encrypt_length(enc, hash, inputlen, length)
 {
   size_t blocksize, hashsize;
 
-  (*(enc->block_size))(&blocksize);
-  (*(hash->hash_size))(&hashsize);
-
+  blocksize = enc->block_size;
+  hashsize = hash->hashsize;
 
   /* checksum + (confounder + inputlen, in even blocksize) */
   *length = hashsize + krb5_roundup(8 + inputlen, blocksize);
@@ -78,9 +77,10 @@ krb5_arcfour_encrypt(enc, hash, key, usage, ivec, input, output)
   size_t keylength, keybytes, blocksize, hashsize;
   krb5_error_code ret;
 
-  (*(enc->block_size))(&blocksize);
-  (*(enc->keysize))(&keybytes, &keylength);
-  (*(hash->hash_size))(&hashsize);
+  blocksize = enc->block_size;
+  keybytes = enc->keybytes;
+  keylength = enc->keylength;
+  hashsize = hash->hashsize;
   
   d1.length=keybytes;
   d1.data=malloc(d1.length);
@@ -206,9 +206,10 @@ krb5_arcfour_decrypt(enc, hash, key, usage, ivec, input, output)
   size_t keybytes, keylength, hashsize, blocksize;
   krb5_error_code ret;
 
-  (*(enc->block_size))(&blocksize);
-  (*(enc->keysize))(&keybytes, &keylength);
-  (*(hash->hash_size))(&hashsize);
+  blocksize = enc->block_size;
+  keybytes = enc->keybytes;
+  keylength = enc->keylength;
+  hashsize = hash->hashsize;
 
   d1.length=keybytes;
   d1.data=malloc(d1.length);
index c759ad8b951b4eaa35141404aba3772307aa29d3..021f3819be31db8082636d6ec33c2f8319e3ad2f 100644 (file)
@@ -43,7 +43,7 @@ krb5_c_block_size(context, enctype, blocksize)
     if (i == krb5_enctypes_length)
        return(KRB5_BAD_ENCTYPE);
 
-    (*(krb5_enctypes_list[i].enc->block_size))(blocksize);
+    *blocksize = krb5_enctypes_list[i].enc->block_size;
 
     return(0);
 }
index f3886f4a9708335a6f78f83ce407e210585a175b..4a0294c5d514edc53d8ef59d60c687abd397fcb1 100644 (file)
@@ -44,11 +44,11 @@ krb5_c_checksum_length(context, cksumtype, length)
        return(KRB5_BAD_ENCTYPE);
 
     if (krb5_cksumtypes_list[i].keyhash)
-       (*(krb5_cksumtypes_list[i].keyhash->hash_size))(length);
+       *length = krb5_cksumtypes_list[i].keyhash->hashsize;
     else if (krb5_cksumtypes_list[i].trunc_size)
        *length = krb5_cksumtypes_list[i].trunc_size;
     else
-       (*(krb5_cksumtypes_list[i].hash->hash_size))(length);
+       *length = krb5_cksumtypes_list[i].hash->hashsize;
 
     return(0);
 }
index 9aad8f54320576642250282e27d385774c67a91f..3d97651640af36551747ce5378278d191b60b0a4 100644 (file)
@@ -100,7 +100,8 @@ krb5_error_code krb5int_c_combine_keys
 
     enc = krb5_enctypes_list[i].enc;
 
-    (*(enc->keysize))(&keybytes, &keylength);
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     /*
      * Allocate and set up buffers
@@ -290,8 +291,9 @@ static krb5_error_code dr
     unsigned char *inblockdata, *outblockdata;
     krb5_data inblock, outblock;
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     /* allocate and set up buffers */
 
index 4633675eb3aa263a021fc4b29bbe0901a3676c4f..30107a2180350dafa40af95471b06ad534cf965b 100644 (file)
@@ -1,3 +1,16 @@
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * checksum.c (krb5_dk_make_checksum, krb5_marc_dk_make_checksum):
+       Use new numeric fields for key/bolck sizes instead of calling
+       functions.
+       * derive.c (krb5_derive_key, krb5_derive_random): Likewise.
+       * dk_decrypt.c (krb5_dk_decrypt_maybe_trunc_hmac,
+       krb5_marc_dk_decrypt): Likewise.
+       * dk_encrypt.c (krb5_dk_encrypt_length, krb5_dk_encrypt,
+       krb5int_aes_encrypt_length, trunc_hmac, krb5int_aes_dk_encrypt,
+       krb5_marc_dk_encrypt_length, krb5_mark_dk_encrypt): Likewise.
+       * stringtokey.c (krb5int_dk_string_to_key): Likewise.
+
 2003-07-17  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBNAME) [##WIN16##]: Don't define.
index 1769b5cce625cdbdf26e5bc580be74729b6ded38..ffdb4e7ceaec7098ba893802762ae338f1362c05 100644 (file)
@@ -59,8 +59,9 @@ krb5_dk_make_checksum(hash, key, usage, input, output)
 
     /* allocate and set to-be-derived keys */
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     /* key->length will be tested in enc->encrypt
        output->length will be tested in krb5_hmac */
@@ -133,8 +134,9 @@ krb5_marc_dk_make_checksum(hash, key, usage, input, output)
 
     /* allocate and set to-be-derived keys */
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     /* key->length will be tested in enc->encrypt
        output->length will be tested in krb5_hmac */
index 0aabdc4ed4a9e3dd6bbf50d70dc600acc296c7ff..6c8ff0bdc32ed5697f83f64a8a063e136a3609cc 100644 (file)
@@ -38,8 +38,9 @@ krb5_derive_key(enc, inkey, outkey, in_constant)
     unsigned char *inblockdata, *outblockdata, *rawkey;
     krb5_data inblock, outblock;
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     if ((inkey->length != keylength) ||
        (outkey->length != keylength))
@@ -124,8 +125,9 @@ krb5_derive_random(enc, inkey, outrnd, in_constant)
     unsigned char *inblockdata, *outblockdata, *rawkey;
     krb5_data inblock, outblock;
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     if ((inkey->length != keylength) ||
        (outrnd->length != keybytes))
index 5f35fa6ace353f3e2aa0c948bf2e55be2f9b4d36..0c95d40798edb34f92d7e485db7e79878fc07ee3 100644 (file)
@@ -88,9 +88,10 @@ krb5_dk_decrypt_maybe_trunc_hmac(enc, hash, key, usage, ivec, input, output,
 
     /* allocate and set up ciphertext and to-be-derived keys */
 
-    (*(hash->hash_size))(&hashsize);
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    hashsize = hash->hashsize;
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     if (hmacsize == 0)
        hmacsize = hashsize;
@@ -223,9 +224,10 @@ krb5_marc_dk_decrypt(enc, hash, key, usage, ivec, input, output)
 
     /* allocate and set up ciphertext and to-be-derived keys */
 
-    (*(hash->hash_size))(&hashsize);
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    hashsize = hash->hashsize;
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     enclen = input->length - hashsize;
 
index 9de05fc02bbcd1ea567a18834cab62610f5d16e0..32cc509afcd9d8c65ebdd5f3ff23fb69f708ea24 100644 (file)
@@ -45,9 +45,8 @@ krb5_dk_encrypt_length(enc, hash, inputlen, length)
 {
     size_t blocksize, hashsize;
 
-    (*(enc->block_size))(&blocksize);
-    (*(hash->hash_size))(&hashsize);
-
+    blocksize = enc->block_size;
+    hashsize = hash->hashsize;
     *length = krb5_roundup(blocksize+inputlen, blocksize) + hashsize;
 }
 
@@ -70,8 +69,9 @@ krb5_dk_encrypt(enc, hash, key, usage, ivec, input, output)
 
     /* allocate and set up plaintext and to-be-derived keys */
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
     plainlen = krb5_roundup(blocksize+input->length, blocksize);
 
     krb5_dk_encrypt_length(enc, hash, input->length, &enclen);
@@ -188,7 +188,7 @@ krb5int_aes_encrypt_length(enc, hash, inputlen, length)
 {
     size_t blocksize, hashsize;
 
-    (*(enc->block_size))(&blocksize);
+    blocksize = enc->block_size;
     hashsize = 96 / 8;
 
     /* No roundup, since CTS requires no padding once we've hit the
@@ -205,7 +205,7 @@ trunc_hmac (const struct krb5_hash_provider *hash,
     krb5_data tmp;
     krb5_error_code ret;
 
-    (hash->hash_size)(&hashsize);
+    hashsize = hash->hashsize;
     if (hashsize < output->length)
        return KRB5_CRYPTO_INTERNAL;
     tmp.length = hashsize;
@@ -239,8 +239,9 @@ krb5int_aes_dk_encrypt(enc, hash, key, usage, ivec, input, output)
 
     /* allocate and set up plaintext and to-be-derived keys */
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
     plainlen = blocksize+input->length;
 
     krb5int_aes_encrypt_length(enc, hash, input->length, &enclen);
@@ -359,9 +360,8 @@ krb5_marc_dk_encrypt_length(enc, hash, inputlen, length)
 {
     size_t blocksize, hashsize;
 
-    (*(enc->block_size))(&blocksize);
-    (*(hash->hash_size))(&hashsize);
-
+    blocksize = enc->block_size;
+    hashsize = hash->hashsize;
     *length = krb5_roundup(blocksize+4+inputlen, blocksize) + hashsize;
 }
 
@@ -384,8 +384,9 @@ krb5_marc_dk_encrypt(enc, hash, key, usage, ivec, input, output)
 
     /* allocate and set up plaintext and to-be-derived keys */
 
-    (*(enc->block_size))(&blocksize);
-    (*(enc->keysize))(&keybytes, &keylength);
+    blocksize = enc->block_size;
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
     plainlen = krb5_roundup(blocksize+4+input->length, blocksize);
 
     krb5_marc_dk_encrypt_length(enc, hash, input->length, &enclen);
index be13ca4a1e266f08689de20c438dab3cf52ed4b5..0e54b849fff147df410a8345dad68e0859a1d7a0 100644 (file)
@@ -42,7 +42,8 @@ krb5int_dk_string_to_key(const struct krb5_enc_provider *enc,
 
     /* key->length is checked by krb5_derive_key */
 
-    (*(enc->keysize))(&keybytes, &keylength);
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     concatlen = string->length+(salt?salt->length:0);
 
index bd0a5febec3cdcf66251d387820592897b0cfbbe..89bf6dec9b9d3e8617be8d9986188d8e1a06faaf 100644 (file)
@@ -1,5 +1,15 @@
 2003-07-22  Ken Raeburn  <raeburn@mit.edu>
 
+       * aes.c (aes_block_size, aes128_keysize, aes256_keysize):
+       Deleted.
+       (krb5int_enc_aes128, krb5int_enc_aes256): Updated.
+       * arcfour.c (k5_arcfour_blocksize, k5_arcfour_keysize): Deleted.
+       (krb5int_enc_arcfour): Updated.
+       * des.c (k5_des_block_size, k5_des_keysize): Deleted.
+       (krb5int_enc_des): Updated.
+       * des3.c (k5_des3_block_size, k5_des3_keysize): Deleted.
+       (krb5int_enc_des3): Updated.
+
        * des3.c (validate_and_schedule): Split out from old
        k5_des3_docrypt.
        (k5_des3_encrypt, k5_des3_decrypt): Call it, and
index 013a688eb1d606f53d34437738854eda75986943..c6b77f0ecf6f2f3093d9596a7be9479935d91bbc 100644 (file)
@@ -2,24 +2,6 @@
 #include "enc_provider.h"
 #include "aes.h"
 
-static void
-aes_block_size(size_t *blocksize)
-{
-    *blocksize = 16;
-}
-
-static void
-aes128_keysize(size_t *keybytes, size_t *keylength)
-{
-    *keybytes = *keylength = 16;
-}
-
-static void
-aes256_keysize(size_t *keybytes, size_t *keylength)
-{
-    *keybytes = *keylength = 32;
-}
-
 #if 0
 aes_rval aes_blk_len(unsigned int blen, aes_ctx cx[1]);
 aes_rval aes_enc_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1]);
@@ -199,8 +181,8 @@ krb5int_aes_init_state (const krb5_keyblock *key, krb5_keyusage usage,
 }
 
 const struct krb5_enc_provider krb5int_enc_aes128 = {
-    aes_block_size,
-    aes128_keysize,
+    16,
+    16, 16,
     krb5int_aes_encrypt,
     krb5int_aes_decrypt,
     k5_aes_make_key,
@@ -209,8 +191,8 @@ const struct krb5_enc_provider krb5int_enc_aes128 = {
 };
 
 const struct krb5_enc_provider krb5int_enc_aes256 = {
-    aes_block_size,
-    aes256_keysize,
+    16,
+    32, 32,
     krb5int_aes_encrypt,
     krb5int_aes_decrypt,
     k5_aes_make_key,
index bfdc19372493c1777c144325bdb75e04cfe20c74..d3a600b299d221a90447de4cb14690fc87275987 100644 (file)
@@ -29,13 +29,6 @@ static krb5_error_code
 k5_arcfour_docrypt(const krb5_keyblock *, const krb5_data *,
                   const krb5_data *, krb5_data *);
 
-
-/* The blocksize for the enctype */
-static void k5_arcfour_blocksize(size_t *);
-
-/* keysize for the enctype (number of bytes, and length of key (parity/etc) */
-static void k5_arcfour_keysize(size_t *, size_t *);
-
 /* from a random bitstrem, construct a key */
 static krb5_error_code
 k5_arcfour_make_key(const krb5_data *, krb5_keyblock *);
@@ -121,24 +114,6 @@ k5_arcfour_init(ArcfourContext *ctx, const unsigned char *key,
   return 0;
 }
 
-/* This seems to work... although I am not sure what the implications are
-   in other places in the kerberos library */
-static void
-k5_arcfour_blocksize(size_t *blocksize)
-{
-  *blocksize = 1;
-}
-
-/* Keysize is arbitrary in arcfour, but the constraints of the system, and
-   to attempt to work with the MSFT system forces us to 16byte/128bit.
-   Since there is no parity in the key, the byte and length are the same.
-*/
-static void
-k5_arcfour_keysize(size_t *keybytes, size_t *keylength)
-{
-    *keybytes = 16;
-    *keylength = 16;
-}
 
 /* The workhorse of the arcfour system, this impliments the cipher */
 static krb5_error_code
@@ -224,8 +199,14 @@ k5_arcfour_init_state (const krb5_keyblock *key,
    we just call "docrypt" directly
 */
 const struct krb5_enc_provider krb5int_enc_arcfour = {
-    k5_arcfour_blocksize,
-    k5_arcfour_keysize,
+    /* This seems to work... although I am not sure what the
+       implications are in other places in the kerberos library */
+    1,
+    /* Keysize is arbitrary in arcfour, but the constraints of the
+       system, and to attempt to work with the MSFT system forces us
+       to 16byte/128bit.  Since there is no parity in the key, the
+       byte and length are the same.  */
+    16, 16,
     k5_arcfour_docrypt,
     k5_arcfour_docrypt,
     k5_arcfour_make_key,
index e9ecb72e1e9f5d88f0b2f06f7562dccdde63c4ba..70082bc245a1ea92397e6cb793730b62c2074d0d 100644 (file)
 
 static const mit_des_cblock mit_des_zeroblock[8] /* = all zero */;
 
-static void
-k5_des_block_size(size_t *blocksize)
-{
-    *blocksize = 8;
-}
-
-static void
-k5_des_keysize(size_t *keybytes, size_t *keylength)
-{
-    *keybytes = 7;
-    *keylength = 8;
-}
-
 static krb5_error_code
 k5_des_docrypt(const krb5_keyblock *key, const krb5_data *ivec,
               const krb5_data *input, krb5_data *output, int enc)
@@ -122,8 +109,8 @@ k5_des_make_key(const krb5_data *randombits, krb5_keyblock *key)
 }
 
 const struct krb5_enc_provider krb5int_enc_des = {
-    k5_des_block_size,
-    k5_des_keysize,
+    8,
+    7, 8,
     k5_des_encrypt,
     k5_des_decrypt,
     k5_des_make_key,
index 54fbb69afcc452c257712f44bbbaf0f42a19a91e..048a220e605685d61d6fcfbf9005e2cb9701eb9e 100644 (file)
 
 static const mit_des_cblock mit_des_zeroblock[8] /* = all zero */;
 
-static void
-k5_des3_block_size(size_t *blocksize)
-{
-    *blocksize = 8;
-}
-
-static void
-k5_des3_keysize(size_t *keybytes, size_t *keylength)
-{
-    *keybytes = 21;
-    *keylength = 24;
-}
-
 static krb5_error_code
 validate_and_schedule(const krb5_keyblock *key, const krb5_data *ivec,
                      const krb5_data *input, const krb5_data *output,
@@ -145,8 +132,8 @@ k5_des3_make_key(const krb5_data *randombits, krb5_keyblock *key)
 }
 
 const struct krb5_enc_provider krb5int_enc_des3 = {
-    k5_des3_block_size,
-    k5_des3_keysize,
+    8,
+    21, 24,
     k5_des3_encrypt,
     k5_des3_decrypt,
     k5_des3_make_key,
index 974fa340370c85fd5e32c1f63367e1bbd760a1d4..d1fa657331ef41fac334d1704bf247cd276d16e9 100644 (file)
@@ -1,3 +1,15 @@
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * hash_crc32.c (k5_crc32_hash_size, k5_crc32_block_size):
+       Deleted.
+       (krb5int_hash_crc32): Updated.
+       * hash_md4.c (k5_md4_hash_size, k5_md4_block_size): Deleted.
+       (krb5int_hash_md4): Updated.
+       * hash_md5.c (k5_md5_hash_size, k5_md5_block_size): Deleted.
+       (krb5int_hash_md5): Updated.
+       * hash_sha1.c (k5_sha1_hash_size, k5_sha1_block_size): Deleted.
+       (krb5int_hash_sha1): Updated.
+
 2003-07-17  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBNAME) [##WIN16##]: Don't define.
index 7c06fa3a6bd7bc954f8de828e5948f8bccfdbfc3..b48b3b3634cc2883acddf0705e79837f7d1dc82a 100644 (file)
 #include "crc-32.h"
 #include "hash_provider.h"
 
-static void
-k5_crc32_hash_size(size_t *output)
-{
-    *output = CRC32_CKSUM_LENGTH;
-}
-
-static void
-k5_crc32_block_size(size_t *output)
-{
-    *output = 1;
-}
-
 static krb5_error_code
 k5_crc32_hash(unsigned int icount, const krb5_data *input,
              krb5_data *output)
@@ -65,7 +53,7 @@ k5_crc32_hash(unsigned int icount, const krb5_data *input,
 }
 
 const struct krb5_hash_provider krb5int_hash_crc32 = {
-    k5_crc32_hash_size,
-    k5_crc32_block_size,
+    CRC32_CKSUM_LENGTH,
+    1,
     k5_crc32_hash
 };
index 5c9d6b1538d84cd36b3faa8d8062c8d03e6093b9..97487923b2936608ca8d44d833d6a20f0ba74b57 100644 (file)
 #include "rsa-md4.h"
 #include "hash_provider.h"
 
-static void
-k5_md4_hash_size(size_t *output)
-{
-    *output = RSA_MD4_CKSUM_LENGTH;
-}
-
-static void
-k5_md4_block_size(size_t *output)
-{
-    *output = 64;
-}
-
 static krb5_error_code
 k5_md4_hash(unsigned int icount, const krb5_data *input,
            krb5_data *output)
@@ -61,7 +49,7 @@ k5_md4_hash(unsigned int icount, const krb5_data *input,
 }
 
 const struct krb5_hash_provider krb5int_hash_md4 = {
-    k5_md4_hash_size,
-    k5_md4_block_size,
+    RSA_MD4_CKSUM_LENGTH,
+    64,
     k5_md4_hash
 };
index c08755fb50c6dcbcc80bab89740c63cb6c888faf..408729337612aa98c61453f39de73f9498d16768 100644 (file)
 #include "rsa-md5.h"
 #include "hash_provider.h"
 
-static void
-k5_md5_hash_size(size_t *output)
-{
-    *output = RSA_MD5_CKSUM_LENGTH;
-}
-
-static void
-k5_md5_block_size(size_t *output)
-{
-    *output = 64;
-}
-
 static krb5_error_code
 k5_md5_hash(unsigned int icount, const krb5_data *input,
            krb5_data *output)
@@ -61,7 +49,7 @@ k5_md5_hash(unsigned int icount, const krb5_data *input,
 }
 
 const struct krb5_hash_provider krb5int_hash_md5 = {
-    k5_md5_hash_size,
-    k5_md5_block_size,
+    RSA_MD5_CKSUM_LENGTH,
+    64,
     k5_md5_hash
 };
index 8b7166c209bffa0bc0893061d84f5ae2cf33f41e..2ee56ad21c806ee9369e54e7f6b82878bcb80158 100644 (file)
 #include "shs.h"
 #include "hash_provider.h"
 
-static void
-k5_sha1_hash_size(size_t *output)
-{
-    *output = SHS_DIGESTSIZE;
-}
-
-static void
-k5_sha1_block_size(size_t *output)
-{
-    *output = SHS_DATASIZE;
-}
-
 static krb5_error_code
 k5_sha1_hash(unsigned int icount, const krb5_data *input,
             krb5_data *output)
@@ -66,7 +54,7 @@ k5_sha1_hash(unsigned int icount, const krb5_data *input,
 }
 
 const struct krb5_hash_provider krb5int_hash_sha1 = {
-    k5_sha1_hash_size,
-    k5_sha1_block_size,
+    SHS_DIGESTSIZE,
+    SHS_DATASIZE,
     k5_sha1_hash
 };
index 763744c0f8b86d304777847cb9bac9c796829b96..ec39520960e7a7c25dd0472c10bcad486f7cd43e 100644 (file)
@@ -52,8 +52,8 @@ krb5_hmac(hash, key, icount, input, output)
     krb5_data *hashin, hashout;
     krb5_error_code ret;
 
-    (*(hash->hash_size))(&hashsize);
-    (*(hash->block_size))(&blocksize);
+    hashsize = hash->hashsize;
+    blocksize = hash->blocksize;
 
     if (key->length > blocksize)
        return(KRB5_CRYPTO_INTERNAL);
index 3667e0f05f1f14ec5a638e93aefca9af87c4dc8c..6f0931f1dbf5990cfe1c9fb1793ddda82e9d5c3a 100644 (file)
@@ -1,3 +1,16 @@
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * descbc.c (k5_descbc_hash_size): Deleted.
+       (krb5int_keyhash_descbc): Updated.
+       * hmac_md5.c (k5_hmac_md5_hash_size): Deleted.
+       (krb5int_keyhash_hmac_md5): Updated.
+       * k5_md4des.c (k5_md4des_hash_size): Deleted.
+       (krb5int_keyhash_md4des): Updated.
+       * k5_md5des.c (k5_md5des_hash_size): Deleted.
+       (krb5int_keyhash_md5des): Updated.
+       * t_cksum.c (main): Use the hashsize field instead of calling a
+       function.
+
 2003-07-17  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBNAME) [##WIN16##]: Don't define.
index 9682fbb3b0844bfc1d6be48c6278e487877bb424..e13b39b853f90a10a8252bade0f874db6d1e5754 100644 (file)
 
 static const mit_des_cblock mit_des_zeroblock[8] /* = all zero */;
 
-static void
-k5_descbc_hash_size(size_t *output)
-{
-    *output = 8;
-}
-
 static krb5_error_code
 k5_descbc_hash(const krb5_keyblock *key, krb5_keyusage usage, const krb5_data *ivec,
               const krb5_data *input, krb5_data *output)
@@ -72,7 +66,7 @@ k5_descbc_hash(const krb5_keyblock *key, krb5_keyusage usage, const krb5_data *i
 }
 
 const struct krb5_keyhash_provider krb5int_keyhash_descbc = {
-    k5_descbc_hash_size,
+    8,
     k5_descbc_hash,
     NULL
 };
index 08808ff9118c132def773093830407af10f6e9b1..a2472a83299aee286f7efd2fa469a8c02b914159 100644 (file)
 #include "rsa-md5.h"
 #include "hash_provider.h"
 
-static void 
-k5_hmac_md5_hash_size (size_t *output) 
-{
-  *output = 16;
-}
-
 static  krb5_error_code
 k5_hmac_md5_hash (const krb5_keyblock *key, krb5_keyusage usage,
                  const krb5_data *iv,
@@ -95,7 +89,7 @@ k5_hmac_md5_hash (const krb5_keyblock *key, krb5_keyusage usage,
                 
 
 const struct krb5_keyhash_provider krb5int_keyhash_hmac_md5 = {
-  k5_hmac_md5_hash_size,
+  16,
   k5_hmac_md5_hash,
   NULL /*checksum  again*/
 };
index 5ff50bfdfac8ad6741139c6b2778e879d6b57ed5..d31eb54a8591cde0a4ecb86a242c63c75a9da841 100644 (file)
 
 static const mit_des_cblock mit_des_zeroblock[8] /* = all zero */;
 
-static void
-k5_md4des_hash_size(size_t *output)
-{
-    *output = CONFLENGTH+RSA_MD4_CKSUM_LENGTH;
-}
-
 /* des-cbc(xorkey, conf | rsa-md4(conf | data)) */
 
 /* this could be done in terms of the md4 and des providers, but
@@ -192,7 +186,7 @@ k5_md4des_verify(const krb5_keyblock *key, krb5_keyusage usage,
 }
 
 const struct krb5_keyhash_provider krb5int_keyhash_md4des = {
-    k5_md4des_hash_size,
+    CONFLENGTH+RSA_MD4_CKSUM_LENGTH,
     k5_md4des_hash,
     k5_md4des_verify
 };
index 2a2bef38d4038730bbf3d7594abd363c0d39ecd4..17353108367d34df3ac4f575aa47b24a6d5eb5a8 100644 (file)
 
 static const mit_des_cblock mit_des_zeroblock[8] /* = all zero */;
 
-static void
-k5_md5des_hash_size(size_t *output)
-{
-    *output = CONFLENGTH+RSA_MD5_CKSUM_LENGTH;
-}
-
 /* des-cbc(xorkey, conf | rsa-md5(conf | data)) */
 
 /* this could be done in terms of the md5 and des providers, but
@@ -189,7 +183,7 @@ k5_md5des_verify(const krb5_keyblock *key, krb5_keyusage usage, const krb5_data
 }
 
 const struct krb5_keyhash_provider krb5int_keyhash_md5des = {
-    k5_md5des_hash_size,
+    CONFLENGTH+RSA_MD5_CKSUM_LENGTH,
     k5_md5des_hash,
     k5_md5des_verify
 };
index 80b820afe935b191bc292bde84923a06268d5431..98187f7f162ccd780c8f9781c7a6987415bb9677 100644 (file)
@@ -89,7 +89,7 @@ main(argc, argv)
   keyblock.length = sizeof(testkey);
   keyblock.contents = testkey;
 
-  (*(khp.hash_size))(&length);
+  length = khp.hashsize;
 
   newstyle_checksum.length = length;
 
index 8a384e710a716d8d4a521c9f2b7715891402ec5c..9d272eb796ab18da8a6473072d7f153f78bb1e1a 100644 (file)
@@ -52,9 +52,9 @@ krb5_c_make_checksum(context, cksumtype, key, usage, input, cksum)
        return(KRB5_BAD_ENCTYPE);
 
     if (krb5_cksumtypes_list[i].keyhash)
-       (*(krb5_cksumtypes_list[i].keyhash->hash_size))(&cksumlen);
+       cksumlen = krb5_cksumtypes_list[i].keyhash->hashsize;
     else
-       (*(krb5_cksumtypes_list[i].hash->hash_size))(&cksumlen);
+       cksumlen = krb5_cksumtypes_list[i].hash->hashsize;
 
     cksum->length = cksumlen;
 
index d5e4fcb7dc7bf0a2f6c9335920cccb65d25e9418..c0c0debde4993465b73d29e4acbdb769e34439a5 100644 (file)
@@ -50,7 +50,8 @@ krb5_c_make_random_key(context, enctype, random_key)
 
     enc = krb5_enctypes_list[i].enc;
 
-    (*(enc->keysize))(&keybytes, &keylength);
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     if ((bytes = (unsigned char *) malloc(keybytes)) == NULL)
        return(ENOMEM);
index 1f58bf983790bc6375c07e447ec726d0c6817dee..126b2f1ad4e83de50df6d76624b60cec8922fc41 100644 (file)
@@ -1,3 +1,10 @@
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * old_decrypt.c (krb5_old_decrypt): Use block_size and hashsize
+       fields instead of calling functions.
+       * old_encrypt.c (krb5_old_encrypt_length, krb5_old_encrypt):
+       Likewise.
+
 2003-07-17  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBNAME) [##WIN16##]: Don't define.
index a43090c27d8062bb57d2c43fdaaafe425d755ea3..cfbbd7272a045a034aaa929d0f59221dddd2fd31 100644 (file)
@@ -42,8 +42,8 @@ krb5_old_decrypt(const struct krb5_enc_provider *enc,
     krb5_data output, cksum, crcivec;
     int alloced;
 
-    (*(enc->block_size))(&blocksize);
-    (*(hash->hash_size))(&hashsize);
+    blocksize = enc->block_size;
+    hashsize = hash->hashsize;
 
     plainsize = input->length - blocksize - hashsize;
 
index 0f7ea8d0cd3eab847d878f7bff60092677dff838..98bd109e0e9f1fc0488b83360ed0036d023a3f73 100644 (file)
@@ -35,8 +35,8 @@ krb5_old_encrypt_length(const struct krb5_enc_provider *enc,
 {
     size_t blocksize, hashsize;
 
-    (*(enc->block_size))(&blocksize);
-    (*(hash->hash_size))(&hashsize);
+    blocksize = enc->block_size;
+    hashsize = hash->hashsize;
 
     *length = krb5_roundup(blocksize+hashsize+inputlen, blocksize);
 }
@@ -55,8 +55,8 @@ krb5_old_encrypt(const struct krb5_enc_provider *enc,
     krb5_data datain, crcivec;
     int real_ivec;
 
-    (*(enc->block_size))(&blocksize);
-    (*(hash->hash_size))(&hashsize);
+    blocksize = enc->block_size;
+    hashsize = hash->hashsize;
 
     krb5_old_encrypt_length(enc, hash, input->length, &enclen);
 
index ce9f215fa6a97c2ec7771ecd4557e720baa1dead..d7aba026ea621d3c74bbca115297b126ca1c1b49 100644 (file)
@@ -221,8 +221,8 @@ static krb5_error_code hmac1(const struct krb5_hash_provider *h,
 
     if (debug_hmac)
        printk(" test key", key);
-    h->block_size(&blocksize);
-    h->hash_size(&hashsize);
+    blocksize = h->blocksize;
+    hashsize = h->hashsize;
     if (hashsize > sizeof(tmp))
        abort();
     if (key->length > blocksize) {
index 33e6afd8d0734f8cc009587b5d539d6f25a27d3e..1bd2a019aee80da6c27beb9ed2b59d2d054e1b1a 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * raw_encrypt.c (krb5_raw_encrypt_length): Use block_size field
+       instead of calling a function.
+
 2003-07-17  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBNAME) [##WIN16##]: Don't define.
index 8505534ec353c261e0ebb490ae897bb9f5cd5378..97e1bb5ee83cb0658deece75fd6cef2074f349a6 100644 (file)
@@ -36,7 +36,7 @@ krb5_raw_encrypt_length(enc, hash, inputlen, length)
 {
     size_t blocksize;
 
-    (*(enc->block_size))(&blocksize);
+    blocksize = enc->block_size;
 
     *length = krb5_roundup(inputlen, blocksize);
 }
index 412583185b482fd4a16ef0675eb0c6d5ec4e23e2..27f49aabe73ce0c874fa71187705f67d87b46c81 100644 (file)
@@ -85,8 +85,8 @@ krb5_c_string_to_key_with_params(context, enctype, string, salt, params, key)
        }
     }
 
-       
-    (*(enc->keysize))(&keybytes, &keylength);
+    keybytes = enc->keybytes;
+    keylength = enc->keylength;
 
     if ((key->contents = (krb5_octet *) malloc(keylength)) == NULL)
        return(ENOMEM);
index 96c2357a5b9adab3d7549303301694274c0726bd..8208eddeded1f6de155470aecf92d4dcdcb58884 100644 (file)
@@ -101,8 +101,8 @@ static krb5_error_code hmac1(const struct krb5_hash_provider *h,
     krb5_error_code err;
 
     printk(" test key", key);
-    h->block_size(&blocksize);
-    h->hash_size(&hashsize);
+    blocksize = h->blocksize;
+    hashsize = h->hashsize;
     if (hashsize > sizeof(tmp))
        abort();
     if (key->length > blocksize) {
index da6fc5a15a86edcd07b197f836f3676555679634..f64c1a2b5c1b454dbbaa884971e31d6f55ed94bf 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-22  Ken Raeburn  <raeburn@mit.edu>
+
+       * ycipher.c (krb5int_yarrow_cipher_init): Use keybytes and
+       keylength fields instead of calling a function.
+
 2003-07-17  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (LIBNAME) [##WIN16##]: Don't define.
index 983f7a2a3a72aecc1688459d269e66237f0662d2..b763815be96da29e417f0abacde8e9aab490abd4 100644 (file)
@@ -42,7 +42,8 @@ krb5int_yarrow_cipher_init
   const struct krb5_enc_provider *enc = &yarrow_enc_provider;
   krb5_error_code ret;
   krb5_data randombits;
-  enc->keysize (&keybytes, &keylength);
+  keybytes = enc->keybytes;
+  keylength = enc->keylength;
   assert (keybytes == CIPHER_KEY_SIZE);
   if (ctx->key.contents) {
     memset (ctx->key.contents, 0, ctx->key.length);