summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2003-07-22 19:09:32 +0000
committerKen Raeburn <raeburn@mit.edu>2003-07-22 19:09:32 +0000
commit60ac58b5130b6ff110e9aeb569c29eeb20823840 (patch)
tree64c1523b7c4e1f5a8e905954cb81623f2c92eac0 /src
parent3610cd5cd67a4f6f9234de36410a75a2902842fe (diff)
downloadkrb5-60ac58b5130b6ff110e9aeb569c29eeb20823840.tar.gz
krb5-60ac58b5130b6ff110e9aeb569c29eeb20823840.tar.xz
krb5-60ac58b5130b6ff110e9aeb569c29eeb20823840.zip
Change crypto "provider" structures to hold numeric values instead of function
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
Diffstat (limited to 'src')
-rw-r--r--src/include/ChangeLog3
-rw-r--r--src/include/k5-int.h10
-rw-r--r--src/lib/crypto/ChangeLog15
-rw-r--r--src/lib/crypto/arcfour/ChangeLog6
-rw-r--r--src/lib/crypto/arcfour/arcfour.c19
-rw-r--r--src/lib/crypto/block_size.c2
-rw-r--r--src/lib/crypto/checksum_length.c4
-rw-r--r--src/lib/crypto/combine_keys.c8
-rw-r--r--src/lib/crypto/dk/ChangeLog13
-rw-r--r--src/lib/crypto/dk/checksum.c10
-rw-r--r--src/lib/crypto/dk/derive.c10
-rw-r--r--src/lib/crypto/dk/dk_decrypt.c14
-rw-r--r--src/lib/crypto/dk/dk_encrypt.c29
-rw-r--r--src/lib/crypto/dk/stringtokey.c3
-rw-r--r--src/lib/crypto/enc_provider/ChangeLog10
-rw-r--r--src/lib/crypto/enc_provider/aes.c26
-rw-r--r--src/lib/crypto/enc_provider/arcfour.c35
-rw-r--r--src/lib/crypto/enc_provider/des.c17
-rw-r--r--src/lib/crypto/enc_provider/des3.c17
-rw-r--r--src/lib/crypto/hash_provider/ChangeLog12
-rw-r--r--src/lib/crypto/hash_provider/hash_crc32.c16
-rw-r--r--src/lib/crypto/hash_provider/hash_md4.c16
-rw-r--r--src/lib/crypto/hash_provider/hash_md5.c16
-rw-r--r--src/lib/crypto/hash_provider/hash_sha1.c16
-rw-r--r--src/lib/crypto/hmac.c4
-rw-r--r--src/lib/crypto/keyhash_provider/ChangeLog13
-rw-r--r--src/lib/crypto/keyhash_provider/descbc.c8
-rw-r--r--src/lib/crypto/keyhash_provider/hmac_md5.c8
-rw-r--r--src/lib/crypto/keyhash_provider/k5_md4des.c8
-rw-r--r--src/lib/crypto/keyhash_provider/k5_md5des.c8
-rw-r--r--src/lib/crypto/keyhash_provider/t_cksum.c2
-rw-r--r--src/lib/crypto/make_checksum.c4
-rw-r--r--src/lib/crypto/make_random_key.c3
-rw-r--r--src/lib/crypto/old/ChangeLog7
-rw-r--r--src/lib/crypto/old/old_decrypt.c4
-rw-r--r--src/lib/crypto/old/old_encrypt.c8
-rw-r--r--src/lib/crypto/pbkdf2.c4
-rw-r--r--src/lib/crypto/raw/ChangeLog5
-rw-r--r--src/lib/crypto/raw/raw_encrypt.c2
-rw-r--r--src/lib/crypto/string_to_key.c4
-rw-r--r--src/lib/crypto/t_hmac.c4
-rw-r--r--src/lib/crypto/yarrow/ChangeLog5
-rw-r--r--src/lib/crypto/yarrow/ycipher.c3
43 files changed, 196 insertions, 235 deletions
diff --git a/src/include/ChangeLog b/src/include/ChangeLog
index eb2606dea6..4f8012c3ac 100644
--- a/src/include/ChangeLog
+++ b/src/include/ChangeLog
@@ -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>
diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index 3c2e382f82..2be8ce5900 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -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,
diff --git a/src/lib/crypto/ChangeLog b/src/lib/crypto/ChangeLog
index a1f135c09b..e02d9790e2 100644
--- a/src/lib/crypto/ChangeLog
+++ b/src/lib/crypto/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/arcfour/ChangeLog b/src/lib/crypto/arcfour/ChangeLog
index 3a536e30c9..3f901cbcfe 100644
--- a/src/lib/crypto/arcfour/ChangeLog
+++ b/src/lib/crypto/arcfour/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/arcfour/arcfour.c b/src/lib/crypto/arcfour/arcfour.c
index a6759700a9..67e0f91894 100644
--- a/src/lib/crypto/arcfour/arcfour.c
+++ b/src/lib/crypto/arcfour/arcfour.c
@@ -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);
diff --git a/src/lib/crypto/block_size.c b/src/lib/crypto/block_size.c
index c759ad8b95..021f3819be 100644
--- a/src/lib/crypto/block_size.c
+++ b/src/lib/crypto/block_size.c
@@ -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);
}
diff --git a/src/lib/crypto/checksum_length.c b/src/lib/crypto/checksum_length.c
index f3886f4a97..4a0294c5d5 100644
--- a/src/lib/crypto/checksum_length.c
+++ b/src/lib/crypto/checksum_length.c
@@ -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);
}
diff --git a/src/lib/crypto/combine_keys.c b/src/lib/crypto/combine_keys.c
index 9aad8f5432..3d97651640 100644
--- a/src/lib/crypto/combine_keys.c
+++ b/src/lib/crypto/combine_keys.c
@@ -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 */
diff --git a/src/lib/crypto/dk/ChangeLog b/src/lib/crypto/dk/ChangeLog
index 4633675eb3..30107a2180 100644
--- a/src/lib/crypto/dk/ChangeLog
+++ b/src/lib/crypto/dk/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/dk/checksum.c b/src/lib/crypto/dk/checksum.c
index 1769b5cce6..ffdb4e7cea 100644
--- a/src/lib/crypto/dk/checksum.c
+++ b/src/lib/crypto/dk/checksum.c
@@ -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 */
diff --git a/src/lib/crypto/dk/derive.c b/src/lib/crypto/dk/derive.c
index 0aabdc4ed4..6c8ff0bdc3 100644
--- a/src/lib/crypto/dk/derive.c
+++ b/src/lib/crypto/dk/derive.c
@@ -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))
diff --git a/src/lib/crypto/dk/dk_decrypt.c b/src/lib/crypto/dk/dk_decrypt.c
index 5f35fa6ace..0c95d40798 100644
--- a/src/lib/crypto/dk/dk_decrypt.c
+++ b/src/lib/crypto/dk/dk_decrypt.c
@@ -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;
diff --git a/src/lib/crypto/dk/dk_encrypt.c b/src/lib/crypto/dk/dk_encrypt.c
index 9de05fc02b..32cc509afc 100644
--- a/src/lib/crypto/dk/dk_encrypt.c
+++ b/src/lib/crypto/dk/dk_encrypt.c
@@ -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);
diff --git a/src/lib/crypto/dk/stringtokey.c b/src/lib/crypto/dk/stringtokey.c
index be13ca4a1e..0e54b849ff 100644
--- a/src/lib/crypto/dk/stringtokey.c
+++ b/src/lib/crypto/dk/stringtokey.c
@@ -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);
diff --git a/src/lib/crypto/enc_provider/ChangeLog b/src/lib/crypto/enc_provider/ChangeLog
index bd0a5febec..89bf6dec9b 100644
--- a/src/lib/crypto/enc_provider/ChangeLog
+++ b/src/lib/crypto/enc_provider/ChangeLog
@@ -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
diff --git a/src/lib/crypto/enc_provider/aes.c b/src/lib/crypto/enc_provider/aes.c
index 013a688eb1..c6b77f0ecf 100644
--- a/src/lib/crypto/enc_provider/aes.c
+++ b/src/lib/crypto/enc_provider/aes.c
@@ -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,
diff --git a/src/lib/crypto/enc_provider/arcfour.c b/src/lib/crypto/enc_provider/arcfour.c
index bfdc193724..d3a600b299 100644
--- a/src/lib/crypto/enc_provider/arcfour.c
+++ b/src/lib/crypto/enc_provider/arcfour.c
@@ -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,
diff --git a/src/lib/crypto/enc_provider/des.c b/src/lib/crypto/enc_provider/des.c
index e9ecb72e1e..70082bc245 100644
--- a/src/lib/crypto/enc_provider/des.c
+++ b/src/lib/crypto/enc_provider/des.c
@@ -30,19 +30,6 @@
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,
diff --git a/src/lib/crypto/enc_provider/des3.c b/src/lib/crypto/enc_provider/des3.c
index 54fbb69afc..048a220e60 100644
--- a/src/lib/crypto/enc_provider/des3.c
+++ b/src/lib/crypto/enc_provider/des3.c
@@ -29,19 +29,6 @@
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,
diff --git a/src/lib/crypto/hash_provider/ChangeLog b/src/lib/crypto/hash_provider/ChangeLog
index 974fa34037..d1fa657331 100644
--- a/src/lib/crypto/hash_provider/ChangeLog
+++ b/src/lib/crypto/hash_provider/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/hash_provider/hash_crc32.c b/src/lib/crypto/hash_provider/hash_crc32.c
index 7c06fa3a6b..b48b3b3634 100644
--- a/src/lib/crypto/hash_provider/hash_crc32.c
+++ b/src/lib/crypto/hash_provider/hash_crc32.c
@@ -28,18 +28,6 @@
#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
};
diff --git a/src/lib/crypto/hash_provider/hash_md4.c b/src/lib/crypto/hash_provider/hash_md4.c
index 5c9d6b1538..97487923b2 100644
--- a/src/lib/crypto/hash_provider/hash_md4.c
+++ b/src/lib/crypto/hash_provider/hash_md4.c
@@ -28,18 +28,6 @@
#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
};
diff --git a/src/lib/crypto/hash_provider/hash_md5.c b/src/lib/crypto/hash_provider/hash_md5.c
index c08755fb50..4087293376 100644
--- a/src/lib/crypto/hash_provider/hash_md5.c
+++ b/src/lib/crypto/hash_provider/hash_md5.c
@@ -28,18 +28,6 @@
#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
};
diff --git a/src/lib/crypto/hash_provider/hash_sha1.c b/src/lib/crypto/hash_provider/hash_sha1.c
index 8b7166c209..2ee56ad21c 100644
--- a/src/lib/crypto/hash_provider/hash_sha1.c
+++ b/src/lib/crypto/hash_provider/hash_sha1.c
@@ -28,18 +28,6 @@
#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
};
diff --git a/src/lib/crypto/hmac.c b/src/lib/crypto/hmac.c
index 763744c0f8..ec39520960 100644
--- a/src/lib/crypto/hmac.c
+++ b/src/lib/crypto/hmac.c
@@ -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);
diff --git a/src/lib/crypto/keyhash_provider/ChangeLog b/src/lib/crypto/keyhash_provider/ChangeLog
index 3667e0f05f..6f0931f1db 100644
--- a/src/lib/crypto/keyhash_provider/ChangeLog
+++ b/src/lib/crypto/keyhash_provider/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/keyhash_provider/descbc.c b/src/lib/crypto/keyhash_provider/descbc.c
index 9682fbb3b0..e13b39b853 100644
--- a/src/lib/crypto/keyhash_provider/descbc.c
+++ b/src/lib/crypto/keyhash_provider/descbc.c
@@ -30,12 +30,6 @@
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
};
diff --git a/src/lib/crypto/keyhash_provider/hmac_md5.c b/src/lib/crypto/keyhash_provider/hmac_md5.c
index 08808ff911..a2472a8329 100644
--- a/src/lib/crypto/keyhash_provider/hmac_md5.c
+++ b/src/lib/crypto/keyhash_provider/hmac_md5.c
@@ -36,12 +36,6 @@
#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*/
};
diff --git a/src/lib/crypto/keyhash_provider/k5_md4des.c b/src/lib/crypto/keyhash_provider/k5_md4des.c
index 5ff50bfdfa..d31eb54a85 100644
--- a/src/lib/crypto/keyhash_provider/k5_md4des.c
+++ b/src/lib/crypto/keyhash_provider/k5_md4des.c
@@ -36,12 +36,6 @@
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
};
diff --git a/src/lib/crypto/keyhash_provider/k5_md5des.c b/src/lib/crypto/keyhash_provider/k5_md5des.c
index 2a2bef38d4..1735310836 100644
--- a/src/lib/crypto/keyhash_provider/k5_md5des.c
+++ b/src/lib/crypto/keyhash_provider/k5_md5des.c
@@ -36,12 +36,6 @@
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
};
diff --git a/src/lib/crypto/keyhash_provider/t_cksum.c b/src/lib/crypto/keyhash_provider/t_cksum.c
index 80b820afe9..98187f7f16 100644
--- a/src/lib/crypto/keyhash_provider/t_cksum.c
+++ b/src/lib/crypto/keyhash_provider/t_cksum.c
@@ -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;
diff --git a/src/lib/crypto/make_checksum.c b/src/lib/crypto/make_checksum.c
index 8a384e710a..9d272eb796 100644
--- a/src/lib/crypto/make_checksum.c
+++ b/src/lib/crypto/make_checksum.c
@@ -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;
diff --git a/src/lib/crypto/make_random_key.c b/src/lib/crypto/make_random_key.c
index d5e4fcb7dc..c0c0debde4 100644
--- a/src/lib/crypto/make_random_key.c
+++ b/src/lib/crypto/make_random_key.c
@@ -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);
diff --git a/src/lib/crypto/old/ChangeLog b/src/lib/crypto/old/ChangeLog
index 1f58bf9837..126b2f1ad4 100644
--- a/src/lib/crypto/old/ChangeLog
+++ b/src/lib/crypto/old/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/old/old_decrypt.c b/src/lib/crypto/old/old_decrypt.c
index a43090c27d..cfbbd7272a 100644
--- a/src/lib/crypto/old/old_decrypt.c
+++ b/src/lib/crypto/old/old_decrypt.c
@@ -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;
diff --git a/src/lib/crypto/old/old_encrypt.c b/src/lib/crypto/old/old_encrypt.c
index 0f7ea8d0cd..98bd109e0e 100644
--- a/src/lib/crypto/old/old_encrypt.c
+++ b/src/lib/crypto/old/old_encrypt.c
@@ -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);
diff --git a/src/lib/crypto/pbkdf2.c b/src/lib/crypto/pbkdf2.c
index ce9f215fa6..d7aba026ea 100644
--- a/src/lib/crypto/pbkdf2.c
+++ b/src/lib/crypto/pbkdf2.c
@@ -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) {
diff --git a/src/lib/crypto/raw/ChangeLog b/src/lib/crypto/raw/ChangeLog
index 33e6afd8d0..1bd2a019ae 100644
--- a/src/lib/crypto/raw/ChangeLog
+++ b/src/lib/crypto/raw/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/raw/raw_encrypt.c b/src/lib/crypto/raw/raw_encrypt.c
index 8505534ec3..97e1bb5ee8 100644
--- a/src/lib/crypto/raw/raw_encrypt.c
+++ b/src/lib/crypto/raw/raw_encrypt.c
@@ -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);
}
diff --git a/src/lib/crypto/string_to_key.c b/src/lib/crypto/string_to_key.c
index 412583185b..27f49aabe7 100644
--- a/src/lib/crypto/string_to_key.c
+++ b/src/lib/crypto/string_to_key.c
@@ -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);
diff --git a/src/lib/crypto/t_hmac.c b/src/lib/crypto/t_hmac.c
index 96c2357a5b..8208eddede 100644
--- a/src/lib/crypto/t_hmac.c
+++ b/src/lib/crypto/t_hmac.c
@@ -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) {
diff --git a/src/lib/crypto/yarrow/ChangeLog b/src/lib/crypto/yarrow/ChangeLog
index da6fc5a15a..f64c1a2b5c 100644
--- a/src/lib/crypto/yarrow/ChangeLog
+++ b/src/lib/crypto/yarrow/ChangeLog
@@ -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.
diff --git a/src/lib/crypto/yarrow/ycipher.c b/src/lib/crypto/yarrow/ycipher.c
index 983f7a2a3a..b763815be9 100644
--- a/src/lib/crypto/yarrow/ycipher.c
+++ b/src/lib/crypto/yarrow/ycipher.c
@@ -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);