3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
31 simple_http_digest_calculate_session_key(const gchar
*username
,
33 const gchar
*password
,
39 g_return_val_if_fail(username
!= NULL
, NULL
);
40 g_return_val_if_fail(realm
!= NULL
, NULL
);
41 g_return_val_if_fail(password
!= NULL
, NULL
);
42 g_return_val_if_fail(nonce
!= NULL
, NULL
);
44 hasher
= g_checksum_new(G_CHECKSUM_MD5
);
45 g_return_val_if_fail(hasher
!= NULL
, NULL
);
47 g_checksum_update(hasher
, (guchar
*)username
, -1);
48 g_checksum_update(hasher
, (guchar
*)":", -1);
49 g_checksum_update(hasher
, (guchar
*)realm
, -1);
50 g_checksum_update(hasher
, (guchar
*)":", -1);
51 g_checksum_update(hasher
, (guchar
*)password
, -1);
53 hash
= g_strdup(g_checksum_get_string(hasher
));
54 g_checksum_free(hasher
);
60 simple_http_digest_calculate_response(const gchar
*method
,
61 const gchar
*digest_uri
,
63 const gchar
*nonce_count
,
64 const gchar
*session_key
)
69 g_return_val_if_fail(method
!= NULL
, NULL
);
70 g_return_val_if_fail(digest_uri
!= NULL
, NULL
);
71 g_return_val_if_fail(nonce
!= NULL
, NULL
);
72 g_return_val_if_fail(session_key
!= NULL
, NULL
);
74 hash
= g_checksum_new(G_CHECKSUM_MD5
);
75 g_return_val_if_fail(hash
!= NULL
, NULL
);
77 g_checksum_update(hash
, (guchar
*)method
, -1);
78 g_checksum_update(hash
, (guchar
*)":", -1);
79 g_checksum_update(hash
, (guchar
*)digest_uri
, -1);
81 hash2
= g_strdup(g_checksum_get_string(hash
));
82 g_checksum_reset(hash
);
85 g_checksum_free(hash
);
86 g_return_val_if_reached(NULL
);
89 g_checksum_update(hash
, (guchar
*)session_key
, -1);
90 g_checksum_update(hash
, (guchar
*)":", -1);
91 g_checksum_update(hash
, (guchar
*)nonce
, -1);
92 g_checksum_update(hash
, (guchar
*)":", -1);
94 g_checksum_update(hash
, (guchar
*)hash2
, -1);
97 hash2
= g_strdup(g_checksum_get_string(hash
));
98 g_checksum_free(hash
);