diff --git a/README.md b/README.md
index 9217499..c4532e0 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,8 @@ Desktop app for securely storing sensitive files
## Features
* **Pretty usable UI**
* **Overkill encryption:** XChaCha20-Poly1305 + Argon2id(m=1GB,t=6,p=4) key derivation
-* **Cross-platform-ish:** Tested on Linux and Windows
+* **Cross-platform-ish:** Builds on Linux, Windows and macOS
+* **Drag and Drop support**
## Building
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 79c09b5..69d5fc1 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -107,8 +107,6 @@ void MainWindow::reload_fs_tree() {
auto *item = new QTreeWidgetItem(ui->fsTreeWidget);
item->setText(0, QString::fromStdString(header.name));
item->setText(1, QString::number(header.content_size));
- item->setText(2, QString::number(header.global_offset));
- item->setText(3, QString::fromStdString(Botan::hex_encode(header.nonce)));
}
for (int i = 0; i < ui->fsTreeWidget->columnCount(); ++i) {
ui->fsTreeWidget->resizeColumnToContents(i);
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 8df10f0..321e29c 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -33,16 +33,6 @@
Size
-
-
- Offset
-
-
-
-
- Nonce
-
-
-
@@ -93,11 +83,6 @@
Add
-
-
- Create
-
-
diff --git a/src/vault.cc b/src/vault.cc
index 96d4c7a..6dd0b22 100644
--- a/src/vault.cc
+++ b/src/vault.cc
@@ -62,8 +62,8 @@ std::optional Vault::read_file(const std::string &filename) {
break;
}
- auto plaintext =
- Crypto::decrypt_xchacha20_poly1305(ciphertext, m_key, header->nonce);
+ auto plaintext = Crypto::decrypt_xchacha20_poly1305(
+ ciphertext, m_key, header->content_nonce);
return std::string(to_char_ptr(plaintext.data()), plaintext.size());
}
@@ -79,23 +79,28 @@ void Vault::create_file(const std::string &filename,
m_file.seekp(0, std::ios::end);
static Botan::AutoSeeded_RNG rng;
- auto nonce_sv = rng.random_vec(24);
- std::vector nonce(nonce_sv.begin(), nonce_sv.end());
+ auto name_nonce_sv = rng.random_vec(24);
+ std::vector name_nonce(name_nonce_sv.begin(), name_nonce_sv.end());
+
+ auto content_nonce_sv = rng.random_vec(24);
+ std::vector content_nonce(content_nonce_sv.begin(),
+ content_nonce_sv.end());
Botan::secure_vector filename_sv(filename.begin(), filename.end());
auto filename_ciphertext =
- Crypto::encrypt_xchacha20_poly1305(filename_sv, m_key, nonce);
+ Crypto::encrypt_xchacha20_poly1305(filename_sv, m_key, name_nonce);
u64 filename_ciphertext_size = filename_ciphertext.size();
Botan::secure_vector content_sv(content.begin(), content.end());
auto ciphertext =
- Crypto::encrypt_xchacha20_poly1305(content_sv, m_key, nonce);
+ Crypto::encrypt_xchacha20_poly1305(content_sv, m_key, content_nonce);
u64 ciphertext_size = ciphertext.size();
- ASSERT(m_file.write(to_char_ptr(nonce.data()), nonce.size()));
+ ASSERT(m_file.write(to_char_ptr(name_nonce.data()), name_nonce.size()));
ASSERT(m_file.write(to_char_ptr(&filename_ciphertext_size), sizeof(u64)));
ASSERT(m_file.write(to_char_ptr(filename_ciphertext.data()),
static_cast(filename_ciphertext_size)));
+ ASSERT(m_file.write(to_char_ptr(content_nonce.data()), content_nonce.size()));
ASSERT(m_file.write(to_char_ptr(&ciphertext_size), sizeof(u64)));
ASSERT(m_file.write(to_char_ptr(ciphertext.data()),
static_cast(ciphertext_size)));
@@ -160,10 +165,10 @@ void Vault::update_file(const std::string &filename,
std::optional Vault::read_file_header() {
FileHeader header{};
- header.global_offset = m_file.tellg();
- header.nonce.resize(24);
- if (!m_file.read(to_char_ptr(header.nonce.data()), 24)) {
+ std::vector name_nonce;
+ name_nonce.resize(24);
+ if (!m_file.read(to_char_ptr(name_nonce.data()), 24)) {
return std::nullopt;
}
@@ -181,9 +186,14 @@ std::optional Vault::read_file_header() {
}
auto name =
- Crypto::decrypt_xchacha20_poly1305(name_ciphertext, m_key, header.nonce);
+ Crypto::decrypt_xchacha20_poly1305(name_ciphertext, m_key, name_nonce);
header.name = std::string(name.begin(), name.end());
+ header.content_nonce.resize(24);
+ if (!m_file.read(to_char_ptr(header.content_nonce.data()), 24)) {
+ return std::nullopt;
+ }
+
if (!m_file.read(to_char_ptr(&header.content_size), sizeof(u64))) {
return std::nullopt;
}
diff --git a/src/vault.h b/src/vault.h
index 317c520..e680767 100644
--- a/src/vault.h
+++ b/src/vault.h
@@ -13,8 +13,7 @@ struct FileHeader {
std::string name;
u64 name_ciphertext_size;
u64 content_size;
- std::vector nonce;
- u64 global_offset;
+ std::vector content_nonce;
};
class Vault {