Skip to content

Commit

Permalink
drivers: versal: fix RSA driver
Browse files Browse the repository at this point in the history
XilSecure has been updated to pack the public exponent right after the
modulus rather than at a fixed 512 bytes (RSA 4096 key size) offset. See
commit below for more details:

Xilinx/embeddedsw@c2dd2eb

Signed-off-by: Jeremie Corbier <jeremie.corbier@provenrun.com>
  • Loading branch information
jcorbier committed Jan 30, 2025
1 parent cd0b356 commit 8e21b82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/drivers/crypto/versal/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ static TEE_Result do_encrypt(struct drvcrypt_rsa_ed *rsa_data)
return ret;

crypto_bignum_bn2bin_pad(rsa_data->key.n_size, p->n, key.buf);
crypto_bignum_bn2bin_pad(RSA_MAX_PUB_EXP_LEN,
p->e, (uint8_t *)key.buf + RSA_MAX_MOD_LEN);
crypto_bignum_bn2bin_pad(RSA_MAX_PUB_EXP_LEN, p->e,
(uint8_t *)key.buf + rsa_data->key.n_size);

ret = versal_mbox_alloc(rsa_data->message.length,
rsa_data->message.data, &msg);
Expand Down Expand Up @@ -179,7 +179,7 @@ static TEE_Result do_decrypt(struct drvcrypt_rsa_ed *rsa_data)

crypto_bignum_bn2bin_pad(rsa_data->key.n_size, p->n, key.buf);
crypto_bignum_bn2bin_pad(rsa_data->key.n_size, p->d,
(uint8_t *)key.buf + RSA_MAX_MOD_LEN);
(uint8_t *)key.buf + rsa_data->key.n_size);

ret = versal_mbox_alloc(rsa_data->cipher.length, rsa_data->cipher.data,
&cipher);
Expand Down

0 comments on commit 8e21b82

Please sign in to comment.