Commit 88e4aed1 authored by Antonio de Angelis's avatar Antonio de Angelis Committed by Dávid Vincze
Browse files

bootutil/crypto: Fix review comments on the ecdsa layer



Fixes in the ecdsa.h abstraction layer:
* Align indentation of parameters to the opening bracket of the function
* Remove inline in some of the bigger functions of the PSA Crypto abstraction
* Fix the prototype of ecdsa_verify for the PSA Crypto abstraction

Signed-off-by: default avatarAntonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I28e1be83bc1a16fdf8b796f89c002528b1bd7791
parent 10529d30
Loading
Loading
Loading
Loading
+29 −24
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#ifndef __BOOTUTIL_CRYPTO_ECDSA_H_
#define __BOOTUTIL_CRYPTO_ECDSA_H_

#include <stdint.h>
#include "mcuboot_config/mcuboot_config.h"

#if defined(MCUBOOT_USE_PSA_CRYPTO) || defined(MCUBOOT_USE_MBED_TLS)
@@ -332,7 +333,7 @@ static inline void get_public_key_from_rfc5280_encoding(uint8_t **p, size_t *siz
 *                               responsibility to ensure the buffer is big enough to
 *                               hold the parsed (r,s) pair.
 */
static inline void parse_signature_from_rfc5480_encoding(const uint8_t *sig,
static void parse_signature_from_rfc5480_encoding(const uint8_t *sig,
                                                  size_t num_of_curve_bytes,
                                                  uint8_t *r_s_pair)
{
@@ -400,7 +401,7 @@ static inline void bootutil_ecdsa_drop(bootutil_ecdsa_context *ctx)
 *     secp256r1 (prime256v1): 1.2.840.10045.3.1.7
 *     secp384r1: 1.3.132.0.34
 */
static inline int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx,
static int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx,
                                           uint8_t **cp, uint8_t *end)
{
    psa_key_attributes_t key_attributes = psa_key_attributes_init();
@@ -434,9 +435,13 @@ static inline int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx,
/* Verify the signature against the provided hash. The signature gets parsed from
 * the encoding first, then PSA Crypto has a dedicated API for ECDSA verification
 */
static inline int bootutil_ecdsa_verify(const bootutil_ecdsa_context *ctx,
    uint8_t *hash, size_t hlen, uint8_t *sig, size_t slen)
static inline int bootutil_ecdsa_verify(bootutil_ecdsa_context *ctx,
                                        uint8_t *pk, size_t pk_len,
                                        uint8_t *hash, size_t hlen,
                                        uint8_t *sig, size_t slen)
{
    (void)pk;
    (void)pk_len;
    (void)slen;

    uint8_t reformatted_signature[96] = {0}; /* Enough for P-384 signature sizes */