From 46408af6a4436e57747c89deb364415c51a5c5c5 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Sat, 5 Mar 2011 13:51:00 +0000 Subject: [PATCH] Remove the init_state and free_state enctype functions and go back to always delegating state to the enc provider. (We needed enctype- specific state initialization for CCM enctypes when we had them.) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24681 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/krb/crypto_int.h | 18 ------------------ src/lib/crypto/krb/etypes.c | 13 ------------- src/lib/crypto/krb/state.c | 20 ++------------------ 3 files changed, 2 insertions(+), 49 deletions(-) diff --git a/src/lib/crypto/krb/crypto_int.h b/src/lib/crypto/krb/crypto_int.h index 6d05095e2..9512e4013 100644 --- a/src/lib/crypto/krb/crypto_int.h +++ b/src/lib/crypto/krb/crypto_int.h @@ -95,14 +95,6 @@ typedef krb5_error_code (*prf_func)(const struct krb5_keytypes *ktp, krb5_key key, const krb5_data *in, krb5_data *out); -typedef krb5_error_code (*init_state_func)(const struct krb5_keytypes *ktp, - const krb5_keyblock *key, - krb5_keyusage keyusage, - krb5_data *out_state); - -typedef void (*free_state_func)(const struct krb5_keytypes *ktp, - krb5_data *state); - struct krb5_keytypes { krb5_enctype etype; char *name; @@ -117,8 +109,6 @@ struct krb5_keytypes { str2key_func str2key; rand2key_func rand2key; prf_func prf; - init_state_func init_state; - free_state_func free_state; krb5_cksumtype required_ctype; krb5_flags flags; }; @@ -291,14 +281,6 @@ krb5_error_code krb5int_dk_cmac_prf(const struct krb5_keytypes *ktp, krb5_key key, const krb5_data *in, krb5_data *out); -/* State initialization/cleanup handlers */ -krb5_error_code krb5int_init_state_enc(const struct krb5_keytypes *ktp, - const krb5_keyblock *key, - krb5_keyusage keyusage, - krb5_data *out_state); -void krb5int_free_state_enc(const struct krb5_keytypes *ktp, - krb5_data *state); - /*** Prototypes for cksumtype handler functions ***/ krb5_error_code krb5int_unkeyed_checksum(const struct krb5_cksumtypes *ctp, diff --git a/src/lib/crypto/krb/etypes.c b/src/lib/crypto/krb/etypes.c index f6da99cc5..a9b176dbd 100644 --- a/src/lib/crypto/krb/etypes.c +++ b/src/lib/crypto/krb/etypes.c @@ -41,7 +41,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_old_crypto_length, krb5int_old_encrypt, krb5int_old_decrypt, krb5int_des_string_to_key, k5_rand2key_des, krb5int_des_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_RSA_MD5_DES, ETYPE_WEAK }, { ENCTYPE_DES_CBC_MD4, @@ -51,7 +50,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_old_crypto_length, krb5int_old_encrypt, krb5int_old_decrypt, krb5int_des_string_to_key, k5_rand2key_des, krb5int_des_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_RSA_MD4_DES, ETYPE_WEAK }, { ENCTYPE_DES_CBC_MD5, @@ -61,7 +59,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_old_crypto_length, krb5int_old_encrypt, krb5int_old_decrypt, krb5int_des_string_to_key, k5_rand2key_des, krb5int_des_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_RSA_MD5_DES, ETYPE_WEAK }, { ENCTYPE_DES_CBC_RAW, @@ -71,7 +68,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_raw_crypto_length, krb5int_raw_encrypt, krb5int_raw_decrypt, krb5int_des_string_to_key, k5_rand2key_des, krb5int_des_prf, - krb5int_init_state_enc, krb5int_free_state_enc, 0, ETYPE_WEAK }, { ENCTYPE_DES3_CBC_RAW, @@ -81,7 +77,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_raw_crypto_length, krb5int_raw_encrypt, krb5int_raw_decrypt, krb5int_dk_string_to_key, k5_rand2key_des3, NULL, /*PRF*/ - krb5int_init_state_enc, krb5int_free_state_enc, 0, ETYPE_WEAK }, @@ -93,7 +88,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_dk_crypto_length, krb5int_dk_encrypt, krb5int_dk_decrypt, krb5int_dk_string_to_key, k5_rand2key_des3, krb5int_dk_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_HMAC_SHA1_DES3, 0 /*flags*/ }, @@ -104,7 +98,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_dk_crypto_length, krb5int_dk_encrypt, krb5int_dk_decrypt, krb5int_dk_string_to_key, k5_rand2key_des, NULL, /*PRF*/ - krb5int_init_state_enc, krb5int_free_state_enc, 0, ETYPE_WEAK }, { ENCTYPE_ARCFOUR_HMAC, @@ -116,7 +109,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_arcfour_crypto_length, krb5int_arcfour_encrypt, krb5int_arcfour_decrypt, krb5int_arcfour_string_to_key, k5_rand2key_direct, krb5int_arcfour_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_HMAC_MD5_ARCFOUR, 0 /*flags*/ }, { ENCTYPE_ARCFOUR_HMAC_EXP, @@ -128,7 +120,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_arcfour_crypto_length, krb5int_arcfour_encrypt, krb5int_arcfour_decrypt, krb5int_arcfour_string_to_key, k5_rand2key_direct, krb5int_arcfour_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_HMAC_MD5_ARCFOUR, ETYPE_WEAK }, @@ -141,7 +132,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_aes_crypto_length, krb5int_dk_encrypt, krb5int_dk_decrypt, krb5int_aes_string_to_key, k5_rand2key_direct, krb5int_dk_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_HMAC_SHA1_96_AES128, 0 /*flags*/ }, { ENCTYPE_AES256_CTS_HMAC_SHA1_96, @@ -152,7 +142,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_aes_crypto_length, krb5int_dk_encrypt, krb5int_dk_decrypt, krb5int_aes_string_to_key, k5_rand2key_direct, krb5int_dk_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_HMAC_SHA1_96_AES256, 0 /*flags*/ }, #ifdef CAMELLIA @@ -165,7 +154,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_dk_cmac_encrypt, krb5int_dk_cmac_decrypt, krb5int_camellia_string_to_key, k5_rand2key_direct, krb5int_dk_cmac_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_CMAC_CAMELLIA128, 0 /*flags*/ }, { ENCTYPE_CAMELLIA256_CTS_CMAC, @@ -177,7 +165,6 @@ const struct krb5_keytypes krb5int_enctypes_list[] = { krb5int_dk_cmac_encrypt, krb5int_dk_cmac_decrypt, krb5int_camellia_string_to_key, k5_rand2key_direct, krb5int_dk_cmac_prf, - krb5int_init_state_enc, krb5int_free_state_enc, CKSUMTYPE_CMAC_CAMELLIA256, 0 /*flags */ }, #endif /* CAMELLIA */ diff --git a/src/lib/crypto/krb/state.c b/src/lib/crypto/krb/state.c index 2c3371c3a..85327de03 100644 --- a/src/lib/crypto/krb/state.c +++ b/src/lib/crypto/krb/state.c @@ -35,22 +35,6 @@ */ #include "crypto_int.h" -/* Most enctypes delegate cipher state handling to the enc provider by using - * this function as their init_state methods. */ -krb5_error_code -krb5int_init_state_enc(const struct krb5_keytypes *ktp, - const krb5_keyblock *key, krb5_keyusage keyusage, - krb5_data *out_state) -{ - return ktp->enc->init_state(key, keyusage, out_state); -} - -void -krb5int_free_state_enc(const struct krb5_keytypes *ktp, krb5_data *state) -{ - (void)ktp->enc->free_state(state); -} - krb5_error_code KRB5_CALLCONV krb5_c_init_state (krb5_context context, const krb5_keyblock *key, krb5_keyusage keyusage, krb5_data *new_state) @@ -60,7 +44,7 @@ krb5_c_init_state (krb5_context context, const krb5_keyblock *key, ktp = find_enctype(key->enctype); if (ktp == NULL) return KRB5_BAD_ENCTYPE; - return ktp->init_state(ktp, key, keyusage, new_state); + return ktp->enc->init_state(key, keyusage, new_state); } krb5_error_code KRB5_CALLCONV @@ -72,6 +56,6 @@ krb5_c_free_state(krb5_context context, const krb5_keyblock *key, ktp = find_enctype(key->enctype); if (ktp == NULL) return KRB5_BAD_ENCTYPE; - ktp->free_state(ktp, state); + ktp->enc->free_state(state); return 0; } -- 2.26.2