lib: ecdsa: Add support for loading ECDSA public key from FDT
authorJamin Lin <jamin_lin@aspeedtech.com>
Fri, 6 Jun 2025 07:34:21 +0000 (15:34 +0800)
committerTom Rini <trini@konsulko.com>
Wed, 25 Jun 2025 19:45:38 +0000 (13:45 -0600)
commited51f3e446f2ee9e2fa6577388451a93122b6551
tree59096e52ed66223451cacac4bbb1e50ca18310a3
parente18472f1dee609b2ee8a492985bf77a5012e4d01
lib: ecdsa: Add support for loading ECDSA public key from FDT

This patch adds support for parsing ECDSA public keys from the device tree
blob (FDT) under the `/signature` node. The public key is expected to be
defined using:

  - ecdsa,curve (e.g., "prime256v1", "secp384r1")
  - ecdsa,x-point
  - ecdsa,y-point

The implementation introduces:
- struct ecdsa_public_key to hold parsed key fields
- fdt_get_key() to parse the curve and coordinates from the FDT
- read_key_from_fdt() to convert the parsed values into an OpenSSL EC_KEY
- load_key_from_fdt() to support loading keys using required_keynode,
  keyname hint, or fallback to scanning all subnodes under "/signature".

If "info->fdt_blob" is provided, the key is loaded from the FDT. Otherwise,
the code falls back to loading a PEM-formatted key from file as before.

This allows for ECDSA signature verification where the public key is
embedded in the FIT image device tree, useful for systems that require
signature validation without external files.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
lib/ecdsa/ecdsa-libcrypto.c