Webdar 1.0.0
Web user interface to libdar
html_ciphering.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_CIPHERING_HPP
25#define HTML_CIPHERING_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <dar/libdar.hpp>
36#include <vector>
37#include <string>
38
39 // webdar headers
40#include "body_builder.hpp"
41#include "actor.hpp"
42#include "html_form.hpp"
43#include "html_form_fieldset.hpp"
44#include "html_form_select.hpp"
45#include "html_crypto_algo.hpp"
46#include "html_form_input.hpp"
47#include "html_form_input_unit.hpp"
48#include "html_form_gnupg_list.hpp"
49#include "html_form_radio.hpp"
50#include "jsoner.hpp"
51
53
55 public actor,
56 public jsoner,
57 public events
58{
59public:
60 static const std::string changed;
61
62 enum crypto_type_t
63 {
64 sym = 0,
65 asym = 1
66 };
67
69 html_ciphering(const html_ciphering & ref) = delete;
70 html_ciphering(html_ciphering && ref) noexcept = delete;
71 html_ciphering & operator = (const html_ciphering & ref) = delete;
72 html_ciphering & operator = (html_ciphering && ref) noexcept = delete;
73 ~html_ciphering() = default;
74
75 void set_crypto_size_range(const libdar::infinint & min,
76 const libdar::infinint & max);
77
78 libdar::U_I get_multi_threaded_crypto() const;
79 libdar::crypto_algo get_crypto_algo() const;
80 crypto_type_t get_crypto_type() const;
81 libdar::secu_string get_crypto_pass() const;
82 libdar::infinint get_iteration_count() const;
83 libdar::hash_algo get_kdf_hash() const;
84 std::vector<std::string> get_gnupg_recipients() const;
85 std::vector<std::string> get_gnupg_signatories() const;
86 libdar::U_32 get_crypto_size() const;
87
89 virtual void load_json(const json & source) override;
90
92 virtual json save_json() const override;
93
95 virtual void clear_json() override;
96
98 virtual void on_event(const std::string & event_name) override;
99
102
104 virtual void bind_to_anchor(const std::string & val) override { form_crypto.bind_to_anchor(val); };
105
106protected:
107
109 virtual std::string inherited_get_body_part(const chemin & path,
110 const request & req) override;
111
113 virtual void css_classes_have_changed() override;
114
116 virtual void new_css_library_available() override;
117
118private:
119 // specific events
120 static constexpr const char* kdf_algo_changed = "kdf_algo_changed";
121
122 bool ignore_events;
123
124 html_form form_crypto;
125 html_form_fieldset crypto_fs;
126 html_form_select crypto_type;
127 html_crypto_algo crypto_algo;
128 html_form_input crypto_pass1;
129 html_form_input crypto_pass2;
130 html_form_input_unit crypto_size;
131 html_form_input crypto_threads;
133 html_form_fieldset crypto_fs_kdf_hash;
134 html_form_radio crypto_kdf_hash;
135 html_form_input iteration_count;
136
137 void set_kdf_hash(libdar::hash_algo hash);
138
139 static constexpr const unsigned int format_version = 1;
140 static constexpr const char* myclass_id = "html_ciphering";
141
142 static constexpr const char* jlabel_type = "type";
143 static constexpr const char* jlabel_algo = "algo";
144 static constexpr const char* jlabel_pass = "key";
145 static constexpr const char* jlabel_size = "block-size";
146 static constexpr const char* jlabel_threads = "threads";
147 static constexpr const char* jlabel_gnupg = "gnupg";
148 static constexpr const char* jlabel_kdf_hash = "hash";
149 static constexpr const char* jlabel_kdf_iter = "iterations";
150
151};
152
153#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
class events
Definition: events.hpp:52
html component used for the user to define a has algorithm
Definition: html_ciphering.hpp:58
virtual json save_json() const override
inherited from jsoner
Definition: html_ciphering.cpp:264
virtual void bind_to_anchor(const std::string &val) override
inherited from body_builder
Definition: html_ciphering.hpp:104
virtual void clear_json() override
inherited from jsoner
Definition: html_ciphering.cpp:282
virtual void on_event(const std::string &event_name) override
actor indirect inheritance
Definition: html_ciphering.cpp:297
void set_to_webdar_defaults()
set the object to webdar defaults
Definition: html_ciphering.cpp:388
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_ciphering.cpp:216
virtual void new_css_library_available() override
inherited from body_builder
Definition: html_ciphering.cpp:414
virtual void css_classes_have_changed() override
inherited from body_builder
Definition: html_ciphering.cpp:403
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_ciphering.cpp:397
html component in the form of a drop-down list used to let the user define the crypto algo
Definition: html_crypto_algo.hpp:46
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_gnupg_list provide interface for the user to give a list of gnupg signatories and gnu...
Definition: html_form_gnupg_list.hpp:78
class html_form_input_unit implements HTML input::number feature with added unit box
Definition: html_form_input_unit.hpp:51
class html_form_input implements HTML input feature
Definition: html_form_input.hpp:57
class html_form_radio implements HTML "input" of type "radio"
Definition: html_form_radio.hpp:53
class html_form_select implements HTML input of type "select"
Definition: html_form_select.hpp:53
class html_form implements HTML form feature
Definition: html_form.hpp:51
virtual void bind_to_anchor(const std::string &value) override
inherited from body_builder
Definition: html_form.hpp:83
class jsoner
Definition: jsoner.hpp:73
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines jsoner class and class exception_json