Loading...
Searching...
No Matches
crypto_asym.hpp
Go to the documentation of this file.
//*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2024 Denis Corbin
//
// 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 2
// 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, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef CRYPTO_ASYM_HPP
#define CRYPTO_ASYM_HPP
extern "C"
{
#if HAVE_GPGME_H
#include <gpgme.h>
#endif
}
#include "../my_config.h"
#include "generic_file.hpp"
#include "mem_ui.hpp"
#include "crypto.hpp"
#include <list>
namespace libdar
{
class crypto_asym : public mem_ui
{
public:
crypto_asym(const std::shared_ptr<user_interaction> & ui) : mem_ui(ui) { build_context(); has_signatories = false; };
crypto_asym(const crypto_asym & ref) = delete;
crypto_asym(crypto_asym && ref) = delete;
crypto_asym & operator = (const crypto_asym & ref) = delete;
crypto_asym & operator = (crypto_asym && ref) = delete;
~crypto_asym() { release_context(); };
void set_signatories(const std::vector<std::string> & signatories);
void encrypt(const std::vector<std::string> & recipients_email, generic_file & clear, generic_file & ciphered);
void decrypt(generic_file & ciphered, generic_file & clear);
const std::list<signator> & verify() const { return signing_result; };
user_interaction & get_ui() const { return mem_ui::get_ui(); };
private:
bool has_signatories;
std::list<signator> signing_result;
#if GPGME_SUPPORT
gpgme_ctx_t context;
void release_context() { gpgme_release(context); };
void build_key_list(const std::vector<std::string> & recipients_email,
gpgme_key_t * & ciphering_keys,
bool signatories
);
void release_key_list(gpgme_key_t * & ciphering_keys);
void fill_signing_result();
#else
void release_context() {};
#endif
void build_context();
};
} // end of namespace
#endif
libdar::crypto_asym
asymetric ciphering
Definition crypto_asym.hpp:51
libdar::crypto_asym::set_signatories
void set_signatories(const std::vector< std::string > &signatories)
defines the list of email or keyid which associated key will be used for signing
libdar::crypto_asym::crypto_asym
crypto_asym(const crypto_asym &ref)=delete
disabling copy constructor
libdar::crypto_asym::crypto_asym
crypto_asym(crypto_asym &&ref)=delete
disabling move constuctor
libdar::crypto_asym::get_ui
user_interaction & get_ui() const
exposing to public visibility the protected method of mem_ui
Definition crypto_asym.hpp:99
libdar::crypto_asym::verify
const std::list< signator > & verify() const
Definition crypto_asym.hpp:93
libdar::crypto_asym::decrypt
void decrypt(generic_file &ciphered, generic_file &clear)
un-cipher data
libdar::crypto_asym::crypto_asym
crypto_asym(const std::shared_ptr< user_interaction > &ui)
general use constructor
Definition crypto_asym.hpp:55
libdar::crypto_asym::encrypt
void encrypt(const std::vector< std::string > &recipients_email, generic_file &clear, generic_file &ciphered)
encrypt (and sign if signatures have been given using set_signatories) data for the given recipients
libdar::crypto_asym::operator=
crypto_asym & operator=(const crypto_asym &ref)=delete
disabling object assignment
libdar::crypto_asym::~crypto_asym
~crypto_asym()
the destructor
Definition crypto_asym.hpp:70
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition generic_file.hpp:77
libdar::mem_ui
class mem_ui to keep a copy of a user_interaction object
Definition mem_ui.hpp:55
libdar::mem_ui::get_ui
user_interaction & get_ui() const
get access to the user_interaction object
Definition mem_ui.hpp:94
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required.
Definition user_interaction.hpp:47
crypto.hpp
the crypto algoritm definition
generic_file.hpp
class generic_file is defined here as well as class fichier
mem_ui.hpp
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47