]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
lib: rsa: Fix const-correctness of rsassa_pss functions
authorSESA644425 <giojahermann@gmail.com>
Wed, 9 Mar 2022 09:27:15 +0000 (01:27 -0800)
committerTom Rini <trini@konsulko.com>
Mon, 11 Apr 2022 15:39:19 +0000 (11:39 -0400)
Prior to introduction of modifications in rsassa_pss functions
related to padding verification, doing a pass to update
const-correctness in targeted functions to comply with
coding-rules and avoid const-cast

Signed-off-by: SESA644425 <gioja.hermann@non.se.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
include/image.h
include/u-boot/rsa.h
lib/rsa/rsa-verify.c

index 673b5f55eca36c7fc1d5a2c6d70be90a01f7ba65..e4c6a50b885ffc603b45ae37ecd5f3541395d6cd 100644 (file)
@@ -1309,7 +1309,7 @@ ll_entry_declare(struct crypto_algo, __name, cryptos)
 struct padding_algo {
        const char *name;
        int (*verify)(struct image_sign_info *info,
-                     uint8_t *pad, int pad_len,
+                     const uint8_t *pad, int pad_len,
                      const uint8_t *hash, int hash_len);
 };
 
index b9634e38d9a92eb3f025483d2f2930c124e1d6ea..085363eb1e5eafefa6cdd6e27073e65d27f02339 100644 (file)
@@ -101,11 +101,11 @@ int rsa_verify_with_pkey(struct image_sign_info *info,
                         const void *hash, uint8_t *sig, uint sig_len);
 
 int padding_pkcs_15_verify(struct image_sign_info *info,
-                          uint8_t *msg, int msg_len,
+                          const uint8_t *msg, int msg_len,
                           const uint8_t *hash, int hash_len);
 
 int padding_pss_verify(struct image_sign_info *info,
-                      uint8_t *msg, int msg_len,
+                      const uint8_t *msg, int msg_len,
                       const uint8_t *hash, int hash_len);
 
 #define RSA_DEFAULT_PADDING_NAME               "pkcs-1.5"
index 112664059c9f15466f5ad61d4c703ef383e3b3fa..c2c7248f902486d80523a649dca9329ab4f9f818 100644 (file)
@@ -73,7 +73,7 @@ static int rsa_verify_padding(const uint8_t *msg, const int pad_len,
 }
 
 int padding_pkcs_15_verify(struct image_sign_info *info,
-                          uint8_t *msg, int msg_len,
+                          const uint8_t *msg, int msg_len,
                           const uint8_t *hash, int hash_len)
 {
        struct checksum_algo *checksum = info->checksum;
@@ -125,7 +125,7 @@ static void u32_i2osp(uint32_t val, uint8_t *buf)
  * Return: 0 if the octet string was correctly generated, others on error
  */
 static int mask_generation_function1(struct checksum_algo *checksum,
-                                    uint8_t *seed, int seed_len,
+                                    const uint8_t *seed, int seed_len,
                                     uint8_t *output, int output_len)
 {
        struct image_region region[2];
@@ -176,9 +176,9 @@ out:
 }
 
 static int compute_hash_prime(struct checksum_algo *checksum,
-                             uint8_t *pad, int pad_len,
-                             uint8_t *hash, int hash_len,
-                             uint8_t *salt, int salt_len,
+                             const uint8_t *pad, int pad_len,
+                             const uint8_t *hash, int hash_len,
+                             const uint8_t *salt, int salt_len,
                              uint8_t *hprime)
 {
        struct image_region region[3];
@@ -215,7 +215,7 @@ out:
  * @hash_len:  Length of the hash
  */
 int padding_pss_verify(struct image_sign_info *info,
-                      uint8_t *msg, int msg_len,
+                      const uint8_t *msg, int msg_len,
                       const uint8_t *hash, int hash_len)
 {
        uint8_t *masked_db = NULL;
@@ -287,7 +287,7 @@ int padding_pss_verify(struct image_sign_info *info,
 
        /* step 12 & 13 */
        compute_hash_prime(checksum, pad_zero, 8,
-                          (uint8_t *)hash, hash_len,
+                          hash, hash_len,
                           salt, salt_len, hprime);
 
        /* step 14 */