iptsec  1.12.11devel
auth_digest.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef AUTH_DIGEST_H
26 
27 #define AUTH_DIGEST_H
28 
46 #ifndef SU_ALLOC_H
47 #include <sofia-sip/su_alloc.h>
48 #endif
49 
50 SOFIA_BEGIN_DECLS
51 
75 typedef struct {
76  int ac_size;
77  char const *ac_realm;
78  char const *ac_domain;
79  char const *ac_nonce;
80  char const *ac_opaque;
81  char const *ac_algorithm;
82  char const *ac_qop;
83  unsigned ac_stale : 1;
84  unsigned ac_md5 : 1;
85  unsigned ac_md5sess : 1;
86  unsigned ac_sha1 : 1;
87  unsigned ac_auth : 1;
88  unsigned ac_auth_int : 1;
89  unsigned : 0;
91 
117 typedef struct {
118  int ar_size;
119  char const *ar_username;
120  char const *ar_realm;
121  char const *ar_nonce;
122  char const *ar_uri;
123  char const *ar_response;
124  char const *ar_algorithm;
125  char const *ar_cnonce;
126  char const *ar_opaque;
127  char const *ar_qop;
128  char const *ar_nc;
129  unsigned ar_md5 : 1;
130  unsigned ar_md5sess : 1;
131  unsigned ar_sha1 : 1;
132  unsigned ar_auth : 1;
133  unsigned ar_auth_int : 1;
134  unsigned : 0;
136 
137 typedef char auth_hexmd5_t[33];
138 
140  char const * const params[]);
142  auth_challenge_t *ac);
144  char const * const params[]);
145 
146 SOFIAPUBFUN int auth_digest_ha1(auth_hexmd5_t ha1,
147  char const *username,
148  char const *realm,
149  char const *secret);
150 
152  auth_hexmd5_t ha1,
153  char const *secret);
154 
155 SOFIAPUBFUN int auth_digest_a1sess(auth_response_t *ar,
156  auth_hexmd5_t ha1sess,
157  char const *ha1);
158 
159 SOFIAPUBFUN int auth_digest_sessionkey(auth_response_t *, auth_hexmd5_t ha1,
160  char const *secret);
161 
162 SOFIAPUBFUN int auth_digest_response(auth_response_t *, auth_hexmd5_t response,
163  auth_hexmd5_t const ha1,
164  char const *method_name,
165  void const *data, isize_t dlen);
166 
167 SOFIAPUBFUN int auth_struct_copy(void *dst, void const *src, isize_t s_size);
168 
169 SOFIAPUBFUN int auth_strcmp(char const *quoted, char const *unquoted);
170 
171 SOFIA_END_DECLS
172 
173 #endif
int auth_strcmp(char const *quoted, char const *unquoted)
Compare two strings, even if they are quoted.
Definition: auth_common.c:180
int auth_digest_sessionkey(auth_response_t *, auth_hexmd5_t ha1, char const *secret)
Generate MD5 session key for digest authentication.
Definition: auth_digest.c:263
SU_HOME_T su_home_t
char const * ac_algorithm
algorithm
Definition: auth_digest.h:81
int auth_digest_response(auth_response_t *, auth_hexmd5_t response, auth_hexmd5_t const ha1, char const *method_name, void const *data, isize_t dlen)
Generate response for digest authentication.
Definition: auth_digest.c:288
char const * ar_cnonce
cnonce
Definition: auth_digest.h:125
char const * ar_nonce
nonce
Definition: auth_digest.h:121
char const * ac_qop
qop
Definition: auth_digest.h:82
issize_t auth_digest_challenge_get(su_home_t *, auth_challenge_t *, char const *const params[])
Get digest-challenge parameters.
Definition: auth_digest.c:61
char const * ac_opaque
opaque
Definition: auth_digest.h:80
char const * ac_nonce
nonce
Definition: auth_digest.h:79
char const * ar_nc
nonce count
Definition: auth_digest.h:128
void auth_digest_challenge_free_params(su_home_t *home, auth_challenge_t *ac)
Free challenge parameters.
Definition: auth_digest.c:111
char const * ar_qop
qop
Definition: auth_digest.h:127
char const * ar_response
response
Definition: auth_digest.h:123
#define SOFIAPUBFUN
int auth_digest_a1(auth_response_t *ar, auth_hexmd5_t ha1, char const *secret)
Generate A1 hash for digest authentication.
Definition: auth_digest.c:233
int auth_digest_ha1(auth_hexmd5_t ha1, char const *username, char const *realm, char const *secret)
Generate the hex A1 hash for digest authentication.
Definition: auth_digest.c:208
char const * ar_algorithm
algorithm
Definition: auth_digest.h:124
char const * ac_domain
domain
Definition: auth_digest.h:78
issize_t auth_digest_response_get(su_home_t *, auth_response_t *, char const *const params[])
Get digest-response parameters.
Definition: auth_digest.c:138
char const * ac_realm
realm
Definition: auth_digest.h:77
Digest parameters for digest-response in Authorize.
Definition: auth_digest.h:117
char const * ar_realm
realm
Definition: auth_digest.h:120
char const * ar_opaque
opaque
Definition: auth_digest.h:126
char const * ar_uri
uri
Definition: auth_digest.h:122
Parameters for digest-challenge.
Definition: auth_digest.h:75

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