| Disk ARchive 2.8.4 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
crypto_asym.hpp
Go to the documentation of this file.
1//*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2026 Denis Corbin
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
25
26#ifndef CRYPTO_ASYM_HPP
27#define CRYPTO_ASYM_HPP
28
29 extern "C"
30{
31#if HAVE_GPGME_H
32#include <gpgme.h>
33#endif
34}
35
36#include "../my_config.h"
37#include "generic_file.hpp"
38#include "mem_ui.hpp"
39#include "crypto.hpp"
40
41#include <list>
42
43 namespace libdar
44{
47
49
50 class crypto_asym : public mem_ui
51 {
52 public:
53
55 crypto_asym(const std::shared_ptr<user_interaction> & ui) : mem_ui(ui) { build_context(); has_signatories = false; };
56
58 crypto_asym(const crypto_asym & ref) = delete;
59
61 crypto_asym(crypto_asym && ref) = delete;
62
64 crypto_asym & operator = (const crypto_asym & ref) = delete;
65
67 crypto_asym & operator = (crypto_asym && ref) = delete;
68
70 ~crypto_asym() { release_context(); };
71
72
74 void set_signatories(const std::vector<std::string> & signatories);
75
77
82 void encrypt(const std::vector<std::string> & recipients_email, generic_file & clear, generic_file & ciphered);
83
85
89 void decrypt(generic_file & ciphered, generic_file & clear);
90
93 const std::list<signator> & verify() const { return signing_result; };
94
96
99 user_interaction & get_ui() const { return mem_ui::get_ui(); };
100
101 private:
102 bool has_signatories;
103 std::list<signator> signing_result;
104#if GPGME_SUPPORT
105 gpgme_ctx_t context;
106
107 void release_context() { gpgme_release(context); };
108 void build_key_list(const std::vector<std::string> & recipients_email,
109 gpgme_key_t * & ciphering_keys,
110 bool signatories
111 );
112 void release_key_list(gpgme_key_t * & ciphering_keys);
113 void fill_signing_result();
114#else
115 void release_context() {};
116#endif
117
118 void build_context();
119 };
120
122
123} // end of namespace
124
125#endif
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::mem_ui
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
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:58
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