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