Migrate certificates, icons, logs to XDG dirs
[pidgin-git.git] / libpurple / protocols / jabber / auth_scram.h
blob9073bb2b786a3187e4a5ed137fe8a56362c9a558
1 /**
2 * @file auth_scram.h Implementation of SASL-SCRAM authentication
4 * purple
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
8 * source distribution.
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.
32 #include "cipher.h"
34 /* Per-connection state stored between messages.
35 * This is stored in js->auth_data_mech.
37 typedef struct {
38 const char *mech_substr;
39 PurpleHash *(*new_cipher)(void);
40 guint size;
41 } JabberScramHash;
43 typedef struct {
44 const JabberScramHash *hash;
45 char *cnonce;
46 GString *auth_message;
48 GString *client_proof;
49 GString *server_signature;
51 gchar *password;
52 gboolean channel_binding;
53 int step;
54 } JabberScramData;
56 #include "auth.h"
58 /**
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);
73 /**
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
78 * of this function.
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,
85 guint iterations);
87 /**
88 * Feed the algorithm with the data from the server.
90 gboolean jabber_scram_feed_parser(JabberScramData *data, gchar *in, gchar **out);
92 /**
93 * Clean up and destroy the data struct
95 void jabber_scram_data_destroy(JabberScramData *data);
97 #endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */