comparison libpurple/protocols/jabber/auth_scram.h @ 28707:c1d41b7484ff

jabber: Complete (though untested) SCRAM implementation. Client proof calculations function properly, but parsing is untested.
author Paul Aurich <paul@darkrain42.org>
date Mon, 09 Nov 2009 03:42:26 +0000
parents 338eeaf371e2
children b0fb53868142
comparison
equal deleted inserted replaced
28706:2b4465db73f1 28707:c1d41b7484ff
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 */ 23 */
24 #ifndef PURPLE_JABBER_AUTH_SCRAM_H_ 24 #ifndef PURPLE_JABBER_AUTH_SCRAM_H_
25 #define PURPLE_JABBER_AUTH_SCRAM_H_ 25 #define PURPLE_JABBER_AUTH_SCRAM_H_
26 26
27 /*
28 * Every function in this file is ONLY exposed for tests.
29 * DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR.
30 */
31
32 /* Per-connection state stored between messages.
33 * This is stored in js->auth_data_mech.
34 */
35
36 typedef struct {
37 const char *hash;
38 char *cnonce;
39 GString *auth_message;
40
41 GString *client_proof;
42 GString *server_signature;
43 gboolean channel_binding;
44 } JabberScramData;
45
46 #include "auth.h"
47
48 JabberSaslMech *jabber_scram_get_sha1(void);
49
27 /** 50 /**
28 * Implements the Hi() function as described in the SASL-SCRAM I-D. 51 * Implements the Hi() function as described in the SASL-SCRAM I-D.
29 * 52 *
30 * @param hash The name of a hash function to be used with HMAC. This should 53 * @param hash The name of a hash function to be used with HMAC. This should
31 * be suitable to be passed to the libpurple cipher API. Typically 54 * be suitable to be passed to the libpurple cipher API. Typically
32 * it will be "sha1". 55 * it will be "sha1".
33 * @param str The string to perform the PBKDF2 operation on. 56 * @param str The string to perform the PBKDF2 operation on.
34 * @param salt The salt. 57 * @param salt The salt.
35 * @param iterations The number of iterations to perform. 58 * @param iterations The number of iterations to perform.
36 * 59 *
37 * @returns A newly allocated string containing the result. 60 * @returns A newly allocated string containing the result. The string is
61 * NOT null-terminated and its length is the length of the binary
62 * output of the hash function in-use.
38 */ 63 */
39 GString *jabber_auth_scram_hi(const char *hash, const GString *str, 64 guchar *jabber_scram_hi(const char *hash, const GString *str,
40 GString *salt, guint iterations); 65 GString *salt, guint iterations);
66
67 /**
68 * Calculates the proofs as described in Section 3 of the SASL-SCRAM I-D.
69 *
70 * @param data A JabberScramData structure. hash and auth_message must be
71 * set. client_proof and server_signature will be set as a result
72 * of this function.
73 * @param password The user's password.
74 * @param salt The salt (as specified by the server)
75 * @param iterations The number of iterations to perform.
76 *
77 * @returns TRUE if the proofs were successfully calculated. FALSE otherwise.
78 */
79 gboolean jabber_scram_calc_proofs(JabberScramData *data, const char *password,
80 GString *salt, guint iterations);
41 81
42 #endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */ 82 #endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */