Skip to content

Add MbedTLS signature verification#54

Open
mzella-ll wants to merge 1 commit into
CiscoDevNet:mainfrom
mzella-ll:feature/add-mbedtls-signature-verification
Open

Add MbedTLS signature verification#54
mzella-ll wants to merge 1 commit into
CiscoDevNet:mainfrom
mzella-ll:feature/add-mbedtls-signature-verification

Conversation

@mzella-ll
Copy link
Copy Markdown

Summary

This PR adds an MbedTLS-based implementation of signature_verify().

The existing OpenSSL implementation remains unchanged. When MBEDTLS is defined, the function now performs real ECDSA signature verification instead of falling back to the temporary stub.

Changes

  • Add MbedTLS includes for public-key handling, SHA-256 hashing, and ASN.1 parsing.
  • Add helper logic to parse DER-encoded ECDSA signatures and extract the r and s values.
  • Add an MbedTLS implementation of signature_verify().
  • Validate input data and signature pointers before verification.
  • Hash the input data using SHA-256.
  • Load the secp256r1 ECDSA curve.
  • Load the public key and verify it against the curve.
  • Verify the ECDSA signature using MbedTLS.

Motivation

Some embedded targets use MbedTLS instead of OpenSSL. These targets should be able to perform signature verification without depending on OpenSSL.

This change adds the missing MbedTLS verification backend while preserving the existing OpenSSL path.

Expected behavior

When built with MBEDTLS defined, signature_verify() verifies the provided ECDSA signature using MbedTLS.

When built with OPENSSL defined, the existing OpenSSL implementation is used.

When neither backend is enabled, the existing fallback behavior remains unchanged.

Related issue

Fixes #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MbedTLS support for signature verification

1 participant