Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ta: pkcs11: fix CKM_RSA_X_509 signature size verification #7179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
16 changes: 9 additions & 7 deletions ta/pkcs11/src/processing_asymm.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,14 +899,16 @@ enum pkcs11_rc step_asymm_operation(struct pkcs11_session *session,
tee_attrs, tee_attrs_count,
in_buf, in_size,
temp_buf, &temp_size);
if (!res && temp_size != sz) {
EMSG("CMK_RSA_X509: signature size %zu != %zu",
temp_size, sz);
rc = PKCS11_CKR_DATA_INVALID;
break;
}
if (!res) {
TEE_MemMove(out_buf, temp_buf, sz);
/*
* Raw RSA decryption may remove some
* leading nul bytes as done by rsadorep()
* (lib/libtomcrypt/rsa.c). Restore them to
* reach target signature size.
*/
TEE_MemFill(out_buf, 0, sz - temp_size);
TEE_MemMove((uint8_t *)out_buf + sz - temp_size,
temp_buf, temp_size);
TEE_MemFill(temp_buf, 0xa5, sz);
}
output_data = true;
Expand Down
Loading