Browse code

auth(k): module removed

- use modules/auth insted of this one

Daniel-Constantin Mierla authored on 25/07/2010 20:14:12
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,168 +0,0 @@
1
-/*
2
- * $Id: rfc2617.c 2 2005-06-13 16:47:24Z bogdan_iancu $
3
- *
4
- * Copyright (C) 2001-2003 FhG Fokus
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
- */
22
-
23
-/*!
24
- * \file
25
- * \brief Digest response calculation as per RFC2617
26
- * \ingroup auth
27
- * - Module: \ref auth
28
- */
29
-
30
-#include <sys/types.h>
31
-#include <stdlib.h>
32
-#include <string.h>
33
-
34
-#include "rfc2617.h"
35
-#include "../../md5.h"
36
-
37
-
38
-/*!
39
- * \brief Convert to hex form
40
- * \param _b hash value
41
- * \param _h hex value
42
- */
43
-inline void cvt_hex(HASH _b, HASHHEX _h)
44
-{
45
-	unsigned short i;
46
-	unsigned char j;
47
-	
48
-	for (i = 0; i < HASHLEN; i++) {
49
-		j = (_b[i] >> 4) & 0xf;
50
-		if (j <= 9) {
51
-			_h[i * 2] = (j + '0');
52
-		} else {
53
-			_h[i * 2] = (j + 'a' - 10);
54
-		}
55
-
56
-		j = _b[i] & 0xf;
57
-
58
-		if (j <= 9) {
59
-			_h[i * 2 + 1] = (j + '0');
60
-		} else {
61
-			_h[i * 2 + 1] = (j + 'a' - 10);
62
-		}
63
-	};
64
-
65
-	_h[HASHHEXLEN] = '\0';
66
-}
67
-
68
-
69
-/*!
70
- * \brief Calculate H(A1) as per HTTP Digest spec
71
- * \param _alg type of hash algorithm
72
- * \param _username username
73
- * \param _realm authentification realm
74
- * \param _password password
75
- * \param _nonce nonce value
76
- * \param _cnonce cnonce value
77
- * \param _sess_key session key, result will be stored there
78
- */
79
-void calc_HA1(ha_alg_t _alg, str* _username, str* _realm, str* _password,
80
-	      str* _nonce, str* _cnonce, HASHHEX _sess_key)
81
-{
82
-	MD5_CTX Md5Ctx;
83
-	HASH HA1;
84
-	
85
-	MD5Init(&Md5Ctx);
86
-	MD5Update(&Md5Ctx, _username->s, _username->len);
87
-	MD5Update(&Md5Ctx, ":", 1);
88
-	MD5Update(&Md5Ctx, _realm->s, _realm->len);
89
-	MD5Update(&Md5Ctx, ":", 1);
90
-	MD5Update(&Md5Ctx, _password->s, _password->len);
91
-	MD5Final(HA1, &Md5Ctx);
92
-
93
-	if (_alg == HA_MD5_SESS) {
94
-		MD5Init(&Md5Ctx);
95
-		MD5Update(&Md5Ctx, HA1, HASHLEN);
96
-		MD5Update(&Md5Ctx, ":", 1);
97
-		MD5Update(&Md5Ctx, _nonce->s, _nonce->len);
98
-		MD5Update(&Md5Ctx, ":", 1);
99
-		MD5Update(&Md5Ctx, _cnonce->s, _cnonce->len);
100
-		MD5Final(HA1, &Md5Ctx);
101
-	};
102
-
103
-	cvt_hex(HA1, _sess_key);
104
-}
105
-
106
-
107
-/*!
108
- * \brief Calculate request-digest/response-digest as per HTTP Digest spec
109
- * \param _ha1 H(A1)
110
- * \param _nonce nonce from server
111
- * \param _nc 8 hex digits
112
- * \param _cnonce cnonce value
113
- * \param _qop qop-value: "", "auth", "auth-int
114
- * \param _auth_int  1 if auth-int is used
115
- * \param _method method from the request
116
- * \param _uri requested URL/ URI
117
- * \param _hentity  H(entity body) if qop="auth-int"
118
- * \param _response request-digest or response-digest
119
- */
120
-void calc_response(HASHHEX _ha1,      /* H(A1) */
121
-		   str* _nonce,       /* nonce from server */
122
-		   str* _nc,          /* 8 hex digits */
123
-		   str* _cnonce,      /* client nonce */
124
-		   str* _qop,         /* qop-value: "", "auth", "auth-int" */
125
-		   int _auth_int,     /* 1 if auth-int is used */
126
-		   str* _method,      /* method from the request */
127
-		   str* _uri,         /* requested URL */
128
-		   HASHHEX _hentity,  /* H(entity body) if qop="auth-int" */
129
-		   HASHHEX _response) /* request-digest or response-digest */
130
-{
131
-	MD5_CTX Md5Ctx;
132
-	HASH HA2;
133
-	HASH RespHash;
134
-	HASHHEX HA2Hex;
135
-	
136
-	/* calculate H(A2) */
137
-	MD5Init(&Md5Ctx);
138
-	MD5Update(&Md5Ctx, _method->s, _method->len);
139
-	MD5Update(&Md5Ctx, ":", 1);
140
-	MD5Update(&Md5Ctx, _uri->s, _uri->len);
141
-
142
-	if (_auth_int) {
143
-		MD5Update(&Md5Ctx, ":", 1);
144
-		MD5Update(&Md5Ctx, _hentity, HASHHEXLEN);
145
-	};
146
-
147
-	MD5Final(HA2, &Md5Ctx);
148
-	cvt_hex(HA2, HA2Hex);
149
-	
150
-	/* calculate response */
151
-	MD5Init(&Md5Ctx);
152
-	MD5Update(&Md5Ctx, _ha1, HASHHEXLEN);
153
-	MD5Update(&Md5Ctx, ":", 1);
154
-	MD5Update(&Md5Ctx, _nonce->s, _nonce->len);
155
-	MD5Update(&Md5Ctx, ":", 1);
156
-
157
-	if (_qop->len) {
158
-		MD5Update(&Md5Ctx, _nc->s, _nc->len);
159
-		MD5Update(&Md5Ctx, ":", 1);
160
-		MD5Update(&Md5Ctx, _cnonce->s, _cnonce->len);
161
-		MD5Update(&Md5Ctx, ":", 1);
162
-		MD5Update(&Md5Ctx, _qop->s, _qop->len);
163
-		MD5Update(&Md5Ctx, ":", 1);
164
-	};
165
-	MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
166
-	MD5Final(RespHash, &Md5Ctx);
167
-	cvt_hex(RespHash, _response);
168
-}
Browse code

- fix a bunch of doxygen errors (mostly in modules, some in the core) - credits belongs to Frederick Bullik, frederick dot bullik at 1und1 dot de

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5299 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 04/12/2008 18:12:33
Showing 1 changed files
... ...
@@ -109,6 +109,7 @@ void calc_HA1(ha_alg_t _alg, str* _username, str* _realm, str* _password,
109 109
  * \param _ha1 H(A1)
110 110
  * \param _nonce nonce from server
111 111
  * \param _nc 8 hex digits
112
+ * \param _cnonce cnonce value
112 113
  * \param _qop qop-value: "", "auth", "auth-int
113 114
  * \param _auth_int  1 if auth-int is used
114 115
  * \param _method method from the request
Browse code

- fix a bunch of errors in doxygen

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5272 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 27/11/2008 12:32:26
Showing 1 changed files
... ...
@@ -70,7 +70,7 @@ inline void cvt_hex(HASH _b, HASHHEX _h)
70 70
  * \brief Calculate H(A1) as per HTTP Digest spec
71 71
  * \param _alg type of hash algorithm
72 72
  * \param _username username
73
- * \param _real authentification realm
73
+ * \param _realm authentification realm
74 74
  * \param _password password
75 75
  * \param _nonce nonce value
76 76
  * \param _cnonce cnonce value
Browse code

- fix a few errors in doxygen documentation - sync one function definitions variables with declaration

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5254 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 25/11/2008 09:34:15
Showing 1 changed files
... ...
@@ -37,8 +37,8 @@
37 37
 
38 38
 /*!
39 39
  * \brief Convert to hex form
40
- * \param Bin hash value
41
- * \param Hex hex value
40
+ * \param _b hash value
41
+ * \param _h hex value
42 42
  */
43 43
 inline void cvt_hex(HASH _b, HASHHEX _h)
44 44
 {
Browse code

- add doxygen documentation

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5211 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 17/11/2008 20:05:27
Showing 1 changed files
... ...
@@ -1,8 +1,6 @@
1 1
 /*
2 2
  * $Id: rfc2617.c 2 2005-06-13 16:47:24Z bogdan_iancu $
3 3
  *
4
- * Digest response calculation as per RFC2617
5
- *
6 4
  * Copyright (C) 2001-2003 FhG Fokus
7 5
  *
8 6
  * This file is part of Kamailio, a free SIP server.
... ...
@@ -22,6 +20,12 @@
22 20
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 21
  */
24 22
 
23
+/*!
24
+ * \file
25
+ * \brief Digest response calculation as per RFC2617
26
+ * \ingroup auth
27
+ * - Module: \ref auth
28
+ */
25 29
 
26 30
 #include <sys/types.h>
27 31
 #include <stdlib.h>
... ...
@@ -31,6 +35,11 @@
31 35
 #include "../../md5.h"
32 36
 
33 37
 
38
+/*!
39
+ * \brief Convert to hex form
40
+ * \param Bin hash value
41
+ * \param Hex hex value
42
+ */
34 43
 inline void cvt_hex(HASH _b, HASHHEX _h)
35 44
 {
36 45
 	unsigned short i;
... ...
@@ -57,8 +66,15 @@ inline void cvt_hex(HASH _b, HASHHEX _h)
57 66
 }
58 67
 
59 68
 
60
-/* 
61
- * calculate H(A1) as per spec 
69
+/*!
70
+ * \brief Calculate H(A1) as per HTTP Digest spec
71
+ * \param _alg type of hash algorithm
72
+ * \param _username username
73
+ * \param _real authentification realm
74
+ * \param _password password
75
+ * \param _nonce nonce value
76
+ * \param _cnonce cnonce value
77
+ * \param _sess_key session key, result will be stored there
62 78
  */
63 79
 void calc_HA1(ha_alg_t _alg, str* _username, str* _realm, str* _password,
64 80
 	      str* _nonce, str* _cnonce, HASHHEX _sess_key)
... ...
@@ -88,8 +104,17 @@ void calc_HA1(ha_alg_t _alg, str* _username, str* _realm, str* _password,
88 104
 }
89 105
 
90 106
 
91
-/* 
92
- * calculate request-digest/response-digest as per HTTP Digest spec 
107
+/*!
108
+ * \brief Calculate request-digest/response-digest as per HTTP Digest spec
109
+ * \param _ha1 H(A1)
110
+ * \param _nonce nonce from server
111
+ * \param _nc 8 hex digits
112
+ * \param _qop qop-value: "", "auth", "auth-int
113
+ * \param _auth_int  1 if auth-int is used
114
+ * \param _method method from the request
115
+ * \param _uri requested URL/ URI
116
+ * \param _hentity  H(entity body) if qop="auth-int"
117
+ * \param _response request-digest or response-digest
93 118
  */
94 119
 void calc_response(HASHHEX _ha1,      /* H(A1) */
95 120
 		   str* _nonce,       /* nonce from server */
... ...
@@ -107,7 +132,7 @@ void calc_response(HASHHEX _ha1,      /* H(A1) */
107 132
 	HASH RespHash;
108 133
 	HASHHEX HA2Hex;
109 134
 	
110
-	     /* calculate H(A2) */
135
+	/* calculate H(A2) */
111 136
 	MD5Init(&Md5Ctx);
112 137
 	MD5Update(&Md5Ctx, _method->s, _method->len);
113 138
 	MD5Update(&Md5Ctx, ":", 1);
... ...
@@ -121,7 +146,7 @@ void calc_response(HASHHEX _ha1,      /* H(A1) */
121 146
 	MD5Final(HA2, &Md5Ctx);
122 147
 	cvt_hex(HA2, HA2Hex);
123 148
 	
124
-	     /* calculate response */
149
+	/* calculate response */
125 150
 	MD5Init(&Md5Ctx);
126 151
 	MD5Update(&Md5Ctx, _ha1, HASHHEXLEN);
127 152
 	MD5Update(&Md5Ctx, ":", 1);
Browse code

- integrate definitions from md5global.h into md5.h/ md5.c after cleanups - remove inclusion of this file from uac and auth module - extend test 12 with variable assignment and md5/ string transformations - small formatting fix for the copyright headers - todo: remove this PROTO_LIST stuff, this mask some warnings, remove this custom mem routines that are not used because of USE_MEM define in md5.c

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4897 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 12/09/2008 16:24:48
Showing 1 changed files
... ...
@@ -28,7 +28,6 @@
28 28
 #include <string.h>
29 29
 
30 30
 #include "rfc2617.h"
31
-#include "../../md5global.h"
32 31
 #include "../../md5.h"
33 32
 
34 33
 
Browse code

- change name in copyright headers

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4518 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/07/2008 15:39:28
Showing 1 changed files
... ...
@@ -5,14 +5,14 @@
5 5
  *
6 6
  * Copyright (C) 2001-2003 FhG Fokus
7 7
  *
8
- * This file is part of openser, a free SIP server.
8
+ * This file is part of Kamailio, a free SIP server.
9 9
  *
10
- * openser is free software; you can redistribute it and/or modify
10
+ * Kamailio is free software; you can redistribute it and/or modify
11 11
  * it under the terms of the GNU General Public License as published by
12 12
  * the Free Software Foundation; either version 2 of the License, or
13 13
  * (at your option) any later version
14 14
  *
15
- * openser is distributed in the hope that it will be useful,
15
+ * Kamailio is distributed in the hope that it will be useful,
16 16
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 17
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 18
  * GNU General Public License for more details.
Browse code

- API extended with MD5 functions to avoid duplicate of rfc2617.{c,h} in many auth modules - rfc2617.{c,h} moved from auth_db here - support to do authentication using username and password from any kind of pseudo-variable (obsoletes the auth_avp module submitted by Carsten Bock, #1689057) - doc updated - devel version increased

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2446 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 13/07/2007 09:46:49
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,143 @@
1
+/*
2
+ * $Id: rfc2617.c 2 2005-06-13 16:47:24Z bogdan_iancu $
3
+ *
4
+ * Digest response calculation as per RFC2617
5
+ *
6
+ * Copyright (C) 2001-2003 FhG Fokus
7
+ *
8
+ * This file is part of openser, a free SIP server.
9
+ *
10
+ * openser is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version
14
+ *
15
+ * openser is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License 
21
+ * along with this program; if not, write to the Free Software 
22
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
+ */
24
+
25
+
26
+#include <sys/types.h>
27
+#include <stdlib.h>
28
+#include <string.h>
29
+
30
+#include "rfc2617.h"
31
+#include "../../md5global.h"
32
+#include "../../md5.h"
33
+
34
+
35
+inline void cvt_hex(HASH _b, HASHHEX _h)
36
+{
37
+	unsigned short i;
38
+	unsigned char j;
39
+	
40
+	for (i = 0; i < HASHLEN; i++) {
41
+		j = (_b[i] >> 4) & 0xf;
42
+		if (j <= 9) {
43
+			_h[i * 2] = (j + '0');
44
+		} else {
45
+			_h[i * 2] = (j + 'a' - 10);
46
+		}
47
+
48
+		j = _b[i] & 0xf;
49
+
50
+		if (j <= 9) {
51
+			_h[i * 2 + 1] = (j + '0');
52
+		} else {
53
+			_h[i * 2 + 1] = (j + 'a' - 10);
54
+		}
55
+	};
56
+
57
+	_h[HASHHEXLEN] = '\0';
58
+}
59
+
60
+
61
+/* 
62
+ * calculate H(A1) as per spec 
63
+ */
64
+void calc_HA1(ha_alg_t _alg, str* _username, str* _realm, str* _password,
65
+	      str* _nonce, str* _cnonce, HASHHEX _sess_key)
66
+{
67
+	MD5_CTX Md5Ctx;
68
+	HASH HA1;
69
+	
70
+	MD5Init(&Md5Ctx);
71
+	MD5Update(&Md5Ctx, _username->s, _username->len);
72
+	MD5Update(&Md5Ctx, ":", 1);
73
+	MD5Update(&Md5Ctx, _realm->s, _realm->len);
74
+	MD5Update(&Md5Ctx, ":", 1);
75
+	MD5Update(&Md5Ctx, _password->s, _password->len);
76
+	MD5Final(HA1, &Md5Ctx);
77
+
78
+	if (_alg == HA_MD5_SESS) {
79
+		MD5Init(&Md5Ctx);
80
+		MD5Update(&Md5Ctx, HA1, HASHLEN);
81
+		MD5Update(&Md5Ctx, ":", 1);
82
+		MD5Update(&Md5Ctx, _nonce->s, _nonce->len);
83
+		MD5Update(&Md5Ctx, ":", 1);
84
+		MD5Update(&Md5Ctx, _cnonce->s, _cnonce->len);
85
+		MD5Final(HA1, &Md5Ctx);
86
+	};
87
+
88
+	cvt_hex(HA1, _sess_key);
89
+}
90
+
91
+
92
+/* 
93
+ * calculate request-digest/response-digest as per HTTP Digest spec 
94
+ */
95
+void calc_response(HASHHEX _ha1,      /* H(A1) */
96
+		   str* _nonce,       /* nonce from server */
97
+		   str* _nc,          /* 8 hex digits */
98
+		   str* _cnonce,      /* client nonce */
99
+		   str* _qop,         /* qop-value: "", "auth", "auth-int" */
100
+		   int _auth_int,     /* 1 if auth-int is used */
101
+		   str* _method,      /* method from the request */
102
+		   str* _uri,         /* requested URL */
103
+		   HASHHEX _hentity,  /* H(entity body) if qop="auth-int" */
104
+		   HASHHEX _response) /* request-digest or response-digest */
105
+{
106
+	MD5_CTX Md5Ctx;
107
+	HASH HA2;
108
+	HASH RespHash;
109
+	HASHHEX HA2Hex;
110
+	
111
+	     /* calculate H(A2) */
112
+	MD5Init(&Md5Ctx);
113
+	MD5Update(&Md5Ctx, _method->s, _method->len);
114
+	MD5Update(&Md5Ctx, ":", 1);
115
+	MD5Update(&Md5Ctx, _uri->s, _uri->len);
116
+
117
+	if (_auth_int) {
118
+		MD5Update(&Md5Ctx, ":", 1);
119
+		MD5Update(&Md5Ctx, _hentity, HASHHEXLEN);
120
+	};
121
+
122
+	MD5Final(HA2, &Md5Ctx);
123
+	cvt_hex(HA2, HA2Hex);
124
+	
125
+	     /* calculate response */
126
+	MD5Init(&Md5Ctx);
127
+	MD5Update(&Md5Ctx, _ha1, HASHHEXLEN);
128
+	MD5Update(&Md5Ctx, ":", 1);
129
+	MD5Update(&Md5Ctx, _nonce->s, _nonce->len);
130
+	MD5Update(&Md5Ctx, ":", 1);
131
+
132
+	if (_qop->len) {
133
+		MD5Update(&Md5Ctx, _nc->s, _nc->len);
134
+		MD5Update(&Md5Ctx, ":", 1);
135
+		MD5Update(&Md5Ctx, _cnonce->s, _cnonce->len);
136
+		MD5Update(&Md5Ctx, ":", 1);
137
+		MD5Update(&Md5Ctx, _qop->s, _qop->len);
138
+		MD5Update(&Md5Ctx, ":", 1);
139
+	};
140
+	MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN);
141
+	MD5Final(RespHash, &Md5Ctx);
142
+	cvt_hex(RespHash, _response);
143
+}