The Battle for Wesnoth  1.15.9+dev
auth.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2015 - 2020 by Iris Morelle <shadowm2006@gmail.com>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file
17  * campaignd authentication API.
18  */
19 
20 #pragma once
21 
22 #include <string>
23 #include <utility>
24 
25 namespace campaignd
26 {
27 
28 namespace auth
29 {
30 
31 /**
32  * Verifies the specified plain text passphrase against a salted hash.
33  *
34  * @param passphrase Passphrase (user input).
35  * @param salt Salt string.
36  * @param hash Base64-encoded salted MD5 hash.
37  */
38 bool verify_passphrase(const std::string& passphrase, const std::string& salt, const std::string& hash);
39 
40 /**
41  * Generates a salted hash from the specified passphrase.
42  *
43  * @param passphrase Passphrase (user input).
44  *
45  * @return A pair consisting of the salt (in @a first) and Base64-encoded MD5
46  * hash (in @a second).
47  */
48 std::pair<std::string, std::string> generate_hash(const std::string& passphrase);
49 
50 } // end namespace auth
51 
52 } // end namespace campaignd
std::pair< std::string, std::string > generate_hash(const std::string &passphrase)
Generates a salted hash from the specified passphrase.
Definition: auth.cpp:54
bool verify_passphrase(const std::string &passphrase, const std::string &salt, const std::string &hash)
Verifies the specified plain text passphrase against a salted hash.
Definition: auth.cpp:49