Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cdoc/CDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ libcdoc::CDocWriter::CDocWriter(int _version, DataConsumer *_dst, bool take_owne
{
};

libcdoc::CDocWriter::~CDocWriter()
libcdoc::CDocWriter::~CDocWriter() noexcept
{
if (owned) delete(dst);
}
Expand Down
6 changes: 3 additions & 3 deletions cdoc/CDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

#include "Exports.h"

#include <cstdint>
#include <string>
#include <vector>

namespace libcdoc {

/**
* @brief A typedef that indicates that integer value may contain libcdoc result code
*/
typedef int64_t result_t;
using result_t = int64_t;

enum {
/**
Expand Down Expand Up @@ -134,7 +134,7 @@ CDOC_EXPORT std::string getVersion();
/**
* @brief Log-level enumeration to indicate severity of the log message.
*/
enum LogLevel
enum LogLevel : uint8_t
{
/**
* @brief Most critical level. Application is about to abort.
Expand Down
14 changes: 2 additions & 12 deletions cdoc/CDoc2Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "Certificate.h"
#include "Configuration.h"
#include "Crypto.h"
#include "CryptoBackend.h"
#include "CDoc2.h"
#include "KeyShares.h"
Expand Down Expand Up @@ -400,7 +401,7 @@ CDoc2Reader::beginDecryption(const std::vector<uint8_t>& fmk)
return libcdoc::WRONG_ARGUMENTS;
}
if (!priv->_at_nonce) {
int result = priv->_src->seek(priv->_nonce_pos);
result_t result = priv->_src->seek(priv->_nonce_pos);
if (result != libcdoc::OK) {
setLastError(priv->_src->getLastErrorStr(result));
LOG_ERROR("{}", last_error);
Expand Down Expand Up @@ -697,14 +698,3 @@ CDoc2Reader::isCDoc2File(libcdoc::DataSource *src)
}
return true;
}

bool
CDoc2Reader::isCDoc2File(const std::string& path)
{
std::ifstream fb(path, std::ios_base::in | std::ios_base::binary);
char in[libcdoc::CDoc2::LABEL.size()];
constexpr size_t len = libcdoc::CDoc2::LABEL.size();
if (!fb.read(&in[0], len) || (fb.gcount() != len)) return false;
if (libcdoc::CDoc2::LABEL.compare(0, len, &in[0], len)) return false;
return true;
}
20 changes: 10 additions & 10 deletions cdoc/CDoc2Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ class CDoc2Reader final: public libcdoc::CDocReader {
public:
~CDoc2Reader() final;

const std::vector<libcdoc::Lock>& getLocks() override final;
libcdoc::result_t getLockForCert(const std::vector<uint8_t>& cert) override final;
libcdoc::result_t getFMK(std::vector<uint8_t>& fmk, unsigned int lock_idx) override final;
libcdoc::result_t decrypt(const std::vector<uint8_t>& fmk, libcdoc::MultiDataConsumer *consumer) override final;
const std::vector<libcdoc::Lock>& getLocks() final;
libcdoc::result_t getLockForCert(const std::vector<uint8_t>& cert) final;
libcdoc::result_t getFMK(std::vector<uint8_t>& fmk, unsigned int lock_idx) final;
libcdoc::result_t decrypt(const std::vector<uint8_t>& fmk, libcdoc::MultiDataConsumer *consumer) final;

// Pull interface
libcdoc::result_t beginDecryption(const std::vector<uint8_t>& fmk) override final;
libcdoc::result_t nextFile(std::string& name, int64_t& size) override final;
libcdoc::result_t readData(uint8_t *dst, size_t size) override final;
libcdoc::result_t finishDecryption() override final;
libcdoc::result_t beginDecryption(const std::vector<uint8_t>& fmk) final;
libcdoc::result_t nextFile(std::string& name, int64_t& size) final;
libcdoc::result_t readData(uint8_t *dst, size_t size) final;
libcdoc::result_t finishDecryption() final;

CDoc2Reader(libcdoc::DataSource *src, bool take_ownership = false);

static bool isCDoc2File(const std::string& path);
static bool isCDoc2File(libcdoc::DataSource *src);
private:
struct Private;
CDOC_DISABLE_MOVE_COPY(CDoc2Reader);

struct Private;
std::unique_ptr<Private> priv;
};

Expand Down
7 changes: 5 additions & 2 deletions cdoc/CDocReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "CDoc.h"

#include <cstdint>
#include <vector>

namespace libcdoc {

Expand All @@ -39,7 +39,7 @@ struct NetworkBackend;
*/
class CDOC_EXPORT CDocReader {
public:
virtual ~CDocReader() = default;
virtual ~CDocReader() noexcept = default;

/**
* @brief The container version (1 or 2)
Expand Down Expand Up @@ -210,6 +210,9 @@ class CDOC_EXPORT CDocReader {
Configuration *conf = nullptr;
CryptoBackend *crypto = nullptr;
NetworkBackend *network = nullptr;

private:
CDOC_DISABLE_MOVE_COPY(CDocReader);
};

} // namespace libcdoc
Expand Down
5 changes: 3 additions & 2 deletions cdoc/CDocWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "CDoc.h"

#include <cstdint>
#include <vector>

namespace libcdoc {
struct Configuration;
Expand All @@ -38,7 +38,7 @@ namespace libcdoc {
*/
class CDOC_EXPORT CDocWriter {
public:
virtual ~CDocWriter();
virtual ~CDocWriter() noexcept;

/**
* @brief The container version (1 or 2)
Expand Down Expand Up @@ -154,6 +154,7 @@ class CDOC_EXPORT CDocWriter {
static CDocWriter *createWriter(int version, const std::string& path, Configuration *conf, CryptoBackend *crypto, NetworkBackend *network);
protected:
explicit CDocWriter(int _version, DataConsumer *dst, bool take_ownership);
CDOC_DISABLE_MOVE_COPY(CDocWriter);

void setLastError(const std::string& message) { last_error = message; }

Expand Down
2 changes: 1 addition & 1 deletion cdoc/CryptoBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <cdoc/CDoc.h>

#include <cstdint>
#include <vector>

namespace libcdoc {

Expand Down
1 change: 1 addition & 0 deletions cdoc/Io.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <vector>

namespace libcdoc {

Expand Down
6 changes: 0 additions & 6 deletions cdoc/KeyShares.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
#ifndef __KEYSHARES_H__
#define __KEYSHARES_H__

#include <cdoc/CryptoBackend.h>
#include <cdoc/NetworkBackend.h>
#include <cdoc/CDoc.h>

#include <cstdint>
#include <string>
#include <system_error>

namespace libcdoc {

Expand Down
3 changes: 1 addition & 2 deletions cdoc/ZStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef __ZSTREAM_H__
#define __ZSTREAM_H__

#include "Crypto.h"
#include "Io.h"

#include <zlib.h>
Expand Down Expand Up @@ -75,7 +74,7 @@ struct ZConsumer : public DataConsumer {
flush = Z_FINISH;
write (nullptr, 0);
deflateEnd(&_s);
if (_owned) return _dst->close();
return _owned ? _dst->close() : OK;
}
};

Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"features": {
"tests": { "description": "Build tests", "dependencies": ["boost-test"] }
},
"builtin-baseline": "425d0412a2c1d5f9a0071d77ccee88c96e0f70d0",
"builtin-baseline": "bc38a15b0bee8bc48a49ea267cc32fbb49aedfc4",
"vcpkg-configuration": {
"overlay-triplets": ["./vcpkg-triplets"],
"registries": [
Expand Down