blob: dbd2d17e11ed59cc01b23b5b340e81aa34760df4 [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001/* $Id: stun.c 3553 2011-05-05 06:14:19Z nanang $ */
Tristan Matthews0a329cc2013-07-17 13:20:14 -04002/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21static int decode_test(void)
22{
23 /* Invalid message type */
24
25 /* Short message */
26
27 /* Long, random message */
28
29 /* Message length in header is shorter */
30
31 /* Message length in header is longer */
32
33 /* Invalid magic */
34
35 /* Attribute length is not valid */
36
37 /* Unknown mandatory attribute type should generate error */
38
39 /* Unknown but non-mandatory should be okay */
40
41 /* String/binary attribute length is larger than the message */
42
43 /* Valid message with MESSAGE-INTEGRITY */
44
45 /* Valid message with FINGERPRINT */
46
47 /* Valid message with MESSAGE-INTEGRITY and FINGERPRINT */
48
49 /* Another attribute not FINGERPRINT exists after MESSAGE-INTEGRITY */
50
51 /* Another attribute exists after FINGERPRINT */
52
53 return 0;
54}
55
56static int decode_verify(void)
57{
58 /* Decode all attribute types */
59 return 0;
60}
61
62static int auth_test(void)
63{
64 /* REALM and USERNAME is present, but MESSAGE-INTEGRITY is not present.
65 * For short term, must with reply 401 without REALM.
66 * For long term, must reply with 401 with REALM.
67 */
68
69 /* USERNAME is not present, server must respond with 432 (Missing
70 * Username).
71 */
72
73 /* If long term credential is wanted and REALM is not present, server
74 * must respond with 434 (Missing Realm)
75 */
76
77 /* If REALM doesn't match, server must respond with 434 (Missing Realm)
78 * too, containing REALM and NONCE attribute.
79 */
80
81 /* When long term authentication is wanted and NONCE is NOT present,
82 * server must respond with 435 (Missing Nonce), containing REALM and
83 * NONCE attribute.
84 */
85
86 /* Simulate 438 (Stale Nonce) */
87
88 /* Simulate 436 (Unknown Username) */
89
90 /* When server wants to use short term credential, but request has
91 * REALM, reject with .... ???
92 */
93
94 /* Invalid HMAC */
95
96 /* Valid static short term, without NONCE */
97
98 /* Valid static short term, WITH NONCE */
99
100 /* Valid static long term (with NONCE */
101
102 /* Valid dynamic short term (without NONCE) */
103
104 /* Valid dynamic short term (with NONCE) */
105
106 /* Valid dynamic long term (with NONCE) */
107
108 return 0;
109}
110
111
112int stun_test(void)
113{
114 decode_verify();
115 decode_test();
116 auth_test();
117 return 0;
118}
119