libkazv
Loading...
Searching...
No Matches
encrypted-file.hpp
Go to the documentation of this file.
1/*
2 * This file is part of libkazv.
3 * SPDX-FileCopyrightText: 2021 Tusooa Zhu <tusooa@kazv.moe>
4 * SPDX-License-Identifier: AGPL-3.0-or-later
5 */
6
7#pragma once
8#include <libkazv-config.hpp>
9
10#include <boost/serialization/string.hpp>
11#include <boost/serialization/split_member.hpp>
12
13#include <types.hpp>
14#include <copy-helper.hpp>
15
16namespace Kazv
17{
19 {
20 public:
27
36 EncryptedFileDesc(std::string mxcUri, std::string key, std::string iv, std::string sha256Hash);
37
39
41
51 static EncryptedFileDesc fromJson(JsonWrap encryptedFile);
52
58 JsonWrap toJson() const;
59
61 std::string mxcUri() const;
63 std::string key() const;
65 std::string iv() const;
67 std::string sha256Hash() const;
68
73 bool operator==(const EncryptedFileDesc &that) const;
74
75 template<class Archive>
76 void save(Archive &ar, const unsigned int /* version */) const {
77 ar << mxcUri()
78 << key()
79 << iv()
80 << sha256Hash();
81 }
82
83 template<class Archive>
84 void load(Archive &ar, const unsigned int /* version */) {
85 std::string mxcUri;
86 std::string key;
87 std::string iv;
88 std::string sha256Hash;
89 ar >> mxcUri
90 >> key
91 >> iv
92 >> sha256Hash;
93
95 }
96
97 BOOST_SERIALIZATION_SPLIT_MEMBER()
98
99 private:
100 struct Private;
101 std::unique_ptr<Private> m_d;
102 };
103}
Definition encrypted-file.hpp:19
void load(Archive &ar, const unsigned int)
Definition encrypted-file.hpp:84
std::string key() const
Definition encrypted-file.cpp:86
JsonWrap toJson() const
Convert the encrypted file metadata to an EncryptedFile json object.
Definition encrypted-file.cpp:61
EncryptedFileDesc()
Constructs an empty EncryptedFileDesc.
Definition encrypted-file.cpp:20
void save(Archive &ar, const unsigned int) const
Definition encrypted-file.hpp:76
std::string sha256Hash() const
Definition encrypted-file.cpp:98
bool operator==(const EncryptedFileDesc &that) const
Definition encrypted-file.cpp:104
std::string iv() const
Definition encrypted-file.cpp:92
static EncryptedFileDesc fromJson(JsonWrap encryptedFile)
Constructs an EncryptedFileDesc from an EncryptedFile json object.
Definition encrypted-file.cpp:34
std::string mxcUri() const
Definition encrypted-file.cpp:80
Definition jsonwrap.hpp:23
#define KAZV_DECLARE_COPYABLE(typeName)
Definition copy-helper.hpp:10
Definition location.hpp:10
Definition clientutil.hpp:140