2016-01-16 22:13:53 +01:00
|
|
|
/*
|
|
|
|
* Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
|
|
|
|
* Copyright (C) 2016 Claws Mail team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PASSWORD_H
|
|
|
|
#define __PASSWORD_H
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#ifndef PASSWORD_CRYPTO_OLD
|
2016-03-03 11:17:41 +01:00
|
|
|
/* Returns TRUE if there is a master passphrase set in preferences. */
|
|
|
|
const gboolean master_passphrase_is_set();
|
|
|
|
/* Returns TRUE if input contains correct master passphrase, as set
|
2016-03-01 19:44:25 +01:00
|
|
|
* in preferences. */
|
2016-03-03 11:17:41 +01:00
|
|
|
const gboolean master_passphrase_is_correct(const gchar *input);
|
|
|
|
/* Returns TRUE if master passphrase is entered (unlocked). */
|
|
|
|
gboolean master_passphrase_is_entered();
|
|
|
|
/* Removes (locks) master passphrase, if it was entered previously
|
2016-03-01 19:44:25 +01:00
|
|
|
* in current session. */
|
2016-03-03 11:17:41 +01:00
|
|
|
void master_passphrase_forget();
|
2016-03-01 19:44:25 +01:00
|
|
|
|
2016-03-03 11:17:41 +01:00
|
|
|
/* Changes master passphrase. Also triggers reencryption of all stored
|
|
|
|
* passwords using the new master passphrase.
|
|
|
|
* oldp - old master passphrase; if NULL, it will be retrieved using
|
|
|
|
* master_passphrase()
|
|
|
|
* newp - new master passphrase */
|
|
|
|
void master_passphrase_change(const gchar *oldp, const gchar *newp);
|
2016-01-16 22:13:53 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Wrapper around the old, DES-CBC-broken implementation which
|
|
|
|
* returns a newly allocated string for the encrypt/decrypt result.
|
|
|
|
* This is for compatibility with with the rest of password-related
|
|
|
|
* functions.*/
|
|
|
|
gchar *password_encrypt_old(const gchar *password);
|
|
|
|
gchar *password_decrypt_old(const gchar *password);
|
|
|
|
|
|
|
|
#ifdef PASSWORD_CRYPTO_GNUTLS
|
|
|
|
/* GNUTLS implementation */
|
|
|
|
gchar *password_encrypt_gnutls(const gchar *password,
|
2016-03-03 11:17:41 +01:00
|
|
|
const gchar *encryption_passphrase);
|
2016-01-16 22:13:53 +01:00
|
|
|
gchar *password_decrypt_gnutls(const gchar *password,
|
2016-03-03 11:17:41 +01:00
|
|
|
const gchar *decryption_passphrase);
|
2016-01-16 22:13:53 +01:00
|
|
|
#define password_encrypt_real(n, m) password_encrypt_gnutls(n, m)
|
|
|
|
#define password_decrypt_real(n, m) password_decrypt_gnutls(n, m)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Wrapper function that will apply best encryption available,
|
|
|
|
* and return a string ready to be saved as-is in preferences. */
|
|
|
|
gchar *password_encrypt(const gchar *password,
|
2016-03-03 11:17:41 +01:00
|
|
|
const gchar *encryption_passphrase);
|
2016-01-16 22:13:53 +01:00
|
|
|
|
|
|
|
/* This is a wrapper function that looks at the whole string from
|
|
|
|
* prefs (e.g. including the leading '!' for old implementation),
|
|
|
|
* and tries to do the smart thing. */
|
|
|
|
gchar *password_decrypt(const gchar *password,
|
2016-03-03 11:17:41 +01:00
|
|
|
const gchar *decryption_passphrase);
|
2016-01-16 22:13:53 +01:00
|
|
|
|
|
|
|
#endif /* __PASSWORD_H */
|