sofia-sip/auth_plugin.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the Sofia-SIP package
00003  *
00004  * Copyright (C) 2005 Nokia Corporation.
00005  *
00006  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation; either version 2.1 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  *
00023  */
00024 
00025 #ifndef AUTH_PLUGIN_H
00026 
00027 #define AUTH_PLUGIN_H 
00028 
00037 #ifndef AUTH_MODULE_H
00038 #include "sofia-sip/auth_module.h"
00039 #endif
00040 
00041 #ifndef AUTH_DIGEST_H
00042 #include "sofia-sip/auth_digest.h"
00043 #endif
00044 
00045 #ifndef AUTH_COMMON_H
00046 #include "sofia-sip/auth_common.h"
00047 #endif
00048 
00049 #ifndef MSG_DATE_H
00050 #include <sofia-sip/msg_date.h>
00051 #endif
00052 
00053 #ifndef SU_MD5_H
00054 #include <sofia-sip/su_md5.h>
00055 #endif
00056 
00057 #include <sofia-sip/htable.h>
00058 
00059 SOFIA_BEGIN_DECLS
00060 
00061 /* ====================================================================== */
00062 /* Plugin interface for authentication */
00063 
00065 struct auth_scheme
00066 {
00068   char const *asch_method;
00069 
00071   usize_t asch_size;
00072 
00074   int (*asch_init)(auth_mod_t *am,
00075                    auth_scheme_t *base,
00076                    su_root_t *root,
00077                    tag_type_t tag, tag_value_t value, ...);
00078 
00080   void (*asch_check)(auth_mod_t *am, 
00081                      auth_status_t *as,
00082                      msg_auth_t *auth,
00083                      auth_challenger_t const *ch);
00084 
00086   void (*asch_challenge)(auth_mod_t *am, 
00087                          auth_status_t *as,
00088                          auth_challenger_t const *ch);
00089 
00093   void (*asch_cancel)(auth_mod_t *am, 
00094                       auth_status_t *as);
00095 
00100   void (*asch_destroy)(auth_mod_t *am);
00101 
00102 };
00103 
00105 typedef struct
00106 {
00107   unsigned        apw_index;    
00108   void const     *apw_type;     
00110   char const     *apw_user;     
00111   char const     *apw_realm;    
00112   char const     *apw_pass;     
00113   char const     *apw_hash;     
00114   char const     *apw_ident;    
00115   auth_uplugin_t *apw_extended; 
00116 } auth_passwd_t;
00117 
00118 
00119 HTABLE_DECLARE_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
00120 
00121 struct stat;
00122 
00124 struct auth_mod_t
00125 {
00126   su_home_t      am_home[1];
00127   unsigned       _am_refcount;  
00129   /* User database / cache */
00130   char const    *am_db;         
00131   struct stat   *am_stat;       
00132   auth_htable_t  am_users[1];   
00134   void          *am_buffer;     
00135   auth_passwd_t *am_locals;     
00136   size_t         am_local_count; 
00138   auth_passwd_t *am_anon_user;  
00140   /* Attributes */
00141   url_t         *am_remote;     
00142   char const    *am_realm;      
00143   char const    *am_opaque;     
00144   char const    *am_gssapi_data; 
00145   char const    *am_targetname; 
00146   auth_scheme_t *am_scheme;     
00147   char const   **am_allow;      
00148   msg_param_t    am_algorithm;  
00149   msg_param_t    am_qop;        
00150   unsigned       am_expires;    
00151   unsigned       am_next_exp;   
00152   unsigned       am_blacklist;  
00153   unsigned       am_forbidden:1;
00154   unsigned       am_anonymous:1;
00155   unsigned       am_challenge:1;
00156   unsigned       am_nextnonce:1;
00157   unsigned       am_mutual:1;   
00158   unsigned       am_fake:1;     
00160   unsigned :0;                  
00161   unsigned       am_count;      
00163   uint8_t        am_master_key[16]; 
00165   su_md5_t       am_hmac_ipad;  
00166   su_md5_t       am_hmac_opad;  
00168   unsigned       am_max_ncount:1; 
00169 };
00170 
00171 SOFIAPUBFUN
00172 auth_passwd_t *auth_mod_getpass(auth_mod_t *am,
00173                                 char const *user,
00174                                 char const *realm);
00175 
00176 SOFIAPUBFUN
00177 auth_passwd_t *auth_mod_addpass(auth_mod_t *am,
00178                                 char const *user,
00179                                 char const *realm);
00180 
00181 SOFIAPUBFUN int auth_readdb_if_needed(auth_mod_t *am);
00182 
00183 SOFIAPUBFUN int auth_readdb(auth_mod_t *am);
00184 
00185 SOFIAPUBFUN msg_auth_t *auth_mod_credentials(msg_auth_t *auth, 
00186                                              char const *scheme,
00187                                              char const *realm);
00188 
00189 SOFIAPUBFUN auth_mod_t *auth_mod_alloc(auth_scheme_t *scheme, 
00190                                        tag_type_t, tag_value_t, ...);
00191 
00192 #define AUTH_PLUGIN(am) (auth_plugin_t *)((am) + 1)
00193 
00194 SOFIAPUBFUN
00195 int auth_init_default(auth_mod_t *am,
00196                       auth_scheme_t *base,
00197                       su_root_t *root,
00198                       tag_type_t tag, tag_value_t value, ...);
00199 
00201 SOFIAPUBFUN void auth_cancel_default(auth_mod_t *am, auth_status_t *as);
00202 
00204 SOFIAPUBFUN void auth_destroy_default(auth_mod_t *am);
00205 
00207 SOFIAPUBFUN
00208 void auth_method_basic(auth_mod_t *am,
00209                        auth_status_t *as,
00210                        msg_auth_t *auth,
00211                        auth_challenger_t const *ach);
00212 
00213 SOFIAPUBFUN
00214 void auth_challenge_basic(auth_mod_t *am, 
00215                           auth_status_t *as,
00216                           auth_challenger_t const *ach);
00217 
00219 SOFIAPUBFUN
00220 msg_auth_t *auth_digest_credentials(msg_auth_t *auth, 
00221                                     char const *realm,
00222                                     char const *opaque);
00223 
00224 SOFIAPUBFUN
00225 void auth_method_digest(auth_mod_t *am,
00226                         auth_status_t *as,
00227                         msg_auth_t *au,
00228                         auth_challenger_t const *ach);
00229 
00230 SOFIAPUBFUN
00231 void auth_info_digest(auth_mod_t *am, 
00232                       auth_status_t *as,
00233                       auth_challenger_t const *ach);
00234 
00235 SOFIAPUBFUN
00236 void auth_check_digest(auth_mod_t *am,
00237                        auth_status_t *as,
00238                        auth_response_t *ar,
00239                        auth_challenger_t const *ach);
00240 
00241 SOFIAPUBFUN
00242 void auth_challenge_digest(auth_mod_t *am, 
00243                            auth_status_t *as,
00244                            auth_challenger_t const *ach);
00245 
00246 SOFIAPUBFUN
00247 isize_t auth_generate_digest_nonce(auth_mod_t *am, 
00248                                    char buffer[],
00249                                    size_t buffer_len,
00250                                    int nextnonce,
00251                                    msg_time_t now);
00252 
00253 SOFIAPUBFUN
00254 int auth_validate_digest_nonce(auth_mod_t *am, 
00255                                auth_status_t *as,
00256                                auth_response_t *ar,
00257                                msg_time_t now);
00258 
00259 SOFIAPUBFUN int auth_allow_check(auth_mod_t *am, auth_status_t *as);
00260 
00262 SOFIAPUBFUN void auth_md5_hmac_init(auth_mod_t *am, su_md5_t *md5);
00263 SOFIAPUBFUN void auth_md5_hmac_digest(auth_mod_t *am, su_md5_t *md5, 
00264                                       void *hmac, size_t size);
00265 
00266 SOFIA_END_DECLS
00267 
00268 #endif /* !defined AUTH_PLUGIN_H */

Sofia-SIP 1.12.8 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.