Skip to content

Commit

Permalink
Merge pull request #343 from Yubico/format-errors
Browse files Browse the repository at this point in the history
Fix format errors on 32-bit
  • Loading branch information
qpernil authored Dec 19, 2021
2 parents 0608fd5 + 8962c37 commit 9291c78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions ykcs11/mechanisms.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ CK_RV sign_mechanism_final(ykcs11_session_t *session, CK_BYTE_PTR sig, CK_ULONG_
size_t siglen = sizeof(sigbuf);
ykpiv_rc rcc = ykpiv_sign_data(session->slot->piv_state, session->op_info.buf, session->op_info.buf_len, sigbuf, &siglen, session->op_info.op.sign.algorithm, session->op_info.op.sign.piv_key);
if(rcc == YKPIV_OK) {
DBG("ykpiv_sign_data %lu bytes with key %x returned %lu bytes data", session->op_info.buf_len, session->op_info.op.sign.piv_key, siglen);
DBG("ykpiv_sign_data %lu bytes with key %x returned %zu bytes data", session->op_info.buf_len, session->op_info.op.sign.piv_key, siglen);
} else {
DBG("ykpiv_sign_data with key %x failed: %s", session->op_info.op.sign.piv_key, ykpiv_strerror(rcc));
return rcc == YKPIV_AUTHENTICATION_ERROR ? CKR_USER_NOT_LOGGED_IN : CKR_DEVICE_ERROR;
Expand All @@ -306,7 +306,7 @@ CK_RV sign_mechanism_final(ykcs11_session_t *session, CK_BYTE_PTR sig, CK_ULONG_
switch(session->op_info.op.sign.algorithm) {
case YKPIV_ALGO_ECCP256:
case YKPIV_ALGO_ECCP384:
DBG("Stripping DER encoding from %lu bytes, returning %lu", siglen, session->op_info.out_len);
DBG("Stripping DER encoding from %zu bytes, returning %lu", siglen, session->op_info.out_len);
rv = do_strip_DER_encoding_from_ECSIG(sigbuf, siglen, session->op_info.out_len);
siglen = session->op_info.out_len;
break;
Expand Down Expand Up @@ -835,7 +835,7 @@ CK_RV digest_mechanism_update(ykcs11_session_t *session, CK_BYTE_PTR in, CK_ULON
}
} else {
if(session->op_info.buf_len + in_len > sizeof(session->op_info.buf)) {
DBG("Too much data added to operation buffer, max is %lu bytes", sizeof(session->op_info.buf));
DBG("Too much data added to operation buffer, max is %zu bytes", sizeof(session->op_info.buf));
return CKR_DATA_LEN_RANGE;
}
memcpy(session->op_info.buf + session->op_info.buf_len, in, in_len);
Expand Down
14 changes: 7 additions & 7 deletions ykcs11/ykcs11.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void cleanup_session(ykcs11_session_t *session) {
}

static void cleanup_slot(ykcs11_slot_t *slot) {
DBG("Cleaning up slot %lu", slot - slots);
DBG("Cleaning up slot %td", slot - slots);
for(size_t i = 0; i < sizeof(slot->data) / sizeof(slot->data[0]); i++) {
free(slot->data[i].data);
slot->data[i].data = NULL;
Expand Down Expand Up @@ -384,7 +384,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetSlotList)(

// Initialize piv_state and increase slot count if this is a new slot
if(slot == slots + n_slots) {
DBG("Initializing slot %lu for '%s'", slot-slots, reader);
DBG("Initializing slot %td for '%s'", slot-slots, reader);
ykpiv_rc rc;
if((rc = ykpiv_init(&slot->piv_state, verbose)) != YKPIV_OK) {
DBG("Unable to initialize libykpiv: %s", ykpiv_strerror(rc));
Expand All @@ -406,7 +406,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetSlotList)(

if (ykpiv_connect(slot->piv_state, buf) == YKPIV_OK) {

DBG("Connected slot %lu to '%s'", slot-slots, reader);
DBG("Connected slot %td to '%s'", slot-slots, reader);

slot->slot_info.flags |= CKF_TOKEN_PRESENT;
slot->token_info.flags = CKF_RNG | CKF_LOGIN_REQUIRED | CKF_USER_PIN_INITIALIZED | CKF_TOKEN_INITIALIZED;
Expand Down Expand Up @@ -974,7 +974,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_OpenSession)(
DBG("Failed to create attestation for object %u slot %lx: %s", pvtk_id, slot, ykpiv_strerror(rc));
len = sizeof(data);
if((rc = ykpiv_get_metadata(session->slot->piv_state, slot, data, &len)) == YKPIV_OK) {
DBG("Fetched %lu bytes metadata for object %u slot %lx", len, pvtk_id, slot);
DBG("Fetched %zu bytes metadata for object %u slot %lx", len, pvtk_id, slot);
ykpiv_metadata md = {0};
if((rc = ykpiv_util_parse_metadata(data, len, &md)) == YKPIV_OK) {
if((rv = do_create_public_key(md.pubkey, md.pubkey_len, md.algorithm, &session->slot->pkeys[sub_id])) == CKR_OK) {
Expand Down Expand Up @@ -2137,7 +2137,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_EncryptUpdate)(
}

if(session->op_info.buf_len + ulPartLen > sizeof(session->op_info.buf)) {
DBG("Too much data added to operation buffer, max is %lu bytes", sizeof(session->op_info.buf));
DBG("Too much data added to operation buffer, max is %zu bytes", sizeof(session->op_info.buf));
rv = CKR_DATA_LEN_RANGE;
goto encupdate_out;
}
Expand Down Expand Up @@ -2351,7 +2351,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_Decrypt)(
DBG("Using slot %x to decrypt %lu bytes", session->op_info.op.encrypt.piv_key, ulEncryptedDataLen);

if(ulEncryptedDataLen > sizeof(session->op_info.buf)) {
DBG("Too much data added to operation buffer, max is %lu bytes", sizeof(session->op_info.buf));
DBG("Too much data added to operation buffer, max is %zu bytes", sizeof(session->op_info.buf));
rv = CKR_DATA_LEN_RANGE;
goto decrypt_out;
}
Expand Down Expand Up @@ -2421,7 +2421,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_DecryptUpdate)(
DBG("Adding %lu bytes to be decrypted", ulEncryptedPartLen);

if(session->op_info.buf_len + ulEncryptedPartLen > sizeof(session->op_info.buf)) {
DBG("Too much data added to operation buffer, max is %lu bytes", sizeof(session->op_info.buf));
DBG("Too much data added to operation buffer, max is %zu bytes", sizeof(session->op_info.buf));
rv = CKR_DATA_LEN_RANGE;
goto decrypt_out;
}
Expand Down

0 comments on commit 9291c78

Please sign in to comment.