Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1b76e52
Added CDocV1 tests
Jan 9, 2026
7a2b181
Added CDoc1 tests and cleaned up testing
Jan 9, 2026
2629756
More CDocCipher cleanups
Jan 13, 2026
4febb5c
Fix windows build
Jan 13, 2026
dd2cf68
Fix initializer order for gcc
Jan 13, 2026
5e4e80f
Use again absolute paths for tests
Jan 13, 2026
bb66be5
Create test tmp path if not exist
Jan 13, 2026
a4efe25
Change SID/MID callback signature to handle QR codes
Jan 14, 2026
0cab1cb
Apply suggestions from code review
lauris71 Jan 14, 2026
0da1fd8
Update cdoc/cdoc-tool.cpp
lauris71 Jan 14, 2026
75d1101
Update cdoc/cdoc-tool.cpp
lauris71 Jan 14, 2026
5b32d9f
Merge branch 'open-eid:master' into master
lauris71 Jan 14, 2026
87e5493
Merge branch 'master' into sid2
Jan 14, 2026
53a6898
Some fixes from ai security audit
May 20, 2026
47715fe
Fixed cdoc-tool index usage
May 22, 2026
fef2389
Update cdoc/cdoc-tool.cpp
lauris71 May 25, 2026
8848542
Update cdoc/cdoc-tool.cpp
lauris71 May 25, 2026
bf5ca62
Some more AI issue fixes
May 26, 2026
0a6b12b
Hardcode SSL timeout
May 27, 2026
a4dafb9
Fixed xstream uint overflow and tool logging
May 27, 2026
8c9b789
Some more fixes
May 27, 2026
e9a8a6e
Secure tool key handling, use explicid compile time definitions for k…
May 27, 2026
fa288ee
Fixed potential tar size overflow and secured proxy password
May 27, 2026
b89e4f1
Windows build fix
May 27, 2026
d0e0c90
Revert proxy password for now
May 27, 2026
87d1547
Make proxy password string_view
May 29, 2026
3631991
Disable potential Bleichenbacher attack for CDoc1 RSA encryption
Jun 1, 2026
7e6cdaa
Moved fix to main decryptRSA method
Jun 1, 2026
f01510a
Added ct.h
Jun 1, 2026
0aec4a1
Bleichenbacher fix for NCrypt backend
Jun 1, 2026
6f37761
Some cleanups
Jun 1, 2026
cc19133
All C,H & M fixes from Caludo Opus review
Jun 5, 2026
6bd12a8
Merge branch 'open-eid:master' into master
lauris71 Jun 5, 2026
8102224
Update cdoc-tool
Jun 5, 2026
c3d8dd2
Merge branch 'open-eid:master' into master
lauris71 Jun 11, 2026
bb9945c
Merge branch 'master' into ai-security
Jun 11, 2026
08ca9e5
Make default KDF iter 600000
Jun 11, 2026
004ce57
Added std_string_view.i
Jun 16, 2026
212825a
Fixed label parsing on Ubuntu 22
Jun 16, 2026
6db3372
Include <string.h>
Jun 17, 2026
8a2f494
Use explicit_bzero on glibc
Jun 17, 2026
573f147
Use SecureZeroMemory on windows
Jun 17, 2026
2d552cb
Use OPENSSL_cleanse for secure cleanup
Jun 17, 2026
f63ed77
Fixed inverted constant-time comparison
Jun 17, 2026
a6fc79a
Merge branch 'open-eid:master' into master
lauris71 Jun 17, 2026
88f1fa7
Merge commit 'a6fc79ad2e3c4d9d34157742f84db1c0c25faca3' into ai-security
Jun 17, 2026
578ff3a
Merge branch 'ai-security' into sid2
Jul 2, 2026
eb091c3
Fix build for SIDMID
Jul 2, 2026
3641679
Fix share encryption
Jul 3, 2026
68cc522
Merge branch 'open-eid:master' into master
lauris71 Jul 3, 2026
32995f7
Merge branch 'master' into sid2
Jul 3, 2026
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
9 changes: 8 additions & 1 deletion cdoc/CDoc2Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ CDoc2Writer::buildHeader(std::vector<uint8_t>& header, const std::vector<libcdoc
std::vector<std::vector<uint8_t>> transaction_ids(N_SHARES);
for (int i = 0; i < N_SHARES; i++) {
std::string send_url = urls[i];
LOG_TRACE_KEY("Sending share: {} {} {}", i, send_url, libcdoc::toHex(kek_shares[i]));
int result = network->sendShare(transaction_ids[i], send_url, RecipientInfo_i, kek_shares[i]);
if (result < 0)
FAIL(network->getLastErrorStr(result), result);
Expand Down Expand Up @@ -479,6 +478,14 @@ CDoc2Writer::addRecipient(const libcdoc::Recipient& rcpt)
if(!rcpt.validate())
FAIL("Invalid recipient parameters", libcdoc::WRONG_ARGUMENTS);
break;
#ifdef HAS_KEYSHARES
case Recipient::KEYSHARE:
if (!network)
FAIL("KeyShares require NetworkBackend", libcdoc::WORKFLOW_ERROR);
if (!rcpt.validate())
FAIL("Invalid recipient parameters", libcdoc::WRONG_ARGUMENTS);
break;
#endif
default:
FAIL("Invalid recipient type", WRONG_ARGUMENTS);
}
Expand Down
2 changes: 1 addition & 1 deletion cdoc/CDocCipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct ToolPKCS11 : public libcdoc::PKCS11Backend {
ToolPKCS11(const std::string& library, const CipherInfo& info) : PKCS11Backend(library), c_info(info) {}

libcdoc::result_t connectToKey(int idx, bool priv) override final {
const libcdoc::RcptInfo *rcpt = c_info.getRcpt(idx);
const libcdoc::RcptInfo *rcpt = c_info.getRcpt(idx);
if (!rcpt) return libcdoc::INTERNAL_ERROR;
if (!priv) {
return useSecretKey(long(rcpt->p11.slot), rcpt->secret, rcpt->p11.key_id, rcpt->p11.key_label);
Expand Down
8 changes: 8 additions & 0 deletions cdoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ add_library(cdoc
CDoc2Writer.cpp CDoc2Writer.h
DDocReader.cpp DDocReader.h
DDocWriter.cpp DDocWriter.h
KeyShares.cpp KeyShares.h
# KeyShares.cpp KeyShares.h
XmlReader.cpp XmlReader.h
XmlWriter.cpp XmlWriter.h
Expand Down Expand Up @@ -79,6 +80,9 @@ target_include_directories(cdoc PUBLIC
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)

# Enable SID/MID
target_compile_definitions(cdoc PRIVATE HAS_KEYSHARES)

if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(cdoc PUBLIC cdoc_STATIC)
endif()
Expand All @@ -102,6 +106,10 @@ target_link_libraries(cdoc PRIVATE
if(BUILD_TOOLS)
add_executable(cdoc-tool cdoc-tool.cpp)
target_include_directories(cdoc-tool PRIVATE ${OPENSSL_INCLUDE_DIR})

# Enable SID/MID
target_compile_definitions(cdoc-tool PRIVATE HAS_KEYSHARES)

target_link_libraries(cdoc-tool cdoc_ver cdoc OpenSSL::SSL)
target_link_options(cdoc-tool PRIVATE
$<$<PLATFORM_ID:Windows>: /MANIFEST:NO /MANIFEST:EMBED /MANIFESTINPUT:${CMAKE_CURRENT_SOURCE_DIR}/cdoc-tool.manifest>
Expand Down
22 changes: 15 additions & 7 deletions cdoc/NetworkBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ libcdoc::NetworkBackend::fetchKey (std::vector<uint8_t>& dst, const std::string&
}

#ifdef HAS_KEYSHARES
libcdoc::result_t
libcdoc::NetworkBackend::authenticateForShares(std::vector<uint8_t>& dst)
{
return NOT_IMPLEMENTED;
}

libcdoc::result_t
libcdoc::NetworkBackend::fetchNonce(std::vector<uint8_t>& dst, const std::string& url, const std::string& share_id)
{
Expand Down Expand Up @@ -608,9 +614,9 @@ rsa_sign(int type, const unsigned char *m, unsigned int m_len, unsigned char *si

#ifdef HAS_KEYSHARES
libcdoc::result_t
libcdoc::NetworkBackend::showVerificationCode(unsigned int code)
libcdoc::NetworkBackend::showFeedback(SIDMIDFeedback& feedback)
{
LOG_INFO("Verification code: {:04d}", code);
LOG_INFO("Verification code: {:04d} url: {}", feedback.code, feedback.url);
return OK;
}

Expand Down Expand Up @@ -836,8 +842,9 @@ libcdoc::NetworkBackend::signSID(std::vector<uint8_t>& dst, std::vector<uint8_t>
// Generate code
uint8_t b[32];
SHA256(digest.data(), digest.size(), b);
unsigned int code = ((b[30] << 8) | b[31]) % 10000;
result = showVerificationCode(code);
SIDMIDFeedback fb;
fb.code = ((b[30] << 8) | b[31]) % 10000;
result = showFeedback(fb);
if (result != OK) return result;

picojson::object aio1 = {
Expand Down Expand Up @@ -962,8 +969,9 @@ libcdoc::NetworkBackend::signMID(std::vector<uint8_t>& dst, std::vector<uint8_t>
}

// Generate verification code. digest is guaranteed non-empty above.
unsigned int code = (((digest[0] & 0xfc) << 5) | (digest[digest.size() - 1] & 0x7f));
result = showVerificationCode(code);
SIDMIDFeedback fb;
fb.code = (((digest[0] & 0xfc) << 5) | (digest[digest.size() - 1] & 0x7f));
result = showFeedback(fb);
if (result != OK) return result;

picojson::object qobj = {
Expand Down Expand Up @@ -991,7 +999,7 @@ libcdoc::NetworkBackend::signMID(std::vector<uint8_t>& dst, std::vector<uint8_t>
LOG_DBG("Response: {}", rsp.body);

picojson::value v;
parse_err = picojson::parse(v, rsp.body);
std::string parse_err = picojson::parse(v, rsp.body);
if (!parse_err.empty()) {
error = FORMAT("JSON parse error: {}", parse_err);
LOG_ERROR("{}", error);
Expand Down
15 changes: 11 additions & 4 deletions cdoc/NetworkBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ struct CDOC_EXPORT NetworkBackend {
std::string_view password;
};

struct SIDMIDFeedback {
int code;
std::string url;
};

NetworkBackend() = default;
virtual ~NetworkBackend() noexcept = default;
NetworkBackend(const NetworkBackend&) = delete;
Expand Down Expand Up @@ -176,6 +181,7 @@ struct CDOC_EXPORT NetworkBackend {
*/
virtual result_t fetchKey (std::vector<uint8_t>& dst, const std::string& url, const std::string& transaction_id);
#ifdef HAS_KEYSHARES
virtual result_t authenticateForShares(std::vector<uint8_t>& dst);
/**
* @brief fetch authentication nonce from share server
* @param dst a destination container for nonce
Expand Down Expand Up @@ -245,13 +251,14 @@ struct CDOC_EXPORT NetworkBackend {

#ifdef HAS_KEYSHARES
/**
* @brief show MID/SID verification code
* @brief show MID/SID verification code or QR code
*
* Show SID/MID verification code or QR code. The default implementation logs the content with level INFO.
*
* Show SID/MID verification code. The default implementation logs it with level INFO.
* @param code verification code
* @param feedback SID/MID feedback data
* @return error code or OK
*/
virtual result_t showVerificationCode(unsigned int code);
virtual result_t showFeedback(SIDMIDFeedback& feedback);

/**
* @brief Sign digest with SmartID authentication key
Expand Down
5 changes: 5 additions & 0 deletions cdoc/Recipient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ Recipient::validate() const
case PUBLIC_KEY:
// Public key should not be empty
return !rcpt_key.empty();
#ifdef HAS_KEYSHARES
case KEYSHARE:
// Server ID and recipient ID should not be empty
return !server_id.empty() && !id.empty();
#endif
default:
return false;
}
Expand Down
Loading