U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pranav Rajendran <pranavkasthuri@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: trini@konsulko.com, sjg@chromium.org,
	philippe.reynes@softathome.com,
	Pranav Rajendran <pranavkasthuri@gmail.com>
Subject: [PATCH v2 4/5] include: u-boot: aes: make disabled cipher stubs static inline
Date: Tue, 25 Aug 2026 15:19:52 +0100	[thread overview]
Message-ID: <20260825141953.9534-5-pranavkasthuri@gmail.com> (raw)
In-Reply-To: <20260825141953.9534-1-pranavkasthuri@gmail.com>

image_aes_encrypt(), image_aes_add_cipher_data() and image_aes_decrypt()
are defined directly in this header, with full bodies rather than just
prototypes, whenever the corresponding IMAGE_ENABLE_ENCRYPT/DECRYPT
feature macro is 0. On target that is always the encrypt side, since
ciphering is host-tool only.

Those definitions have external linkage, so a second translation unit
including this header under the same disabled configuration collides
with the first at link time. Only boot/image-cipher.c currently
includes the header on target, so this has not been reachable before,
but it stops any other file - such as a unit test - from including it
too.

Make the disabled-path stubs static inline, as is conventional for
header-defined no-op fallbacks, so the header can be included from more
than one translation unit.

Signed-off-by: Pranav Rajendran <pranavkasthuri@gmail.com>
---
v2:
- New in v2. Needed by patch 5: the new fit_cipher test suite is a
  second translation unit including this header under the same
  disabled configuration, which failed to link before this change.

 include/u-boot/aes.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/u-boot/aes.h b/include/u-boot/aes.h
index acbc50b9e6f..d72322c1013 100644
--- a/include/u-boot/aes.h
+++ b/include/u-boot/aes.h
@@ -16,15 +16,16 @@ int image_aes_encrypt(struct image_cipher_info *info,
 int image_aes_add_cipher_data(struct image_cipher_info *info, void *keydest,
 			      void *fit, int node_noffset);
 #else
-int image_aes_encrypt(struct image_cipher_info *info,
-		      const unsigned char *data, int size,
-		      unsigned char **cipher, int *cipher_len)
+static inline int image_aes_encrypt(struct image_cipher_info *info,
+				    const unsigned char *data, int size,
+				    unsigned char **cipher, int *cipher_len)
 {
 	return -ENXIO;
 }
 
-int image_aes_add_cipher_data(struct image_cipher_info *info, void *keydest,
-			      void *fit, int node_noffset)
+static inline int image_aes_add_cipher_data(struct image_cipher_info *info,
+					    void *keydest, void *fit,
+					    int node_noffset)
 {
 	return -ENXIO;
 }
@@ -35,9 +36,9 @@ int image_aes_decrypt(struct image_cipher_info *info,
 		      const void *cipher, size_t cipher_len,
 		      void **data, size_t *size);
 #else
-int image_aes_decrypt(struct image_cipher_info *info,
-		      const void *cipher, size_t cipher_len,
-		      void **data, size_t *size)
+static inline int image_aes_decrypt(struct image_cipher_info *info,
+				    const void *cipher, size_t cipher_len,
+				    void **data, size_t *size)
 {
 	return -ENXIO;
 }
-- 
2.50.1 (Apple Git-155)


  parent reply	other threads:[~2026-08-25 16:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15 22:07 [PATCH v1 0/3] fit: cipher: bounds checks on the ciphered image path Pranav Rajendran
2026-08-15 22:07 ` [PATCH v1 1/3] lib: aes: reject a ciphertext length that is not a whole number of blocks Pranav Rajendran
2026-08-25 12:52   ` Simon Glass
2026-08-15 22:07 ` [PATCH v1 2/3] image-fit: check the length of the data-size-unciphered property Pranav Rajendran
2026-08-25 12:52   ` Simon Glass
2026-08-15 22:07 ` [PATCH v1 3/3] lib: aes: reject an unciphered size larger than the ciphertext Pranav Rajendran
2026-08-25 12:52   ` Simon Glass
2026-08-25 12:53 ` [v1,0/3] fit: cipher: bounds checks on the ciphered image path Simon Glass
2026-08-25 14:19 ` [PATCH v2 0/5] " Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 1/5] lib: aes: reject a ciphertext length that is not a whole number of blocks Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 2/5] image-fit: check the length of the data-size-unciphered property Pranav Rajendran
2026-08-25 14:19   ` [PATCH v2 3/5] lib: aes: reject an unciphered size larger than the ciphertext Pranav Rajendran
2026-08-25 14:19   ` Pranav Rajendran [this message]
2026-08-25 14:19   ` [PATCH v2 5/5] test: boot: add regression tests for the FIT cipher bounds checks Pranav Rajendran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260825141953.9534-5-pranavkasthuri@gmail.com \
    --to=pranavkasthuri@gmail.com \
    --cc=philippe.reynes@softathome.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox