Skip to content

Commit 3f01d7a

Browse files
committed
Clarify pin.reserve() comment, update extension submodule in mac/js
WE2-1007 Signed-off-by: Mart Somermaa <[email protected]>
1 parent 3ac0927 commit 3f01d7a

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/controller/command-handlers/authenticate.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,13 @@ QVariantMap Authenticate::onConfirm(WebEidUI* window,
124124
const auto signatureAlgorithm =
125125
QString::fromStdString(cardCertAndPin.cardInfo->eid().authSignatureAlgorithm());
126126
pcsc_cpp::byte_vector pin;
127-
pin.reserve(5 + 16); // Avoid realloc: apdu + pin padding
127+
// Reserve space for APDU overhead (5 bytes) + PIN padding (16 bytes) to prevent PIN memory
128+
// reallocation. The 16-byte limit comes from the max PIN length of 12 bytes across all card
129+
// implementations in lib/libelectronic-id/src/electronic-ids/pcsc/.
130+
pin.reserve(5 + 16);
128131
getPin(pin, cardCertAndPin.cardInfo->eid(), window);
129-
const auto signature =
130-
createSignature(origin.url(), challengeNonce, cardCertAndPin.cardInfo->eid(), std::move(pin));
132+
const auto signature = createSignature(origin.url(), challengeNonce,
133+
cardCertAndPin.cardInfo->eid(), std::move(pin));
131134
return createAuthenticationToken(signatureAlgorithm, cardCertAndPin.certificateBytesInDer,
132135
signature);
133136

src/controller/command-handlers/sign.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ QVariantMap Sign::onConfirm(WebEidUI* window, const CardCertificateAndPinInfo& c
9999
{
100100
try {
101101
pcsc_cpp::byte_vector pin;
102-
pin.reserve(5 + 16); // Avoid realloc: apdu + pin padding
102+
// Reserve space for APDU overhead (5 bytes) + PIN padding (16 bytes) to prevent PIN memory
103+
// reallocation. The 16-byte limit comes from the max PIN length of 12 bytes across all card
104+
// implementations in lib/libelectronic-id/src/electronic-ids/pcsc/.
105+
pin.reserve(5 + 16);
103106
getPin(pin, cardCertAndPin.cardInfo->eid(), window);
104-
const auto signature = signHash(cardCertAndPin.cardInfo->eid(), std::move(pin), docHash, hashAlgo);
107+
const auto signature =
108+
signHash(cardCertAndPin.cardInfo->eid(), std::move(pin), docHash, hashAlgo);
105109
return {{QStringLiteral("signature"), signature.first},
106110
{QStringLiteral("signatureAlgorithm"), signature.second}};
107111

0 commit comments

Comments
 (0)