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
25 #ifndef PURPLE_JABBER_AUTH_SCRAM_H
26 #define PURPLE_JABBER_AUTH_SCRAM_H
29 * Every function in this file is ONLY exposed for tests.
30 * DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR.
33 /* Per-connection state stored between messages.
34 * This is stored in js->auth_data_mech.
37 const char *mech_substr
;
42 const JabberScramHash
*hash
;
44 GString
*auth_message
;
46 GString
*client_proof
;
47 GString
*server_signature
;
50 gboolean channel_binding
;
57 * Implements the Hi() function as described in the SASL-SCRAM I-D.
59 * @param hash The struct corresponding to the hash function to be used.
60 * @param str The string to perform the PBKDF2 operation on.
61 * @param salt The salt.
62 * @param iterations The number of iterations to perform.
64 * @returns A newly allocated string containing the result. The string is
65 * NOT null-terminated and its length is the length of the binary
66 * output of the hash function in-use.
68 guchar
*jabber_scram_hi(const JabberScramHash
*hash
, const GString
*str
,
69 GString
*salt
, guint iterations
);
72 * Calculates the proofs as described in Section 3 of the SASL-SCRAM I-D.
74 * @param data A JabberScramData structure. hash and auth_message must be
75 * set. client_proof and server_signature will be set as a result
77 * @param salt The salt (as specified by the server)
78 * @param iterations The number of iterations to perform.
80 * @returns TRUE if the proofs were successfully calculated. FALSE otherwise.
82 gboolean
jabber_scram_calc_proofs(JabberScramData
*data
, GString
*salt
,
86 * Feed the algorithm with the data from the server.
88 gboolean
jabber_scram_feed_parser(JabberScramData
*data
, gchar
*in
, gchar
**out
);
91 * Clean up and destroy the data struct
93 void jabber_scram_data_destroy(JabberScramData
*data
);
95 #endif /* PURPLE_JABBER_AUTH_SCRAM_H */