2 * @file auth_scram.h Implementation of SASL-SCRAM authentication
6 * Purple is the legal property of its developers, whose names are too numerous
7 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * This program 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.
15 * This program 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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
24 #ifndef PURPLE_JABBER_AUTH_SCRAM_H_
25 #define PURPLE_JABBER_AUTH_SCRAM_H_
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.
34 /* Per-connection state stored between messages.
35 * This is stored in js->auth_data_mech.
38 const char *mech_substr
;
39 PurpleHash
*(*new_cipher
)(void);
44 const JabberScramHash
*hash
;
46 GString
*auth_message
;
48 GString
*client_proof
;
49 GString
*server_signature
;
52 gboolean channel_binding
;
59 * Implements the Hi() function as described in the SASL-SCRAM I-D.
61 * @param hash The struct corresponding to the hash function to be used.
62 * @param str The string to perform the PBKDF2 operation on.
63 * @param salt The salt.
64 * @param iterations The number of iterations to perform.
66 * @returns A newly allocated string containing the result. The string is
67 * NOT null-terminated and its length is the length of the binary
68 * output of the hash function in-use.
70 guchar
*jabber_scram_hi(const JabberScramHash
*hash
, const GString
*str
,
71 GString
*salt
, guint iterations
);
74 * Calculates the proofs as described in Section 3 of the SASL-SCRAM I-D.
76 * @param data A JabberScramData structure. hash and auth_message must be
77 * set. client_proof and server_signature will be set as a result
79 * @param salt The salt (as specified by the server)
80 * @param iterations The number of iterations to perform.
82 * @returns TRUE if the proofs were successfully calculated. FALSE otherwise.
84 gboolean
jabber_scram_calc_proofs(JabberScramData
*data
, GString
*salt
,
88 * Feed the algorithm with the data from the server.
90 gboolean
jabber_scram_feed_parser(JabberScramData
*data
, gchar
*in
, gchar
**out
);
93 * Clean up and destroy the data struct
95 void jabber_scram_data_destroy(JabberScramData
*data
);
97 #endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */