libkazv
key-export.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of libkazv.
3  * SPDX-FileCopyrightText: 2025 tusooa <tusooa@kazv.moe>
4  * SPDX-License-Identifier: AGPL-3.0-or-later
5  */
6 
7 #pragma once
8 #include <libkazv-config.hpp>
9 #include <vector>
10 #include <nlohmann/json.hpp>
11 #include <maybe.hpp>
12 #include "crypto-util.hpp"
13 
14 namespace Kazv
15 {
27  std::pair<ByteArray, ByteArray> deriveKeyExportKey(
28  std::string password,
29  ByteArray salt,
30  std::size_t iterations
31  );
32 
33  namespace DecryptKeyExportErrorCodes
34  {
36  static const std::string FILE_MALFORMED{"FILE_MALFORMED"};
38  static const std::string VERSION_UNSUPPORTED{"VERSION_UNSUPPORTED"};
40  static const std::string NOT_JSON{"NOT_JSON"};
42  static const std::string HMAC_FAILED{"HMAC_FAILED"};
43  }
44 
54  Maybe<nlohmann::json> decryptKeyExport(std::string exportContent, std::string password);
55 }
Definition: maybe.hpp:25
Definition: location.hpp:10
std::pair< ByteArray, ByteArray > deriveKeyExportKey(std::string password, ByteArray salt, std::size_t iterations)
Derive the key-export key from the user-inputted password.
Definition: key-export.cpp:29
Maybe< nlohmann::json > decryptKeyExport(std::string exportContent, std::string password)
Decrypt the key-export file with the user-inputted password.
Definition: key-export.cpp:81
std::vector< unsigned char > ByteArray
Definition: crypto-util.hpp:21