Ignore:
Timestamp:
Oct 10, 2007 11:37:56 AM (17 years ago)
Author:
bennylp
Message:

Ticket #396: initial implementation of digest AKA (akav1-md5) authentication for IMS/3GPP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_auth.h

    r1407 r1488  
    4747 
    4848 
    49 /** Type of data in the credential information. */ 
     49/** Type of data in the credential information in #pjsip_cred_info. */ 
    5050typedef enum pjsip_cred_data_type 
    5151{ 
    52     PJSIP_CRED_DATA_PLAIN_PASSWD,   /**< Plain text password.   */ 
    53     PJSIP_CRED_DATA_DIGEST          /**< Hashed digest.         */ 
     52    PJSIP_CRED_DATA_PLAIN_PASSWD=0, /**< Plain text password.           */ 
     53    PJSIP_CRED_DATA_DIGEST      =1, /**< Hashed digest.                 */ 
     54 
     55    PJSIP_CRED_DATA_EXT_AKA     =16 /**< Extended AKA info is available */ 
     56 
    5457} pjsip_cred_data_type; 
    5558 
     
    6467 
    6568 
     69/** 
     70 * Type of callback function to create authentication response. 
     71 * Application can specify this callback in \a cb field of the credential info 
     72 * (#pjsip_cred_info) and specifying PJSIP_CRED_DATA_DIGEST_CALLBACK as  
     73 * \a data_type. When this function is called, most of the fields in the  
     74 * \a auth authentication response will have been filled by the framework.  
     75 * Application normally should just need to calculate the response digest  
     76 * of the authentication response. 
     77 * 
     78 * @param pool      Pool to allocate memory from if application needs to. 
     79 * @param chal      The authentication challenge sent by server in 401 
     80 *                  or 401 response, in either Proxy-Authenticate or 
     81 *                  WWW-Authenticate header. 
     82 * @param cred      The credential that has been selected by the framework 
     83 *                  to authenticate against the challenge. 
     84 * @param auth      The authentication response which application needs to 
     85 *                  calculate the response digest. 
     86 * 
     87 * @return          Application may return non-PJ_SUCCESS to abort the 
     88 *                  authentication process. When this happens, the  
     89 *                  framework will return failure to the original function 
     90 *                  that requested authentication. 
     91 */ 
     92typedef pj_status_t (*pjsip_cred_cb)(pj_pool_t *pool, 
     93                                     const pjsip_digest_challenge *chal, 
     94                                     const pjsip_cred_info *cred, 
     95                                     const pj_str_t *method, 
     96                                     pjsip_digest_credential *auth); 
     97 
     98 
    6699/**  
    67100 * This structure describes credential information.  
     
    70103 * 
    71104 * Note that since PJSIP 0.7.0.1, it is possible to make a credential that is 
    72  * valid for any realms, by setting the realm to star/asterisk character, 
     105 * valid for any realms, by setting the realm to star/wildcard character, 
    73106 * i.e. realm = pj_str("*");. 
    74107 */ 
     
    83116    pj_str_t    data;           /**< The data, which can be a plaintext  
    84117                                     password or a hashed digest.           */ 
     118 
     119    /** Extended data */ 
     120    union { 
     121        /** Digest AKA credential information. Note that when AKA credential 
     122         *  is being used, the \a data field of this #pjsip_cred_info is 
     123         *  not used, but it still must be initialized to an empty string. 
     124         */ 
     125        struct { 
     126            pj_str_t      k;    /**< Permanent key.                     */ 
     127            pj_str_t      op;   /**< Operator variant key.              */ 
     128            pj_str_t      amf;  /**< Authentication Management Field    */ 
     129            pjsip_cred_cb cb;   /**< Callback to create AKA digest.     */ 
     130        } aka; 
     131 
     132    } ext; 
    85133}; 
    86134 
     
    151199 
    152200/** 
     201 * Duplicate a credential info. 
     202 * 
     203 * @param pool      The memory pool. 
     204 * @param dst       Destination credential. 
     205 * @param src       Source credential. 
     206 */ 
     207PJ_DECL(void) pjsip_cred_info_dup(pj_pool_t *pool, 
     208                                  pjsip_cred_info *dst, 
     209                                  const pjsip_cred_info *src); 
     210 
     211/** 
    153212 * Type of function to lookup credential for the specified name. 
    154213 * 
     
    350409                                               pjsip_tx_data *tdata); 
    351410 
     411/** 
     412 * Helper function to create MD5 digest out of the specified  
     413 * parameters. 
     414 * 
     415 * @param result        String to store the response digest. This string 
     416 *                      must have been preallocated by caller with the  
     417 *                      buffer at least PJSIP_MD5STRLEN (32 bytes) in size. 
     418 * @param nonce         Optional nonce. 
     419 * @param nc            Nonce count. 
     420 * @param cnonce        Optional cnonce. 
     421 * @param qop           Optional qop. 
     422 * @param uri           URI. 
     423 * @param realm         Realm. 
     424 * @param cred_info     Credential info. 
     425 * @param method        SIP method. 
     426 */ 
     427PJ_DECL(void) pjsip_auth_create_digest(pj_str_t *result, 
     428                                       const pj_str_t *nonce, 
     429                                       const pj_str_t *nc, 
     430                                       const pj_str_t *cnonce, 
     431                                       const pj_str_t *qop, 
     432                                       const pj_str_t *uri, 
     433                                       const pj_str_t *realm, 
     434                                       const pjsip_cred_info *cred_info, 
     435                                       const pj_str_t *method); 
    352436 
    353437/** 
     
    355439 */ 
    356440 
    357 /* Internal function defined in sip_auth_client.c */ 
    358 void pjsip_auth_create_digest( pj_str_t *result, 
    359                                const pj_str_t *nonce, 
    360                                const pj_str_t *nc, 
    361                                const pj_str_t *cnonce, 
    362                                const pj_str_t *qop, 
    363                                const pj_str_t *uri, 
    364                                const pj_str_t *realm, 
    365                                const pjsip_cred_info *cred_info, 
    366                                const pj_str_t *method); 
    367  
    368441 
    369442 
Note: See TracChangeset for help on using the changeset viewer.