mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
rsa: add a structure for the padding
The rsa signature use a padding algorithm. By default, we use the padding pkcs-1.5. In order to add some new padding algorithm, we add a padding framework to manage several padding algorithm. The choice of the padding is done in the file .its. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Tom Rini
parent
3b5d6979fc
commit
20031567e1
@@ -387,11 +387,13 @@ static void rsa_engine_remove(ENGINE *e)
|
||||
}
|
||||
}
|
||||
|
||||
static int rsa_sign_with_key(RSA *rsa, struct checksum_algo *checksum_algo,
|
||||
static int rsa_sign_with_key(RSA *rsa, struct padding_algo *padding_algo,
|
||||
struct checksum_algo *checksum_algo,
|
||||
const struct image_region region[], int region_count,
|
||||
uint8_t **sigp, uint *sig_size)
|
||||
{
|
||||
EVP_PKEY *key;
|
||||
EVP_PKEY_CTX *ckey;
|
||||
EVP_MD_CTX *context;
|
||||
int ret = 0;
|
||||
size_t size;
|
||||
@@ -422,7 +424,14 @@ static int rsa_sign_with_key(RSA *rsa, struct checksum_algo *checksum_algo,
|
||||
goto err_create;
|
||||
}
|
||||
EVP_MD_CTX_init(context);
|
||||
if (EVP_DigestSignInit(context, NULL,
|
||||
|
||||
ckey = EVP_PKEY_CTX_new(key, NULL);
|
||||
if (!ckey) {
|
||||
ret = rsa_err("EVP key context creation failed");
|
||||
goto err_create;
|
||||
}
|
||||
|
||||
if (EVP_DigestSignInit(context, &ckey,
|
||||
checksum_algo->calculate_sign(),
|
||||
NULL, key) <= 0) {
|
||||
ret = rsa_err("Signer setup failed");
|
||||
@@ -488,7 +497,7 @@ int rsa_sign(struct image_sign_info *info,
|
||||
ret = rsa_get_priv_key(info->keydir, info->keyname, e, &rsa);
|
||||
if (ret)
|
||||
goto err_priv;
|
||||
ret = rsa_sign_with_key(rsa, info->checksum, region,
|
||||
ret = rsa_sign_with_key(rsa, info->padding, info->checksum, region,
|
||||
region_count, sigp, sig_len);
|
||||
if (ret)
|
||||
goto err_sign;
|
||||
|
Reference in New Issue
Block a user