Ignore:
Timestamp:
Mar 19, 2008 11:00:30 PM (16 years ago)
Author:
bennylp
Message:

Related to ticket #485: huge changeset to update STUN relating to managing authentication. See the ticket for the details

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/include/pjnath/stun_auth.h

    r1869 r1877  
    4040 
    4141/** 
     42 * Type of authentication. 
     43 */ 
     44typedef enum pj_stun_auth_type 
     45{  
     46    /** 
     47     * No authentication. 
     48     */ 
     49    PJ_STUN_AUTH_NONE = 0, 
     50 
     51    /** 
     52     * Authentication using short term credential. 
     53     */ 
     54    PJ_STUN_AUTH_SHORT_TERM = 1, 
     55 
     56    /** 
     57     * Authentication using long term credential. 
     58     */ 
     59    PJ_STUN_AUTH_LONG_TERM = 2 
     60 
     61} pj_stun_auth_type; 
     62 
     63 
     64/** 
    4265 * Type of authentication data in the credential. 
    4366 */ 
     
    6083 
    6184} pj_stun_auth_cred_type; 
     85 
     86 
     87/** 
     88 * Type of encoding applied to the password stored in the credential. 
     89 */ 
     90typedef enum pj_stun_passwd_type 
     91{ 
     92    /** 
     93     * Plain text password. 
     94     */ 
     95    PJ_STUN_PASSWD_PLAIN    = 0, 
     96 
     97    /** 
     98     * Hashed password, valid for long term credential only. The hash value 
     99     * of the password is calculated as MD5(USERNAME ":" REALM ":" PASSWD) 
     100     * with all quotes removed from the username and realm values. 
     101     */ 
     102    PJ_STUN_PASSWD_HASHED = 1 
     103 
     104} pj_stun_passwd_type; 
    62105 
    63106 
     
    90133             * If not-empty, it indicates that this is a long term credential. 
    91134             */ 
    92             pj_str_t      realm; 
     135            pj_str_t            realm; 
    93136 
    94137            /**  
    95138             * The username of the credential. 
    96139             */ 
    97             pj_str_t      username; 
     140            pj_str_t            username; 
    98141 
    99142            /** 
    100143             * Data type to indicate the type of password in the \a data field. 
    101              * Value zero indicates that the data contains a plaintext 
    102              * password. 
    103              */ 
    104             int           data_type; 
     144             */ 
     145            pj_stun_passwd_type data_type; 
    105146 
    106147            /**  
     
    109150             * plaintext password. 
    110151             */ 
    111             pj_str_t      data; 
     152            pj_str_t            data; 
    112153 
    113154            /**  
    114155             * Optional NONCE. 
    115156             */ 
    116             pj_str_t      nonce; 
     157            pj_str_t            nonce; 
    117158 
    118159        } static_cred; 
     
    157198 
    158199            /** 
    159              * Get the credential to be put in outgoing message. 
     200             * Get the credential to be put in outgoing request. 
    160201             * 
    161202             * @param msg       The outgoing message where the credential is 
     
    187228                                    pj_str_t *username, 
    188229                                    pj_str_t *nonce, 
    189                                     int *data_type, 
     230                                    pj_stun_passwd_type *data_type, 
    190231                                    pj_str_t *data); 
    191232 
     
    218259                                        const pj_str_t *username, 
    219260                                        pj_pool_t *pool, 
    220                                         int *data_type, 
     261                                        pj_stun_passwd_type *data_type, 
    221262                                        pj_str_t *data); 
    222263 
     
    251292 
    252293/** 
     294 * This structure contains the credential information that is found and 
     295 * used to authenticate incoming requests. Application may use this 
     296 * information when generating authentication for the outgoing response. 
     297 */ 
     298typedef struct pj_stun_req_cred_info 
     299{ 
     300    /** 
     301     * The REALM value found in the incoming request. If short term  
     302     * credential is used, the value will be empty. 
     303     */ 
     304    pj_str_t    realm; 
     305 
     306    /** 
     307     * The USERNAME value found in the incoming request. 
     308     */ 
     309    pj_str_t    username; 
     310 
     311    /** 
     312     * Optional NONCE. 
     313     */ 
     314    pj_str_t    nonce; 
     315 
     316    /** 
     317     * Authentication key that was used to authenticate the incoming  
     318     * request. This key is created with #pj_stun_create_key(), and 
     319     * it can be used to encode the credential of the outgoing 
     320     * response. 
     321     */ 
     322    pj_str_t    auth_key; 
     323 
     324} pj_stun_req_cred_info; 
     325 
     326 
     327/** 
    253328 * Duplicate authentication credential. 
    254329 * 
     
    261336                                      const pj_stun_auth_cred *src); 
    262337 
     338/** 
     339 * Duplicate request credential. 
     340 * 
     341 * @param pool          Pool to be used to allocate memory. 
     342 * @param dst           Destination credential. 
     343 * @param src           Source credential. 
     344 */ 
     345PJ_DECL(void) pj_stun_req_cred_info_dup(pj_pool_t *pool, 
     346                                        pj_stun_req_cred_info *dst, 
     347                                        const pj_stun_req_cred_info *src); 
     348 
     349 
     350/** 
     351 * Create authentication key to be used for encoding the message with 
     352 * MESSAGE-INTEGRITY. If short term credential is used (i.e. the realm 
     353 * argument is NULL or empty), the key will be copied from the password. 
     354 * If long term credential is used, the key will be calculated from the 
     355 * MD5 hash of the realm, username, and password. 
     356 * 
     357 * @param pool          Pool to allocate memory for the key. 
     358 * @param key           String to receive the key. 
     359 * @param realm         The realm of the credential, if long term credential 
     360 *                      is to be used. If short term credential is wanted, 
     361 *                      application can put NULL or empty string here. 
     362 * @param username      The username. 
     363 * @param data_type     Password encoding. 
     364 * @param data          The password. 
     365 */ 
     366PJ_DECL(void) pj_stun_create_key(pj_pool_t *pool, 
     367                                 pj_str_t *key, 
     368                                 const pj_str_t *realm, 
     369                                 const pj_str_t *username, 
     370                                 pj_stun_passwd_type data_type, 
     371                                 const pj_str_t *data); 
    263372 
    264373/** 
     
    278387 * @param pool          If response is to be created, then memory will 
    279388 *                      be allocated from this pool. 
    280  * @param auth_key      Optional pointer to receive authentication key to 
    281  *                      calculate MESSAGE-INTEGRITY of the response, if 
    282  *                      the response needs to be authenticated. 
     389 * @param info          Optional pointer to receive authentication information 
     390 *                      found in the request and the credential that is used 
     391 *                      to authenticate the request. 
    283392 * @param p_response    Optional pointer to receive the response message 
    284393 *                      then the credential in the request fails to 
     
    295404                                                  pj_stun_auth_cred *cred, 
    296405                                                  pj_pool_t *pool, 
    297                                                   pj_str_t *auth_key, 
     406                                                  pj_stun_req_cred_info *info, 
    298407                                                  pj_stun_msg **p_response); 
    299408 
Note: See TracChangeset for help on using the changeset viewer.