[go: up one dir, main page]

File: commands.h

package info (click to toggle)
securefs 0.8.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 864 kB
  • sloc: cpp: 11,356; python: 300; makefile: 7; sh: 2
file content (46 lines) | stat: -rw-r--r-- 1,229 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include "myutils.h"
#include "platform.h"

#include <cryptopp/secblock.h>
#include <string>

namespace securefs
{
int commands_main(int argc, const char* const* argv);

struct FSConfig
{
    CryptoPP::AlignedSecByteBlock master_key;
    unsigned block_size;
    unsigned iv_size;
    unsigned version;
};

class CommandBase
{
    DISABLE_COPY_MOVE(CommandBase)

protected:
    static std::shared_ptr<FileStream> open_config_stream(const std::string& full_path, int flags);
    static FSConfig read_config(FileStream*, const void* password, size_t pass_len);
    static void write_config(FileStream*,
                             const std::string& pbdkf_algorithm,
                             const FSConfig&,
                             const void* password,
                             size_t pass_len,
                             unsigned rounds);

public:
    CommandBase() {}
    virtual ~CommandBase() {}

    virtual const char* long_name() const noexcept = 0;
    virtual char short_name() const noexcept = 0;
    virtual const char* help_message() const noexcept = 0;

    virtual void parse_cmdline(int argc, const char* const* argv) = 0;
    virtual int execute() = 0;
};
}    // namespace securefs