Skip to content

Commit 985e226

Browse files
authored
Merge branch 'open-eid:master' into master
2 parents 252333f + a03401c commit 985e226

File tree

12 files changed

+113
-40
lines changed

12 files changed

+113
-40
lines changed

cdoc/CDoc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ libcdoc::CDocWriter::CDocWriter(int _version, DataConsumer *_dst, bool take_owne
200200
{
201201
};
202202

203-
libcdoc::CDocWriter::~CDocWriter()
203+
libcdoc::CDocWriter::~CDocWriter() noexcept
204204
{
205205
if (owned) delete(dst);
206206
}

cdoc/CDoc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
#include "Exports.h"
2323

24+
#include <cstdint>
2425
#include <string>
25-
#include <vector>
2626

2727
namespace libcdoc {
2828

2929
/**
3030
* @brief A typedef that indicates that integer value may contain libcdoc result code
3131
*/
32-
typedef int64_t result_t;
32+
using result_t = int64_t;
3333

3434
enum {
3535
/**
@@ -134,7 +134,7 @@ CDOC_EXPORT std::string getVersion();
134134
/**
135135
* @brief Log-level enumeration to indicate severity of the log message.
136136
*/
137-
enum LogLevel
137+
enum LogLevel : uint8_t
138138
{
139139
/**
140140
* @brief Most critical level. Application is about to abort.

cdoc/CDoc2Reader.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "Certificate.h"
2222
#include "Configuration.h"
23+
#include "Crypto.h"
2324
#include "CryptoBackend.h"
2425
#include "CDoc2.h"
2526
#include "KeyShares.h"
@@ -400,7 +401,7 @@ CDoc2Reader::beginDecryption(const std::vector<uint8_t>& fmk)
400401
return libcdoc::WRONG_ARGUMENTS;
401402
}
402403
if (!priv->_at_nonce) {
403-
int result = priv->_src->seek(priv->_nonce_pos);
404+
result_t result = priv->_src->seek(priv->_nonce_pos);
404405
if (result != libcdoc::OK) {
405406
setLastError(priv->_src->getLastErrorStr(result));
406407
LOG_ERROR("{}", last_error);
@@ -697,14 +698,3 @@ CDoc2Reader::isCDoc2File(libcdoc::DataSource *src)
697698
}
698699
return true;
699700
}
700-
701-
bool
702-
CDoc2Reader::isCDoc2File(const std::string& path)
703-
{
704-
std::ifstream fb(path, std::ios_base::in | std::ios_base::binary);
705-
char in[libcdoc::CDoc2::LABEL.size()];
706-
constexpr size_t len = libcdoc::CDoc2::LABEL.size();
707-
if (!fb.read(&in[0], len) || (fb.gcount() != len)) return false;
708-
if (libcdoc::CDoc2::LABEL.compare(0, len, &in[0], len)) return false;
709-
return true;
710-
}

cdoc/CDoc2Reader.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ class CDoc2Reader final: public libcdoc::CDocReader {
2727
public:
2828
~CDoc2Reader() final;
2929

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

3535
// Pull interface
36-
libcdoc::result_t beginDecryption(const std::vector<uint8_t>& fmk) override final;
37-
libcdoc::result_t nextFile(std::string& name, int64_t& size) override final;
38-
libcdoc::result_t readData(uint8_t *dst, size_t size) override final;
39-
libcdoc::result_t finishDecryption() override final;
36+
libcdoc::result_t beginDecryption(const std::vector<uint8_t>& fmk) final;
37+
libcdoc::result_t nextFile(std::string& name, int64_t& size) final;
38+
libcdoc::result_t readData(uint8_t *dst, size_t size) final;
39+
libcdoc::result_t finishDecryption() final;
4040

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

43-
static bool isCDoc2File(const std::string& path);
4443
static bool isCDoc2File(libcdoc::DataSource *src);
4544
private:
46-
struct Private;
45+
CDOC_DISABLE_MOVE_COPY(CDoc2Reader);
4746

47+
struct Private;
4848
std::unique_ptr<Private> priv;
4949
};
5050

cdoc/CDocReader.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "CDoc.h"
2323

24-
#include <cstdint>
24+
#include <vector>
2525

2626
namespace libcdoc {
2727

@@ -39,7 +39,7 @@ struct NetworkBackend;
3939
*/
4040
class CDOC_EXPORT CDocReader {
4141
public:
42-
virtual ~CDocReader() = default;
42+
virtual ~CDocReader() noexcept = default;
4343

4444
/**
4545
* @brief The container version (1 or 2)
@@ -210,6 +210,9 @@ class CDOC_EXPORT CDocReader {
210210
Configuration *conf = nullptr;
211211
CryptoBackend *crypto = nullptr;
212212
NetworkBackend *network = nullptr;
213+
214+
private:
215+
CDOC_DISABLE_MOVE_COPY(CDocReader);
213216
};
214217

215218
} // namespace libcdoc

cdoc/CDocWriter.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "CDoc.h"
2323

24-
#include <cstdint>
24+
#include <vector>
2525

2626
namespace libcdoc {
2727
struct Configuration;
@@ -38,7 +38,7 @@ namespace libcdoc {
3838
*/
3939
class CDOC_EXPORT CDocWriter {
4040
public:
41-
virtual ~CDocWriter();
41+
virtual ~CDocWriter() noexcept;
4242

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

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

cdoc/CryptoBackend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <cdoc/CDoc.h>
2323

24-
#include <cstdint>
24+
#include <vector>
2525

2626
namespace libcdoc {
2727

cdoc/Io.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <algorithm>
2525
#include <filesystem>
2626
#include <fstream>
27+
#include <vector>
2728

2829
namespace libcdoc {
2930

cdoc/KeyShares.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@
1919
#ifndef __KEYSHARES_H__
2020
#define __KEYSHARES_H__
2121

22-
#include <cdoc/CryptoBackend.h>
2322
#include <cdoc/NetworkBackend.h>
24-
#include <cdoc/CDoc.h>
25-
26-
#include <cstdint>
27-
#include <string>
28-
#include <system_error>
2923

3024
namespace libcdoc {
3125

cdoc/ZStream.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#ifndef __ZSTREAM_H__
2020
#define __ZSTREAM_H__
2121

22-
#include "Crypto.h"
2322
#include "Io.h"
2423

2524
#include <zlib.h>
@@ -75,7 +74,7 @@ struct ZConsumer : public DataConsumer {
7574
flush = Z_FINISH;
7675
write (nullptr, 0);
7776
deflateEnd(&_s);
78-
if (_owned) return _dst->close();
77+
return _owned ? _dst->close() : OK;
7978
}
8079
};
8180

0 commit comments

Comments
 (0)