Skip to content
14 changes: 8 additions & 6 deletions cdoc/NetworkBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@ rsa_sign(int type, const unsigned char *m, unsigned int m_len, unsigned char *si
}

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 @@ -747,8 +747,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 @@ -834,8 +835,9 @@ libcdoc::NetworkBackend::signMID(std::vector<uint8_t>& dst, std::vector<uint8_t>
std::string algo_name = algo_names[(int) algo];

// Generate code
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;

// etsi/PNOEE-01234567890
Expand Down
14 changes: 10 additions & 4 deletions cdoc/NetworkBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ struct CDOC_EXPORT NetworkBackend {
std::string password;
};

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

NetworkBackend() = default;
virtual ~NetworkBackend() noexcept = default;
NetworkBackend(const NetworkBackend&) = delete;
Expand Down Expand Up @@ -235,13 +240,14 @@ struct CDOC_EXPORT NetworkBackend {
}

/**
* @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