1 /*
2 * Copyright (C) 2018 Rafael Ostertag
3 *
4 * This file is part of YAPET.
5 *
6 * YAPET is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
9 * version.
10 *
11 * YAPET is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * YAPET. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Additional permission under GNU GPL version 3 section 7
20 *
21 * If you modify this program, or any covered work, by linking or combining it
22 * with the OpenSSL project's OpenSSL library (or a modified version of that
23 * library), containing parts covered by the terms of the OpenSSL or SSLeay
24 * licenses, Rafael Ostertag grants you additional permission to convey the
25 * resulting work. Corresponding Source for a non-source form of such a
26 * combination shall include the source code for the parts of OpenSSL used as
27 * well as that of the covered work.
28 */
29
30 #include "blowfishfactory.hh"
31
32 using namespace yapet;
33
BlowfishFactory(const SecureArray & password,const MetaData & keyingParameters)34 BlowfishFactory::BlowfishFactory(const SecureArray& password,
35 const MetaData& keyingParameters)
36 : _key448{new Key448{}} {
37 _key448->keyingParameters(keyingParameters);
38 _key448->password(password);
39 }
40
newFactory(const SecureArray & password,const MetaData & keyingParameters) const41 std::shared_ptr<AbstractCryptoFactory> BlowfishFactory::newFactory(
42 const SecureArray& password, const MetaData& keyingParameters) const {
43 return std::shared_ptr<AbstractCryptoFactory>{
44 new BlowfishFactory(password, keyingParameters)};
45 }
46
crypto() const47 std::unique_ptr<Crypto> BlowfishFactory::crypto() const {
48 return std::unique_ptr<Crypto>{new Blowfish{_key448}};
49 }
50
file(const std::string & filename,bool create,bool secure) const51 std::unique_ptr<YapetFile> BlowfishFactory::file(const std::string& filename,
52 bool create,
53 bool secure) const {
54 return std::unique_ptr<YapetFile>{
55 new Yapet10File{filename, create, secure}};
56 }