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

[0.25] pkcs15-crypt: Use correct PKCS#1 v1.5 padding type #3172

Open
wants to merge 1 commit into
base: stable-0.25
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
pkcs15-crypt: Use correct PKCS#1 v1.5 padding type
  • Loading branch information
xhanulik authored and kunkku committed Jun 5, 2024
commit 4e1375284baef8d8d14494401ec2d5159471a653
10 changes: 6 additions & 4 deletions src/tools/pkcs15-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int sign(struct sc_pkcs15_object *obj)
{
u8 buf[1024], out[1024];
struct sc_pkcs15_prkey_info *key = (struct sc_pkcs15_prkey_info *) obj->data;
int r;
int r, flags;
size_t c, len;

if (opt_input == NULL) {
Expand All @@ -238,7 +238,8 @@ static int sign(struct sc_pkcs15_object *obj)
return SC_ERROR_NOT_SUPPORTED;
}

r = sc_pkcs15_compute_signature(p15card, obj, opt_crypt_flags, buf, c, out, len, NULL);
flags = opt_crypt_flags & ~SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
r = sc_pkcs15_compute_signature(p15card, obj, flags, buf, c, out, len, NULL);
if (r < 0) {
fprintf(stderr, "Compute signature failed: %s\n", sc_strerror(r));
return 1;
Expand Down Expand Up @@ -270,7 +271,7 @@ static int sign(struct sc_pkcs15_object *obj)
static int decipher(struct sc_pkcs15_object *obj)
{
u8 buf[1024], out[1024];
int r, len;
int r, len, flags;
size_t c;

if (opt_input == NULL) {
Expand All @@ -286,7 +287,8 @@ static int decipher(struct sc_pkcs15_object *obj)
return SC_ERROR_NOT_SUPPORTED;
}

r = sc_pkcs15_decipher(p15card, obj, opt_crypt_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02, buf, c, out, len, NULL);
flags = opt_crypt_flags & ~SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01;
r = sc_pkcs15_decipher(p15card, obj, flags, buf, c, out, len, NULL);
if (r < 0) {
fprintf(stderr, "Decrypt failed: %s\n", sc_strerror(r));
return 1;
Expand Down
Loading