[Madwifi-cvs] madwifi/net80211 ieee80211_radius.c,1.1.2.5,1.1.2.6
Status: Beta
Brought to you by:
otaku
From: <sam...@us...> - 2004-03-04 22:42:39
|
Update of /cvsroot/madwifi/madwifi/net80211 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30939 Modified Files: Tag: WPA ieee80211_radius.c Log Message: add 2.4 support/glue (untested except for compilation and loading): o no kernel crypto support; so fall back to a private md5 implementation and reorg code to match o juggle include files o work around various incompatiblities in the kernel APIs also: o remove __init/__exit usage until module split is done Index: ieee80211_radius.c =================================================================== RCS file: /cvsroot/madwifi/madwifi/net80211/Attic/ieee80211_radius.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** ieee80211_radius.c 29 Feb 2004 23:08:17 -0000 1.1.2.5 --- ieee80211_radius.c 4 Mar 2004 22:21:08 -0000 1.1.2.6 *************** *** 61,67 **** --- 61,76 ---- #include <linux/sysctl.h> #include <linux/in.h> + #include <linux/utsname.h> + #include <linux/smp_lock.h> /* for lock_kernel */ + + #include <asm/uaccess.h> /* for KERNEL_DS, et al */ + #ifdef CONFIG_CRYPTO #include <linux/crypto.h> #include <asm/scatterlist.h> + #else + #include "md5.h" + #define crypto_tfm MD5Context + #endif #include <linux/random.h> *************** *** 184,189 **** --- 193,205 ---- int len; + lock_kernel(); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) daemonize("kradiusd"); allow_signal(SIGKILL); + #else + daemonize(); + sprintf(current->comm, "kradiusd"); + /* XXX equivalent for allow_signal */ + #endif for (;;) { *************** *** 423,429 **** --- 439,450 ---- */ radius_cleanup(rc); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) module_put_and_exit(0); + #else + return 0; + #endif } + #ifdef CONFIG_CRYPTO /* * Write-around for bogus crypto API; requiring the address *************** *** 441,444 **** --- 462,499 ---- } + static void + radius_hmac(struct radiuscom *rc, void *data, u_int len, + void *key, u_int keylen, u_int8_t hash[16]) + { + struct scatterlist sg; + + sg.page = virt_to_page(data); + sg.offset = offset_in_page(data); + sg.length = len; + + crypto_hmac(rc->rc_md5, key, &keylen, &sg, 1, hash); + } + #else /* !CONFIG_CRYPTO */ + /* + * Backwards compatibility shims to Jouni's md5 code + * for systems that lack the kernel crypto support. + */ + #define crypto_digest_init(x) MD5Init(x) + #define crypto_digest_final(x,h) MD5Final(h,x) + + static __inline void + digest_update(struct radiuscom *rc, void *data, u_int len) + { + MD5Update(rc->rc_md5, data, len); + } + + static void + radius_hmac(struct radiuscom *rc, void *data, u_int len, + void *key, u_int keylen, u_int8_t hash[16]) + { + hmac_md5(key, keylen, data, len, hash); + } + #endif + /* * Verify the authenticator hash in each reply using *************** *** 467,483 **** } - static void - radius_hmac(struct radiuscom *rc, void *data, u_int len, - void *key, u_int keylen, u_int8_t hash[16]) - { - struct scatterlist sg; - - sg.page = virt_to_page(data); - sg.offset = offset_in_page(data); - sg.length = len; - - crypto_hmac(rc->rc_md5, key, &keylen, &sg, 1, hash); - } - /* * Validate the Message-Authenticator hash. --- 522,525 ---- *************** *** 1462,1468 **** rc->rc_secretlen = radius_secretlen; rc->rc_md5 = crypto_alloc_tfm("md5", 0); if (rc->rc_md5 == NULL) { - /* XXX fallback on internal implementation? */ printf("%s: unable to allocate md5 crypto state\n", __func__); eapolstats.rs_nocrypto++; --- 1504,1514 ---- rc->rc_secretlen = radius_secretlen; + #ifdef CONFIG_CRYPTO rc->rc_md5 = crypto_alloc_tfm("md5", 0); + #else + MALLOC(rc->rc_md5, struct crypto_tfm *, sizeof(struct crypto_tfm), + M_DEVBUF, M_NOWAIT | M_ZERO); + #endif if (rc->rc_md5 == NULL) { printf("%s: unable to allocate md5 crypto state\n", __func__); eapolstats.rs_nocrypto++; *************** *** 1532,1536 **** --- 1578,1586 ---- sock_release(rc->rc_sock); if (rc->rc_md5 != NULL) + #ifdef CONFIG_CRYPTO crypto_free_tfm(rc->rc_md5); + #else + FREE(rc->rc_md5, M_DEVBUF); + #endif if (rc->rc_secret != NULL) FREE(rc->rc_secret, M_DEVBUF); *************** *** 1708,1712 **** * Called once on startup. */ ! int __init init_ieee80211_radius(void) { --- 1758,1762 ---- * Called once on startup. */ ! int init_ieee80211_radius(void) { *************** *** 1728,1732 **** * Called once at shutdown/unload. */ ! void __exit exit_ieee80211_radius(void) { --- 1778,1782 ---- * Called once at shutdown/unload. */ ! void exit_ieee80211_radius(void) { |