From 8e21b82ea11983b765d7cddee04f82f9f7e2894c Mon Sep 17 00:00:00 2001 From: Jeremie Corbier Date: Wed, 14 Feb 2024 11:24:23 +0100 Subject: [PATCH] drivers: versal: fix RSA driver 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: https://github.com/Xilinx/embeddedsw/commit/c2dd2eb Signed-off-by: Jeremie Corbier --- core/drivers/crypto/versal/rsa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/drivers/crypto/versal/rsa.c b/core/drivers/crypto/versal/rsa.c index 9457d5076ed..232c0dec62c 100644 --- a/core/drivers/crypto/versal/rsa.c +++ b/core/drivers/crypto/versal/rsa.c @@ -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); @@ -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);